function isURL(urlStr) 
{
		if (urlStr.indexOf(" ") != -1) {
		alert("Spaces are not allowed in a URL");
          return false;
		}

		if (urlStr == "" || urlStr == null) {
		return true;
		}

		urlStr=urlStr.toLowerCase();

		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
		var validChars="\[^\\s" + specialChars + "\]";
		var atom=validChars + '+';
		var urlPat=/^http:\/\/(\w*)\.([\-\+a-z0-9]*)\.(\w*)/;
		var matchArray=urlStr.match(urlPat);

		if (matchArray==null) {
		alert("The URL seems incorrect \ncheck it begins with http://");
		return false;
		}

		var user=matchArray[2];
		var domain=matchArray[3];

		for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
		alert("This domain contains invalid characters.");
		return false;
		}
		}

		for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i) > 127) {
		alert("This domain name contains invalid characters.");
		return false;
		}
		}

		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;

		for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat) == -1) {
		alert("The domain name does not seem to be valid.");
		return false;
		}
		}

		return true;
} 


function Trim(str)
		{
		
		return LTrim(RTrim(str));
		
		}
		
		function LTrim(str)
		{
		
		for (var i=0; str.charAt(i)==" "; i++)
		{
		str =  str.substring(i,str.length-1);
		}
		return str;
		}
		
		
		function RTrim(str)
		{
		
		for (var i=str.length-1; str.charAt(i)==" "; i--)
		{  
		str = str.substring(0,i);
		}
		return str;
		}
		
	function isNum(phone)
			{
			var reNum=/^[0-9\.]+$/;
			if(!reNum.test(phone))
			{
			return false;
			}
			return true;
			}
				
		function validateLogin(){
		if(RTrim(document.frmLogin.txtusername.value)=="")
		{
		alert("Please enter user name");
		document.frmLogin.txtusername.focus();
		document.frmLogin.txtusername.value="";
		return false;
		}
		
		if(RTrim(document.frmLogin.txtpsw.value)=="")
		{
		alert("Please enter password ");
		document.frmLogin.txtpsw.focus();
		return false;
		}
		document.frmLogin.submit();
		return true;
		}
		
	function validateMemProfile()
	{
	extArray = new Array(".gif", ".jpg", ".jpeg");

	    if(RTrim(document.memprofile.txtfnmae.value)=="")
				{
				alert("Please enter first name");
				document.memprofile.txtfnmae.focus();
				document.memprofile.txtfnmae.value="";
				return false;
				}
		if(RTrim(document.memprofile.txtlnmae.value)=="")
				{
				alert("Please enter last name");
				document.memprofile.txtlnmae.focus();
				document.memprofile.txtlnmae.value="";
				return false;
				}
				
		if(RTrim(document.memprofile.txtemail.value)=="")
				{
				alert("Please enter E-mail address");
				document.memprofile.txtemail.focus();
				document.memprofile.txtemail.value="";
				return false;
				}
				
				if (document.memprofile.txtemail.value != "")
				{
				re=/\w{1,}/;
				emailExp= /^\w+(\-\w+)*(\.\w+(\-\w+)*)*@\w+(\-\w+)*(\.\w+(\-\w+)*)+$/ ; 
				if(!(emailExp.test(document.memprofile.txtemail.value)))
				{
				alert("Please Enter Correct E-mail address");
				document.memprofile.txtemail.focus();
				return false;
				}
				}
				
		/* if(RTrim(document.memprofile.txtphoneno.value)=="")
				{
				alert("Please enter phone number");
				document.memprofile.txtphoneno.focus();
				document.memprofile.txtphoneno.value="";
				return false;
				}
		*/
		if(RTrim(document.memprofile.txtphoneno.value)!="")
				{
				if(!isNum(document.memprofile.txtphoneno.value))
				{
				alert("Please enter your correct phone number");
				document.memprofile.txtphoneno.focus();
				return false;
				}
				}
				
				
		if(RTrim(document.memprofile.txtmobileno.value)!="")
				{
				if(!isNum(document.memprofile.txtmobileno.value))
				{
				alert("Please enter your correct mobile number");
				document.memprofile.txtmobileno.focus();
				return false;
				}
				}
			
			if(RTrim(document.memprofile.txtfaxno.value)!="")
				{
					if(!isNum(document.memprofile.txtfaxno.value))
					{
					alert("Please enter your correct fax number");
					document.memprofile.txtfaxno.focus();
					return false;
					}
				}	
				
			if(RTrim(document.memprofile.category.value) =="")
				{
					
					alert("Please select your Category ");
					document.memprofile.category.focus();
					return false;
					
				}	

		/*if(RTrim(document.memprofile.txtwebsite.value)!="" || RTrim(document.memprofile.txtwebsite.value)!="http://")
			{     
				if(isURL(document.memprofile.txtwebsite.value) == false)
				  {
					document.memprofile.txtwebsite.focus();
					return false;
				 }
				 
			}
			*/
		
		if(RTrim(document.memprofile.txtSuburb.value)=="")
				{
				alert("Please enter suburb");
				document.memprofile.txtSuburb.focus();
				document.memprofile.txtSuburb.value="";
				return false;
				}
		
		
		if(RTrim(document.memprofile.txtpostcode.value)=="")
				{
				alert("Please enter post code");
				document.memprofile.txtpostcode.focus();
				document.memprofile.txtpostcode.value="";
				return false;
				}
				
		if(RTrim(document.memprofile.txtpostcode.value)!="")
				{
				if(!isNum(document.memprofile.txtpostcode.value))
				{
				alert("Please enter your correct post code");
				document.memprofile.txtpostcode.focus();
				return false;
				}
				}		
				
		if(RTrim(document.memprofile.image.value) !="") 
		 {
				file=document.memprofile.image.value;
				allowSubmit = false;
				if (!file) return;
				while (file.indexOf("\\") != -1)
				file = file.slice(file.indexOf("\\") + 1);
				ext = file.slice(file.indexOf(".")).toLowerCase();
				//alert(ext);
				for (var i = 0; i < extArray.length; i++) {
				if (extArray[i] == ext) { allowSubmit = true; break; }
				}
				//alert(allowSubmit);
				if (allowSubmit == false)
				{alert("Please only upload images that end in types:  " 
				+ (extArray.join("  ")) + "\nPlease select a new "
				+ "image to upload and submit again.");
				document.memprofile.image.focus();
				return false;
				}
									
		 }	
		 
	    if(RTrim(document.memprofile.specialise.value)=="")
	    {
	      alert("Please select Specialising In !")
	      document.memprofile.specialise.focus();
	      return false;
	    }
        if(RTrim(document.memprofile.envoiement.value)=="")
	    {
	      alert("Please select Training Environment  !")
	      document.memprofile.envoiement.focus();
	      return false;
	    }
        if(RTrim(document.memprofile.traing_type.value)=="")
	    {
	      alert("Please select Training Type  !")
	      document.memprofile.traing_type.focus();
	      return false;
	    }	
       
        if(RTrim(document.memprofile.qualification.value)=="")
	    {
	      alert("Please enter qualification  !")
	      document.memprofile.qualification.focus();
	      return false;
	    }	 
		 				
	    allSelect_location();
	    document.memprofile.submit();
		return true;
	}
	
	function changepassword_validate()
	{
	    var invalid = " ";
		if(RTrim(document.frmpassword.oldpassword.value)=="")
		{
		alert("Please enter current password ");
		document.frmpassword.oldpassword.focus();
		return false;
		}
		if(RTrim(document.frmpassword.newpassword.value)=="")
		{
		alert("Please enter new password ");
		document.frmpassword.newpassword.focus();
		return false;
		}
		if (document.frmpassword.newpassword.value.indexOf(invalid) > -1) {
		alert( "Please enter valid new password. Password should not contain white spaces at any place." );
		document.frmpassword.newpassword.focus();
		return false;
		}
		
		if(RTrim(document.frmpassword.confpassword.value)=="")
		{
		alert("Please enter confirm password");
		document.frmpassword.confpassword.focus();
		return false;
		}
		if(RTrim(document.frmpassword.newpassword.value)!=RTrim(document.frmpassword.confpassword.value))
		{
		alert("Please Re-enter your confirm password !");
		document.frmpassword.confpassword.value="";
		document.frmpassword.confpassword.focus();
		return false;
		}
		
		document.frmpassword.submit();
		return true;
	    
	}
	
	function userValidate()
					{
						 if(Trim(document.frmForgetPsw.txtusername.value)=="")
							{
								alert("Please enter user name");
								document.frmForgetPsw.txtusername.focus();
								document.frmForgetPsw.txtusername.value="";
								return false;
							}
							document.frmForgetPsw.submit();			
							return true;
					}