var URL = location.href;
if(URL.indexOf('fpmenu') != -1 || URL.indexOf('fpprintmenu') != -1){

menu2 = URL.split('menu');
menu = menu2[3].split('#')
menu = menu[0];
phase1 = URL.split('phase');
phase2 = phase1[1].split('=')
phase = phase2[1].split('&')
phase = phase[0]
}
var isPopUp = '<table border="0" cellpadding="0" cellspacing="0">'
	isPopUp += '<tr><td align="right"><a href="#" onclick="window.close();"><img src="/content/usa/images/close.gif" width="48" height="12" alt="" border="0"></a></td>'
	isPopUp += '<tr><td><a href="#" onclick="printCheck();"><img src="/content/usa/images/print.gif" width="146" height="22" alt="" border="0"></a></td></tr>'
	isPopUp += '<tr><td><a href="#" onclick="sendToFriend(\'staf\')"><img src="/content/usa/images/send.gif" width="146" height="22" alt="" border="0"></a></td>'
	isPopUp += '</tr></table>';
var phase 
if(URL.indexOf('fpmenu') != -1){
	isPopUp = '<table border="0" cellpadding="0" cellspacing="0">'
	isPopUp += '<tr><td><a href="#" onclick="printCheck();"><img src="/content/usa/images/print_friend.gif" width="155" height="23" alt="" border="0"></a></td></tr><tr><td></td></tr>'
	isPopUp += '<tr><td><a href="#" onclick="shoplist(\'/fpshoplist?phase='+phase+'&menuid=menu' + menu + '\')"><img src="/content/usa/images/shop_list.gif" width="155" height="23" alt="" border="0"></a></td></tr>'
	isPopUp += '<tr><td><a href="#" onclick="sendToFriend(\'staf\')"><img src="/content/usa/images/send_to_friend.gif" width="155" height="23" alt="" border="0"></a></td>'
	isPopUp += '</tr></table>'
}
//
function printCheck(){
	if(URL.indexOf('fpmenu') != -1){
		PAGE = '/fpprintmenu?phase='+phase+'&menuid=menu'+menu
		window.open(PAGE,'printMe','width=592,height=700,scrollbars=yes');
	}
	else{
		window.print();
	}
	
}
function shoplist(PAGE){
	window.open(PAGE,'theList','width=592,height=700,scrollbars=yes');
}

function openPrivacy(){
	window.open('/privacypop', 'thewindow', 'width=592,height=700,scrollbars=yes');
}

function openRegHelp(){
	window.open('/reghelppop', 'thewindow', 'width=592,height=700,scrollbars=yes');
}

function openWin(URL){
	window.open(URL, 'thewindow', 'width=592,height=700,scrollbars=yes');
}

function openFinder(URL){
	window.open(URL, 'thewindow', 'width=420,height=683,scrollbars=yes');
}

function openBF2(URL){
	window.open(URL, 'thewindow', 'width=354,height=650,scrollbars=yes');
}

function openBF360(URL){
	window.open(URL, 'thewindow', 'width=500,height=400,scrollbars=yes');
}
function openRelease(URL){
	window.open(URL, 'thewindow', 'width=592,height=700,scrollbars=yes');
}

function moveMe(URL){
	alert(URL)
	opender.location = URL;
}

function sendToFriend(URL){
	window.open(URL, 'thewindow', 'width=379,height=573');
}

