// JavaScript Document
var code0='BOOST'; //special promotion
var code1='NJ107928SBS'; //all bottles + wrap regular price
var code2='NJ107940CAS'; //18 oz only bottle
var code3='small-large-bottles@@@'; // small and large bottles regular price
var code4='small-medium-bottles@@@'; //small and medium lower price
var code5='small-medium-bottles@@@'; //NH103290NS' small and medium regular price

var code6='NJ107928MAS';
var code7='NJ107928WAS';
var code8='NJ107928LAS';

var code9='large-medium-bottles@@@';
var code10='NJ107928CHS';
var code11='NJ107928SP';
var code12='notactive'; //'UPPERML'
var code13='NORFOLK';
var code14='BIZMOM';
var code15='notactive'; //'EXLEYTX'
var code16='MI148306HMS';
var code17='notactive';//'HUNTVALLEY'
var code18='notactive';//"CAMPAVE";
var code19='MILLBURN GREEN';
var code20='MILLBURNGREEN';
var code21='RMCS';


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 callPage(code){

   	alert("Shopping cart is closed!");
   	return false;
	

	if (code == "")
      alert("Please enter school code");
  	else 
  	{
 	if (code == code1 || code == code6 || code == code7 || code == code8 || code == code11) /* 3 bottles fr + wrap*/
   		window.location = "http://www.back2tap.com/products_fr1.html";
    else if (code == code3) /* small and large bottles bottles fr*/
   		window.location = "http://www.back2tap.com/products_fr1_sl.html";
	else if (code == code4) /* small and medium bottles lower price fr*/
		window.location = "http://www.back2tap.com/products_fr1_sm1.html";
	else if (code == code5) /* small and medium bottles regular price fr*/
		window.location = "http://www.back2tap.com/products_fr1_sm.html";
	else if(code == code9) /* bottles only med large */
   		window.location = "http://www.back2tap.com/products_fr1_ml.html";	
	else if(code == code10) /* all 3 bottles only */
   		window.location = "http://www.back2tap.com/products_fr1_btlonly.html";	
	else if(code == code0 || code == code2) /*18 special price */
		window.location = "http://www.back2tap.com/products_fr1_18only.html";
	else if(code == code12) 
		window.location = "http://www.back2tap.com/schools/upperml/products_fr.html";
	else if(code == code13) 
		window.location = "http://www.back2tap.com/schools/norfolk/products_fr.html";
	else if(code == code14)
		window.location = "http://www.back2tap.com/schools/bizmom/products_fr.html";
	else if(code == code15) 
		window.location = "http://www.back2tap.com/schools/ellaexley/products_fr.html";
	else if(code == code16) 
		window.location = "http://www.back2tap.com/schools/hartmiddleschool/products_fr.html";	
	else if(code == code17) 
		window.location = "http://www.back2tap.com/schools/huntvalley/products_fr.html";	
	else if(code == code18) 
		window.location = "http://www.back2tap.com/schools/campavenue/products_fr.html";	
	else if(code == code19 || code == code20)
		window.location = "http://www.back2tap.com/schools/millburn/products_fr.html";	
	else if(code == code21) 
		window.location = "http://www.back2tap.com/schools/rickmarcotte/products_fr.html";	
	else	
  	   alert("Code does not exist, Please re-enter code");
  }
}

function readSchoolCode(frm){
	var code = frm.schoolCode.value.toUpperCase();  
	createCookie('schoolcode', code, 7);
	callPage(code);	
}

function getSchoolCode(){
	var code = readCookie('schoolcode');
	callPage(code);
}


