window.onload = pageInit;

function printWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}

function pageInit() {
	rolloversInit();
}

function rolloversInit() {
	if (!document.getElementById) return;
	
	var arrPreload = new Array();
	var strSrcTmp;
	var arrImages = document.getElementsByTagName('img');
	
	for (var i=0; i<arrImages.length; i++) {
		if (arrImages[i].className == "rollover") {
			var src = arrImages[i].src;
			var imgtype = src.substring(src.lastIndexOf("."), src.length);
			var altsrc = src.replace(imgtype, "_over" + imgtype);

			arrImages[i].setAttribute('altsrc', altsrc);
			arrPreload[i] = new Image();
			arrPreload[i].src = altsrc;
			
			arrImages[i].onmouseover = function() {
				strSrcTmp = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('altsrc'));
			}

			arrImages[i].onmouseout = function() {
				if (!strSrcTmp) strSrcTmp = this.getAttribute('src').replace("_on" + imgtype, imgtype);
				this.setAttribute('src', strSrcTmp);
			}

		}
	}
}

function close_leaving_popup(){
	window.close();
}


function popup_window2(popup_url,popup_width,popup_height){
	var pwin2;
	window.resizeTo(popup_width,popup_height);
	pwin2 = window.open(popup_url,"newWindow","scrollbars=yes,scrolling=yes,resizable=yes,width="+popup_width+",height="+popup_height+",left=0,top=100");

}
function leaving_popup(popup_url,popup_width,popup_height){
	var pwin3;
	pwin3 = window.open(popup_url,"newWindow","width="+popup_width+",height="+popup_height+",left=0,top=100");
}


// This function is used when the user come first time to the page
function MyIndexOf(text,what,from){ if(text=="") return -1; else return text.indexOf(what,from)}

function CheckTheCookie()
{
	var bgin = MyIndexOf(document.cookie,"FirstTimeUser=",0);
	if(bgin == -1)
	{
      //AjaxProxy.ClientPutObservation('101', location.href);
      //AjaxProxy.ClientPutObservationData('101', "ican_disclaimer" , 0);
			window.location.href = "disclaimer.aspx";
	}
	else	
	{
       var receipepage = IcanwithRAUpdateClientProxy.GetReceipePage().value;
	    if( receipepage != "")
	    {
	    window.location.href = receipepage;
	    }
	    else
	    {
	    window.location.href = "recipes.aspx";
	    }
	    
        //AjaxProxy.ClientPutObservation('101', location.href);
        //AjaxProxy.ClientPutObservationData('101', "ican_recipes", 0);
			
	}
}
function LoadRecipes()
{
	document.cookie = "FirstTimeUser=1";	
	var receipepage = IcanwithRAUpdateClientProxy.GetReceipePage().value;
	if( receipepage != "")
	{
	    window.location.href = receipepage;
	}
	else
	
	{
	  window.location.href =  "recipes.aspx";
	} 
	//AjaxProxy.ClientPutObservation('101', 'ican_recipes');
    //AjaxProxy.ClientPutObservationData('101', "ican_recipes", 0);
}
function MyWindowOpen(name){
window.open(name,'Max','toolbar=no,width=410,height=700,left=10,top=10,screenX=10,screenY=10,status=no,scrollbars=yes,resize=yes');
//AjaxProxy.ClientPutObservation('101', location.href);
//var myURL = location.href.match(/^.*\//);
//AjaxProxy.ClientPutObservationData('101', myURL + name, 0);
}
function ToolOpen(name){
window.open(name,'Tool','toolbar=no,width=600,height=450,left=10,top=10,screenX=10,screenY=10,status=no,scrollbars=yes,resize=yes');
}
function TermOpen(name){
window.open(name,'Term','toolbar=no,width=760,height=750,left=10,top=10,screenX=10,screenY=10,status=no,scrollbars=yes,resize=yes');
//AjaxProxy.ClientPutObservation('101', location.href);
//var myURL = location.href.match(/^.*\//);
//AjaxProxy.ClientPutObservationData('101', myURL + name, 0);
}
function refreshPage(name){
	opener.location.href = name;
	window.close();
}