var States = new Array("AL","AK","AZ","AR","CA","CO","CT","DE","DC","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY")
var Provs = new Array("AB","BC","MB","NB","NL","NT","NS","NU","ON","PE","QC","SK","YT","AL","AK","AZ","AR","CA","CO","CT","DE","DC","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY");
var CheckState = false;
function formVal(form){
	var hiddenSplit = form.txtNextPage.value
	hiddenValue = hiddenSplit.split("?addr=")
	form.txtNextPage.value = hiddenValue[0];

	if(form.txtFirstName.value == "" || form.txtLastName.value == ""){
		alert('Sorry you have not entered your Name')
		return (false);
	}
	if(form.txtAddress1.value == ""){
		alert('Sorry you have not entered your Address')
		return (false);
	}
	if(form.txtCity.value == ""){
		alert('Sorry you have not entered your City')
		return (false);
	}
	for(var i=0; i < States.length;i++){
		if(form.txtState.value == States[i]){
			CheckState = true;
		}
	}
	if(!CheckState){
		alert("You have not entered a valid state.  Try Again!")
		form.txtState.value = "";
		form.txtState.focus();
		return (false);
	}
	var zipfullStr = form.txtZip.value;
	var zipNaNcheck = isNaN(zipfullStr);
	var zipcharCount = zipfullStr.length;
	if (zipcharCount == 5 && !zipNaNcheck){
		zipPass = true;
	}
	else {
		zipPass = false;
	}
	
	if(!zipPass){
		alert("Sorry you entered an invalid zip code. Try Again!");
		form.txtZip.focus();
		return (false);
	}
	
	var fullStr = "";
	var fullStr2 = form.txtPhone.value;
	var splitString = fullStr2.split(" ");
	for(var i =0; i < splitString.length; i++){
		fullStr = fullStr + splitString[i]
	}
	var NaNcheck = isNaN(fullStr);
	var charCount = fullStr.length;
	if (charCount == 10 && !NaNcheck){
		pass = true;
	}
	else {
		pass = false;
	}
	if(!pass){
		alert("Sorry your phone number is not entered correctly. Try Again!");
		form.txtPhone.focus();
		return (false);
	}
	if(!checkEmail()){
		alert("Sorry you did not enter a valid E-mail address.  Try Again!");
		form.txtEmail.focus();
		return (false);
	}
	if(form.txtEmail.value != form.txtEmail2.value){
		alert("Your E-mail address do not match. Try Again!")
		form.txtEmail2.value = "";
		form.txtEmail2.focus();
		return (false);
	}
	tempValue = form.txtNotes.value
	if(tempValue == ""){
		alert("Sorry you did not enter your comment.  Please try again")
		form.txtNotes.focus();
		return (false);
	}
	wordCount = tempValue.split('');
	someValue = wordCount.length;
	if(someValue > 500){
		alert("Sorry you are over the character limit.  Try Again!")
		form.txtNotes.focus();
		return (false);
	}
	if(form.txtCategory.value == ""){
		alert("Please enter a catagory. Try Again!")
		return (false);
	}
	if(form.numProductCategory.value == ""){
		alert("Please enter a product category. Try Again!")
		return (false);
	}
	form.txtNextPage.value = form.txtNextPage.value + "?addr=" + form.txtEmail.value;
}

function formValCA(form){
	var hiddenSplit = form.txtNextPage.value
	hiddenValue = hiddenSplit.split("?addr=")
	form.txtNextPage.value = hiddenValue[0];

	if(form.txtFirstName.value == "" || form.txtLastName.value == ""){
		alert('Sorry you have not entered your Name')
		return (false);
	}
	if(form.txtAddress1.value == ""){
		alert('Sorry you have not entered your Address')
		return (false);
	}
	if(form.txtCity.value == ""){
		alert('Sorry you have not entered your City')
		return (false);
	}
	for(var i=0; i < States.length;i++){
		if(form.txtState.value == Provs[i]){
			CheckState = true;
		}
	}
	if(!CheckState){
		alert("You have not entered a valid state / province.  Try Again!")
		form.txtState.value = "";
		form.txtState.focus();
		return (false);
	}
	var zipfullStr = form.txtZip.value;
	var zipNaNcheck = isNaN(zipfullStr);
	var zipcharCount = zipfullStr.length;
	if (zipcharCount == 7 || zipcharCount == 5){
		zipPass = true;
	}
	else {
		zipPass = false;
	}
	
	if(!zipPass){
		alert("Sorry you entered an invalid zip code. Try Again!");
		form.txtZip.focus();
		return (false);
	}
	
	var fullStr = "";
	var fullStr2 = form.txtPhone.value;
	var splitString = fullStr2.split(" ");
	for(var i =0; i < splitString.length; i++){
		fullStr = fullStr + splitString[i]
	}
	var NaNcheck = isNaN(fullStr);
	var charCount = fullStr.length;
	if (charCount == 10 && !NaNcheck){
		pass = true;
	}
	else {
		pass = false;
	}
	if(!pass){
		alert("Sorry your phone number is not entered correctly. Try Again!");
		form.txtPhone.focus();
		return (false);
	}
	if(!checkEmail()){
		alert("Sorry you did not enter a valid E-mail address.  Try Again!");
		form.txtEmail.focus();
		return (false);
	}
	if(form.txtEmail.value != form.txtEmail2.value){
		alert("Your E-mail address do not match. Try Again!")
		form.txtEmail2.value = "";
		form.txtEmail2.focus();
		return (false);
	}
	tempValue = form.txtNotes.value
	if(tempValue == ""){
		alert("Sorry you did not enter your comment.  Please try again")
		form.txtNotes.focus();
		return (false);
	}
	wordCount = tempValue.split('');
	someValue = wordCount.length;
	if(someValue > 500){
		alert("Sorry you are over the character limit.  Try Again!")
		form.txtNotes.focus();
		return (false);
	}
	if(form.txtCategory.value == ""){
		alert("Please enter a catagory. Try Again!")
		return (false);
	}
	if(form.numProductCategory.value == ""){
		alert("Please enter a product category. Try Again!")
		return (false);
	}
	form.txtNextPage.value = form.txtNextPage.value + "?addr=" + form.txtEmail.value;
}

