window.onerror = onError;

function onError(sMessage, sURL, sLine) 
{ 
        var sPrompt; 
        sPrompt = "________________________________________________________\n\n" 
        sPrompt += "A client-side javascript error has occured.\n" 
        sPrompt += "________________________________________________________\n\n" 
        sPrompt += "Line:\t" + sLine + "\n" 
        sPrompt += "Reason:\t" + sMessage + "\n" 
        sPrompt += "URL:\t" + sURL + "\n" 
                
        //test to see if this is the development site 
      	if ( window.location.href.indexOf('byteinteractive.com') > 0 ) 
                window.alert(sPrompt); 
                
        return true; 
 } 

function onLoad()
{ 
	setTableHeight(0);
	cacheImages();	//function to cache all rollover images
	return true;
}

function onResize()
{ 
	//only reloads IE 5+
	if (document.getElementById)
		location.reload();
	return;
}

function setTableHeight(iFactor)
{
	var oTable;
	var oLayer;
	var lHeight;
	
	if (iFactor == 0)
		if (document.all)
			iFactor = 111;										//IE sizing factor
		else	
			iFactor = 176;										//NN sizing factor

	if ( document.getElementById )								//IE5+ & NN6
	{
		oTable = document.getElementById("tblMain")
		lHeight = getWindowHeight(iFactor);

		if (oTable)
			oTable.style.height = (lHeight);
	}
	else
	{
		if ( document.all )										//IE4
			if (document.all.tblContent)
				document.all.tblContent.setAttribute("height", (lHeight));
	}
	return;
}

function cacheImages()
{
	var i;
	var oImages = new Array(document.images.length);			//array of image objects
	//reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/_off.gif/) > 0 )
		{	
			oImages[i] = new Image();
			oImages[i].src = document.images[i].src.replace("_off.gif", "_on.gif");
		}
	}
	return;
}

function setImage(oImage)
{
	var i;

	//first reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/_on.gif/) )
			document.images[i].src.replace("_on.gif", "_off.gif");
	}
	
	//now set the image to be in the "on" state		
	oImage.src = oImage.src.replace("_off.gif", "_on.gif");
				
	return;
}

function setImageJPG(oImage)
{
	var i;

	//first reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/_on.jpg/) )
			document.images[i].src.replace("_on.jpg", "_off.jpg");
	}
	
	//now set the image to be in the "on" state		
	oImage.src = oImage.src.replace("_off.jpg", "_on.jpg");
				
	return;
}

function clearImages()
{
	var i;
	
	//reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/_on.gif/) > 0 )
			document.images[i].src = document.images[i].src.replace("_on.gif", "_off.gif");
	}
	return;
}

function clearImagesJPG()
{
	var i;
	
	//reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/_on.jpg/) > 0 )
			document.images[i].src = document.images[i].src.replace("_on.jpg", "_off.jpg");
	}
	return;
}

function openWindow(url, name, resize, w, h)
{
	var resize = "";
	
	if (resize) 
    	resize = "yes";
	else 
		resize = "no";
  
  popupWin = window.open(url, name,'resizable=' + resize + ',width=' + w + ',height=' + h+',scrollbars=yes');

  window.name = 'opener';
  
  return;
}

function getWindowHeight(iFactor)
{
	var lHeight;
	if ( document.all )										//IE specific
		lHeight = document.body.clientHeight;
	else
		lHeight = window.innerHeight;						//NN specific
	
	return lHeight-iFactor;
}

function insertDivOpen()
{
		
	if (getWindowHeight(0) > 500)
	{
		var sHTML='<div id="divScroll" onScroll="">'
		if ( document.getElementById || document.all  )			//IE5+ & NN6+, MAC & PC platforms
			document.write(sHTML);
	}
}

