function initPage(){
	document.creditform.couponID.disabled = true;
}

function disablecreditAmountRadioButtons(){
	
	for(i=0; i<document.creditform.creditAmount.length;i++){
		document.creditform.creditAmount[i].disabled = true;
	}
}

function enablecreditAmountRadioButtons(){

	for(i=0; i<document.creditform.creditAmount.length;i++){
		document.creditform.creditAmount[i].disabled = false;
	}

	
}

function disableCouponIDText(){
	document.creditform.couponID.disabled = true;
}

function enableCouponIDText(){
	document.creditform.couponID.disabled = false;
	document.creditform.couponID.focus();
}

function formValidation(){

	if(document.creditform.termsOfServiceOK[1].checked){			//if conditions is not ok
		alert('Error.\n\nYou have chosen not to agree to the Terms of Service.\n\nYou cannot charge your account unless you agree to the terms.');
		document.creditform.termsOfServiceOK[0].focus();
		//return false;
	}
	else if(document.creditform.paymentMethod[2].checked){				//if payment method is coupon
		if(document.creditform.couponID.value.length != 26){			//but an ugly coupon ID
			alert('Error.\n\nCoupon must be 26 characters.\n\nPlease return and correct this.');
			document.creditform.couponID.focus();
			//return false;
		}
		else{
			//return true;
			selectOrderProcessing();
		}
	}
	else{
		//return true;
 		if(document.creditform.paymentMethod[0].checked)alert('You will now be redirected to the Credit Card payment interface.\n\nIMPORTANT: Sometimes, in the end of the payment process, a prompt alerts you that the connection is insecure. DO NOT CANCEL as this is only the confirmation data sent back to Navigraph. No credit card details are sent insecurely! Cancelling this confirmation will only leave your account without credits. Close the window when it says "You may close this window" - not before.');
 		//if(document.creditform.paymentMethod[1].checked)alert('You will now be redirected to the PayPal payment interface.\n\nIMPORTANT: Please DO NOT close the confirmation window directly when PayPal confirms a successful payment. You will be redirected back to Navigraph within 10 seconds, where the credits will be charged to your account automatically. Close the window when it says "You may close this window" - not before.');
 		if(document.creditform.paymentMethod[1].checked)alert('You will now be redirected to the PayPal payment interface.');
 		
		selectOrderProcessing();
	}
}

function selectOrderProcessing(){



	var winProps = 'toolbar=no,width=800,height=500,menubar=yes,status=yes,scrollbars=yes,resizable=yes,menubar=no,location=yes';

	 if(document.creditform.paymentMethod[0].checked){					//creditcard
	 		
		if(document.creditform.creditAmount[0].checked){				//10 EUR
	
			window.location = "myaccount_chargecredits_creditcardinstructions.asp?strCredit=" + document.creditform.creditAmount[0].value
			var ccWin = window.open("myaccount_chargecredits_ccgatewayrelay.asp?strCredit=" + document.creditform.creditAmount[0].value, "CenseoWindow", winProps);
		
		}else if(document.creditform.creditAmount[1].checked){			//20 EUR
		
			window.location = "myaccount_chargecredits_creditcardinstructions.asp?strCredit=" + document.creditform.creditAmount[1].value
			var ccWin = window.open("myaccount_chargecredits_ccgatewayrelay.asp?strCredit=" + document.creditform.creditAmount[1].value, "CenseoWindow", winProps);
			
		}else if(document.creditform.creditAmount[2].checked){			//30 EUR
		
			window.location = "myaccount_chargecredits_creditcardinstructions.asp?strCredit=" + document.creditform.creditAmount[2].value
			var ccWin = window.open("myaccount_chargecredits_ccgatewayrelay.asp?strCredit=" + document.creditform.creditAmount[2].value, "CenseoWindow", winProps);
		
		}
		
		
		
	 
	 }
	 else if(document.creditform.paymentMethod[1].checked){				//paypal
	 
		if(document.creditform.creditAmount[0].checked){				//10 EUR
	
			window.location = "myaccount_chargecredits_paypalinstructions.asp?strCredit=" + document.creditform.creditAmount[0].value
			var ppWin = window.open("myaccount_chargecredits_ppgatewayrelay.asp?strCredit=" + document.creditform.creditAmount[0].value, "PayPalWindow", winProps);
		
		}else if(document.creditform.creditAmount[1].checked){			//20 EUR
		
			window.location = "myaccount_chargecredits_paypalinstructions.asp?strCredit=" + document.creditform.creditAmount[1].value
			var ppWin = window.open("myaccount_chargecredits_ppgatewayrelay.asp?strCredit=" + document.creditform.creditAmount[1].value, "PayPalWindow", winProps);
		
		}else if(document.creditform.creditAmount[2].checked){			//30 EUR
		
			window.location = "myaccount_chargecredits_paypalinstructions.asp?strCredit=" + document.creditform.creditAmount[2].value
			var ppWin = window.open("myaccount_chargecredits_ppgatewayrelay.asp?strCredit=" + document.creditform.creditAmount[2].value, "PayPalWindow", winProps);
		}
	 }
	 else if(document.creditform.paymentMethod[2].checked){				//coupon
	 
	 	window.location = "myaccount_chargecredits_couponvalidate.asp?strCouponID=" + document.creditform.couponID.value
		
	 }
	 else{
	 	alert('Error.\n\nApplication cannot determine where to go to process order.');
	 }

}


