var root = "http://www.readonsoftware.com/"
var secureroot = "https://www.readonsoftware.com/"

//var root = "http://localhost/readon/"
//var secureroot = "http://localhost/readon/"

function viewStatement() {
	window.open("privacy.asp","Privacy","top=" + (screen.availHeight-410)/2 + ",left=" + (screen.availWidth-600)/2 + ",width=600,height=410,location=no,status=no,toolbar=no,titlebar=no")
}
function viewDisclaimer() {
	window.open("disclaimer.asp","Disclaimer","top=" + (screen.availHeight-325)/2 + ",left=" + (screen.availWidth-500)/2 + ",width=500,height=325,location=no,status=no,toolbar=no,titlebar=no")
}
function viewRegistration() {
	window.open("register.asp","Register","top=" + (screen.availHeight-325)/2 + ",left=" + (screen.availWidth-500)/2 + ",width=500,height=325,location=no,status=no,toolbar=no,titlebar=no")
}
function viewCVN() {
	window.open("CVN.asp","CVN","top=" + (screen.availHeight-325)/2 + ",left=" + (screen.availWidth-500)/2 + ",width=500,height=325,location=no,status=no,toolbar=no,titlebar=no")
}

function chgStatus(id,s)
{
	document.location.href="changestatus.asp?id=" + id + "&status=" + s
}

function doSubmit(p)
{


	if (!isInt(document.Purchaseform.squantity.value) || document.Purchaseform.squantity.value < 1 || document.Purchaseform.squantity.value > 999) {
		alert("Please enter a quantity greater than 1 and less than 1000");
		document.Purchaseform.squantity.focus();
		return false
	}
	else {
		document.Purchaseform.action= secureroot + p
		document.Purchaseform.submit()
	}
}

function pwRequest()
{
	if (loginForm.itechemailaddr.value == "" || loginForm.itechemailaddr.value.indexOf('@',1)== -1 || loginForm.itechemailaddr.value.indexOf('.',2)==-1){
		alert("Please fill in your Email Address.");
		loginForm.itechemailaddr.focus();
		//return false;
	}
	else {
		reqForm.itechemailaddr.value=loginForm.itechemailaddr.value
		reqForm.submit()
		return true;
	}
}

function validateCust(theForm){
	if (theForm.fname.value == "" || theForm.fname.value.length < 2){
		alert("Please fill in your First Name.");
		theForm.fname.focus();
		return false;
	}
	if (theForm.lname.value == "" || theForm.lname.value.length < 2){
		alert("Please fill in your Last Name.");
		theForm.lname.focus();
		return false;
	}
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
		alert("Please fill in your Email Address.");
		theForm.email.focus();
		return false;
	}
	if (theForm.address.value == "" || theForm.address.value.length < 2){
		alert("Please fill in your Street Address.");
		theForm.address.focus();
		return false;
	}
	if (theForm.town.value == "" || theForm.town.value.length < 2){
		alert("Please fill in your Town/Suburb.");
		theForm.town.focus();
		return false;
	}
	if (theForm.zip.value == "" || theForm.zip.value.length < 2){
		alert("Please fill in your Zip/Post code.");
		theForm.zip.focus();
		return false;
	}
	if (theForm.state.value == ""){
		alert("Please fill in your State.");
		theForm.state.focus();
		return false;
	}
	if (theForm.country.value == "" || theForm.country.value.length < 2){
		alert("Please fill in your Country.");
		theForm.country.focus();
		return false;
	}
	if (theForm.phone.value == "" || theForm.phone.value.length < 2){
		alert("Please fill in your Telephone Number.");
		theForm.phone.focus();
		return false;
	}
return true;
}

function validateCustELC(theForm){
	if (theForm.fname.value == "" || theForm.fname.value.length < 2){
		alert("Please fill in your First Name.");
		theForm.fname.focus();
		return false;
	}
	if (theForm.lname.value == "" || theForm.lname.value.length < 2){
		alert("Please fill in your Last Name.");
		theForm.lname.focus();
		return false;
	}
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
		alert("Please fill in your Email Address.");
		theForm.email.focus();
		return false;
	}
	if (theForm.organisation.value == "" || theForm.organisation.value.length < 2){
		alert("Please fill in your School/LEA.");
		theForm.organisation.focus();
		return false;
	}
	if (theForm.address.value == "" || theForm.address.value.length < 2){
		alert("Please fill in your Street Address.");
		theForm.address.focus();
		return false;
	}
	if (theForm.town.value == "" || theForm.town.value.length < 2){
		alert("Please fill in your Town/Suburb.");
		theForm.town.focus();
		return false;
	}
	if (theForm.zip.value == "" || theForm.zip.value.length < 2){
		alert("Please fill in your Zip/Post code.");
		theForm.zip.focus();
		return false;
	}
	if (theForm.phone.value == "" || theForm.phone.value.length < 2){
		alert("Please fill in your Telephone Number.");
		theForm.phone.focus();
		return false;
	}