function insertDivClose()
{
	if (getWindowHeight(0)> 500)
	{
		var sHTML='</div>'
		if ( document.getElementById || document.all )			//IE5+ & NN6+, MAC & PC platforms
			document.write(sHTML);
	}
}

		
function openWindowWater(){
	var pounds=document.index.txtweight.value;
	var climate=document.index.optclimate.checked;

	var Exc=document.index.chkexc15.checked;
	var Elev=document.index.chkelev.checked;
	var diet=document.index.chkdiet.checked;
	
	window.open('/health/calcpageresult.asp?weight='+pounds+'&weather='+climate+'&exer='+Exc+'&elevation='+Elev+'&Dieting='+diet,'Calculator','width=535,height=360,resizeable=0');			

	}

function isPhoneNumber(theStr) {
	var theReg = /^\(?\d{3}\)?.?\d{3}.?\d{4}$/;
	return(theReg.test(theStr));
}

function isZipCode(theStr) {
	var theReg =  /^\d{5}(\-\d{4})?$/;
	return(theReg.test(theStr));
}

function openKleiner(url, name, resize, w, h)
{
	var resize = "";
	
	if (resize) 
    	resize = "yes";
	else 
		resize = "no";
  
  popupWin = window.open(url, name,'resizable=' + resize + ',width=' + w + ',height=' + h+',scrollbars=yes');

  window.name = 'opener';
  
  return;
}

function openContact()
{
	/*
	if(navigator.appName == "Netscape")
		openWindow('/contact.asp', 'contact', true, 550, 150, true);
	else
		openWindow('/contact.asp', 'contact', true, 550, 150, false);
	*/

	if(navigator.appName == "Netscape")
		openWindow('/email/contact.asp?bsc=3', 'contact', true, 500, 650, true);
	else
		openWindow('/email/contact.asp?bsc=3', 'contact', true, 500, 650, false);	
		
}		

function openRules()
{
	if(navigator.appName == "Netscape")
		openWindow('/rules.asp', 'rules', true, 550, 450, true);
	else
		openWindow('/rules.asp', 'rules', true, 550, 450, false);
}			
	function setPic(set)
		{
			var oImage = document.images.left_default;
						
			switch (set)
			{
				case 0:	
					oImage.src='images/home_00_left.jpg';
					return;
				case 1:	
					oImage.src='images/home_01_left.jpg';
					return;
				case 2:	
					oImage.src='images/home_02_left.jpg';
					return;
				case 3:	
					oImage.src='images/home_03_left.jpg';
					return;
				case 4:	
					oImage.src='images/home_04_left.jpg';
					return;				
				case 5:	
					oImage.src='images/home_05_left.jpg';
					return;									
				default:
					oImage.src='images/home_00_left.jpg';
					return;
			}
			
		}

		function cacheMap()
		{
			var k=8;
			var oImages = new Array(k);			//array of image objects
		
			//reset all rollover images to their "off" state
			for (i=0; i<k; i++)
				oImages[i] = new Image;

			oImages[0].src='images/home_00_left.jpg';
			oImages[1].src='images/home_01_left.jpg';
			oImages[2].src='images/home_02_left.jpg';
			oImages[3].src='images/home_03_left.jpg';
			oImages[4].src='images/home_04_left.jpg';
			oImages[5].src='images/home_05_left.jpg';
			return;
		}
	
//===============================================================================================================================================================
//=	FUNCTION: 	setImagegif()
//=	PARAMETERS:	oImage (Image Object)
//=	RETURNS:	null
//=	PURPOSE:	Used for JavaScript rollovers.  This function changes the src of oImage to the "on" state
//=	AUTHOR:		Steve Jansen, Byte Interactive <stj@byteinteractive.com>
//=	DATE:		November 30th, 2000
//===============================================================================================================================================================
function setImagegif(oImage)
{
	var i;

	//first reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/_on.gif/) )
			document.images[i].src.replace("_on.gif", "_off.gif");
	}
	
	//now set the image to be in the "on" state		
	oImage.src = oImage.src.replace("_off.gif", "_on.gif");
				
	return;
}

