//=====================================================================||
// This file manages the function of routing the customer to the       ||
// correct Checkout page, based on the "Zone" they have selected on the||
// Managecart.html page.                                               ||
// It then validates info on the Checkout Page for submission of the   ||
// order.                                                              ||
//=====================================================================||



//---------------------------------------------------------------------||
// FUNCTION:    CheckIt                                                ||
// PARAMETERS:  Zone                                                   ||
// RETURNS:     Radio button group value                               ||
// PURPOSE:     Routes customer to correct Checkout page               ||
//---------------------------------------------------------------------||


function CheckIt(){
LocationSelected = GetCookie("ZoneSelected"); 
iNumberOrdered = GetCookie("NumberOrdered");

   if (( iNumberOrdered == 0 )||( iNumberOrdered == null)) {
        alert( 'Your Cart is empty - please order something before trying to check out!' );
        return false;
   }

   if ((LocationSelected==null)||(LocationSelected==9)){
          alert('Please Select Your Shipping Location');
      return false;
   }

   if ( LocationSelected <= 3 ) {
        document.form.method="Get";
        document.form.action="checkout_aus.html";
        document.form.submit();
   }

   if ( LocationSelected == 4 ) {
        document.form.method="Get";
        document.form.action="checkout_zone1.html";
        document.form.submit();
   }

   if ( LocationSelected == 5 ) {
        document.form.method="Get";
        document.form.action="checkout_zone2.html";
        document.form.submit();
   }

   if ( LocationSelected == 6 ) {
        document.form.method="Get";
        document.form.action="checkout_zone3.html";
        document.form.submit();
   }


   if ( LocationSelected == 7 ) {
        document.form.method="Get";
        document.form.action="checkout_zone4.html";
        document.form.submit();
   }


}



//---------------------------------------------------------------------||
// FUNCTION:    CheckIt1                                               ||
// PARAMETERS:  Zone                                                   ||
// RETURNS:     Radio Group button value                               ||
// PURPOSE:     Test for previous function before going live           ||
//---------------------------------------------------------------------||


function CheckIt1(){
LocationSelected = GetCookie("ZoneSelected"); 
iNumberOrdered = GetCookie("NumberOrdered");

   if (( iNumberOrdered == 0 )||( iNumberOrdered == null)) {
        alert( 'Your Cart is empty - please order something before trying to check out!' );
        return false;
   }

   if ((LocationSelected==null)||(LocationSelected==9)){
          alert('Please Select Your Shipping Location');
      return false;
   }

        document.form.method="Get";
        document.form.action="checkout.html";
        document.form.submit();
}



//---------------------------------------------------------------------||
// FUNCTION:    CheckFormAus                                           ||
// PARAMETERS:  theForm                                                ||
// RETURNS:     Any incomplete form fields                             ||
// PURPOSE:     To ensure customer fills out all required fields before||
//              order can be submitted.                                ||
//---------------------------------------------------------------------||

function CheckFormAus( theform )
{
	var bMissingFields = false;
	var strFields = "";
	
	if( theform.b_first.value == '' ){
		bMissingFields = true;
		strFields += "     First Name\n";
	}
	if( theform.b_last.value == '' ){
		bMissingFields = true;
		strFields += "     Last Name\n";
	}
	if( theform.b_addr.value == '' ){
		bMissingFields = true;
		strFields += "     Address\n";
	}
	if( theform.b_city.value == '' ){
		bMissingFields = true;
		strFields += "     Suburb\n";
	}
	if( theform.b_state.value == '' ){
		bMissingFields = true;
		strFields += "     State\n";
	}
	if( theform.b_pcode.value == '' ){
		bMissingFields = true;
		strFields += "     Postcode\n";
	}
	if( theform.b_country.value == '' ){
		bMissingFields = true;
		strFields += "     Country\n";
	}
	if( theform.b_phone.value == '' ){
		bMissingFields = true;
		strFields += "     Phone\n";
	}
	if( theform.b_email.value == '' ){
		bMissingFields = true;
		strFields += "     Email\n";
	}
		
	if( bMissingFields ) {
		alert( "You must provide the following field(s) before continuing:\n" + strFields );
		return false;
	}
	
	return true;
}





