function validatePostComment()
{
	author     = document.commentform.author;	
	email      = document.commentform.email;	
	url        = document.commentform.url;	
	comment    = document.commentform.comment;
	if((author.value==null)|| (author.value==""))
	{
	alert("Please enter your name");
	author.value="";
	author.focus();
	return false;
	}
	if((email.value==null)|| (email.value==""))
	{
	alert("Please enter your email id");
	email.value="";
	email.focus();
	return false;
	}
	if (echeck(email.value)==false){
		email.value="";
		email.focus();
		return false;
	}
	if ((url.value!=null)&& (url.value!=""))
	{
	 
	  if(checkURL(url.value)==false)
	  {
	    alert("Please Enter valid url");
		url.value="";
	    url.focus();  
	    return false
	  }
	
	}
	if((comment.value==null)|| (comment.value==""))
	{
	alert("Please enter comment");
	comment.value="";
	comment.focus();
	return false;
	}
	
	return true;
}

function advertisingFormValidation()
{
	
	firstname  = document.AdvertisingEnquiryForm.firstname;
	lastname   = document.AdvertisingEnquiryForm.lastname;
	company    = document.AdvertisingEnquiryForm.company;
	email      = document.AdvertisingEnquiryForm.email;
	phone      = document.AdvertisingEnquiryForm.phone;
	address    = document.AdvertisingEnquiryForm.address;
	city       = document.AdvertisingEnquiryForm.city;
	state      = document.AdvertisingEnquiryForm.state;
	postcode   = document.AdvertisingEnquiryForm.postcode;
	country    = document.AdvertisingEnquiryForm.country;
	product    = document.AdvertisingEnquiryForm.product;
	url        = document.AdvertisingEnquiryForm.url;
	audience   = document.AdvertisingEnquiryForm.audience;
	advertising= document.AdvertisingEnquiryForm.advertising;
	if((firstname.value==null)|| (firstname.value==""))
	{
	alert("Please enter your first name");
	firstname.value="";
	firstname.focus();
	return false;
	}
	if((lastname.value==null)|| (lastname.value==""))
	{
	alert("Please enter your last name");
	lastname.value="";
	lastname.focus();
	return false;
	}
	if((company.value==null)|| (company.value==""))
	{
	alert("Please enter your company");
	company.value="";
	company.focus();
	return false;
	}
	if((email.value==null)|| (email.value==""))
	{
	alert("Please enter your email id");
	email.value="";
	email.focus();
	return false;
	}
	if (echeck(email.value)==false){
		email.value="";
		email.focus();
		return false;
	}
	
	
	if((phone.value==null)|| (phone.value==""))
	{
	alert("Please enter your phone number")
	phone.value="";
	phone.focus();
	return false;
	}
	
	if ((phone.value!=null)&& (phone.value!=""))
	{
	   if (checkInternationalPhone(phone.value)==false){
			alert("Enter valid phone number")
			phone.value="";
			phone.focus();
			return false;
		}
		
	}
	
	if((city.value==null)|| (city.value==""))
	{
	alert("Please enter your city name");
	city.value="";
	city.focus();
	return false;
	}
	if((state.value==null)|| (state.value==""))
	{
	alert("Please enter your state name");
	state.value="";
	state.focus();
	return false;
	}
	if((postcode.value==null)|| (postcode.value==""))
	{
	alert("Please enter your zip code");
	postcode.value="";
	postcode.focus();
	return false;
	}
	
	
	if ((url.value!=null)&& (url.value!=""))
	{
	 
	  if(checkURL(url.value)==false)
	  {
	    alert("Please Enter valid url");
		url.value="";
	    url.focus();  
	    return false
	  }
	
	}
    
   return true;
	
	
	
}


function contactUsFormValidation()
{
   var name=document.ContactUsForm.name;
   var phone=document.ContactUsForm.phone;
   var fax=document.ContactUsForm.fax;
   var email=document.ContactUsForm.email;
	if((name.value==null)|| (name.value==""))
	{
		alert("Please enter your name");
		name.value="";
		name.focus();
		return false;
	}
	
	if((phone.value==null)|| (phone.value==""))
	{
	alert("Please enter your phone number")
	phone.value="";
	phone.focus();
	return false;
	}
	
	if ((phone.value!=null)&& (phone.value!=""))
	{
	   if (checkInternationalPhone(phone.value)==false){
			alert("Enter valid phone number")
			phone.value="";
			phone.focus();
			return false;
		}
		
	}
	
	
	
	if((fax.value==null)|| (fax.value==""))
	{
	alert("Please enter your fax number")
	fax.value="";
	fax.focus();
	return false;
	}
	
	if ((fax.value!=null)&& (fax.value!=""))
	{
	   if (checkInternationalPhone(fax.value)==false){
			alert("Enter valid fax number")
			fax.value="";
			fax.focus();
			return false;
		}
		
	}
	
	if ((email.value==null)||(email.value=="")){
		alert("Please enter your email id")
		email.value="";
		email.focus();
		return false;
	}
	if (echeck(email.value)==false){
		email.value="";
		email.focus();
		return false;
	}
    
  
   return true;


}




	 /**
 * DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function trim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("-")!=-1)bracket=bracket+1
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
var brchr=strPhone.indexOf("(")
if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}




 function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false;
		 }

 		 return true;					
	}
	
	
	
	function checkURL(value) {
     var tomatch= /\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
     if (tomatch.test(value))
     {      
        return true;
     }
     else
     {     
         return false; 
     }
}
	