//===============================================================================================================================================================
//=	FUNCTION: 	clearImagesgif()
//=	PARAMETERS:	oImage (Image Object)
//=	RETURNS:	null
//=	PURPOSE:	Used for JavaScript rollovers.  This function resets all images to their "off" state upon the mouseout event
//=	AUTHOR:		Steve Jansen, Byte Interactive <stj@byteinteractive.com>
//=	DATE:		November 30th, 2000
//===============================================================================================================================================================
function clearImagesgif()
{
	var i;
	
	//reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/_on.gif/) > 0 )
			document.images[i].src = document.images[i].src.replace("_on.gif", "_off.gif");
	}
	return;
}

// /_scripts/productstrip.js
//===============================================================================================================================================================
//=     PURPOSE:        All functions pertaining to ProductStrip
//=     AUTHOR:         Josh Drew, Byte Interactive <jd@byteinteractive.com> 
//=     DATE:           Dec 15, 2003
//===============================================================================================================================================================

function switchDiv(div_id)
{
	var style_sheet = getStyleObject(div_id);
	if (style_sheet)
	{
		if(style_sheet.visibility == "hidden") {
			changeObjectVisibility(div_id,"visible");					
		} else {
			changeObjectVisibility(div_id,"hidden");
		}
	}
	else 
	{
		alert("sorry, this only works in browsers that do Dynamic HTML");
	}
}


function getStyleObject(objectId) {
// checkW3C DOM, then MSIE 4, then NN 4.
//
	if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId).style;
	}
	else if (document.all && document.all(objectId)) {  
		return document.all(objectId).style;
	} 
	else if (document.layers && document.layers[objectId]) { 
		return document.layers[objectId];
	} else {
		return false;
	}
}

function changeObjectVisibility(objectId, newVisibility) {
// first get a reference to the cross-browser style object 
// and make sure the object exists
	var styleObject = getStyleObject(objectId);
			
	if(styleObject) {
		styleObject.visibility = newVisibility;
		return true;
	} 
	else 
	{
		// we couldn't find the object, so we can't change its visibility
		return false;
	}
}

function popWin (file,width,height,scrollbars) {
	
	newWin = open(file,
		 'pop',
		 'toolbar=no,left=20,top=20,status=no,width='+width+',height='+height+',scrollbars='+scrollbars+',directories=no,location=no,resizable=no,menubar=no,copyhistory=yes');
		
	newWin.focus();
}


var sDestination = "http://eacquisitions.nestle-watersna.com/default.aspx?";
window.onerror = onError;

function onError()
{
	return true;
}

function launchGame(email) 
{
	openWindow("/game/game.asp", "game", false, "800", "505");
}

if (flash.ver[6])
{
	launchGame();
}
else if (flash.ver[7])
{
	F;
}
else if (flash.installed)
{
	window.location.href="noflash.asp"
}
else
{
	window.location.href="noflash.asp"
}

function openHomeFlash()
{
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="794" height="403" id="1_0_HOMEPAGE_goplay" align="middle">');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="1_0_HOMEPAGE_goplay.swf" />');
document.write ('<param name="quality" value="high" />');
document.write ('<param name="bgcolor" value="#ffffff" />');
document.write ('<embed src="1_0_HOMEPAGE_goplay.swf" quality="high" bgcolor="#ffffff" width="794" height="403" name="1_0_HOMEPAGE_goplay" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');
}

function openPromoCoupon()
{
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="290" height="130" id="Banner" align="middle">');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="Banner.swf?url=coupon.asp" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="Banner.swf?url=coupon.asp" quality="high" wmode="transparent" bgcolor="#ffffff" width="290" height="130" name="Banner" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');
}

function openPromoCoupon2(fname,lname,email)
{
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="290" height="130" id="Banner" align="middle">');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="Banner.swf?url=_crypto.asp%3Ffname='+fname+'%26lname='+lname+'%26email='+email+'" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="Banner.swf?url=_crypto.asp%3Ffname='+fname+'%26lname='+lname+'%26email='+email+'" quality="high" wmode="transparent" bgcolor="#ffffff" width="290" height="130" name="Banner" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');
}