//---------------------------------------------------------------------||
// FUNCTION:    CheckForm                                              ||
// PARAMETERS:  theForm                                                ||
// RETURNS:     Any incomplete form fields                             ||
// PURPOSE:     To ensure customer fills out all required fields before||
//              order can be submitted.                                ||
//---------------------------------------------------------------------||

function CheckForm( theform )
{
	var bMissingFields = false;
	var strFields = "";
	
	if( theform.b_first.value == '' ){
		bMissingFields = true;
		strFields += "     First Name\n";
	}
	if( theform.b_last.value == '' ){
		bMissingFields = true;
		strFields += "     Last Name\n";
	}
	if( theform.b_addr.value == '' ){
		bMissingFields = true;
		strFields += "     Address\n";
	}
	if( theform.b_city.value == '' ){
		bMissingFields = true;
		strFields += "     City\n";
	}
	if( theform.b_pcode.value == '' ){
		bMissingFields = true;
		strFields += "     Postcode\n";
	}
	if( theform.b_country.value == '' ){
		bMissingFields = true;
		strFields += "     Country\n";
	}
	if( theform.b_phone.value == '' ){
		bMissingFields = true;
		strFields += "     Phone\n";
	}
	if( theform.b_email.value == '' ){
		bMissingFields = true;
		strFields += "     Email\n";
	}
		
	if( bMissingFields ) {
		alert( "You must provide the following field(s) before continuing:\n" + strFields );
		return false;
	}
	
	return true;
}

//---------------------------------------------------------------------||
// FUNCTION:    CheckFormFi	ghter                                         ||
// PARAMETERS:  theForm                                                ||
// RETURNS:     Any incomplete form fields                             ||
// PURPOSE:     To ensure customer fills out all required fields before||
//              order can be submitted.                                ||
//---------------------------------------------------------------------||

function CheckFormFighter( theform )
{
	var bMissingFields = false;
	var strFields = "";
	
	if( theform.b_first.value == '' ){
		bMissingFields = true;
		strFields += "     First Name\n";
	}
	if( theform.b_last.value == '' ){
		bMissingFields = true;
		strFields += "     Last Name\n";
	}
	if( theform.b_addr.value == '' ){
		bMissingFields = true;
		strFields += "     Address\n";
	}
	if( theform.b_city.value == '' ){
		bMissingFields = true;
		strFields += "     Suburb\n";
	}
	if( theform.b_state.value == '' ){
		bMissingFields = true;
		strFields += "     State\n";
	}
	if( theform.b_pcode.value == '' ){
		bMissingFields = true;
		strFields += "     Postcode\n";
	}
	if( theform.b_country.value == '' ){
		bMissingFields = true;
		strFields += "     Country\n";
	}
	if( theform.b_email.value == '' ){
		bMissingFields = true;
		strFields += "     Email\n";
	}
	if( theform.b_joytype.value == '' ){
		bMissingFields = true;
		strFields += "     Joystick Type\n";
	}
	if( theform.b_btnlay.value == '' ){
		bMissingFields = true;
		strFields += "     Buttons Layout\n";
	}
	if( theform.b_btn1.value == '' ){
		bMissingFields = true;
		strFields += "     Button 1\n";
	}
	if( theform.b_btn2.value == '' ){
		bMissingFields = true;
		strFields += "     Button 2\n";
	}
	if( theform.b_btn3.value == '' ){
		bMissingFields = true;
		strFields += "     Button 3\n";
	}
	if( theform.b_btn4.value == '' ){
		bMissingFields = true;
		strFields += "     Button 4\n";
	}
	if( theform.b_btn5.value == '' ){
		bMissingFields = true;
		strFields += "     Button 5\n";
	}		
	if( theform.b_btn6.value == '' ){
		bMissingFields = true;
		strFields += "     Button 6\n";
	}
	if( theform.b_btn7.value == '' ){
		bMissingFields = true;
		strFields += "     Button 7\n";
	}
	if( theform.b_btn8.value == '' ){
		bMissingFields = true;
		strFields += "     Button 8\n";
	}
	if( theform.b_paytype.value == '' ){
		bMissingFields = true;
		strFields += "     Payment Type\n";
	}

	if( bMissingFields ) {
		alert( "You must provide the following field(s) before continuing:\n" + strFields );
		return false;
	}
	
	return true;
}

