// JavaScript Document


function validateTasteOfPaulina() {
	
		var packageField = document.getElementById('VARSize').value;

		var buttonValue = 'paulinamarket|Monthly Gift-Box Club - ' + packageField + ' Months';
	
		var silentPost = packageField + '-';
		
			for (i = 1; i <= packageField; i++) {
				
				var choiceCategoryName = 'month' + i + 'choice-category';
				var choiceTypeName = 'month' + i + 'choice-type';
				var sausagesChoices = 'sausagesChoices' + i;
				var choiceCategory =  document.getElementById(choiceCategoryName).value;
				var choiceType =  document.getElementById(choiceTypeName).value;
				var sausagesChoicesValue =  document.getElementById(sausagesChoices).value;
				var choiceTypeSplit = choiceType.split(" - ");
				var elseTypeSplit = choiceType.split("_");
				
				if (choiceCategory == "sausage") {
					var theChoiceType = choiceType;
				} else {
					var theChoiceType = elseTypeSplit[1];
				}
						
				if (!choiceType || choiceType == "") {
					alert ("Please make a selection for Month " + i);
					return false
				} else {
					buttonValue = buttonValue + '<br /><br />Month '+i+': '+choiceCategory+' ('+theChoiceType+')';
						if (choiceCategory == "sausage") {
							silentPost = silentPost + sausagesChoicesValue + '-';
						} else {
							silentPost = silentPost + elseTypeSplit[0] + '-';
						}
					
					if (choiceCategory == "sausage") {
						var noteFieldGet = 'month' + i + 'choice-sausage-details';
						var noteField = document.getElementById(noteFieldGet).value;
						if (!noteField || noteField == "") {
						} else {
							buttonValue = buttonValue + '<br />Notes: '+noteField;
						}
					}
				}
				
			}
			
			var  priceValue = (75.00 * packageField);
						
			var newSilentPost = silentPost.substring(0, silentPost.length-1);

			buttonValue = buttonValue + '|$' + priceValue + '.00|1|' + newSilentPost + '||||Shipping:Tax||http://www.paulinameatmarket.com/processTasteOfPaulina.php|||';

			document.getElementById('AddItem').value = buttonValue;

			var answer = confirm("Are you sure you a ready to submit your choices?\n\nYou will not be able to change your choice once you submit them\n\nYou will need to re-pick them if you want to change them")

			if (answer){
				return true;
			}
			else{
				return false;
			}

}



function updateMonthOptions(monthId, theObj)
{
	
	if(theObj.value == "steak") {
		document.getElementById('month'+monthId+'steak').style.display = 'block';	
		document.getElementById('month'+monthId+'sausage').style.display = 'none';	
		document.getElementById('month'+monthId+'entree').style.display = 'none';	
		document.getElementById('month'+monthId+'roast').style.display = 'none';
		document.getElementById('month'+monthId+'paulina').style.display = 'none';
	}
	if(theObj.value == "sausage") {
		document.getElementById('month'+monthId+'steak').style.display = 'none';	
		document.getElementById('month'+monthId+'sausage').style.display = 'block';	
		document.getElementById('month'+monthId+'entree').style.display = 'none';	
		document.getElementById('month'+monthId+'roast').style.display = 'none';
		document.getElementById('month'+monthId+'paulina').style.display = 'none';
	}
	if(theObj.value == "entree") {
		document.getElementById('month'+monthId+'steak').style.display = 'none';	
		document.getElementById('month'+monthId+'sausage').style.display = 'none';	
		document.getElementById('month'+monthId+'entree').style.display = 'block';	
		document.getElementById('month'+monthId+'roast').style.display = 'none';
		document.getElementById('month'+monthId+'paulina').style.display = 'none';
	}
	if(theObj.value == "roast") {
		document.getElementById('month'+monthId+'steak').style.display = 'none';	
		document.getElementById('month'+monthId+'sausage').style.display = 'none';	
		document.getElementById('month'+monthId+'entree').style.display = 'none';	
		document.getElementById('month'+monthId+'roast').style.display = 'block';
		document.getElementById('month'+monthId+'paulina').style.display = 'none';
	}
	if(theObj.value == "paulina") {
		document.getElementById('month'+monthId+'steak').style.display = 'none';	
		document.getElementById('month'+monthId+'sausage').style.display = 'none';	
		document.getElementById('month'+monthId+'entree').style.display = 'none';	
		document.getElementById('month'+monthId+'roast').style.display = 'none';
		document.getElementById('month'+monthId+'paulina').style.display = 'block';
	}

updateCategory(monthId, theObj.value);

}

function updateCheckbox(monthId, nameObj, theCount, choiceObj)
{
	var checkThisName = eval("document.formMain." + nameObj);
		
	var cValue = "";

	var splitValue = "";
	var splitId = "";

	var getIds = "";

	var cCount = 0;
	
		for (i = 0; i < checkThisName.length; i++) {
			if (checkThisName[i].checked)
			{
				cCount ++;	
				if (cCount > 4) {
					alert ("You can only select 4 choices");
					checkThisName[theCount].checked = false;
				} else {
					splitValue = checkThisName[i].value;
					splitId = splitValue.split("_");
					getIds += splitId[0] + ",";
					cValue += splitId[1] + " - ";
				}
			}
		}

		var newStr = cValue.substring(0, cValue.length-3);
		var newIds = getIds.substring(0, getIds.length-1);
		document.getElementById("sausagesChoices"+monthId).value = newIds;
		document.getElementById("month"+monthId+"choice-type").value = newStr;
}



