		function preloader(x,y,z){ // x=upc, y=image src, z = coupon/text container

			var myimageDiv = document.getElementById(z);
			objImage = new Image(); 
			objImage.src = y;
			//myimageDiv.style.display = 'block';
			//myimageDiv.style.marginTop = '140px';
			objImage.onLoad=printSomething(x);
		
		}

		function makeSwf(mySwfPath){
		var flashinstall = 'flash/expressInstall.swf';
    var flashvars = {};
    var params = {};
    params.play = "true";
    params.loop = "true";
    params.menu = "false";
    params.quality = "autohigh";
    params.scale = "noscale";
    params.wmode = "window";
    params.swliveconnect = "true";
    params.allowfullscreen = "false";
    params.allowscriptaccess = "always";
    var attributes = {};
    attributes.id = "flashcontent";
    attributes.name = "flashcontent";
//    swfobject.embedSWF(mySwfPath, "myAlternativeContent", "1", "1", "9.0.0", flashinstall, flashvars, params, attributes);
		swfobject.embedSWF(mySwfPath, "flashcontent", "1", "1", "8",flashinstall);	
		}

		function toggleRadioSpot(onoff){
			var myRadioButton = document.getElementById('radioButton');
			if (onoff == 1) {
				var mySwfPath = "flash/radioSpot1.swf";
				myRadioButton.innerHTML = '<a class="buttonRadioOff" href="javascript:toggleRadioSpot(0);"><img src="images/spacer.gif" /></a>';
			} else {
				var mySwfPath = "flash/radioSpot-none.swf";
				myRadioButton.innerHTML = '<a class="buttonRadio" href="javascript:toggleRadioSpot(1);"><img src="images/spacer.gif" /></a>';
			};					
			makeSwf(mySwfPath);
		}

		
function createSubContainerNav(myNav){ 
// myNav is an array 
// var myNav = ['item1','item2','item3'];
// setup subnav links for fades	
		$("#recipeSingle1").show(0); $("#recipeSingle2").hide(); $("#recipeSingle3").hide(); // default - 1st bton on

		$.each( myNav, function(i, n){ 
			$('.'+myNav[0]).addClass(myNav[0]+"On"); // default - show 1st item
			if (i == 0){
			$('.' + n).click(function () { $("#recipeSingle1").fadeIn(400); $("#recipeSingle2").hide(); $("#recipeSingle3").hide();
				$('.'+myNav[0]).removeClass(myNav[0]+"On"); 
				$('.'+myNav[0]).addClass(myNav[0]+"On"); 
				$('.'+myNav[1]).removeClass(myNav[1]+"On");
				$('.'+myNav[1]).addClass(myNav[1]);
				$('.'+myNav[2]).removeClass(myNav[2]+"On");
				$('.'+myNav[2]).addClass(myNav[2]);
			return true; });
			}
			if (i == 1){
			$('.' + n).click(function () { $("#recipeSingle1").hide(); $("#recipeSingle2").fadeIn(400); $("#recipeSingle3").hide();
				$('.'+myNav[0]).removeClass(myNav[0]+"On"); 
				$('.'+myNav[0]).addClass(myNav[0]); 
				$('.'+myNav[1]).removeClass(myNav[1]+"On");
				$('.'+myNav[1]).addClass(myNav[1]+"On");
				$('.'+myNav[2]).removeClass(myNav[2]+"On");
				$('.'+myNav[2]).addClass(myNav[2]);
			 return true; });
			}
			if (i == 2){
			$('.' + n).click(function () { $("#recipeSingle1").hide(); $("#recipeSingle2").hide(); $("#recipeSingle3").fadeIn(400);
				$('.'+myNav[0]).removeClass(myNav[0]+"On"); 
				$('.'+myNav[0]).addClass(myNav[0]); 
				$('.'+myNav[1]).removeClass(myNav[1]+"On");
				$('.'+myNav[1]).addClass(myNav[1]);
				$('.'+myNav[2]).removeClass(myNav[2]+"On");
				$('.'+myNav[2]).addClass(myNav[2]+"On");
			 return true; });
			}
	});

}

// page obsconce


		function createCookie(name,value,days) {
			if (days) {
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}
			else var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
		}
		
		function readCookie(name) {
			var nameEQ = name + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			return null;
		}
		
		function eraseCookie(name) 
		{
			createCookie(name,"",-1);
		}


	function allowPrint()
	{
		// Get the cookie
		var prints = readCookie('com.pastavalue.prints');
		
		// create the cookie if it doesn't exist
		if(!prints)
		{
			createCookie('com.pastavalue.prints','0',365);
			return true;
		}
	
		// Fail if the cookie is over 3
		if(prints > 3)
			return false;
	
		// Increment cookie
		createCookie('com.pastavalue.prints',prints + 1 + '',365);
		
		return true;
	}
	
	function openPopup()
	{
		if(allowPrint())
			window.open("popup.php", "Test", "menubar=no,width=320,height=100,toolbar=no,status=no");
		else
		// changed from error.html to popup.html to avoid count.
		window.open("popup.php", "Test", "menubar=no,width=320,height=100,toolbar=no,status=no");
	}

	function printSomething(x){
			// x is sent from preloader(x), where x comes from body onload.
			window.print();
			// add google tracking
			pageTracker._trackEvent('Coupon', 'Print', 'Post Print Dialog', x);
			// end google tracking
			window.close();
	}