function addToFavorites() { 
	if (window.external) { 
		window.external.AddFavorite(urlAddress,pageName);
	} else { alert("Sorry! Your browser doesn't support this function."); 
} } 

function bookmark(){
    var title=document.title;
    var url=location.href;

    if (window.sidebar) window.sidebar.addPanel(title, url,"");

    else if( window.opera && window.print )
    {
    var mbm = document.createElement('a');
    mbm.setAttribute('rel','sidebar');
    mbm.setAttribute('href',url);
    mbm.setAttribute('title',title);
    mbm.click();
    }
    else if( document.all ) window.external.AddFavorite( url, title);
}

function getDarker(divNum){
	var div = document.getElementById(divNum);
	div.style.backgroundColor='#336699';
}
function getLighter(divNum){
	var div = document.getElementById(divNum);
	div.style.backgroundColor='#004080';
}

function populateNotedProductsDiv() {
	/* <%=AdminConstants.V_OPT_MODE_SHOW_NTP%> */
	ajaxUpdate("notedProductsContent", "/CookieProducts.htm?opt=sntp");
}
function populateRecentlyViewedProductsDiv(context) {
	/* opt=<%=AdminConstants.V_OPT_MODE_SHOW_RVP%> */
	ajaxUpdate("recentlyViewedProductsDiv", "/CookieProducts.htm?opt=srvp&col=2");
}

function prePopup(e,modelName,context) {
	var loc_obj = getPageXY(e);	
	prdDetailTimeout = setTimeout("popup('"+loc_obj.mX+"','"+loc_obj.mY+"','"+modelName+"','" + context + "')",600);
}

function popup(mX,mY,modelName,context){
	ajaxUpdate("hvp", "/ProductDetail.htm?modelName=" + modelName);
	
	//loc_obj = getPageXY(prdDetailEvent);
    
    var div = document.getElementById("hvp");
    
	div.style.position="absolute";
	div.style.left= Number(mX)-100 + "px";
	div.style.top=Number(mY)+20 + "px";
	
	div.style.display='block';
	div.style.visibility='visible';

}
function kill(){
	clearTimeout(prdDetailTimeout);	
	var div = document.getElementById("hvp");
	div.style.display='none';
	div.innerHTML="<p><b>Retrieving data ...</b></p><p><img src='/images/common/imgLoading.gif' /></p>";
}
function getPageXY(e){
	if (navigator.appName == "Microsoft Internet Explorer"){	
		mX = e.clientX+document.body.scrollLeft;		
		mY = e.clientY+document.body.scrollTop;
	}else{
		mX = e.clientX+document.body.scrollLeft;
		mY = e.clientY+document.body.scrollTop;
	}

	var page_obj = new Object;
	page_obj.mX = mX;
	page_obj.mY = mY;
	return page_obj;
}

function ajaxUpdate(ctnrId, url) {
	var xmlhttp;
	if (window.XMLHttpRequest) {
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else {
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}

	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			document.getElementById(ctnrId).innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET",url,true);
	xmlhttp.send();

}