function formValCF(form){
	var hiddenSplit = form.txtNextPage.value
	hiddenValue = hiddenSplit.split("?addr=")
	form.txtNextPage.value = hiddenValue[0];

	if(form.txtFirstName.value == "" || form.txtLastName.value == ""){
		alert('Désolé, mais vous n’avez pas introduit votre nom')
		return (false);
	}
	if(form.txtAddress1.value == ""){
		alert('Désolé, mais vous n’avez pas introduit votre adresse')
		return (false);
	}
	if(form.txtCity.value == ""){
		alert('Désolé, mais vous n’avez pas introduit votre ville')
		return (false);
	}
	for(var i=0; i < States.length;i++){
		if(form.txtState.value == Provs[i]){
			CheckState = true;
		}
	}
	if(!CheckState){
		alert("Vous n’avez pas inscrit un nom d’État valide.  Essayez de nouveau!")
		form.txtState.value = "";
		form.txtState.focus();
		return (false);
	}
	var zipfullStr = form.txtZip.value;
	var zipNaNcheck = isNaN(zipfullStr);
	var zipcharCount = zipfullStr.length;
	if (zipcharCount == 7 || zipcharCount == 5){
		zipPass = true;
	}
	else {
		zipPass = false;
	}
	
	if(!zipPass){
		alert("Désolé, mais vous n'avez pas introduit un code postal valide.  Essayez de nouveau!");
		form.txtZip.focus();
		return (false);
	}
	
	var fullStr = "";
	var fullStr2 = form.txtPhone.value;
	var splitString = fullStr2.split(" ");
	for(var i =0; i < splitString.length; i++){
		fullStr = fullStr + splitString[i]
	}
	var NaNcheck = isNaN(fullStr);
	var charCount = fullStr.length;
	if (charCount == 10 && !NaNcheck){
		pass = true;
	}
	else {
		pass = false;
	}
	if(!pass){
		alert("Désolé, mais votre numéro de téléphone n’est pas correctement introduit.  Essayez de nouveau!");
		form.txtPhone.focus();
		return (false);
	}
	if(!checkEmail()){
		alert("Désolé, mais vous n’avez pas introduit une adresse électronique valide.  Essayez de nouveau!");
		form.txtEmail.focus();
		return (false);
	}
	if(form.txtEmail.value != form.txtEmail2.value){
		alert("Vos adresses électroniques ne correspondent pas.  Essayez de nouveau!")
		form.txtEmail2.value = "";
		form.txtEmail2.focus();
		return (false);
	}
	tempValue = form.txtNotes.value
	if(tempValue == ""){
		alert("Désolé, mais vous n’avez pas introduit vos observations.  Veuillez essayer de nouveau.")
		form.txtNotes.focus();
		return (false);
	}
	wordCount = tempValue.split('');
	someValue = wordCount.length;
	if(someValue > 500){
		alert("Désolé, mais vous avez dépassé la limite permise de caractères.  Essayez de nouveau!")
		form.txtNotes.focus();
		return (false);
	}
	if(form.txtCategory.value == ""){
		alert("Veuillez introduire une catégorie.  Essayez de nouveau!")
		return (false);
	}
	if(form.numProductCategory.value == ""){
		alert("Veuillez introduire une catégorie de produits.  Essayez de nouveau!")
		return (false);
	}
	form.txtNextPage.value = form.txtNextPage.value + "?addr=" + form.txtEmail.value;
}

