﻿// JScript File

var http = false;
if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
}
function closeMiniCart(e)
{
    ele=(!e)?e=window.event.srcElement.id:e.target.id;
    if(ele.indexOf("Mini")==-1)
    {
        if(document.getElementById('divMiniCart')) document.getElementById('divMiniCart').style.visibility="hidden";
    }
}
function ShowMiniCartVisible()
{
    document.getElementById('divMiniCart').style.top = document.getElementById('MiniCart').offsetTop + 18 + "px";
    document.getElementById('divMiniCart').style.left = document.getElementById('MiniCart').offsetLeft-225 + "px";
    document.getElementById('divMiniCart').style.visibility = "visible";
    http.open('GET','/mini-cart.aspx?id='+Math.random());
    http.onreadystatechange = function() {
      if(http.readyState == 4)      
      document.getElementById('divMiniCart').innerHTML = http.responseText;
};
    http.send(null);
}
function OpenDetail()
{
    var url="/newslettersubscribe.aspx";
    var cwind = window.open(url,"cw","width=320,height=220,top=200,left=200,right=100,scrollbar=true,statusbar=true");
	cwind.focus();
}
function openChat()
{
	var hchatwin=window.open("/epageinside/chat/default.aspx","chat","width=400,height=420,top=200,left=200,scrollbar=no,menubar=no");
	hchatwin.focus();
}
document.onclick=closeMiniCart;

function doPrint()
{   
    var w = window.open("","","width=650,height=300,scrollbars");
    w.document.write("<html><head><link href='/css/style.css' rel='stylesheet'/></head><body onload='self.print()'>" + document.getElementById('divPrint').innerHTML + "</body></html>");
    w.document.close();          
}	
function doSearch()
{
    var str=document.getElementById('search').value;
    if(str=='SEARCH')
    {
    alert("please enter search string");
    return false;
    }
    else
    document.location.href="/search.aspx?search="+str;
    return true; 
}

//to solver menu over dropdown
function hideDropDown()
{
    if(navigator.userAgent.toLowerCase().indexOf("msie")>=0 && navigator.appVersion.toLowerCase().indexOf("msie 7")==-1)
    {
        if(document.getElementById('Filter'))
        {
            document.getElementById('Filter').style.display="none";
        }
    }
}
function showDropDown()
{
	if(navigator.userAgent.toLowerCase().indexOf("msie")>=0 && navigator.appVersion.toLowerCase().indexOf("msie 7")==-1)
	{
		if(document.getElementById('Filter'))
		{
			setTimeout("document.getElementById('Filter').style.display=\"\"",1000);
		}
	}
}
function registerUser(sess,ip)
{
    ref = (document.referrer != '')?document.referrer:'http://www.houseofgems.com';
    http.open('GET','/track-user.aspx?sess='+sess+'&ip='+ip+'&page='+document.location.href+'&referrer='+escape(ref)+'&browser='+navigator.appName+'&date='+Date()+'&id='+Math.random()); 
    http.onreadystatechange = function() {
      if(http.readyState == 4)      
        setTimeout("registerUser(\""+sess+"\",\""+ip+"\")",15000);
};
    http.send(null);
}
function killFrames(url) {
    if (top.location != location) {
        if(document.referrer && 
           document.referrer.indexOf(url) == -1) {
            top.location.replace(document.location.href);
        }
    }
}


document.onmouseover=closeMiniCart;

 
