/*** SET BUTTON'S FOLDER HERE ***/
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function updatetotal(elid, price)
{
	var subtotal = parseInt(document.getElementById("subtotal").value) || 0;
	var mygrand = parseInt(document.getElementById("grandtotal").value) || 0;
	var myelement = document.getElementById("total_"+elid);
	var myelementval = 0;
	if(document.getElementById("total_"+elid).value != 0)
		myelementval = parseInt(document.getElementById("total_"+elid).value);
	var myqty = parseInt(document.getElementById("qty_"+elid).value);
	myelement.value = parseInt(price) * myqty;
	var newelementval = parseInt(myelement.value) || 0;
	
	document.getElementById("subtotal").value = subtotal + newelementval - myelementval;
	
	if(mygrand > subtotal)
	{
		document.getElementById("grandtotal").value = parseInt(document.getElementById("subtotal").value) + 5;
		document.getElementById("Total").value = parseInt(document.getElementById("subtotal").value) + 5;
	}
	else
	{
		document.getElementById("grandtotal").value = document.getElementById("subtotal").value;
		document.getElementById("Total").value = document.getElementById("subtotal").value;
	}
}
function updatetotal2(elid, price, subid)
{
	var subtotal = parseInt(document.getElementById("subtotal").value) || 0;
	var subtotal2 = parseInt(document.getElementById("subtotal_"+subid).value) || 0;
	var mygrand = parseInt(document.getElementById("grandtotal").value) || 0;
	var myelement = document.getElementById("total_"+elid);
	var myelementval = 0;
	if(document.getElementById("total_"+elid).value != 0)
		myelementval = parseInt(document.getElementById("total_"+elid).value);
	var myqty = parseInt(document.getElementById("qty_"+elid).value);
	myelement.value = parseInt(price) * myqty;
	var newelementval = parseInt(myelement.value) || 0;
	
	document.getElementById("subtotal_"+subid).value = subtotal2 + newelementval - myelementval;
	document.getElementById("subtotal").value = subtotal + newelementval - myelementval;
	
	document.getElementById("grandtotal").value = parseInt(document.getElementById("subtotal").value) + 5;
	document.getElementById("Total").value = parseInt(document.getElementById("subtotal").value) + 5;

/*
	if(mygrand > subtotal)
	{
		document.getElementById("grandtotal").value = parseInt(document.getElementById("subtotal").value) + 5;
		document.getElementById("Total").value = parseInt(document.getElementById("subtotal").value) + 5;
	}
	else
	{
		document.getElementById("grandtotal").value = document.getElementById("subtotal").value + 5;
		document.getElementById("Total").value = document.getElementById("subtotal").value + 5;
	}
*/
}
function addpostage()
{
	var total = document.getElementById("grandtotal");
	var t_total = document.getElementById("Total");
	var subpost = document.getElementById("txtPost");
	var postage = document.getElementById("regpost");
	var gtotal = parseInt(total.value) || 0;
	
	if(postage.checked)
	{
		total.value = gtotal + 5;
		t_total.value = gtotal + 5;
		subpost.value = 5;
	}
	else
	{
		total.value = gtotal - 5;
		t_total.value = gtotal - 5;
		subpost.value = 0;
	}
}
function cancelOrder()
{
	document.location = "?page=main";
}
function show_guide(locale)
{
	window.open(locale+"/downloads/eventguide.pdf");	
}
function show_prizes(locale)
{
	window.open(locale+"/downloads/prizes.pdf");	
}
function show_results(locale)
{
	window.open(locale+"/downloads/results.pdf");	
}
function show_program(locale)
{
	window.open(locale+"/downloads/program.pdf");	
}
function show_tradeform(locale)
{
	window.open(locale+"/downloads/tradeform.pdf");	
}

function show_venuemap(locale)
{
	window.open(locale+"/downloads/venuemap.pdf");	
}
function show_premium(locale)
{
	window.open(locale+"/downloads/premium.pdf");	
}
function show_camping(locale)
{
	alert('Coming Soon!');	
}
function show_popup(pagename)
{
	window.open("includes/popups/"+pagename, "_page", "scrollbars, width=660, height=700, left=" + ((screen.width - 660) / 2) + ", top=0");	
}
function open_gallery()
{
	window.open("phpAlbum/index.php", "_page", "width=1024, height=768, scrollbars, left=" + ((screen.width - 1024) / 2) + ", top=0");	
}
function open_sub(subtype)
{
	window.open("http://www.powercruise.com/newssub/index.php?page="+subtype, "_page", "width=500, height=400, left=" + ((screen.width - 500) / 2) + ", top=0");	
}
function openinterestform()
{
	window.open("http://www.powercruise.com/usa/includes/popups/interest.php", "_page", "scrollbars width=650, height=800, left=" + ((screen.width - 650) / 2) + ", top=0");	
}
function dvd_order()
{
	window.open("https://gold102.hostingbay.net/~power713/includes/pages/order.php","order","width=640, height=600, left=0, top=0, scrollbars=1, resizable=1");
}