function formValProf(form){
	var hiddenSplit = form.txtNextPage.value
	hiddenValue = hiddenSplit.split("?addr=")
	form.txtNextPage.value = hiddenValue[0];

	if(form.txtFirstName.value == "" || form.txtLastName.value == ""){
		alert('Sorry you have not entered your Name')
		return (false);
	}
	if(form.txtAddress1.value == ""){
		alert('Sorry you have not entered your Address')
		return (false);
	}
	if(form.txtCity.value == ""){
		alert('Sorry you have not entered your City')
		return (false);
	}
	for(var i=0; i < States.length;i++){
		var st = form.txtState.value.toUpperCase();
		if( st == States[i]) {
			CheckState = true;
			break;
		}
	}
	if(!CheckState){
		alert("You have not entered a valid state.  Try Again!")
		form.txtState.value = "";
		form.txtState.focus();
		return (false);
	}
	var zipfullStr = form.txtZip.value;
	var zipNaNcheck = isNaN(zipfullStr);
	var zipcharCount = zipfullStr.length;
	if (zipcharCount == 5 && !zipNaNcheck){
		zipPass = true;
	}
	else {
		zipPass = false;
	}
	
	if(!zipPass){
		alert("Sorry you entered an invalid zip code. Try Again!");
		form.txtZip.focus();
		return (false);
	}
	
	var fullStr = "";
	var fullStr2 = form.txtPhone.value;
	var splitString = fullStr2.split(" ");
	for(var i =0; i < splitString.length; i++){
		fullStr = fullStr + splitString[i]
	}
	var NaNcheck = isNaN(fullStr);
	var charCount = fullStr.length;
	if (charCount == 10 && !NaNcheck){
		pass = true;
	}
	else {
		pass = false;
	}
	if(!pass){
		alert("Sorry your phone number is not entered correctly. Try Again!");
		form.txtPhone.focus();
		return (false);
	}
	if(!checkEmail()){
		alert("Sorry you did not enter a valid E-mail address.  Try Again!");
		form.txtEmail.focus();
		return (false);
	}
	if(form.txtEmail.value != form.txtEmail2.value){
		alert("Your E-mail address do not match. Try Again!")
		form.txtEmail2.value = "";
		form.txtEmail2.focus();
		return (false);
	}
	tempValue = form.txtNotes.value
	if(tempValue == ""){
		alert("Sorry you did not enter your comment.  Please try again")
		form.txtNotes.focus();
		return (false);
	}
	wordCount = tempValue.split('');
	someValue = wordCount.length;
	if(someValue > 500){
		alert("Sorry you are over the character limit.  Try Again!")
		form.txtNotes.focus();
		return (false);
	}
	form.txtNextPage.value = form.txtNextPage.value + "?addr=" + form.txtEmail.value;
}


function checkEmail() {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(contact.txtEmail.value)){
	return (true)
	}
	return (false)
}

/** ****************************************************************************
*** e-centives, breastfeeding couponing
**/

function coupon0()
{
	var fname = document.couponForm0.firstname.value;
	var lname = document.couponForm0.lastname.value;
	var email = document.couponForm0.email.value;

	var invalid = /^[^a-zA-Z]*$/i;

	if ( fname.match( invalid ) || lname.match( invalid ) || email.match( invalid ) )
	{
		alert( "Please enter all values" );
		return;
	}

	var url = 'http://offers.e-centives.com/registration/col.cfm?type=promo&id=47790AD0-F9D1-4BDA-872E-FFEE513CD248&'+
	          'e='+email+'&fn='+fname+'&ln='+lname+'&co_id=249';

	window.location = url;
}

/** ****************************************************************************
*** e-centives, Liquilytes couponing
**/

function getCookie (name) {

	var cname = name + "=";
	var dcookies = document.cookie.split(";");

	for ( var i = 0 ; i < dcookies.length ; i++ )
	{
		var entry = dcookies[i].split('=');
		if ( name == entry[0] ) return unescape(entry[1]);
	}
}

function setCookie (name, value ) { 
	var expires = new Date();
	    expires.setFullYear( expires.getFullYear() + 1 );
	document.cookie = name + "=" + escape (value) + "; expires=" + expires.toGMTString() +  "; path=/";
}


