﻿// JScript File

	
	var sortfield;
	var sorttype=1;
	var currpage=1;
	var totalpages;
	var totaldiamonds;
	var pagesize="";
	var Shape="";
	var Cut="";
	var Color="";
	var Clarity="";
	var CutL="";
    var CutH="";
    var ColorL="";
    var ColorH="";
    var ClarityL="";
    var ClarityH="";
	var CaratL=0;
	var CaratH=1000000;
	var PriceL;
	var PriceH;
	var IsThreeStone=false;
	var IsBYR=false;
	var CurrDiamondCaratL=0;
	var SPID=0;
	
	var MainFunction=getDiamondResults;
	
	
	
	  

  
    function ShowBlurb(obj)
    {
        obj.bgColor='#CBD7FB';
        BlurbDivHTML=document.getElementById("BlurbDiv").innerHTML;
        currid=obj.id;
        overlib(BlurbDivHTML,WIDTH,225,HEIGHT,212,FULLHTML,REF,currid,REFC,'UL',REFP,'UR',REFY,-75,NOJUSTY);
      //    overlib(BlurbDivHTML);
        
        
        document.getElementById("spnStkNumber").innerHTML=obj.getAttribute('StockNo');
     
        document.getElementById("spnDepth").innerHTML=obj.getAttribute('Depth')+"%";
        
        document.getElementById("spnTable").innerHTML=obj.getAttribute('Table')+"%";
        document.getElementById("spnGridle").innerHTML=obj.getAttribute('Gridle');
        document.getElementById("spnCulet").innerHTML=obj.getAttribute('Culet');
        document.getElementById("spnFlr").innerHTML=obj.getAttribute('Fluorescence');
        document.getElementById("spnMsrmnts").innerHTML=obj.getAttribute('Measurements');
        
        
    }
	function UpdateComparisonList(obj,rightstoneid)
	{
            if(obj.checked)
            {
                if(readCookie('CL_'+obj.getAttribute('ProductID'))==null)
                    createCookie('CL_'+obj.getAttribute('ProductID'),obj.getAttribute('ProductID'),30);
                
                if(rightstoneid!=null)
                {
                    if(readCookie('CL_'+rightstoneid)==null)
                        createCookie('CL_'+rightstoneid,rightstoneid,30);
                }
              
            }
            else 
            {
                if(readCookie('CL_'+obj.getAttribute('ProductID'))!=null)
                    eraseCookie('CL_'+obj.getAttribute('ProductID'));
                if(rightstoneid!=null)
                {
                    if(readCookie('CL_'+rightstoneid)!=null)
                        eraseCookie('CL_'+rightstoneid);
                }
            }
            
                
	}
        
	function SubmitNewSearchData()
	{
	    
	    
	    
	    
	    sortfield=document.getElementById("_ctl0_DiamondGrid1_hiddenSort").value;
	    Shape=document.getElementById("_ctl0_DiamondGrid1_hiddenShape").value;
	    Cut=document.getElementById("_ctl0_DiamondGrid1_hiddenCut").value;
	    Color =document.getElementById("_ctl0_DiamondGrid1_hiddenColor").value;
	    Clarity=document.getElementById("_ctl0_DiamondGrid1_hiddenClarity").value;
	    CaratL=document.getElementById("_ctl0_DiamondGrid1_hiddenCaratsL").value;
	    CaratH=document.getElementById("_ctl0_DiamondGrid1_hiddenCaratsH").value;
	    PriceL=document.getElementById("_ctl0_DiamondGrid1_hiddenPriceL").value;
	    PriceH=document.getElementById("_ctl0_DiamondGrid1_hiddenPriceH").value;
	    
/*(sortfield);
	   alert(Shape);
	alert(Cut);
	alert(Color);
	alert(Clarity);
	alert(CaratL);
	alert(CaratH);
	alert(PriceL);
	alert(PriceH);*/

	    if(IsThreeStone=="True")
	        CaratL = CaratL < CurrDiamondCaratL? CurrDiamondCaratL : CaratL;
	   
 
	    /* alert("Shape: "+Shape);alert("Cut: "+Cut);alert("Color: "+Color);
	     alert("Clarity: "+Clarity);alert("CaratL: "+CaratL);alert("CaratH: "+CaratH);
	     alert("PriceL: "+PriceL);alert("PriceH: "+PriceH);alert("SortField: "+sortfield);*/
	 
	    SetPaging(1);//set back to page 1 if new search
	    
	 // overlib("<img src='skins/skin_1/images/loading.gif'/>");
	    //alert(pagesize);
	   //alert("sorttype: "+sorttype); alert("currpage: "+currpage); alert("pagesize: "+pagesize);
	   AspDotNetStorefront.MainDiamondGrid.GetDiamondResults(Shape,Cut,Color,Clarity,CaratL,CaratH,PriceL,PriceH,sortfield,sorttype,currpage,pagesize,IsThreeStone,getNewSearchCriteria_callback);  // asynchronous call
	   
	}
	
	
	
	function getDiamondResults()
	{
	    if(IsThreeStone=="True")
	        CaratL = CaratL < CurrDiamondCaratL? CurrDiamondCaratL : CaratL;
	        
	    ShowLoadingImg();
	    //on comparison page, need to call special function to get products again. NOTHING TO DO with search fields. 
	    //but this is the central ajax function. All links come back here. So call it here. By the way, same call back function.
	    if(document.location.toString().indexOf("CompareDiamonds")>-1)
	        {GetComparisonDiamonds();}
	        
	     else   
	        AspDotNetStorefront.MainDiamondGrid.GetDiamondResults(Shape,Cut,Color,Clarity,CaratL,CaratH,PriceL,PriceH,sortfield,sorttype,currpage,pagesize,IsThreeStone,getDiamondResults_callback);  // asynchronous call
	}
	
	function getDSDiamondResults()
	{ 
	   
	 
	    if(IsThreeStone=="True")
	        CaratL = CaratL < CurrDiamondCaratL? CurrDiamondCaratL : CaratL;
	   
	    ShowLoadingImg();
	
	        AspDotNetStorefront.MainDiamondGrid.GetDiamondResults(Shape,Cut,Color,Clarity,CaratL,CaratH,PriceL,PriceH,sortfield,sorttype,currpage,pagesize,IsThreeStone,getNewSearchCriteria_callback);  // asynchronous call
	}
	
	function getPairedDiamondResults()
	{ 
	    
	    ShowLoadingImg();
	     //CenterDiamond=161;
	     
	    AspDotNetStorefront.MainDiamondGrid.GetPairedDiamondResults(SPID,Shape,Cut,Color,Clarity,CaratL,CaratH,PriceL,PriceH,sortfield,sorttype,currpage,pagesize,CenterDiamond,PairLimit,getPairedDiamondResults_callback);  // asynchronous call
	}
	
	function getPairedDiamondResults_Earrings()
	{ 
	    
	    ShowLoadingImg();
	     //CenterDiamond=161;
	     
	    AspDotNetStorefront.MainDiamondGrid.GetPairedDiamondResults_Earrings(Shape,Cut,Color,Clarity,CaratL,CaratH,PriceL,PriceH,sortfield,sorttype,currpage,pagesize,PairLimit,getPairedDiamondResults_callback);  // asynchronous call
	}
	
	
	//hidden for default sortfield
	function getSortedDiamondResults(_sortfield,_sorttype)
	{
	SetSort(_sortfield,_sorttype);
	
	//if reset sort, start at page 1
	SetPaging(1);
	
	    
	 //this is defaulted to "getdiamondresults" but on some pages like byr_threestone it's overwritten. 
	 //that way i can use the same template over on pages that call different ajax functions.
	
	 MainFunction();  
	 
	}
	
	var the_timeout=null;
	var count=0;
	function SetDynamicGridTimeout(Name,Value)
	{
	    if(the_timeout!=null)
	        clearTimeout(the_timeout);
	    the_timeout = setTimeout("DynamicSearchGetDiamondResult('"+Name+"','"+Value+"')", 200);
	}
	function sayhi(Name,Value)
	{
	    document.getElementById("testtext").value=Name+" "+Value;
	    count++;
	}
	function DynamicSearchGetDiamondResult_old(Name,Value)
	{
	 
	    document.getElementById("temp").value=count++;
	   
	   switch(Name)
	   {
	        case "Shape":
	            Shape=Value;
	            break;
	    	case "CaratL":
	    	    CaratL=Value;
	    	    break;
	        case "CaratH":
	            CaratH=Value;
	            break;
	        case "PriceL":
	            PriceL=Value;
	            break;
	        case "PriceH":
	            PriceH=Value;
	            break;
	        case "CutL":
	             Cut="";
    	       
	           
	            cuthigh=4;
    	        
	            cutlow=Value;
	          
	            for(i=0;i<4;i++)
	            {
	                if(document.getElementById("slider2_end").value>=i && document.getElementById("slider2_end").value<(i+1))
	                    cuthigh=i+1;
	            }
    	        
	            for(i = cutlow; i <= cuthigh; i++)
                {
                   Cut+=i+",";
                }
                break;
	        case "CutH":
	            Cut="";
    	       
	            cutlow=1;
	           
    	        
	            cuthigh=Value;
	            for(i=0;i<4;i++)
	            {
	                if(document.getElementById("slider2_start").value>=i && document.getElementById("slider2_start").value<(i+1))
	                    cutlow=i+1;
	            }
	            
	            for(i = cutlow; i <= cuthigh; i++)
                {
                   Cut+=i+",";
                }
                
                break;
            case "ClarityL":
            Clarity="";
	        claritylow=Value;
	        clarityhigh=10;
	        
	       
	        for(i=0;i<10;i++)
	        {
	            if(document.getElementById("slider5_end").value>=i && document.getElementById("slider5_end").value<(i+1))
	                clarityhigh=i+1;
	        }
            for(i = claritylow; i <= clarityhigh; i++)
            {
               Clarity+=i+",";
            }
           document.getElementById("temp").value=clarityhigh;
            break;
            
	        case "ClarityH":
	        Clarity="";
	        claritylow=1;
	        clarityhigh=Value;
	        
	        for(i=0;i<10;i++)
	        {
	            if(document.getElementById("slider5_start").value>=i && document.getElementById("slider5_start").value<(i+1))
	                claritylow=i+1;
	        }
	        
            for(i = claritylow; i <= clarityhigh; i++)
            {
               Clarity+=i+",";
            }
           
            break;
            case "ColorL":
            Color="";
	        colorlow=Value;
	        colorhigh=8;
	        
	        
	        for(i=0;i<8;i++)
	        {
	            if(document.getElementById("slider4_end").value>=i && document.getElementById("slider4_end").value<(i+1))
	                colorhigh=i+1;
	        }
            for(i = colorlow; i <= colorhigh; i++)
            {
               Color+=i+",";
            }
            
            break;
	        case "ColorH":
	        Color="";
	        colorlow=1;
	        colorhigh=Value;
	        
	        for(i=0;i<8;i++)
	        {
	            if(document.getElementById("slider4_start").value>=i && document.getElementById("slider4_start").value<(i+1))
	                colorlow=i+1;
	        }
	       
            for(i = colorlow; i <= colorhigh; i++)
            {
               Color+=i+",";
            }
            
            break;
      }
            
	  
	    
	    SetPaging(1);
	    getDSDiamondResults();
	}
	
	function DynamicSearchGetDiamondResult()
	{
	Cut="";
	Clarity="";
	Color="";

	    for(i = CutL; i <= CutH; i++)
        {
           Cut+=i+",";
        }
        
        for(i = ClarityL; i <= ClarityH; i++)
        {
           Clarity+=i+",";
        }
        
        for(i = ColorL; i <= ColorH; i++)
        {
           Color+=i+",";
        }
        
	    SetPaging(1);
	    getDSDiamondResults();
	}
	
	function getDSShapeDiamondResults(_shape)
	{
	SetShape(_shape);
	
	//if reset sort, start at page 1
	SetPaging(1);
	
	    
	   
	 getDSDiamondResults();
	}
	function SetShape(_shape)
	{
	    document.getElementById("_ctl0_DiamondGrid1_hiddenShape").value=_shape;
	    Shape=_shape;
	}
	function SetSort(_sortfield,_sorttype)
	{
	    if(_sortfield==null || _sortfield=="")
	    {sortfield="Price";}
	else
	    sortfield=_sortfield;
	if(_sorttype != 0 && (_sorttype==null || _sorttype==""))
	    {sorttype=1;}
	else
	    sorttype=_sorttype;
	   
	}
	
	function getPagingDiamondResults(page)
	{
	   SetPaging(page);
    	
	   MainFunction();
	}
	
	function SetPaging(page)
	{
	     if(page == null || page == "" || page ==0)
	        currpage = 1;
	    else if(page > totalpages)
	        currpage=totalpages;
	    else
	         currpage=page;
	}

	// This method will be called after the method has been executed
	// and the result has been sent to the client.


    //todo: put an image over table while loading
   
   function SetPageProperties(TotalPages,CurrPage,SortField,SortOrder)
   {
         sortfield=SortField;
	     sorttype=SortOrder;
	     currpage=CurrPage;
	     totalpages=TotalPages;//only really dynamic variable
   }
   
  
   
   function SetTotalDiamondText(totaldiamonds)
   {
   
        document.getElementById("TotalDiamonds").innerHTML=totaldiamonds;
   }
	function getDiamondResults_callback(res)
	{ 
	   
	    //don't use innerhtml cuz then can't add eventhandlers. do thru appendchild. functionality seems to be about the same
	     var PageProperties = res.value;
	     var MyCollection=PageProperties.ProductList;
	       
	     SetPageProperties(PageProperties.TotalPages,PageProperties.CurrPage,PageProperties.SortField,PageProperties.SortOrder);
	 //     CaratL=PageProperties.CaratL;
	      
	    //grid:
	   ClearTable();
	   //  var table=document.createElement("TABLE");
	    
	     
	     
	  //   var tbody=document.createElement("TBODY");
	  //   tbody.valign="top";
	     
	     
	 //    table.appendChild(tbody);
	    
	    
	     document.getElementById("NoResultsDiv").style.display="none";
	   
	   var TableHtml="";
	     for(i=0;i<MyCollection.length;i++)
	     {
	       
	      
	        var myproduct = MyCollection[i];
    	    
    	   
    	    
    	 //   tbody.appendChild(AddRow(myproduct));
         //  document.getElementById("AjaxResults").appendChild(AddRow(myproduct));
          TableHtml+=AddRowInnerHTML(myproduct);
          //document.getElementById("GridDiv").innerHTML+=AddRowInnerHTML(myproduct);
          
            if(i<MyCollection.length-1)
            //     tbody.appendChild(AddSeparatingRow());
           // document.getElementById("AjaxResults").appendChild(AddSeparatingRow());
            TableHtml+=AddSeparatingRowInnerHTML();
          
    	    
	     }
	     
	    if(MyCollection.length==0)
	    {
	     
	     
	        document.getElementById("spnNoResultsShape").innerHTML=Shape;
	        document.getElementById("spnNoResultsPriceL").innerHTML=formatCurrency(PriceL);
	        document.getElementById("spnNoResultsPriceH").innerHTML=formatCurrency(PriceH);
	        document.getElementById("spnNoResultsColorL").innerHTML=ColorHash[ColorL];
	        document.getElementById("spnNoResultsColorH").innerHTML=ColorHash[ColorH];
	        document.getElementById("spnNoResultsClarityL").innerHTML=ClarityHash[ClarityL];
	        
	         document.getElementById("spnNoResultsClarityH").innerHTML=ClarityHash[ClarityH];
	        document.getElementById("spnNoResultsCutL").innerHTML=CutHash[CutL];
	        
	        document.getElementById("spnNoResultsCutH").innerHTML=CutHash[CutH];
	        document.getElementById("spnNoResultsCaratL").innerHTML=CaratL;
	        document.getElementById("spnNoResultsCaratH").innerHTML=CaratH;
    	    
    	    
    
    	 
	        document.getElementById("NoResultsDiv").style.display='';
    	    
	   
	    }
	  //  document.getElementById("GridDiv").innerHTML+="<tr><td>hi aliza</td></tr>";
	       document.getElementById("GridDiv").innerHTML = "<table valign=top border=0 cellspacing=0 cellpadding=0><tbody>"+TableHtml+"</tbody></table>";
	     //  document.getElementById("test").value= document.getElementById("GridDiv").innerHTML;
	   //  var tableHTML = table.innerHTML;
	  //   document.getElementById("AjaxResultsTable").tbody=null;
	    
	  //   document.getElementById("GridDiv").innerHTML = "<table><tbody><tr><td>Hi Aliza </td></tr></tbody></table>";//<table><tr><td>Hi Aliza </td></tr></table>";//tbody.innerHTML;
	    
	     
	     //pagination:
	     ClearPagination();
	     SetPagination();
	       
	     if(document.getElementById("CheckBoxHeader").innerHTML=="")
	        document.getElementById("CheckBoxHeader").innerHTML=SetCheckBoxHeaderName();
	    
	     HideLoadingImg();
	   
	     //nd();
	     
	}
	
	function getPairedDiamondResults_callback(res)
	{ 
	   
	  
	     var PageProperties = res.value;
	     var MyCollection=PageProperties.ProductList;
	   
	     SetPageProperties(PageProperties.TotalPages,PageProperties.CurrPage,PageProperties.SortField,PageProperties.SortOrder);
	    
	     // CaratL=PageProperties.CaratL;
	     // CaratH=PageProperties.CaratH;
	      
	    //grid:
	   ClearTable();
	
	     document.getElementById("NoResultsDiv").style.display="none";
	
	    var TableHtml="";  
	
	    for(i=0;i<MyCollection.length;i++)
	     { 
	         var myproduct = MyCollection[i]; 
	         TableHtml+=AddPairedDiamondRow(myproduct); 
	         if(i<MyCollection.length-1)
                TableHtml+=AddSeparatingRowInnerHTML();  
         }
	  
	    if(MyCollection.length==0)
	    {
	        document.getElementById("spnNoResultsShape").innerHTML=Shape;
	        document.getElementById("spnNoResultsPriceL").innerHTML=formatCurrency(PriceL);
	        document.getElementById("spnNoResultsPriceH").innerHTML=formatCurrency(PriceH);
	        document.getElementById("spnNoResultsColorL").innerHTML=ColorHash[ColorL];
	        document.getElementById("spnNoResultsColorH").innerHTML=ColorHash[ColorH];
	        document.getElementById("spnNoResultsClarityL").innerHTML=ClarityHash[ClarityL];
	         document.getElementById("spnNoResultsClarityH").innerHTML=ClarityHash[ClarityH];
	        document.getElementById("spnNoResultsCutL").innerHTML=CutHash[CutL];
	        document.getElementById("spnNoResultsCutH").innerHTML=CutHash[CutH];
	        document.getElementById("spnNoResultsCaratL").innerHTML=CaratL;
	        document.getElementById("spnNoResultsCaratH").innerHTML=CaratH;
    	 
	        document.getElementById("NoResultsDiv").style.display='';
    	    
	   
	    } 
	 
	       document.getElementById("GridDiv").innerHTML = "<table valign=top border=0 cellspacing=0 cellpadding=0><tbody>"+TableHtml+"</tbody></table>";
	  
	    
	     //pagination:
	     ClearPagination();
	     SetPagination();
	   
	     if(document.getElementById("CheckBoxHeader").innerHTML=="")
	        document.getElementById("CheckBoxHeader").innerHTML=SetCheckBoxHeaderName();
	   
	     HideLoadingImg();
	      
	}
	
	
	
	function HideLoadingImg()
	{
	    if(document.getElementById("LoadingDiv")!=null)
	    {
	        document.getElementById("LoadingDiv").style.display="none";
	        //document.getElementById("GridDiv").style.display='';
	    }
	        
	}
	function ShowLoadingImg()
	{
	    if(document.getElementById("LoadingDiv")!=null)
	    {
	        
	       // document.getElementById("LoadingDiv").style.top="100px";
	        document.getElementById("LoadingDiv").style.display="";
	        
	        //document.getElementById("GridDiv").style.display="none";
	    }
	        
	}
	function SetCheckBoxHeaderName()
	{
	    if(document.location.toString().indexOf("CompareDiamonds")>-1)
	        return "Remove";
	    else
	        return "Compare";
	}
	
	
	function ClearPagination()
	{
	    var PageSpan =document.getElementById("Pages");
	    PageSpan.innerHTML="";
	}
	
	function SetPagination()
	{
	   
	   
	    var PageSpan = document.getElementById("Pages");
	    PageSpan.innerHTML="Pages: ";
	    
	    var PageSpan2 = document.getElementById("Pages2");
	    PageSpan2.innerHTML="Pages: ";
	    
	    //only room for 8. when it goes past 8 show 8 surrounding pages
	    if(currpage>=8)
	    {
	       var startpagination=currpage-7;
	       var endpagination =startpagination + 7;
	    }
	    else if(currpage < 8)
	    {
	        startpagination = 1;
	        if(totalpages<=8)
	            endpagination=totalpages;
	        if(totalpages>8)
	            endpagination = 8;
	    }
	    
	    for(i=startpagination;i<=endpagination;i++)
	    {
	        PageSpan.innerHTML+=AddPageLink(i);
	        PageSpan2.innerHTML+=AddPageLink(i);
	    }
	    
	   
	    if(currpage<totalpages)
	    {
	        nextpage=currpage+1;
	        document.getElementById("NextLink").href="javascript:getPagingDiamondResults("+nextpage+")";
	        document.getElementById("NextLink").style.display="";
	        document.getElementById("NextLink2").href="javascript:getPagingDiamondResults("+nextpage+")";
	        document.getElementById("NextLink2").style.display="";
	    }
	    if(currpage>=totalpages)
	    {
	        nextpage=currpage;
	        document.getElementById("NextLink").href="javascript:getPagingDiamondResults("+nextpage+")";
	        document.getElementById("NextLink").style.display="none";
	         document.getElementById("NextLink2").href="javascript:getPagingDiamondResults("+nextpage+")";
	        document.getElementById("NextLink2").style.display="none";
	    }
	    
	    
	}
	

	
	function AddPageLink(pagenum)
	{
	   if(pagenum==currpage)
	        return "<a href='javascript:getPagingDiamondResults("+pagenum+");'><b>"+pagenum+"</b></a>&nbsp;"
	    return "<a href='javascript:getPagingDiamondResults("+pagenum+");'>"+pagenum+"</a>&nbsp;"
	}
	function AddSeparatingRow()
	{
	    var Row = document.createElement("TR");
	    Row.height="1";
	    
	    var Cell1 = document.createElement("TD");
	    Cell1.align="center";
	    Cell1.height="1";
	    
	    var Cell2 = document.createElement("TD");
	    Cell2.align="center";
	    Cell2.colSpan = "9";
	    Cell2.height="1"
	    
	    Cell2.innerHTML="<img src='skins/skin_1/images/lb_dot.gif' alt='' height='1' width='100%' border='0'/>";
	    Row.appendChild(Cell1);
	    Row.appendChild(Cell2);
	  
	   /*<tr height="1">
			<td align="center" height="1"></td>
			<td colspan="8" align="center" height="1"><img src="images/lb_dot.gif" alt="" height="1" width="100%" border="0"/></td>
		</tr>*/
	    
	    return Row;
	}
	
	function AddSeparatingRowInnerHTML()
	{
	    var RowString="<tr height='1'>";
	    
	    var Cell1String="<td align='center' height='1'></td>";
	    var Cell2String="<td align='center' colspan='9' height='1'><img src='skins/skin_1/images/lb_dot.gif' alt='' height='1' width='100%' border='0'/></td>";
	    
	   RowString+=Cell1String;
	   RowString+=Cell2String;
	  
	    
	     RowString+="</tr>";
	   
	    
	   
	   
	    
	    return RowString;
	}
	function showproductblurb()
	{
	    overlib("<iframe scrolling='no' width='373' height='396' frameborder='0' src='popup/diamondproductblurb.aspx?productid="+this.getAttribute('ProductID')+"'></iframe>'", FIXX, 10,OFFSETY, -100,DELAY, 250, FULLHTML);
	}
	function ChangeBgColor()
	{
	
	   // this.bgColor="#CBD7FB";
	}
	
	


