current = 0;
oldTotal = 0;
good2go=0;
function calcTotal(peopleCount){
	current = peopleCount.value;
	if(isNaN(current)){
		alert('not a number');
	} else {
		if(current != oldTotal){
			sumBox = document.getElementById('DEPOSIT');
			//sumBox = document.getElementById('amount');
			sumBox.value = "$" + current * 25 + ".00";
			oldTotal = current;
			
			buildFormRow(current);
		}		
	}
}

//good2go = 0;
//function submitChk(){
	
//	agree = document.getElementById('AGREE');
		
//	if(agree.checked){
//		return true;
//	} else {
//		alert('You must check the agreement checkbox');
//		return false;
//	}	
//}

good2go = 0;
function submitChk()
{

missinginfo = "";
if (document.form.CONTACT_NAME.value == "") {
missinginfo += "\n     -  Contact Name";
}
if(document.form.CONTACT_EMAIL.value == "") {
missinginfo += "\n     -  Contact Email";
}
if(document.form.CONTACT_PHONE.value == "") {
missinginfo += "\n     -  Contact Phone";
}
if(document.form.DATE.value == "") {
missinginfo += "\n     -  Date of Party";
}
if(document.form.START_TIME.value == "") {
missinginfo += "\n     -  Start Time of Party";
}
if(document.form.PEOPLE_COUNT.value == "") {
missinginfo += "\n     -  Amount of People";
}
if(document.form.CC_Type.value == "") {
missinginfo += "\n     -  Credit Card Type";
}
if(document.form.CC_Number.value == "") {
missinginfo += "\n     -  Credit Card Number";
}
if(document.form.CC_Exp_Date.value == "") {
missinginfo += "\n     -  Credit Card Expiry Date";
}

if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}
else return true;

}

oldTarg = '';
function toggleView(targ){
	if(oldTarg != targ){
		document.getElementById(targ).style.display ="block";
		if(oldTarg!=''){
			document.getElementById(oldTarg).style.display = "none";
		}
		oldTarg = targ;
	}
}
function buildFormRow(rowCount){
	toggle = 0;
	dump = "";
	tableDump = "";
	styleSwitch = new Array('odd','even');
	
	
	
	for(i=1; i<=rowCount;i++){
		if(toggle == 0){ 
			toggle = 1;
		} else {
			toggle = 0;
		}
		dump+= "<tr>";
		dump+= '<td class="'+styleSwitch[toggle]+'">'+i+'</td>';
		dump+= '<td class="'+styleSwitch[toggle]+'"><input name="row_'+i+'[name]" type="text" id="CLIENT_NAME" size="20" maxlength="32" /></td>';
		dump+= '<td class="'+styleSwitch[toggle]+'"><input name="row_'+i+'[phone]" type="text" id="PHONE" size="12" maxlength="16" /></td>';
		dump+= '<td class="'+styleSwitch[toggle]+'"><input name="row_'+i+'[manicure]" type="checkbox" id="MANICURE" value="Spa Manicure" /></td>';
		dump+= '<td class="'+styleSwitch[toggle]+'"><input name="row_'+i+'[pedicure]" type="checkbox" id="PEDICURE" value="Spa Pedicure" /></td>';
		dump+= '<td class="'+styleSwitch[toggle]+'"><input name="row_'+i+'[waxing]" type="checkbox" id="WAXING" value="Waxing Service" /></td>';
		dump+= '<td class="'+styleSwitch[toggle]+'"><input name="row_'+i+'[email]" type="text" id="EMAIL" size="20" maxlength="128" /></td>';
		
		dump+= "</tr>";
	}

	tableDump += '<table cellpadding="0" cellspacing="0" width="100%">';
	tableDump +='	<tr>';
	tableDump +='		<td colspan="8">Please indicate each person’s name & fill out the service they will require in the chart below.</td>';
	tableDump +='	</tr>';
	tableDump +='	<tr>';
	tableDump +='		<th>#</th>';
	tableDump +='		<th>CLIENT NAME</th>';
	tableDump +='		<th>PHONE NUMBER</th>';
	tableDump +='		<th>Spa manicure $40</th>';
	tableDump +='		<th>Spa pedicure $67</th>';
	tableDump +='		<th>Peel and polish $70</th>';
	tableDump +='		<th>Email</th>';
	tableDump +='	</tr>';	
	tableDump += dump;
	tableDump +='</table>';

	document.getElementById('party_form').innerHTML = tableDump;
	document.getElementById('party_form').style.display = "block";
	document.getElementById('mySubmit').style.display = "block";

}

