/**
 * @author Shesha Marvin - modified by James Bianco
 */

	var eventDate = "March 2nd, 3rd, 4th 2012";
	
	var contestNames = ["Harvest Moon Lindy Hop Contest", 
					"24 Hour Jack and Jill",
					"30 Second Showcase",
					"Pro-Am Jack and Jill",
					"Balboa",
					"After Seben Charleston Contest",
					"1st Timers Lindy Hop Contest"];
					
	var contestNamesDesc = ["Harvest Moon Lindy Hop Contest  (your partner must pay and register separately)", 
					"24 Hour Jack and Jill",
					"30 Second Showcase  (your partner must pay and register separately)",
					"Pro-Am Jack and Jill",
					"Balboa",
					"After Seben Charleston Contest",
					"1st Timers Lindy Hop Contest"];

	var numberOfContests = 4;
					
	var itemnames = ["HMLHC", 
					"24HRJJ",
					"30SS",
					"Pro-AMJJ",
					"BALBOA",
					"AFTERSEBEN",
					"1STTIMERS"];


function validatename()
{
	frm = document.regForm;
	
	if (frm.os0.value=="") {
		alert("You must enter a first and last name for this registration!");
		frm.os0.focus();
		return false;
	}
	else
		return true;
}


function validateNameAndPrint()
{
	if (validatename()) {
		window.print();
		return true;
	}
	else
		return false;
}