function ChangeBGColor(obj,color)
{
    obj.bgColor=color;
   //obj.bgColor='#CBD7FB';
}
function AddRowInnerHTML(myproduct)
{
    var RowString="<tr height='25'";
    RowString+=" name='productrow'";
    RowString+=" productid='"+myproduct.ProductID+"'";
    RowString+=" id='"+myproduct.ProductID+"A'";
    
    //these properties are for the blurb
    RowString+=" StockNo='"+myproduct.StockNumber+"'";
    RowString+=" Depth="+myproduct.Depth;
    RowString+=" Table="+myproduct.Table;
    RowString+=" Gridle='"+myproduct.Gridle+"'";
    RowString+=" Culet='"+myproduct.Culet+"'";
    RowString+=" Fluorescence='"+myproduct.Fluorescence+"'";
	RowString+=" Measurements='"+myproduct.Measurements+"'";
	

	if(document.location.toString().toLowerCase().indexOf("step2")>-1 ||document.location.toString().toLowerCase().indexOf("dynamic")>-1)
    {
	      RowString+=" onmouseover=ShowBlurb(this);";
	      RowString+=" onmouseout=ChangeBGColor(this,'#ffffff');nd();"; 
	    
       
     }
   else
   {
     
         RowString+=" onmouseover=ChangeBGColor(this,'#CBD7FB');";  
         RowString+=" onmouseout=ChangeBGColor(this,'#ffffff');"; 
	   
   }
   RowString+=">";
   RowString+=AppendCells(myproduct);
   RowString+="</tr>";
   
   return RowString;
  
}

