
function f_trimmer(thisstring)
{
	while(thisstring.charAt(0)==" ")
	{
		thisstring=thisstring.substring(1,thisstring.length);
	}
	return thisstring;
}

function checkme(){
if (document.myform.username){
	if (f_trimmer(document.myform.username.value)==""){
	
		 alert("Username is required");
		 document.myform.username.focus();
		 return false;
	}
}
if (document.myform.password){
	if (f_trimmer(document.myform.password.value)==""){
	
		 alert("Password is required");
		 document.myform.password.focus();
		 return false;
	}
}

if (document.myform.name){
	if (f_trimmer(document.myform.name.value)==""){
	
		 alert("Name is required");
		 document.myform.name.focus();
		 return false;
	}
}

if (document.getElementById('categories')){
	if (f_trimmer(document.getElementById('categories').value)=="" || f_trimmer(document.getElementById('categories').value)==0){
	
		 alert("Select Categories");
		 document.getElementById('categories').focus();
		 return false;
	}
}
if (document.myform.country_id){
	if (f_trimmer(document.myform.country_id.value)==0){
	
		 alert("Country is required");
		 document.myform.country_id.focus();
		 return false;
	}
}

if (document.myform.county_id){
	if (f_trimmer(document.myform.county_id.value)==0){
	
		 alert("County is required");
		 document.myform.county_id.focus();
		 return false;
	}
}

if (document.myform.town_id){
	if (f_trimmer(document.myform.town_id.value)==0){
	
		 alert("Town is required");
		 document.myform.town_id.focus();
		 return false;
	}
}

if (document.myform.phone){
	if (f_trimmer(document.myform.phone.value)==""){
	
		 alert("Telephone is required");
		 document.myform.phone.focus();
		 return false;
	}
}
if (document.myform.email){
	
	if (f_trimmer(document.myform.email.value)==""){
		alert("Your Email is required\n");
		document.myform.email.focus();
		return false;
	} else {
   		var s = new String(document.myform.email.value);

       	if ((s.indexOf(".")==-1 || s.indexOf("@")==-1)){       
       		alert ("Your Email address is invalid.");
			document.myform.email.focus();
			return false;
		}
	}
}

if (document.myform.scode){
	if (f_trimmer(document.myform.scode.value)==""){
		 alert("Confirm security code please!");
		 document.myform.scode.focus();
		 return false;
	}
}
}
