// JavaScript Document


	var coupons = new Array (  // place to put coupon codes
	  "BSC",                 // 1st coupon value - comma seperated
	  "CAOG",
	  "LEIC",
	  "LSWCD",
	  "OVO",
	  "TOLCOM",
	  "TMETRO",
	  "W0356",
	  "XMAS08"
	);
	
	var couponsDesc = new Array (  // description shown in pop up on TNR when checkout is clicked
	  "The Black Swamp Conservancy appreciates your support.\n\nA donation of $5.00 will be made on your behalf to advance land preservation in Northwest Ohio.",                 // 1st coupon value - comma seperated
	  "Congratulations! Because you are one of the first 25 readers to respond, you will receive $3 off the regular purchase price: $19.99 - $3.00 = $16.99 (+ tax). Your discount will be reflected at checkout.\n\n Country Anglin' Outdoor Guide appreciates your support. A donation of $5.00 will also be made on your behalf to maintain CAOG as a free publication.",
	  "LEIC appreciates your support.\n\nA donation of $5.00 will be made on your behalf to advance Lake Erie Island land preservation.",
	   "The Lucas County Soil & Water Conservation District appreciates your support.\n\nA donation of $5.00 will be made on your behalf to advance conservation efforts of the LSWCD.",
	   "Ohio Valley Outdoor Magazine appreciates your support.\n\nA donation of $5.00 will be made on your behalf to benefit efforts to get young people involved in the outdoors in the OVO coverage area.",
	   "Thanks for ordering through Toledo.com!",
	   "The Metroparks of Toledo appreciates your support.\n\nA donation of $5.00 will be made on your behalf to provide additional fishing access on the Maumee River.",
	  "And thanks for your interest in Ohio's fishing resources.\n\nYour $2.00 discount will be reflected at checkout.\n\n$19.99 - $2.00 = $17.99 (+ tax)",
	  "Thanks for your order. An additional $5 will be taken off your order for a total price of $14.99 per unframed print. Happy holidays!"
	);
	
	var couponsDescPM = new Array (  // description for PLAQUE-MOUNTED
	  "The Black Swamp Conservancy appreciates your support.\n\nA donation of $15.00 will be made on your behalf to advance land preservation in Northwest Ohio.",                 // 1st coupon value - comma seperated
	  "Congratulations! Because you are one of the first 25 readers to respond, you will receive $3 off the regular purchase price: $79.99 - $3.00 = $76.99 (+ tax). Your discount will be reflected at checkout.\n\n Country Anglin' Outdoor Guide appreciates your support. A donation of $5.00 will also be made on your behalf to maintain CAOG as a free publication.",
	  "LEIC appreciates your support.\n\nA donation of $5.00 will be made on your behalf to advance Lake Erie Island land preservation.",
	   "The Lucas County Soil & Water Conservation District appreciates your support.\n\nA donation of $5.00 will be made on your behalf to advance conservation efforts of the LSWCD.",
	   "Ohio Valley Outdoor Magazine appreciates your support.\n\nA donation of $5.00 will be made on your behalf to benefit efforts to get young people involved in the outdoors in the OVO coverage area.",
	   "Thanks for ordering through Toledo.com!",
	   "The Metroparks of Toledo appreciates your support.\n\nA donation of $12.00 will be made on your behalf to provide additional fishing access on the Maumee River.",
	  "And thanks for your interest in Ohio's fishing resources.\n\nYour $2.00 discount will be reflected at checkout.\n\n$79.99 - $2.00 = $77.99 (+ tax)",
	  "Thanks for your order. An additional $12 will be taken off your order for a total price of $67.99 per plaque mounted print. Happy holidays!"
	);
	
	var couponsDescAbrev = new Array (  // description sent to paypal or google checkout
	  "$5.00 of proceeds to benefit BSC (Black Swamp Conservancy)",                 // 1st coupon value - comma seperated
	  "$5.00 of proceeds to benefit CAOG. $19.99 - $3.00 (CAOG discount) =",
	  "$5.00 of proceeds to benefit LEIC",
	  "$5.00 of proceeds to benefit the LSWCD (Lucas Soil & Water Conservation District)",
	  "$5.00 of proceeds to benefit youth organizations in the OVO coverage area",
	  "Ordered through Toledo.com",
	  "$5.00 of proceeds to benefit The Metroparks of the Toledo Area",
	  "$19.99 - $2.00 (W0356 discount) =",
	  "$19.99 - $5.00 (Friends & Family discount) ="
	  
	);
	
	var couponsDescAbrevPM = new Array (  // description for PLAQUE-MOUNTED
	  "$15.00 of proceeds to benefit BSC (Black Swamp Conservancy)",                 // 1st coupon value - comma seperated
	  "$5.00 of proceeds to benefit CAOG. $79.99 - $3.00 (CAOG discount) =",
	  "$5.00 of proceeds to benefit LEIC",
	  "$5.00 of proceeds to benefit the LSWCD (Lucas Soil & Water Conservation District)",
	  "$5.00 of proceeds to benefit youth organizations in the OVO coverage area",
	  "Ordered through Toledo.com",
	  "$12.00 of proceeds to benefit The Metroparks of the Toledo Area",
	  "$79.99 - $2.00 (W0356 discount) =",
	  "$79.99 - $12.00 (Friends & Family discount) ="
	);
	
	
	var coupdc  = new Array (  // place to put discounts for coupon vals (dollar value)
	  0,
	  3,
	  0,
	  0,
	  0,
	  0,
	  0,
	  2,
	  5
	);
	
	var coupdcPM  = new Array (  // place to put discounts foPLAQUE-MOUNTED
	  0,
	  3,
	  0,
	  0,
	  0,
	  0,
	  0,
	  2,
	  12
	);

	function show_ccode() {
		(document.getElementById('ccode').style.display=='none')? document.getElementById('ccode').style.display='block' : document.getElementById('ccode').style.display='none'
	
	}
	
	function check_on_load() {
		//check for a code to be passed via the querystring
		//if code found, populate tnr_code and show_ccode()
		var codeIn = gup('tnr_code');
		//if not empty then fill in and show code box
		if(codeIn!=''){ 
			document.getElementById('tnr_code').value = codeIn;
			//show box
			//show_ccode();			
		} else { 
			//do nothing
		} 

		
	}
	
	function gup(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 results[1];
	}
	
	function pp_check_code(num) {
		var bbad = false;
		
		if (document.getElementById('tnr_code').value != "") {
			switch(num) {
				case '1':
					document.getElementById('os1').value = 'No Code Selected.';
					document.getElementById('amount1').value = 19.99;
					var c_var = 19.99;
					for (i=0; i<coupons.length; i++) {
						//alert(coupons[i]+" ---"+couponsDesc[i]);
						if (document.getElementById('tnr_code').value == coupons[i]) {
						 var discnt = coupdc[i];  // remember the discount amt
						 var discntdesc = couponsDesc[i];
						  alert ("Thank you for entering a valid promotional code. \n\n"+discntdesc);
						  var tres = (c_var - discnt);
						  tres = Math.round(tres*Math.pow(10,2))/Math.pow(10,2)
						  document.getElementById('amount1').value = tres
						  document.getElementById('os1').value = couponsDescAbrev[i];
						  return true;
						}
						else {
							bbad = true;
						}
					}
					break;
				case '2':
					document.getElementById('os2').value = 'No Code Selected.';
					document.getElementById('amount2').value = 79.99;
					var c_var = 79.99;
					for (i=0; i<coupons.length; i++) {
						//alert(coupons[i]+" ---"+couponsDesc[i]);
						if (document.getElementById('tnr_code').value == coupons[i]) {
						 var discnt = coupdcPM[i];  // remember the discount amt
						 var discntdesc = couponsDescPM[i];
						  alert ("Thank you for entering a valid promotional code. \n\n"+discntdesc);
						  var tres = (c_var - discnt);
						  tres = Math.round(tres*Math.pow(10,2))/Math.pow(10,2)
						  document.getElementById('amount2').value = tres
						  document.getElementById('os2').value = couponsDescAbrevPM[i];
						  return true;
						}
						else {
							bbad = true;
						}
					}
					break;
			}
		
			
			if (bbad) {
			 alert ("Invalid promotional code! \n\n Please try again. \n\n If you do not have a valid code, simple clear this field and proceed to the checkout.");
					 return false;
			 }
		}
	}
			 

	
	function pp_check_code_working(num) {
		var bbad = false;
		if (document.getElementById('tnr_code').value != "") {
			//reset form values
				document.getElementById('os1').value = 'No Code Selected.';
				document.getElementById('os2').value = 'No Code Selected.';
				document.getElementById('amount1').value = 19.99;
				var c_var1 = 19.99;
				
				document.getElementById('amount2').value = 79.99;
				var c_var2 = 79.99;

			for (i=0; i<coupons.length; i++) {
				//alert(coupons[i]+" ---"+couponsDesc[i]);
				if (document.getElementById('tnr_code').value == coupons[i]) {
				 var discnt = coupdc[i];  // remember the discount amt
				 var discntdesc = couponsDesc[i];
				  alert ("Thank you for entering a valid promotional code. \n\n"+discntdesc);
				  
				  document.getElementById('amount1').value = (c_var1 - discnt);
				  document.getElementById('amount2').value = (c_var2 - discnt);
				  //alert(document.forms.BB_BuyButtonForm.item_price_1.value+" - "+(18.5-3));
				  //return false
				 
				    document.getElementById('os1').value = couponsDescAbrev[i];
					document.getElementById('os2').value = couponsDescAbrev[i];
				  return true;
				}
				else {
					bbad = true;
				}
			  }
			 if (bbad) {
			 alert ("Invalid promotional code! \n\n Please try again. \n\n If you do not have a valid code, simple clear this field and proceed to the checkout.");
					 return false;
			 }
		}
		
	}
	
	
	function gotoupp(x) {
		
		var tmp = document.getElementById(x).value;
		document.getElementById(x).value = tmp.toUpperCase();
	}