function formValidationV2(){

	if(document.creditform.termsOfServiceOK[1].checked){			//if conditions is not ok
		alert('Error.\n\nYou have chosen not to agree to the Terms of Service.\n\nYou cannot charge your account unless you agree to the terms.');
		document.creditform.termsOfServiceOK[0].focus();
		//return false;
	}
	else if(document.creditform.paymentMethod[2].checked){				//if payment method is coupon
		if(document.creditform.couponID.value.length != 26){			//but an ugly coupon ID
			alert('Error.\n\nCoupon must be 26 characters.\n\nPlease return and correct this.');
			document.creditform.couponID.focus();
			//return false;
		}
		else{
			//return true;
			selectOrderProcessingV2();
		}
	}
	else{
		//return true;
 		if(document.creditform.paymentMethod[0].checked)alert('You will now be redirected to the Credit Card payment interface.\n\nIMPORTANT: Sometimes, in the end of the payment process, a prompt alerts you that the connection is insecure. DO NOT CANCEL as this is only the confirmation data sent back to Navigraph. No credit card details are sent insecurely! Cancelling this confirmation will only leave your account without credits. Close the window when it says "You may close this window" - not before.');
 		//if(document.creditform.paymentMethod[1].checked)alert('You will now be redirected to the PayPal payment interface.\n\nIMPORTANT: Please DO NOT close the confirmation window directly when PayPal confirms a successful payment. You will be redirected back to Navigraph within 10 seconds, where the credits will be charged to your account automatically. Close the window when it says "You may close this window" - not before.');
 		if(document.creditform.paymentMethod[1].checked)alert('You will now be redirected to the PayPal payment interface.');
 		
		selectOrderProcessingV2();
	}
}


function selectOrderProcessingV2(){



	var winProps = 'toolbar=no,width=800,height=500,menubar=yes,status=yes,scrollbars=yes,resizable=yes,menubar=no,location=yes';

	 if(document.creditform.paymentMethod[0].checked){					//creditcard
	 		
		if(document.creditform.creditAmount[0].checked){				//10 EUR
	
			window.location = "myaccount_chargecredits_creditcardinstructions.asp?strCredit=" + document.creditform.creditAmount[0].value
			var ccWin = window.open("myaccount_chargecredits_ccgatewayrelayPCI.asp?strCredit=" + document.creditform.creditAmount[0].value, "CenseoWindow", winProps);
		
		}else if(document.creditform.creditAmount[1].checked){			//20 EUR
		
			window.location = "myaccount_chargecredits_creditcardinstructions.asp?strCredit=" + document.creditform.creditAmount[1].value
			var ccWin = window.open("myaccount_chargecredits_ccgatewayrelayPCI.asp?strCredit=" + document.creditform.creditAmount[1].value, "CenseoWindow", winProps);
			
		}else if(document.creditform.creditAmount[2].checked){			//30 EUR
		
			window.location = "myaccount_chargecredits_creditcardinstructions.asp?strCredit=" + document.creditform.creditAmount[2].value
			var ccWin = window.open("myaccount_chargecredits_ccgatewayrelayPCI.asp?strCredit=" + document.creditform.creditAmount[2].value, "CenseoWindow", winProps);
		
		}
		
		
		
	 
	 }
	 else if(document.creditform.paymentMethod[1].checked){				//paypal
	 
		if(document.creditform.creditAmount[0].checked){				//10 EUR
	
			window.location = "myaccount_chargecredits_paypalinstructions.asp?strCredit=" + document.creditform.creditAmount[0].value
			var ppWin = window.open("myaccount_chargecredits_ppgatewayrelay.asp?strCredit=" + document.creditform.creditAmount[0].value, "PayPalWindow", winProps);
		
		}else if(document.creditform.creditAmount[1].checked){			//20 EUR
		
			window.location = "myaccount_chargecredits_paypalinstructions.asp?strCredit=" + document.creditform.creditAmount[1].value
			var ppWin = window.open("myaccount_chargecredits_ppgatewayrelay.asp?strCredit=" + document.creditform.creditAmount[1].value, "PayPalWindow", winProps);
		
		}else if(document.creditform.creditAmount[2].checked){			//30 EUR
		
			window.location = "myaccount_chargecredits_paypalinstructions.asp?strCredit=" + document.creditform.creditAmount[2].value
			var ppWin = window.open("myaccount_chargecredits_ppgatewayrelay.asp?strCredit=" + document.creditform.creditAmount[2].value, "PayPalWindow", winProps);
		}
	 }
	 else if(document.creditform.paymentMethod[2].checked){				//coupon
	 
	 	window.location = "myaccount_chargecredits_couponvalidate.asp?strCouponID=" + document.creditform.couponID.value
		
	 }
	 else{
	 	alert('Error.\n\nApplication cannot determine where to go to process order.');
	 }

}