cute=0;
function validate(){
	var formName = document.getElementById('FormName');
	var cleared = false;
	var count = formName.elements.length;
	var body = "";
	
	if(formName.type.value=="1"){
		for(i=0;i<count-4;i++){
			if(formName.elements[i].checked==true){
				cleared = true;
			}
		}
		if(cute) cleared= true;
		if(!cleared && !cute) alert("Please choose a flavour.");
	} else {
		cleared = true;
	}
	return cleared;
}

function pageRefHidden(){
	document.write('<input type="hidden" name="refURL" value="' + window.location  + '" />');
}


// Swap Functions

imagepath = "images/main/header/";
// Preload images - ON


	coldOn = new Image();
	coldOn.src = imagepath + "";
	
//Preload images - OFF

	coldOff = new Image();
	coldOff.src = imagepath + "";
	
// Image Rollovers
function menuSwap(img){
	if (document.images) {
		document [img].src = eval(img + "On.src");
		
	}
}

function menuUnSwap(img){
    if (document.images) {
		document [img].src = eval(img + "Off.src");
		
	}
}

// Table Cell Rollovers
function cOn(td,color){
	if(document.getElementById||(document.all && !(document.getElementById))){
		td.style.backgroundColor=color;
	}
}

function cOut(td,color){
	if(document.getElementById||(document.all && !(document.getElementById))){
		td.style.backgroundColor=color;
	}
}

function scentStation(){
	window.open('index.php?pageID=scentstation','scentstation','width=725,height=400');
}

function popWindow(url,w,h){
	window.open(url,"cartWindow","width="+w+",height="+h+",scrollbars=1,resizable=1,status=1")
}

function printPop(url){
	window.open('https://host.newwinnipeg.net/urbanvenus/includes/print.php?uID='+ url + '&confirm=1' ,'printwindow','width=570,height=600,resizable=1');
}

function processForm(){
// PROCESS AUTHOR NAMES
	document.adminForm.submit();
}



function checkForm(){
	passFail = 1;
	formName = document.getElementById('FormName');
	
	if(formName.name.value=="") { passFail=0; }
	if(formName.email.value=="") { passFail=0; }
	if(formName.address.value=="") { passFail=0; }
	if(formName.city.value=="") { passFail=0; }
	if(formName.zippostcode.value=="") { passFail=0; }
	if(formName.phone.value=="") { passFail=0; }
	if(formName.provstate.value=="") { passFail=0; }
	
	if(passFail){
		formName.submit();
	} else {
		alert('please fill all fields.');
	}
}

function checkFormcc(){
	passFail = 1;
	formName = document.getElementById('ccsend');
	
	if(formName.ccholder.value=="") { passFail=0; }
	if(formName.cardtype.value=="") { passFail=0; }
	if(formName.cardnumber.value=="") { passFail=0; }
	if(formName.ccmonth.value=="") { passFail=0; }
	if(formName.ccyear.value=="") { passFail=0; }
	
	if(passFail){
		return true;
	} else {
		alert('please fill all fields.');
		return false;
	}
}

function checkOrderOptions(){
	formName = document.getElementById('formName');
	if(formName.orderTool.value == "0"){
		alert('please select an option');
		return false;
	} else if(formName.orderTool.value == "delete"){
		choice = confirm('are you sure you want to delete the selected orders from the database?');
		if(choice) {
			return true;
		} else {
			return false;
		}
	} else {
			return true;
	}
}

// Certificate Item Name filler
function itemSelect(){
	formName = document.getElementById('FormName');
	itemNamePair = formName.service.value;
	var itemArray = itemNamePair.split("/");
	formName.itemName.value = itemArray[0];
	formName.itemValue.value = itemArray[1];
}

function confirmDelete(newLoc){
	choice = confirm("Are you sure you want to delete this item?")
	if(choice){
		window.location = newLoc;
	}
}