//---------------------------------------------------------------------||
// FUNCTION:    CheckFormUlt                                           ||
// PARAMETERS:  theForm                                                ||
// RETURNS:     Any incomplete form fields                             ||
// PURPOSE:     To ensure customer fills out all required fields before||
//              order can be submitted.                                ||
//---------------------------------------------------------------------||

function CheckFormUlt( theform )
{
	var bMissingFields = false;
	var strFields = "";
	
	if( theform.b_first.value == '' ){
		bMissingFields = true;
		strFields += "     First Name\n";
	}
	if( theform.b_last.value == '' ){
		bMissingFields = true;
		strFields += "     Last Name\n";
	}
	if( theform.b_addr.value == '' ){
		bMissingFields = true;
		strFields += "     Address\n";
	}
	if( theform.b_city.value == '' ){
		bMissingFields = true;
		strFields += "     Suburb\n";
	}
	if( theform.b_state.value == '' ){
		bMissingFields = true;
		strFields += "     State\n";
	}
	if( theform.b_pcode.value == '' ){
		bMissingFields = true;
		strFields += "     Postcode\n";
	}
	if( theform.b_country.value == '' ){
		bMissingFields = true;
		strFields += "     Country\n";
	}
	if( theform.b_email.value == '' ){
		bMissingFields = true;
		strFields += "     Email\n";
	}
	if( theform.b_joytype.value == '' ){
		bMissingFields = true;
		strFields += "     Joystick Type\n";
	}
	if( theform.b_btnlay.value == '' ){
		bMissingFields = true;
		strFields += "     Buttons Layout\n";
	}
	if( theform.b_p1b1.value == '' ){
		bMissingFields = true;
		strFields += "     Button 1\n";
	}
	if( theform.b_p1b2.value == '' ){
		bMissingFields = true;
		strFields += "     Button 2\n";
	}
	if( theform.b_p1b3.value == '' ){
		bMissingFields = true;
		strFields += "     Button 3\n";
	}
	if( theform.b_p1b4.value == '' ){
		bMissingFields = true;
		strFields += "     Button 4\n";
	}
	if( theform.b_p1b5.value == '' ){
		bMissingFields = true;
		strFields += "     Button 5\n";
	}		
	if( theform.b_p1b6.value == '' ){
		bMissingFields = true;
		strFields += "     Button 6\n";
	}
	if( theform.b_p2b1.value == '' ){
		bMissingFields = true;
		strFields += "     Button 1\n";
	}
	if( theform.b_p2b2.value == '' ){
		bMissingFields = true;
		strFields += "     Button 2\n";
	}
	if( theform.b_p2b3.value == '' ){
		bMissingFields = true;
		strFields += "     Button 3\n";
	}
	if( theform.b_p2b4.value == '' ){
		bMissingFields = true;
		strFields += "     Button 4\n";
	}
	if( theform.b_p2b5.value == '' ){
		bMissingFields = true;
		strFields += "     Button 5\n";
	}		
	if( theform.b_p2b6.value == '' ){
		bMissingFields = true;
		strFields += "     Button 6\n";
	}
	if( theform.b_p1start.value == '' ){
		bMissingFields = true;
		strFields += "     Button 6\n";
	}
	if( theform.b_coin.value == '' ){
		bMissingFields = true;
		strFields += "     Button 6\n";
	}
	if( theform.b_p2start.value == '' ){
		bMissingFields = true;
		strFields += "     Button 6\n";
	}
	if( theform.b_pinball.value == '' ){
		bMissingFields = true;
		strFields += "     Button 6\n";
	}
	if( theform.b_usb.value == '' ){
		bMissingFields = true;
		strFields += "     Button 6\n";
	}
	if( theform.b_paytype.value == '' ){
		bMissingFields = true;
		strFields += "     Payment Type\n";
	}

	if( bMissingFields ) {
		alert( "You must provide the following field(s) before continuing:\n" + strFields );
		return false;
	}
	
	return true;
}