function openFlashGame(email,score)
{
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="780" height="500" id="nwna_springshot" align="middle">');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="nwna_springshot.swf?email='+email+'&lastscore='+score+'" />');
document.write ('<param name="quality" value="high" />');
document.write ('<param name="bgcolor" value="#3b4753" />');
document.write ('<embed src="nwna_springshot.swf?email='+email+'&lastscore='+score+'" quality="high" bgcolor="#3b4753" width="780" height="500" name="nwna_springshot" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');
}

function openFlashGame2(email,score)
{
document.write ('<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH=670 HEIGHT=600>');
document.write ('<PARAM NAME=movie VALUE="photogame_main.swf?email='+email+'&lastscore='+score+'">');
document.write ('<PARAM NAME=quality VALUE="HIGH">');
document.write ('<PARAM NAME=bgcolor VALUE="#FFFFFF">');
document.write ('<EMBED SRC="photogame_main.swf?email='+email+'&lastscore='+score+'" QUALITY=HIGH BGCOLOR="#FFFFFF" WIDTH="670" HEIGHT="600" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
document.write ('</EMBED>');
document.write ('</OBJECT>');
}

function openRulesCristina()
{
	openWindow('/promotions/cristina_rules.html', 'cristinarules', true, 550, 450, false);
}	

function openRulesCristinaES()
{
	openWindow('/promotions/cristina_rules.html#spanish', 'cristinarules', true, 550, 450, false);
}	

function openRulesCristinaDetails()
{
	openWindow('/promotions/cristina_rules.html#prizedetailsen', 'cristinarules', true, 550, 450, false);
}	

function openRulesCristinaDetailsES()
{
	openWindow('/promotions/cristina_rules.html#prizedetailses', 'cristinarules', true, 550, 450, false);
}	

function openPrivacy()
{
	openWindow('/privacy.asp', 'privacy', true, 500, 650, false);
}	

function openLegal()
{
	openWindow('/legal.asp', 'legal', true, 500, 650, false);
}	

function openHomeFlashSP()
{
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="794" height="403" id="1_0_HOMEPAGE_goplay" align="middle">');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="/sp/1_0_HOMEPAGE_goplay.swf" />');
document.write ('<param name="quality" value="high" />');
document.write ('<param name="bgcolor" value="#ffffff" />');
document.write ('<embed src="/sp/1_0_HOMEPAGE_goplay.swf" quality="high" bgcolor="#ffffff" width="794" height="403" name="1_0_HOMEPAGE_goplay" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');
}

function openNutritionSP()
{
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="794" height="403" id="3_1_NUTRITIONAL_INFO" align="middle">');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="/sp/products/3_1_NUTRITIONAL_INFO.swf" />');
document.write ('<param name="quality" value="high" />');
document.write ('<param name="bgcolor" value="#ffffff" />');
document.write ('<embed src="/sp/products/3_1_NUTRITIONAL_INFO.swf" quality="high" bgcolor="#ffffff" width="794" height="403" name="3_1_NUTRITIONAL_INFO" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');
}
	
function openContactSP()
{

	if(navigator.appName == "Netscape")
		openWindow('/email/contactSP.asp?bsc=3', 'contact', true, 500, 650, true);
	else
		openWindow('/email/contactSP.asp?bsc=3', 'contact', true, 500, 650, false);	
		
}		

function openPrivacySP()
{
	openWindow('/privacySP.asp', 'privacy', true, 500, 650, false);
}	

function openRulesCristina09()
{
	openWindow('/promotions/sweeps/cristina_rules09.html', 'cristinarules', true, 550, 450, false);
}	

function openRulesCristinaES09()
{
	openWindow('/promotions/sweeps/cristina_rules09.html#spanish', 'cristinarules', true, 550, 450, false);
}	