function updateType(monthId, cat, choiceObj)
{
	document.getElementById("month"+monthId+"choice-type").value = choiceObj.value;
}

function updateCategory(monthId, choiceObj)
{
	document.getElementById("month"+monthId+"choice-category").value = choiceObj;
	document.getElementById("month"+monthId+"choice-type").value = '';
}


function updatePaulina(monthId, thisObj)
{
	document.getElementById("month"+monthId+"choice-type").value = thisObj.value;
}






function updatemonths()
{
var packageField = document.getElementById('VARSize');

	if(packageField.value == "3") {
		document.getElementById('monthly3months').style.display = 'block';	
		document.getElementById('monthly6months').style.display = 'none';	
		document.getElementById('monthly9months').style.display = 'none';	
		document.getElementById('monthly12months').style.display = 'none';	
		document.getElementById('totalPrice').innerHTML = 'Total $225.00';	
		
	}
	if(packageField.value == "6") {
		document.getElementById('monthly3months').style.display = 'block';	
		document.getElementById('monthly6months').style.display = 'block';	
		document.getElementById('monthly9months').style.display = 'none';	
		document.getElementById('monthly12months').style.display = 'none';
		document.getElementById('totalPrice').innerHTML = 'Total $450.00';
	}
	if(packageField.value == "12") {
		document.getElementById('monthly3months').style.display = 'block';	
		document.getElementById('monthly6months').style.display = 'block';	
		document.getElementById('monthly9months').style.display = 'block';	
		document.getElementById('monthly12months').style.display = 'block';	
		document.getElementById('totalPrice').innerHTML = 'Total $900.00';	
	}

}


function changeprice(box, txtname, boxname, selobj)
{
txtname.value=box;
var selectedOption = selobj[selobj.selectedIndex];
var label = selectedOption.firstChild.nodeValue;
boxname.value=label;
}
function changeprices(box, txtname, boxname, selobj, qtyid, qtybox)
{
txtname.value=box;
var selectedOption = selobj[selobj.selectedIndex];
var label = selectedOption.firstChild.nodeValue;
boxname.value=label;
qtybox.value=qtyid;
}

function blank_search()
{
if (searchform.term.value == "" || searchform.term.value == "Search")
{
alert("Please provide a search term.");
searchform.term.focus();
return (false);
}
return (true);
}

function P7_swapClass(){ //v1.4 by PVII
 var i,x,tB,j=0,tA=new Array(),arg=P7_swapClass.arguments;
 if(document.getElementsByTagName){for(i=4; i<arg.length; i++){tB=document.getElementsByTagName(arg[i]);
  for(x=0;x<tB.length;x++){tA[j]=tB[x];j++;}}for(i=0;i<tA.length;i++){
  if(tA[i].className){if(tA[i].id==arg[1]){if(arg[0]==1){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}else{tA[i].className=arg[2];}
  }else if(arg[0]==1 && arg[1]=='none'){if(tA[i].className==arg[2] || tA[i].className==arg[3]){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}
  }else if(tA[i].className==arg[2]){tA[i].className=arg[3];}}}}
}

function P7_writeStyles(a){ //v1.1 by PVII
 var tS="<style type=\"text/css\">";
 tS+="\n"+a+"\n</style>";document.write(tS);
}
P7_writeStyles('.closed ul{display:none; list-style:none;} .open ul{display:block; padding:0px; margin:0px; font-weight:normal;} li.open{font-weight:normal; color:#000000; list-style: none;} li.closed{font-weight:normal; color:#000000; list-style: none;}');
//-->
NewImg = new Array (
"tour_images/01_paulina.gif",
"tour_images/02_paulina.gif",
"tour_images/03_paulina.gif",
"tour_images/04_paulina.gif",
"tour_images/05_paulina.gif",
"tour_images/06_paulina.gif",
"tour_images/07_paulina.gif",
"tour_images/08_paulina.gif",
"tour_images/09_paulina.gif",
"tour_images/10_paulina.gif",
"tour_images/11_paulina.gif",
"tour_images/12_paulina.gif",
"tour_images/13_paulina.gif",
"tour_images/14_paulina.gif",
"tour_images/15_paulina.gif",
"tour_images/16_paulina.gif",
"tour_images/17_paulina.gif",
"tour_images/18_paulina.gif",
"tour_images/19_paulina.gif",
"tour_images/20_paulina.gif",
"tour_images/21_paulina.gif",
"tour_images/22_paulina.gif",
"tour_images/23_paulina.gif",
"tour_images/24_paulina.gif"
);
var ImgNum = 0;
var ImgLength = NewImg.length - 1;

//Time delay between Slides in milliseconds
var delay = 3000;

var lock = false;
var run;
function chgImg(direction) {
if (document.images) {
ImgNum = ImgNum + direction;
if (ImgNum > ImgLength) {
ImgNum = 0;
}
if (ImgNum < 0) {
ImgNum = ImgLength;
}
document.slideshow.src = NewImg[ImgNum];
   }
}
function auto() {
if (lock == true) {
lock = false;
document.playstop.src = "images/slideshow_play.gif";
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
document.playstop.src = "images/slideshow_stop.gif";
run = setInterval("chgImg(1)", delay);
   }
}