function calc()
{

	var frm = document.regForm;
	var frmtwo = document.receiptForm;
	var receipt = "Your total cost is calculated below:\n\n";
	var total = 0;
	var items = "";
	var notes = "";

	
//	alert("calc IN");
	
//	alert(frm.name);
	frm.item_name.value = "Inspiration Weekend in Orange County " + eventDate;

//	alert("calc 1");

	if (frm.pass[0].checked == true) {
//	alert("calc a1");
		if (frm.membership[0].checked == true) {
//	alert("calc aa1");
			//NON MEMBER promo code
			
			if (frm.promo.value == "ninarocks" | frm.promo.value == "atomic") {
//	alert("calc aaa1");
				total = total + 99;
				receipt = receipt + "$99 PROMOTIONAL Full Weekend Pass\n";
				items = items + "FullPass Promotional Rate ";
				notes = notes + "You entered the promo code that got you the early bird price!";
			}
			else {
//	alert("calc baa1");
				//full price
				total = total + 119;
				receipt = receipt + "$119 Full Weekend Pass\n";
				items = items + "FullPass ";
				notes = notes + "Thanks for registering early.";
			}
		}
		else if (frm.membership[1].checked == true) {
//	alert("calc ba1");
			//member AND promocode same discount 
			
			if (frm.promo.value == "ATOMIC" | frm.promo.value == "atomic") {
//	alert("calc aba1");
				total = total + 129;
				receipt = receipt + "$129 PROMOTIONAL Full Weekend Pass\n";
				items = items + "FullPass ATOMIC Promo ";
				notes = notes + "You entered the ATOMIC promo code that got you $20 off the current pre-sale price!  This discount does not stack with the membership discount.";
			}
			else {
//	alert("calc bba1");
				// member price no promo code
				total = total + 129;
				receipt = receipt + "$149 Full Weekend Pass (Members Price #" + frm.membernumber.value + ")\n";
				items = items + "(FullPassMem # " + frm.membernumber.value + ") ";
				notes = notes + "Thanks for registering early.";
				
				if (frm.membernumber.value == "") {
//	alert("calc aaba1");
					frm.membernumber.focus();
					notes = notes + "\n\nALERT*** Please enter your member number!!!";
				}
			}
		}
		else {
//	alert("calc ca1");
			//VIP PRICE
			total = total + 129;
			receipt = receipt + "$129 Full Weekend Pass (VIP Price #" + frm.VIPnumber.value + ")\n";
			items = items + "(FullPassVIP # " + frm.VIPnumber.value + ") ";
			notes = notes + "Thanks for registering early.  This will ensure that you get a space.  The final price for VIP's will be $129!";
			
			if (frm.VIPnumber.value == "") {
//	alert("calc aca1");
				frm.VIPnumber.focus();
				notes = notes + "\n\nALERT*** Please enter your member number!!!";
			}
		}
	}
	else if (frm.pass[1].checked == true) {
//	alert("calc b1");
		total = total + 50;
		receipt = receipt + "$50 Competitors Pass\n";
		items = items + "CompPass ";
		notes = notes + "If you want to compete you must have this competitor's pass OR a Full Event Pass.  It's a good deal!  Half the price of similar events!  Includes all dances!";
		
		if (frm.membership[1].checked == true | frm.membership[2].checked == true)
			notes = notes + "\n\nMembership discounts only apply to full weekend passes.  There are no membership discounts for competitor's passes or day passes.";
	}
	else if (frm.pass[2].checked == true) {
//	alert("calc c1");
		total = total + 75;
		receipt = receipt + "$75 Saturday Day Pass\n";
		items = items + "SatPass ";
		notes = notes + "This pass will get you into the Saturday Classes, let you watch the Saturday contests, and get you into the Saturday evening AND late night dances.";
		
		if (frm.membership[1].checked == true | frm.membership[2].checked == true)
			notes = notes + "\n\nMembership discounts only apply to full weekend passes.  There are no membership discounts for competitor's passes or day passes.";
	}
	else if (frm.pass[3].checked == true) {
//	alert("calc d1");
		total = total + 70;
		receipt = receipt + "$70 Sunday Day Pass\n";
		items = items + "SunPass ";
		notes = notes + "This pass will get you into the Sunday Classes, let you watch the Sunday contests, and get you into the Sunday evening AND late night dances.";
		if (frm.membership[1].checked == true | frm.membership[2].checked == true)
			notes = notes + "\n\nMembership discounts only apply to full weekend passes.  There are no membership discounts for competitor's passes or day passes.";
	}
	/*
	else if (frm.pass[4].checked == true) {
		total = total + 60;
		receipt = receipt + "$60 Mon Day Pass\n";
		items = items + "MonPass ";
		notes = notes + "This pass will get you into the Monday Classes!";
		
		if (frm.membership[1].checked == true | frm.membership[2].checked == true)
			notes = notes + "\n\nMembership discounts only apply to full weekend passes.  There are no membership discounts for competitor's passes or day passes.";
	}
	*/
	else {
//alert("calc e1");
		receipt = receipt + "I have a pass!\n";
		notes = notes + "So you have a pass already huh?  Go ahead and add other stuff!";

		if (frm.membership[1].checked == true | frm.membership[2].checked == true)
			notes = notes + "\n\nMembership discounts only apply to full weekend passes.  There are no membership discounts for anything else.";
	}
	
//	alert("calc before loop");

	for (i = 0; i < numberOfContests; i++) {
		if (frm.contest[i].checked == true) {
			total = total + 10;
			receipt = receipt + "$10 "+ contestNames[i] + "\n";
			items = items + itemnames[i] + ": ";
		}
	}
	
	/*
	if (frm.extras[0].checked == true) {
		total = total + 55;
		receipt = receipt + "$55 Weekend Review Video\n";
		items = items + "ReviewVideo ";
		notes = notes + "\n\nThe review video will include all class reviews, contest footage, performance footage, dance footage and whatever other crazy things happen! This price includes five bucks shipping.  DVD will be $60 + shipping at the event.";
	}
	*/

//	alert("calc 2");

	if (frm.extras.checked == true) {
//	alert("calc a2");
		total = total + 10;
		receipt = receipt + "$10 T-Shirt "+ frm.shirtsize.value +"\n";
		items = items + "(T-Shirt " + frm.shirtsize.value + ")";
	
		if (frm.shirtsize.value == "") 
			notes = notes + "\n\nALERT*** Please Choose a t-shirt size!!!";
	}

	/*
	if (frm.extras[2].checked == true) {
		total = total + 50;
		receipt = receipt + "$50 Table for 2 for Weekend\n";
		items = items + "Tablefor2 ";
	}
	*/

//	alert("calc 3");
	
	receipt = receipt + "_________\n$" + total + " Total\n\n" + notes;
	frmtwo.dancetab.value = receipt;
	frm.amount.value = total;
	frm.item_number.value = items;

//	alert("calc OUT");
}


function toggleBlock(elementId, identifierId) {
	var element = document.getElementById(elementId);
	var identifier = document.getElementById(identifierId);
	
//	alert("toggleBlock IN");

	if (element.style.display == 'block') {
		element.style.display = 'none';
		//identifier.innerHTML = '+';
		identifier.innerHTML = 'Refund Policy [+]';
	}  else {
		element.style.display = 'block';  
		//identifier.innerHTML = '-';
		identifier.innerHTML = 'Refund Policy [-]';
	}

//	alert("toggleBlock OUT");
}				



$j=jQuery.noConflict();


//$j.fn.foobar = function() {
//	alert("foobar");
//};

$j(document).ready(function() {
//	alert("Registration page");
//	$j.foobar();
});


$j("#clickableArea").click(function(){
	alert("jquery hit");
	//toggleBlock("myId", "clickableArea");
});


function checkIt() {
//	alert("CHECK IT");
//	calc();
//	alert("CHECK IT OUT");
}


