// JavaScript Document
//********************************* for register ************************************//
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function phcheck(pnum)
  {
  var phchar="1234567890 -_+.()";
  for (i=0;i<=pnum.length;i++)
    {	
	if(phchar.indexOf(pnum.charAt(i))==-1)
	  {	  
	  alert("Only Numbers and (+-_. ) are allowed");
	  return false ;
	  }	
	}
  return true ;
  }
  
  
/*function validate()
{
	if(trim(document.regi.title.value)=="")
		{
			alert("Title must be filled out!");
			document.regi.title.focus();
			return false;
		}
	
	if(trim(document.regi.fname.value)=="")
		{
			alert("First name must be filled out!");
			document.regi.fname.focus();
			return false;
		}
	if(trim(document.regi.lname.value)=="")
		{
			alert("Last name must be filled out!");
			document.regi.lname.focus();
			return false;
		}
		
	if(trim(document.regi.add.value)=="")
		{
			alert("Address must be filled out!");
			document.regi.add.focus();
			return false;
		}
	
	if(trim(document.regi.city.value)=="")
		{
			alert("Suburb/City must be filled out!");
			document.regi.city.focus();
			return false;
		}
		
	if(trim(document.regi.state.value)=="")
		{
			alert("State must be filled out!");
			document.regi.state.focus();
			return false;
		}
		
	if(trim(document.regi.pcode.value)=="")
		{
			alert("Postcode must be filled out!");
			document.regi.pcode.focus();
			return false;
		}
if(isNaN(document.regi.pcode.value))
	{
	alert("Only numbers for post code");
	document.regi.pcode.value="";
	document.regi.pcode.focus();
	return false; 
	}
	
	if(trim(document.regi.country.value)=="")
	{
		alert("Country must be filled out!");
		document.regi.country.focus();
		return false;
	}
	
   if(trim(document.regi.email.value)=="")
		{
			alert("Email must be filled out!");
			document.regi.email.focus();
			return false;
		}
	if(!echeck(document.regi.email.value))
    {
	document.regi.email.value="";
	document.regi.email.focus();
	return false;
    }	
	
	
	if(trim(document.regi.phone.value)=="")
    {
	alert("Tel number must be filled out!");
	document.regi.phone.value="";
	document.regi.phone.focus();
	return false;
    }
	else if (document.regi.phone.value!="")
		{
		if(!phcheck(document.regi.phone.value))
			{
			document.regi.phone.focus();
			document.regi.phone.value="";
			return false;			
			}
		}
		
		return true;
	}
	
	
function echeck(Email)  
{

var at=Email.indexOf('@');
var dot=Email.lastIndexOf('.');
var atpos=Email.lastIndexOf('@');
var emlen=Email.length;
if (at<1||dot-at<2||atpos+1==emlen||dot+1==emlen||emlen-dot<3) 
  {
  alert('Invalid email address');
  return false;
  }
  return true;
}	*/

//********************************* end of register ************************************//




//********************************* Start survey ************************************//

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function phcheck(pnum)
  {
  var phchar="1234567890 -_+.()";
  for (i=0;i<=pnum.length;i++)
    {	
	if(phchar.indexOf(pnum.charAt(i))==-1)
	  {	  
	  alert("Only Numbers and (+-_. ) are allowed");
	  return false ;
	  }	
	}
  return true ;
  }
  
  
function valid()
{
	/*if(trim(document.survey.title1.value)=="")
		{
			alert("Title must be filled out!");
			document.survey.title1.focus();
			return false;
		}*/
	
	if(trim(document.survey.fname1.value)=="")
		{
			alert("First name must be filled out!");
			document.survey.fname1.focus();
			return false;
		}
		if(trim(document.survey.lname1.value)=="")
		{
			alert("Last name must be filled out!");
			document.survey.lname1.focus();
			return false;
		}
		
	/*if(trim(document.survey.position.value)=="")
		{
			alert("Position must be filled out!");
			document.survey.position.focus();
			return false;
		}
	
	if(trim(document.survey.industry.value)=="")
		{
			alert("Industry must be filled out!");
			document.survey.industry.focus();
			return false;
		}
		
	if(trim(document.survey.cname.value)=="")
		{
			alert("Website name must be filled out!");
			document.survey.cname.focus();
			return false;
		}
		
	if(trim(document.survey.add1.value)=="")
		{
			alert("Address must be filled out!");
			document.survey.add1.focus();
			return false;
		}

		
	if(trim(document.survey.suburb1.value)=="")
		{
			alert("Suburb must be filled out!");
			document.survey.suburb1.focus();
			return false;
		}*/
		
		if(trim(document.survey.state1.value)=="")
		{
			alert("State must be filled out!");
			document.survey.state1.focus();
			return false;
		}
		
	/*if(trim(document.survey.pcode1.value)=="")
		{
			alert("Postcode must be filled out!");
			document.survey.pcode1.focus();
			return false;
		}
		
	if(isNaN(document.survey.pcode1.value))
		{
			alert("Only numbers for post code");
			document.survey.pcode1.value="";
			document.survey.pcode1.focus();
			return false; 
		}*/
	
    	if(trim(document.survey.phone1.value)=="")
    {
	alert("Tel number must be filled out!");
	document.survey.phone1.value="";
	document.survey.phone1.focus();
	return false;
    }
	else if (document.survey.phone1.value!="")
		{
		if(!phcheck(document.survey.phone1.value))
			{
			document.survey.phone1.focus();
			document.survey.phone1.value="";
			return false;			
			}
		}
		
		
		/*if(trim(document.survey.mobile1.value)=="")
    {
	alert("Mobile must be filled out!");
	document.survey.mobile1.value="";
	document.survey.mobile1.focus();
	return false;
    }
	else if (document.survey.mobile1.value!="")
		{
		if(!phcheck(document.survey.mobile1.value))
			{
			document.survey.mobile1.focus();
			document.survey.mobile1.value="";
			return false;			
			}
		}*/
	

   if(trim(document.survey.email1.value)=="")
		{
			alert("Email must be filled out!");
			document.survey.email1.focus();
			return false;
		}
	if(!echeck(document.survey.email1.value))
    {
	document.survey.email1.value="";
	document.survey.email1.focus();
	return false;
    }
	/*if(trim(document.survey.captcha.value)=="")
		{
			alert("Enter Security code!");
			document.survey.captcha.focus();
			return false;
		}*/
	
/*
	if(trim(document.survey.special.value)=="")
	{
		alert("Special offer code must be filled out!");
		document.survey.special.focus();
		return false;
	}
		*/
		return true;
	}
	
	
function echeck(Email)  
{
var at=Email.indexOf('@');
var dot=Email.lastIndexOf('.');
var atpos=Email.lastIndexOf('@');
var emlen=Email.length;
if (at<1||dot-at<2||atpos+1==emlen||dot+1==emlen||emlen-dot<3) 
  {
  alert('Invalid email address');
  return false;
  }
  return true;
}	
//********************************* End of survey ************************************//