function coupon1()
{
	var uid = getCookie("coupon1"); 

	if ( null == uid )
	{

		var k = (navigator.appName + navigator.appVersion + navigator.userAgent).split('');;

		//var k0 = k.slice(0,8);
		//k = k.slice(8);

		for ( var i= 8 ; i < k.length; i++ )
		{
			k[ i%8 ] ^= k[i];
			k[i] = null;
		}

		var now = new Date();

		uid = k.join('') + now.getTime();
		setCookie("coupon1", uid );
	}

	//alert( "id ["+uid+"]" );

    var url = "http://offers.e-centives.com/registration/col.cfm?type=promo&id=98455CBB-AFC4-4E0C-A356-6C49D880F11E&"+
	          "e="+uid+"&eid="+uid+"&fn="+uid+"&ln="+uid+"&co_id=249";

	//alert( "url ["+url+"]" );

	window.location = url;
}
function coupon2(b)
{
	
	var uid = getCookie("coupon2"); 
	var id="";
	id = b == 5044  ? "445E39A1-429D-44AD-83E2-27D6B26BABD9" : id;
	id = b == 5045  ? "445E39A1-429D-44AD-83E2-27D6B26BABD9" : id;
	id = b == 5046  ? "445E39A1-429D-44AD-83E2-27D6B26BABD9" : id;
	id = b == 5047  ? "445E39A1-429D-44AD-83E2-27D6B26BABD9" : id;
	id = b == 5048  ? "445E39A1-429D-44AD-83E2-27D6B26BABD9" : id;
	id = b == 5049  ? "445E39A1-429D-44AD-83E2-27D6B26BABD9" : id;
	id = b == 5050  ? "445E39A1-429D-44AD-83E2-27D6B26BABD9" : id;
	id = b == 5051  ? "98455CBB-AFC4-4E0C-A356-6C49D880F11E" : id;
	id = b == 5052  ? "98455CBB-AFC4-4E0C-A356-6C49D880F11E" : id;
	id = b == 5053  ? "98455CBB-AFC4-4E0C-A356-6C49D880F11E" : id;
	id = b == 5054  ? "98455CBB-AFC4-4E0C-A356-6C49D880F11E" : id;
	//Garden Mashers:
	id = b == 5056  ? "0AA78C41-29DD-4AEB-AEB7-5392A8BC6337" : id;
	id = b == 5058  ? "0AA78C41-29DD-4AEB-AEB7-5392A8BC6337" : id;
	id = b == 5059  ? "0AA78C41-29DD-4AEB-AEB7-5392A8BC6337" : id;
	id = b == 5060  ? "0AA78C41-29DD-4AEB-AEB7-5392A8BC6337" : id;
	//Graduates Mini Fruits & Mini Veggies
	id = b == 5061  ? "381A6507-F872-44BE-B8E9-B1AD2C958DFC" : id;
	id = b == 5063  ? "381A6507-F872-44BE-B8E9-B1AD2C958DFC" : id;
	id = b == 5064  ? "381A6507-F872-44BE-B8E9-B1AD2C958DFC" : id;
	id = b == 5065  ? "381A6507-F872-44BE-B8E9-B1AD2C958DFC" : id;
	//Little Flakes
	id = b == 5066  ? "076CBF27-7719-42AC-B5AB-E79C63C9C9D6" : id;
	id = b == 5068  ? "076CBF27-7719-42AC-B5AB-E79C63C9C9D6" : id;
	id = b == 5069  ? "076CBF27-7719-42AC-B5AB-E79C63C9C9D6" : id;
	id = b == 5070  ? "076CBF27-7719-42AC-B5AB-E79C63C9C9D6" : id;

	
	if ( null == uid )
	{

		var k = (navigator.appName + navigator.appVersion + navigator.userAgent).split('');;

		//var k0 = k.slice(0,8);
		//k = k.slice(8);

		for ( var i= 8 ; i < k.length; i++ )
		{
			k[ i%8 ] ^= k[i];
			k[i] = null;
		}

		var now = new Date();

		uid = k.join('') + now.getTime();
		setCookie("coupon2", uid );
	}

	//alert( "id ["+uid+"]" );
			
    var url = "http://offers.e-centives.com/registration/col.cfm?type=promo&id="+id+"&b="+b+
	          "&e="+uid+"&eid="+uid+"&fn="+uid+"&ln="+uid+"&co_id=249";

	//alert( "url ["+url+"]" );

	window.location = url;
}
function coupon3()
{
	var uid = getCookie("coupon1"); 

	if ( null == uid )
	{

		var k = (navigator.appName + navigator.appVersion + navigator.userAgent).split('');;

		//var k0 = k.slice(0,8);
		//k = k.slice(8);

		for ( var i= 8 ; i < k.length; i++ )
		{
			k[ i%8 ] ^= k[i];
			k[i] = null;
		}

		var now = new Date();

		uid = k.join('') + now.getTime();
		setCookie("coupon1", uid );
	}

	//alert( "id ["+uid+"]" );

    var url = "http://offers.e-centives.com/registration/col.cfm?type=promo&id=47B9B6C2-6C43-4561-887B-C95D0213CB2D&"+
	          "e="+uid+"&eid="+uid+"&fn="+uid+"&ln="+uid+"&co_id=249";

	//alert( "url ["+url+"]" );

	window.location = url;
}