// JavaScript Document
function validate_linkpopulority(s){
	//alert("ok")
		if(trim(s.objective.value)==""){
		alert("please enter your objective")
		s.objective.focus()
		return false
	}
	if(trim(s.yname.value)==""){
		alert("please enter your full name")
		s.yname.focus()
		return false
	}
	if(trim(s.cname.value)==""){
		alert("please enter your company name")
		s.cname.focus()
		return false
	}
	if(trim(s.ctitle.value)==""){
		alert("please enter your title in company")
		s.ctitle.focus()
		return false
	}
	if(trim(s.emailid.value)==""){
		alert("please enter your email id")
		s.emailid.focus()
		return false
	}else{
		st=s.emailid.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					s.emailid.focus();
					return false;
			}
	}
	
	if(trim(s.city.value)==""){
		alert("please enter city")
		s.city.focus()
		return false
	}
	if(trim(s.country.value)==""){
		alert("please enter country")
		s.country.focus()
		return false
	}
	if(trim(s.zip.value)==""){
		alert("please enter zip/postal code")
		s.zip.focus()
		return false
	}
	
	if(trim(s.phone.value)==""){
		alert("please enter your phone no.")
		s.phone.focus()
		return false
	}
	if((trim(s.website.value)=="")||(trim(s.website.value)=="http://")){
		alert("please enter your website URl")
		s.website.focus()
		return false
	}
	if(trim(s.s_cat.value)==""){
		alert("please choose one website category")
		s.s_cat.focus()
		return false
	}
	if(trim(s.hits.value)==""){
		alert("please choose hits per month")
		s.hits.focus()
		return false
	}
	if(trim(s.wbisteold.value)==""){
		alert("please choose website status")
		s.wbisteold.focus()
		return false
	}
	if(trim(s.fkeyword.value)==""){
		alert("please enter most important keywords")
		s.fkeyword.focus()
		return false
	}
	
	if(trim(s.budget.value)==""){
		alert("please enter your estimated budget per month")
		s.budget.focus()
		return false
	}
	if(trim(s.start_date.value)==""){
		alert("please enter start date")
		s.start_date.focus()
		return false
	}
	if(trim(s.addinfo.value)==""){
		alert("please enter additional info")
		s.addinfo.focus()
		return false
	}
	if((s.prev_work[1].checked)||(s.prev_work[5].checked)){
		if(trim(s.specify.value)==""){
			alert("please specify other search engine")
			s.specify.focus()
			return false
		}
		if(trim(s.email.value)==""){
			alert("please enter your friends email id")
			s.email.focus()
			return false
		}else{
			st=s.email.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					s.email.focus();
					return false;
			}
		}
		if(trim(s.url.value)==""){
			alert("please enter website url")
			s.url.focus()
			return false
		}
	}

}
function validate_freequote(s){
	if(trim(s.objective.value)==""){
		alert("please enter your objective")
		s.objective.focus()
		return false
	}
	if(trim(s.yname.value)==""){
		alert("please enter your full name")
		s.yname.focus()
		return false
	}
	if(trim(s.cname.value)==""){
		alert("please enter your company name")
		s.cname.focus()
		return false
	}
	if(trim(s.ctitle.value)==""){
		alert("please enter title in company")
		s.ctitle.focus()
		return false
	}
	if(trim(s.emailid.value)==""){
		alert("please enter your email id")
		s.emailid.focus()
		return false
	}else{
		st=s.emailid.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					s.emailid.focus();
					return false;
			}
	}
	if(trim(s.city.value)==""){
		alert("please enter city")
		s.city.focus()
		return false
	}
	if(trim(s.country.value)==""){
		alert("please enter country")
		s.country.focus()
		return false
	}
	if(trim(s.zip.value)==""){
		alert("please enter zip")
		s.zip.focus()
		return false
	}
	if(trim(s.phone.value)==""){
		alert("please enter phone")
		s.phone.focus()
		return false
	}
	if((trim(s.website.value)=="")||(trim(s.website.value)=="http://")){
		alert("please enter your website URl")
		s.website.focus()
		return false
	}
	if(trim(s.fkeyword.value)==""){
		alert("please enter most important keywords")
		s.fkeyword.focus()
		return false
	}
	if(trim(s.budget.value)==""){
		alert("please enter your estimated budget per month")
		s.budget.focus()
		return false
	}
	if(trim(s.start_date.value)==""){
		alert("please enter start date")
		s.start_date.focus()
		return false
	}
	if(trim(s.addinfo.value)==""){
		alert("please enter additional info")
		s.addinfo.focus()
		return false
	}
	if((s.prev_work[1].checked)||(s.prev_work[5].checked)){
		if(trim(s.specify.value)==""){
			alert("please specify search engine")
			s.specify.focus()
			return false
		}
		if(trim(s.email.value)==""){
			alert("please enter your friends email id")
			s.email.focus()
			return false
		}else{
			st=s.email.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					s.email.focus();
					return false;
			}
		}
		if(trim(s.url.value)==""){
			alert("please enter website url")
			s.url.focus()
			return false
		}
	}
}
function validate_contact(s){
	if(trim(s.yname.value)==""){
		alert("please enter your full name")
		s.yname.focus()
		return false
	}
	if(trim(s.cname.value)==""){
		alert("please enter your company name")
		s.cname.focus()
		return false
	}
	if(trim(s.s_cat.value)==""){
		alert("please select your website category")
		s.s_cat.focus()
		return false
	}
	if(trim(s.phoneno.value)==""){
		alert("please enter your phone no.")
		s.phoneno.focus()
		return false
	}
	if(trim(s.emailid.value)==""){
		alert("please enter your email id")
		s.emailid.focus()
		return false
	}else{
		st=s.emailid.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					s.emailid.focus();
					return false;
			}
	}
	if(trim(s.message.value)==""){
		alert("please enter message")
		s.message.focus()
		return false
	}
	if((s.prev_work[1].checked)||(s.prev_work[5].checked)){
		if(trim(s.specify.value)==""){
			alert("please specify other search engine")
			s.specify.focus()
			return false
		}
		if(trim(s.email.value)==""){
			alert("please enter your friends email id")
			s.email.focus()
			return false
		}else{
			st=s.email.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					s.email.focus();
					return false;
			}
		}
		if(trim(s.url.value)==""){
			alert("please enter website url")
			s.url.focus()
			return false
		}
	}
	
}


