		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 toggleRecipeDiv(recipe){
			var myRecipe1 = document.getElementById('recipeSingle1');
			var myRecipe2 = document.getElementById('recipeSingle2');
			var myRecipe3 = document.getElementById('recipeSingle3');

			if (recipe == 1){
				pageTracker._trackEvent('Recipe', 'Print', 'View 1');
				myRecipe1.style.display = 'block';
				myRecipe2.style.display = 'none';
				myRecipe3.style.display = 'none';
			} else if (recipe == 2){
				pageTracker._trackEvent('Recipe', 'Print', 'View 2');
				myRecipe1.style.display = 'none';
				myRecipe2.style.display = 'block';
				myRecipe3.style.display = 'none';
			} else if (recipe == 3){
				pageTracker._trackEvent('Recipe', 'Print', 'View 3');
				myRecipe1.style.display = 'none';
				myRecipe2.style.display = 'none';
				myRecipe3.style.display = 'block';
			}

		}
		

// 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=100toolbar=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");
	}

	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();
	}