function gettotal()
{
	var total = 0;

	total = (30 * document.getElementById('PC9_Qty').value) + (40 * document.getElementById('PC10_Qty').value) + (40 * document.getElementById('PC12_Qty').value) + (40 * document.getElementById('PC13_Qty').value) + (40 * document.getElementById('PC14_Qty').value) + (40 * document.getElementById('PC15_Qty').value) + (1 * document.getElementById('rbPost').value);

	rettotal = new Number(total);

	document.getElementById("Total").value = rettotal.toFixed(2);
}
function changepost(amount)
{
	document.getElementById('regpost').value = amount;
}

function verifyform()
{
	var iagree = document.getElementById("Agree").checked;
	var txtcount = 0;
	document.getElementById('dName').style.visibility = (document.getElementById('Name').value == "") ? "visible" : "hidden";
	document.getElementById('dAddress').style.visibility = (document.getElementById('Address').value == "") ? "visible" : "hidden";
	document.getElementById('dSuburb').style.visibility = (document.getElementById('Suburb').value == "") ? "visible" : "hidden";
	document.getElementById('dState').style.visibility = (document.getElementById('State').value == "") ? "visible" : "hidden";
	document.getElementById('dPostcode').style.visibility = (document.getElementById('Postcode').value == "") ? "visible" : "hidden";
	document.getElementById('dPhone').style.visibility = (document.getElementById('Phone').value == "") ? "visible" : "hidden";
	document.getElementById('dEmail').style.visibility = (document.getElementById('Email').value == "") ? "visible" : "hidden";

	txtcount = (document.getElementById('Name').value != "") ? txtcount + 1 : txtcount;
	txtcount = (document.getElementById('Address').value != "") ? txtcount + 1 : txtcount;
	txtcount = (document.getElementById('Suburb').value != "") ? txtcount + 1 : txtcount;
	txtcount = (document.getElementById('State').value != "") ? txtcount + 1 : txtcount;
	txtcount = (document.getElementById('Postcode').value != "") ? txtcount + 1 : txtcount;
	txtcount = (document.getElementById('Phone').value != "") ? txtcount + 1 : txtcount;
	txtcount = (document.getElementById('Email').value != "") ? txtcount + 1 : txtcount;

	if(txtcount == 7 && document.getElementById('regpost').value != "" && iagree)
		document.getElementById("Submit").disabled = false;
	else
		document.getElementById("Submit").disabled = true;

	document.getElementById("txtcount").value = txtcount;
}
function verifyform2()
{
	var iagree = document.getElementById("chkTerms").checked;
	var txtcount = 0;
	document.getElementById('dName').style.visibility = (document.getElementById('Name').value == "") ? "visible" : "hidden";
	document.getElementById('dAddress').style.visibility = (document.getElementById('Address').value == "") ? "visible" : "hidden";
	document.getElementById('dSuburb').style.visibility = (document.getElementById('Suburb').value == "") ? "visible" : "hidden";
	document.getElementById('dState').style.visibility = (document.getElementById('State').value == "") ? "visible" : "hidden";
	document.getElementById('dPostcode').style.visibility = (document.getElementById('Postcode').value == "") ? "visible" : "hidden";
	document.getElementById('dPhone').style.visibility = (document.getElementById('Phone').value == "") ? "visible" : "hidden";
	document.getElementById('dEmail').style.visibility = (document.getElementById('Email').value == "") ? "visible" : "hidden";

	txtcount = (document.getElementById('Name').value != "") ? txtcount + 1 : txtcount;
	txtcount = (document.getElementById('Address').value != "") ? txtcount + 1 : txtcount;
	txtcount = (document.getElementById('Suburb').value != "") ? txtcount + 1 : txtcount;
	txtcount = (document.getElementById('State').value != "") ? txtcount + 1 : txtcount;
	txtcount = (document.getElementById('Postcode').value != "") ? txtcount + 1 : txtcount;
	txtcount = (document.getElementById('Phone').value != "") ? txtcount + 1 : txtcount;
	txtcount = (document.getElementById('Email').value != "") ? txtcount + 1 : txtcount;

	if(txtcount == 7 && document.getElementById('Total').value != "0.00" && iagree)
		document.getElementById("Submit").disabled = false;
	else
		document.getElementById("Submit").disabled = true;

	document.getElementById("txtcount").value = txtcount;
}
	function open_page()
	{
		window.open("http://www.powercruise.com/includes/popups/register.php","regwin","width=800, height=600, scrollbars=0, left=0, top=0");
	}

	function showpic(picture)
	{
		window.open("http://www.powercruise.com/includes/popups/class_pic.php?image="+picture,"picwin","width=700, height=700, scrollbars=0, left="+((screen.width - 700) / 2)+", top=0");
	}