return true;
}

function validateTrialReg(theForm){
	if (theForm.fname.value == "" || theForm.fname.value.length < 2){
		alert("Please fill in your First Name.");
		theForm.fname.focus();
		return false;
	}
	if (theForm.lname.value == "" || theForm.lname.value.length < 2){
		alert("Please fill in your Last Name.");
		theForm.lname.focus();
		return false;
	}
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
		alert("Please fill in your Email Address.");
		theForm.email.focus();
		return false;
	}
	if (theForm.organisation.value == "" || theForm.organisation.value.length < 2){
		alert("Please fill in your School.");
		theForm.organisation.focus();
		return false;
	}
	if (theForm.address.value == "" || theForm.address.value.length < 2){
		alert("Please fill in your Street Address.");
		theForm.address.focus();
		return false;
	}
	if (theForm.town.value == "" || theForm.town.value.length < 2){
		alert("Please fill in your City.");
		theForm.town.focus();
		return false;
	}
	if (theForm.state.value == "" || theForm.state.value.length < 2){
		alert("Please fill in your State.");
		theForm.state.focus();
		return false;
	}
	if (theForm.country.value == "" || theForm.country.value.length < 2){
		alert("Please fill in your Country.");
		theForm.country.focus();
		return false;
	}
	if (theForm.zip.value == "" || theForm.zip.value.length < 2){
		alert("Please fill in your Zip code.");
		theForm.zip.focus();
		return false;
	}
	if (theForm.phone.value == "" || theForm.phone.value.length < 2){
		alert("Please fill in your Telephone Number.");
		theForm.phone.focus();
		return false;
	}
return true;
}

function validateReg(theForm){
	if (theForm.fname.value == "" || theForm.fname.value.length < 2){
		alert("Please fill in your First Name.");
		theForm.fname.focus();
		return false;
	}
	if (theForm.lname.value == "" || theForm.lname.value.length < 2){
		alert("Please fill in your Last Name.");
		theForm.lname.focus();
		return false;
	}
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
		alert("Please fill in your Email Address.");
		theForm.email.focus();
		return false;
	}
	if (theForm.country.value == "" || theForm.country.value.length < 2){
		alert("Please fill in your Country Name.");
		theForm.country.focus();
		return false;
	}
	/*if (theForm.phone.value == "" || theForm.phone.value.length < 2){
		alert("Please fill in your Telephone Number.");
		theForm.phone.focus();
		return false;
	}*/
return true;
}

var submitcount = 0;

function validateCC(theForm){

	if (submitcount != 0){
		alert("Payment in progress.");
		theForm.paymentm.focus();
		return false;
	}
	if (theForm.paymentm.value == ""){
		alert("Please select your credit card type.");
		theForm.paymentm.focus();
		return false;
	}
	if (theForm.cardname.value == "" || theForm.cardname.value.length < 2){
		alert("Please enter the name found on your credit card.");
		theForm.cardname.focus();
		return false;
	}
	if (theForm.cardno.value == "" || theForm.cardno.value.length < 15 || theForm.cardno.value == "0000-0000-0000-0000"){
		alert("Please enter the credit card number with no spaces");
		theForm.cardno.focus();
		return false;
	}
	if (theForm.CVN.value == "" || theForm.CVN.value.length < 3){
		alert("Please enter the verification code found on the back your credit card.\nThe Verification Code is the last three digits that appear on the signature strip of your card.");
		theForm.cardname.focus();
		return false;
	}
	if (theForm.expMonth.value == ""){
		alert("Please select the expiry month of your credit card.");
		theForm.expMonth.focus();
		return false;
	}
	if (theForm.expYear.value == ""){
		alert("Please select the expiry year of your credit card.");
		theForm.expYear.focus();
		return false;
	}
	submitcount ++;	
	return true;
}

function isInt (str)
{
	var i = parseInt (str);

	if (isNaN (i))
		return false;

	i = i . toString ();
	if (i != str)
		return false;

	return true;
}


