
/*------------------------------------------------------------------------------
	init stuff
------------------------------------------------------------------------------*/	
	
	window.onload = function(){ 
		initRollovers();
		externalLinks();
		initTabs();
	}
	



/*------------------------------------------------------------------------------
	Popup Windows
------------------------------------------------------------------------------*/	

	var myWin = null;
	function popup(theUrl, width, height) {
		if ((! myWin) || (myWin.closed)) {
			theDim = 'width='+width+',height='+height+',left=5,top=5,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,';
			myWin = window.open(theUrl, '', theDim);
			myWin.opener = window;
		} else {
			myWin.location = theUrl;
			myWin.focus();
			myWin.opener = window;
		}
	}
	

/*------------------------------------------------------------------------------
	IE flickering background fix
------------------------------------------------------------------------------*/	
	try {
	  document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}


/*------------------------------------------------------------------------------
	XHTML valid external links
------------------------------------------------------------------------------*/	

	function externalLinks() { 
		if (!document.getElementsByTagName) return; 
		var anchors = document.getElementsByTagName("a"); 
		for (var i=0; i<anchors.length; i++) { 
			var anchor = anchors[i]; 
			if (anchor.getAttribute("href") && 
					anchor.getAttribute("rel") == "external") 
				anchor.target = "_blank"; 
		} 
	} 

	
/*------------------------------------------------------------------------------
	img rollover
------------------------------------------------------------------------------*/

	
	function initRollovers() {
		if (!document.getElementById) return
		
		var aPreLoad = new Array();
		var sTempSrc;
		var aImages = document.getElementsByTagName('img');
	
		for (var i = 0; i < aImages.length; i++) {		
			if (aImages[i].className == 'imgover') {
				var src = aImages[i].getAttribute('src');
				var ftype = src.substring(src.lastIndexOf('.'), src.length);
				var hsrc = src.replace(ftype, '_o'+ftype);
	
				aImages[i].setAttribute('hsrc', hsrc);
				
				aPreLoad[i] = new Image();
				aPreLoad[i].src = hsrc;
				
				aImages[i].onmouseover = function() {
					sTempSrc = this.getAttribute('src');
					this.setAttribute('src', this.getAttribute('hsrc'));
				}	
				
				aImages[i].onmouseout = function() {
					if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
					this.setAttribute('src', sTempSrc);
				}
			}
		}
	}
	
/*------------------------------------------------------------------------------
	Product Locator Window
------------------------------------------------------------------------------*/
	function openProdLoc(url) {
		quizWin=window.open(url, "",  "toolbar=no,directories=no,status=no,location=0,resizable=no,scrollbars=yes,menubar=no,width=533,height=495,screenY=25,screenX=25,top=25,left=25")
	}


/*------------------------------------------------------------------------------
	Recipe Tabs
------------------------------------------------------------------------------*/

	//real function on the main recipe page
	//this is just so other templates don't throw errors
	function initTabs(){ }


/*------------------------------------------------------------------------------
Get Query String Variables
------------------------------------------------------------------------------*/
	function getParameterByName(name) {
	    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
	    var regexS = "[\\?&]" + name + "=([^&#]*)";
	    var regex = new RegExp(regexS);
	    var results = regex.exec(window.location.href);
	    if (results == null)
	        return "";
	    else
	        return decodeURIComponent(results[1].replace(/\+/g, " "));
	}
