var div1;
var dv1;
var dv2;
var dv3;
var dv4;
var dv5;
var regTag=/^[0-9a-zA-Z_]+$/;
//var regSrch=/^[0-9a-zA-Z_()-:!/]+$/;
function isNull(aStr)
{
	var index;		
	for (index=0; index < aStr.length; index++)
		if (aStr.charAt(index) != ' ')
			return false;
	return true;
}
function trim(str)
{
    s = str.replace(/^(\s)*/, '');
    s = s.replace(/(\s)*$/, '');
    return s;
}
//For checking invalid E-Mail address
function isEmail(aStr)
{
	var reEmail=/^[0-9a-zA-Z_'\.-]+\@[0-9a-zA-Z_\.-]+\.[0-9a-zA-Z_\.-]+$/;
	if(!reEmail.test(aStr))
	{
		return false;
	}
	return true;
}
function isNumeric(value)
{
	var regNumeric=/^[0-9]+$/;
	if(!regNumeric.test(value))
	{
		return false;
	}
	return true;
}
function isValidPhoneNum(value)
{
	var regNumeric=/^[0-9.-]+$/;
	if(!regNumeric.test(value))
	{
		return false;
	}
	return true;
}
function chkForm()
{	
   	if(document.getElementById("sTitle").value =='')
	{
	  alert("Please enter the title");
	  document.getElementById("sTitle").focus();
	  return false;
	}
	if(document.getElementById("sDescription").value =='')
	{
	  alert("Please enter the description");
	  document.getElementById("sDescription").focus();
	  return false;
	}
	else
	{
	  return true;	
	}

}
function validate_contact_form(siteurl)
{
	var url; 
	var contact_firstname = document.getElementById("contact_firstname").value;
  	var contact_lastname = document.getElementById("contact_lastname").value;
 	var contact_emailid = document.getElementById("contact_emailid").value;
  	var contact_phone = document.getElementById("contact_phone").value;
 	var contact_state = document.getElementById("contact_state").value;
 	var contact_city= document.getElementById("contact_city").value;
 	var contact_comments= document.getElementById("contact_comments").value; 
 	var contact_looking = document.getElementById("contact_looking").value;
 	var conatct_hearabout= document.getElementById("conatct_hearabout").value;
	
	
	if(isNull(trim(contact_firstname)))
	{
      alert("Please enter the First name");
	  document.getElementById("contact_firstname").focus();
	  return false;
	}
	if(isNull(trim(contact_lastname)))
	{
      alert("Please enter the Last name");
	  document.getElementById("contact_lastname").focus();
	  return false;
	}
	 if(isNull(contact_phone))
	{
		alert("Please enter the Phone number")
		document.getElementById("contact_phone").focus();
		return false;
	}
	if(!isValidPhoneNum(contact_phone))
	{
		alert("Please enter the correct Phone number")
		document.getElementById("contact_phone").focus();
		return false;
	}
	
	if(isNull(trim(contact_emailid)))
	{
      alert("Please enter the Email");
	  document.getElementById("contact_emailid").focus();
	  return false;
	}
	if(!isEmail(contact_emailid))
	{
      alert("Please enter the valid Email");
	  document.getElementById("contact_emailid").focus();
	  return false;
	}
	
	if(isNull(trim(contact_state)))
	{
      alert("Please enter the State");
	  document.getElementById("contact_state").focus();
	  return false;
	}
	if(isNull(trim(contact_city)))
	{
      alert("Please enter the City");
	  document.getElementById("contact_city").focus();
	  return false;
	}
	if(isNull(trim(contact_comments)))
	{
      alert("Please enter the Comments");
	  document.getElementById("contact_comments").focus();
	  return false;
	}
	else
	{   
		if(siteurl!='')
		{
 		url =siteurl+"/posted_contact.php?contact_firstname="+escape(contact_firstname)+"&contact_lastname="+escape(contact_lastname)+"&contact_emailid="+escape(contact_emailid)+"&contact_state="+escape(contact_state)+"&contact_city="+escape(contact_city)+"&contact_comments="+escape(contact_comments)+"&contact_looking="+escape(contact_looking)+"&conatct_hearabout="+escape(conatct_hearabout)+"&contact_phone="+escape(contact_phone);
		var x=new Ajax.Updater('formbox',url,{asynchronous:true}); 
		return false;
		}	
 	}

}
//This function is used to set the header backgroun image
function loadHeaderBckImg(img_name)
{
	
	var t;
	t= img_name;
	document.getElementById("header_main_img").style.backgroundImage  = "url(" + t + ")";
}
function vaildate_serach()
{
	 
	var searchbox = document.getElementById("searchbox").value;
	if(isNull(trim(searchbox)))
	{
      alert("Please enter the keyword to be searched");
	  document.getElementById("searchbox").focus();
	  return false;
	}
	else
	{   
	 	return true;
	 
 	}
}