function LTrim(str)
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...

      var j=0, i = s.length;

      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      // Get the substring from the first non-whitespace
      // character to the end of the string...
      s = s.substring(j, i);
   }
   return s;
}

function RTrim(str)
{
   // We don't want to trip JUST spaces, but also tabs,
   // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...

      var i = s.length - 1;       // Get length of string

      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;


      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }

   return s;
}


function trim(str)
{
   return RTrim(LTrim(str));
}

function checkEmail(str)
	{
		if((str.indexOf("@")==-1) || (str.indexOf(".")==-1))
		{
			fstr="Please Enter @ or .";
			return false;
		}
		else
		{
		if((str.indexOf("@") == 0) || (str.indexOf(".") == 0))
		{
			fstr="@ or . Cannot Be first";
			return false;
		}
		if((str.indexOf("@") == (str.length-1)) || (str.indexOf(".") == (str.length-1)))
		{
			fstr="@ or . Cannot Be Last";
			return false;
		}

		if(str.indexOf("@") > str.indexOf("."))
		{
			fstr="@ Should be After .";
			return false;
		}
		if((str.indexOf("@")+1) == str.indexOf("."))
		{
			fstr="@. IS Invalid Email";
			return false;
		}
		}
		var cp=0;					
		for(i=0;i<str.length;i++)
		{
			c=str.charAt(i);
			b=(((c >= "0") && (c <= "9")) || ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) || (c == ".") || (c == "@") || (c == "_")|| (c == "-"))
			if(c=="@") cp++;
			if(b==true)
			   continue;
			else
			{
				fstr="Cannot include "+c;
				return false;
			}
		}
		if(cp==2)
		{
			fstr="@ cannnot be repetaed";
			return false;

		}
		return true;
	}

