function classChange(styleChange,item) {
	item.className = styleChange;
}

// other functions
function mailStr(recipient, subject, link) {
//  var contact = "info";
//  var email = "info";
  if (link)
  	return link;
  var eHost = "takeware.co.uk";
  eSub="";
  if (subject)
  	eSub = "?subject=TWGK - " + subject;
  return(recipient + "&#064;" + eHost + eSub);
}

function roundIt(num, plcs) {
//  Rounds num to plcs decimal places
  return (Math.round((num * Math.pow(10, plcs)))/Math.pow(10, plcs));
}

// Gatekeeper SME price calc functions
function sme5Calc(x) {
//	alert("x is " + x);
if (x == 'x'){
//	alert("x is x");
	document.sme5.pricetext.value=document.sme5.totprice.value;
	return true;	
}
document.sme5.totprice.value=3*x;
document.sme5.pricetext.value=3*x;
return true;
}

function sme10Calc()
{
//  alert("Hello from sme10Calc");
document.sme10.pricetext.value=document.sme10.totprice.value;
return true;
}

function smeplusCalc(x){
if (x == 'x'){
//	alert("x is x");
	document.smeplus.pricetext.value=document.smeplus.totprice.value;
	return true;	
}
if (document.smeplus.num_seats.value > 250 || document.smeplus.num_seats.value < 11) {
	alert("Please input a number of seats in the range 11 to 250");
	document.smeplus.num_seats.value=11;
	select(document.smeplus.num_seats);
//	return true;
}
val=roundIt(((17 * document.smeplus.num_seats.value)*1.2),2);
document.smeplus.totprice.value=val;
document.smeplus.pricetext.value=val;
return true;	
}

//  functions to validate forms
//
// A utility function that returns true if a string contains only 
// whitespace characters.
function isblank(s)
{
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}

	function checkEmail(checkStr,verbose) {
		rgxp = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if(checkStr.search(rgxp)) {
			if(verbose) {
				alert("Please enter a valid email address");
			}
			return false;
		}
		else {
			return true;
		}
	}
	function checkLength(checkStr,length,strText,verbose) {
		if(checkStr.length<length) {
			if(verbose) {
				alert("Please enter a valid " + strText);
			}
			return false;
		}
		else {
			return true;
		}
	}
	function checkTel(checkStr,verbose) {
		rgxp = /[^0-9 -]/g;
//		alert("checkTel value " + checkStr.search(rgxp));
		return(checkStr.search(rgxp));
	}
	function checkAll(thisform) {
//		return;
		blnError = false;
		strAlert = "To continue, please enter the following details:\n";
		//Title
		if(!checkLength(thisform.title.value,1,false)) {
			strAlert+=" - Title\n";
			blnError=true;
		}
		
		
		//first_names
		if(!checkLength(thisform.firstname.value,1,false)) {
			strAlert+=" - First name\n";
			blnError=true;
		}

		//Surname
		if(!checkLength(thisform.surname.value,1,false)) {
			strAlert+=" - Surname\n";
			blnError=true;
		}
		//email address
		if(!checkEmail(thisform.email.value,false)) {
				strAlert+=" - Email address\n";
				blnError=true;
			}
		//PhoneNumber length
		if(!checkLength(thisform.phone_no.value,9,false)) {
			strAlert+=" - Phone No (min length 10)\n";
			blnError=true
		}
		//PhoneNumber numeric
		if(checkTel(thisform.phone_no.value,false) >= 0) {
			strAlert+=" - Phone No (must be numeric)\n";
			blnError=true
		}
		
		
		//Street_Address
		if(!checkLength(thisform.address_1.value,4,false)) {
			strAlert+=" - Address - Number and Street\n";
			blnError=true;
		}
		//City_Town
		if(!checkLength(thisform.town.value,3,false)) {
			strAlert+=" - Town/City\n";
			blnError=true;
		}
		//State_Region
		if(!checkLength(thisform.region.value,3,false)) {
			strAlert+=" - Region\n";
			blnError=true;
		}
		//postcode
		if(!checkLength(thisform.postcode.value,3,false)) {
			strAlert+=" - Postcode\n";
			blnError=true;
		}
		//Country
		if(!checkLength(thisform.country.value,2,false)) {
			strAlert+=" - Country\n";
			blnError=true;
		}
		//Organisation
		if(!checkLength(thisform.organisation.value,2,false)) {
			strAlert+=" - Organisation\n";
			blnError=true;
		}
		if(blnError) {
			alert(strAlert);
			
			return false;
		}
		else {
			return true;
		}
	}

