﻿// JScript File
//http://www.quirksmode.org/js/cookies.html
var cookiename="comapreidscookie";

function createCookie(value) {
    //eraseCookie();
	document.cookie = cookiename+"="+value+"; path=/";	
	//updatecookiepgIds(content);
}
function readPgloadcookie()
{
    
    var content;
	content=readCookie();	
	if(content!="")
	{
	    updatecookiepgIds(content);
	}
}
function readCookie() {
    var cids="";
	var nameEQ = cookiename + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) cids= c.substring(nameEQ.length,c.length);		
	}
	return cids;
}

function eraseCookie() {
	createCookie(cookiename,"",-1);
}
    setTimeout('dummyfunction()', 0);    
    function dummyfunction()
    {   
        var reqfrom = document.getElementById("hdnfrom");
        var DiaIds = document.getElementById("hdnDiaIds");
        if(reqfrom!=null && DiaIds!=null)        
        Templates_CompareItem.GetDiamondComparisonData(reqfrom.value,DiaIds.value,callbackcompare);
    }
    
    function callbackcompare(res)
    {
        var html="";
        if(res!=null)
            html = res.value;
        
        var tdhtml = document.getElementById("ComparisonHtml");
        if(tdhtml!=null)
        {
            tdhtml.innerHTML = html;
        }
    }
    function vdisplay(diaid)
    {
        var destination = "http://www.diamondstudearringsonline.com/";        
        window.location.href=destination + "templates/template4.aspx?Item_id=" + diaid;
    }
    function ShowDetailsCompare(diaid,Price)
    {
        var reqfrom = document.getElementById("hdnfrom");
        if(reqfrom!=null)
        {
//            if(reqfrom.value=="REC")
//                CompareDiamondDetails('R',diaid,Price);
//            if(reqfrom.value=="NUP" || reqfrom.value=="VP")
//                CompareDiamondDetails('N',diaid,Price);
            var destination = "http://www.mysolitaire.com/Jewelry/JewelryDetails/Template4.aspx";
            window.open(destination + "?Item_id=" + diaid);
        }
    }
    
    function BackToSearch()
    {
        Search22.BackToSearch(callback_BackToSearch);
    }
    
    function callback_BackToSearch(res)
    {   
        if(res!=null)
            setTimeout("window.location='" + res.value + "'",0);
        else
            setTimeout("window.location='http://www.mysolitaire.com/jewelry/SelectDiamond.aspx'",0);
        
    }
    
    function AddDetailsCompareToCart(item_id)
    {
       if(item_id != "")
       {
            //setTimeout("window.location='http://www.mysolitaire.com/jewelry/jewelrydetails/basket_disp?fromCompID='",0);
            setTimeout("window.location='http://localhost/mysol/templates/basket_disp.aspx?fromCompID=" + item_id + "'",0);
       }
    
    }
    
    function RemoveDetailsCompare(item_no)
    {  

            var DiaIds=item_no.toString();
             retainremovedIDs(DiaIds);
//alert(DiaIds);
           include_bottomnavintpg.GetDiamondComparisonDataremcompare(DiaIds,callbackremovecompare);
    }
    
    function callbackremovecompare(res)
    {   
        if(res.value!=null)
        {
            document.getElementById("ComparisonHtml").innerHTML = res.value;
            try
	    {
	 	document.getElementById("Comparepg").style.top=posy+'px';
	    }
	    catch(e)
	    {
            	document.getElementById("Comparepg").style.top="400px";
 	    }
            document.getElementById("Comparepg").style.left="100px";
            document.getElementById("Comparepg").style.display="inline";
        }
    }
    function callbackclosecompare()
    {
        document.getElementById("Comparepg").style.display="none";
    }