function AppendCells(myproduct)
{
var Cell1String="<td align='center' width='74' height='25'><span class='welcome' >"+myproduct.Shape+"</span></td>"
var Cell2String="<td align='center' width='64' height='25'><span class='welcome' >"+myproduct.Carat+"</span></td>"
var Cell3String="<td align='center' width='64' height='25'><span class='welcome' >"+myproduct.Color+"</span></td>"
 var Cell4String="<td align='center' width='66' height='25'><span class='welcome' >"+myproduct.Clarity+"</span></td>"
 var Cell5String="<td align='center' width='69' height='25'><span class='welcome' >"+myproduct.Cut+"</span></td>"
 var Cell6String="<td align='center' width='66' height='25'><span class='welcome' >"+myproduct.Report+"</span></td>"
 var Cell7String="<td align='center' width='81' height='25'><span class='welcome' >"+myproduct.Symmetry+"</span></td>"
 var Cell8String="<td align='center' width='66' height='25'><span class='welcome' >"+myproduct.Price+"</span></td>"
 var CellCompareString="<td align='center' width='76' height='25'><input align='center' type='checkbox' productid='"+myproduct.ProductID+"' name='compareBox' value='checkboxValue' onclick='UpdateComparisonList(this);'></td>";
  
   
  var onclick=document.location.toString().indexOf("Similiar")>-1?"window.top.location=this.href;return false;":"return true;";

 
var Cell9String;
var HREFAddition="";

if(document.location.toString().toLowerCase().indexOf("pendants")>-1 )
    HREFAddition="?pendants=true&byr=true&Metal="+Metal+"&Style="+Style;

else if(BYR=="True")
    HREFAddition="?byr=True";
    
 Cell9String="<td align='center' width='25' height='25'><img src='skins/skin_1/images/icon_view.gif' alt='' height='14' width='18' border='0'><span class='welcome'><a href='p-"+myproduct.ProductID+"-"+myproduct.Name+".aspx"+HREFAddition+"' id='"+myproduct.Name+"' onclick='"+onclick+"'><u>View</u></a></span></td>";

	    
	  
	    
 return Cell1String+Cell2String+Cell3String+Cell4String+Cell5String+Cell6String+Cell7String+Cell8String+CellCompareString+Cell9String;
	    
}
	function AddRow(myproduct)
	{

	    
	    var Row = document.createElement("TR");
	    Row.height="25";
	    Row.name="ProductRow";
	    Row.productid=myproduct.ProductID;
	    Row.id=myproduct.ProductID+"A";//need character in id for REF to work in overlib
	    
	    //these properties are for the blurb
	    Row.StockNo=myproduct.StockNumber;
	    Row.Depth=myproduct.Depth;
	    Row.Table=myproduct.Table;
	    Row.Gridle=myproduct.Gridle;
	    Row.Culet=myproduct.Culet;
	    Row.Fluorescence=myproduct.Fluorescence;
	    Row.Measurements=myproduct.Measurements;
	    
	   

        if(document.location.toString().indexOf("step2")>-1 ||document.location.toString().indexOf("dynamic")>-1)
        {
	            Row.onmouseover=function () 
	            {
        	  
        	            this.bgColor='#CBD7FB';
	                    BlurbDivHTML=document.getElementById("BlurbDiv").innerHTML;
	                    currid=this.id;
	                    overlib(BlurbDivHTML,WIDTH,225,HEIGHT,212,FULLHTML,REF,currid,REFC,'UL',REFP,'UR',REFY,-75,NOJUSTY);
        	            
        	            
	                    document.getElementById("spnStkNumber").innerHTML=this.StockNo;
            	     
	                    document.getElementById("spnDepth").innerHTML=this.Depth+"%";
            	        
	                    document.getElementById("spnTable").innerHTML=this.Table+"%";
	                    document.getElementById("spnGridle").innerHTML=this.Gridle;
	                    document.getElementById("spnCulet").innerHTML=this.Culet;
	                    document.getElementById("spnFlr").innerHTML=this.Fluorescence;
	                    document.getElementById("spnMsrmnts").innerHTML=this.Measurements;
        	        
        	
        	
            //,FULLHTML,REF,currid, REFC,'UL',REFP,'UR',REFY,-75,NOJUSTY,NOJUSTX,WRAP
                 }
                 
                
	           Row.onmouseout=function(){this.bgColor='#ffffff';nd();}
	   }
	   else
	   {
	     
	    Row.onmouseover=function(){this.bgColor='#CBD7FB';}
	    //= function () {alert(1);/*this.style.color = '#' +'CBD7FB';*/}//assign function
		Row.onmouseout=function(){this.bgColor='#ffffff';}
		//.onmouseout = function(){this.style.color='#' + 'ffffff';}//assign function
	   }

	   
	    
	     var Cell1 = document.createElement("TD");
	    Cell1.align="center";
	    Cell1.width="74";
	    Cell1.height="25";
	    
	    var Cell2 = document.createElement("TD");
	    Cell2.align="center";
	    Cell2.width="64";
	    Cell2.style.height=25;
	    //Cell2.style.vertical-align="middle";
	    
	   
	    
	    var Cell3 = document.createElement("TD");
	    Cell3.align="center";
	    Cell3.width="64";
	    Cell3.height="25";
	    
	    var Cell4 = document.createElement("TD");
	    Cell4.align="center";
	    Cell4.width="66";
	    Cell4.height="25";
	    
	      var Cell5 = document.createElement("TD");
	    Cell5.align="center";
	    Cell5.width="69";
	    Cell5.height="25";
	    
	    var Cell6 = document.createElement("TD");
	    Cell6.align="center";
	    Cell6.width="66";
	    Cell6.height="25";
	    
	    var Cell7 = document.createElement("TD");
	    Cell7.align="center";
	    Cell7.width="81";
	    Cell7.height="25";
	    
	    var Cell8 = document.createElement("TD");
	    Cell8.align="center";
	    Cell8.width="66";
	    Cell8.height="25";
	    
	     var Cell9 = document.createElement("TD");
	     Cell9.align="center";
	     Cell9.height="25";
	     Cell9.width="56";
	     
	      var CellCompare = document.createElement("TD");
	    Cell1.align="center";
	    Cell1.width="76";
	    Cell1.height="25";
	    
	   
	   Cell1.innerHTML="<span class='welcome' >"+myproduct.Shape+"</span>";
	    Cell2.innerHTML="<span class='welcome'  >"+myproduct.Carat+"</span>";
	    Cell3.innerHTML="<span class='welcome'>"+myproduct.Color+"</span>";
	    Cell4.innerHTML="<span class='welcome'>"+myproduct.Clarity+"</span>";
	    Cell5.innerHTML="<span class='welcome'>"+myproduct.Cut+"</span>";
	    Cell6.innerHTML="<span class='welcome'>"+myproduct.Report+"</span>";
	    Cell7.innerHTML="<span class='welcome'>"+myproduct.Symmetry+"</span>";
	    Cell8.innerHTML="<span class='welcome'>"+myproduct.Price+"</span>";
	    CellCompare.innerHTML="<input align='center' type='checkbox' productid='"+myproduct.ProductID+"' name='compareBox' value='checkboxValue' onclick='UpdateComparisonList(this);'>";
	   
	 var onclick=document.location.toString().indexOf("Similiar")>-1?"window.top.location=this.href;return false;":"return true;";
	 // var onclick=document.location.toString().indexOf("Similiar")>-1?"alert(this.href);":"alert(true);";
	    Cell9.innerHTML="<img src='skins/skin_1/images/icon_view.gif' alt='' height='14' width='18' border='0'><span class='welcome'><a href='p-"+myproduct.ProductID+"-"+myproduct.Name+".aspx' id='"+myproduct.Name+"' onclick='"+onclick+"'><u>View</u></a></span>";
	    
	    
	    Row.appendChild(Cell1);
	    Row.appendChild(Cell2);
	     Row.appendChild(Cell3);
	    Row.appendChild(Cell4);
	     Row.appendChild(Cell5);
	    Row.appendChild(Cell6);
	     Row.appendChild(Cell7);
	    Row.appendChild(Cell8);
	    Row.appendChild(CellCompare);
	    Row.appendChild(Cell9);
	    
	    /*<tr height="25">
							<td align="center" width="74" height="25"><span class="welcome">Round</span></td>
							<td align="center" width="64" height="25"><span class="welcome">7.27</span></td>
							<td align="center" width="64" height="25"><span class="welcome">J</span></td>
							<td align="center" width="66" height="25"><span class="welcome">VS2</span></td>
							<td align="center" width="69" height="25"><span class="welcome">Ideal</span></td>
							<td align="center" width="66" height="25"><span class="welcome">GIA</span></td>
							<td align="center" width="81" height="25"><span class="welcome">VG/EX</span></td>
							<td align="center" width="66" height="25"><span class="welcome">$105,432</span></td>
							<td align="center" width="76" height="25"><input type="checkbox" name="checkboxName" value="checkboxValue"></td>
							<td align="center" width="56" height="25"><img src="images/icon_view.gif" alt="" height="14" width="18" border="0"><span class="welcome"><a href="(EmptyReference!)"><u>View</u></a></span></td>
						</tr>*/
	 
	  
	   
	    
	    return Row;
	    
	}
	function ClearTable()
	{
	    var ua = navigator.userAgent.toLowerCase();
	    var isIE = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv')== -1)	);

	   //ie doesn't allow me to set innerhtml of tbody to null, other browsers don't recognize ".children"
	   document.getElementById("GridDiv").innerHTML=null;
	  /*  if(isIE)
	    {
		      while(document.getElementById("AjaxResults").children.length>0)
	          { document.getElementById("AjaxResultsTable").deleteRow(0);}
    		
    			
	    }
	    else 
	    {	
		    document.getElementById("GridDiv").innerHTML=null;
	    }*/
	
	}
	
	