﻿// 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();	
//alert(content);
	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 = sitepath1;        
        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;
//        var reqfrom = document.getElementById("hdnfrom");
//        DiaIds = document.getElementById("hdnDiaIds").value;
//         var answerIdx = DiaIds.indexOf(item_no);
//         
//         var repla; 
//         
//         repla = DiaIds.replace(item_no+",", "");
//         
//         if(repla == DiaIds)
//             repla = DiaIds.replace(","+item_no, "");
//         
//         
//         document.getElementById("hdnDiaIds").value = repla;
            //callbackclosecompare();
            var DiaIds=item_no.toString();
             retainremovedIDs(DiaIds);
           include_bottomnavintpg.GetDiamondComparisonDataremcompare(DiaIds,callbackremovecompare);

           // callbackclosecompare();
//           document.getElementById("ComparisonHtml").innerHTML="Loading Content Please Wait...";
//          include_bottomnavintpg.GetDiamondComparisonDataremcompare(item_no,callbackremovecompare);
    }
    
    function callbackremovecompare(res)
    {   
        if(res.value!=null)
        {
            document.getElementById("ComparisonHtml").innerHTML = res.value;
            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";
    }

