color='#eedede';
function form_validation1()
{
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
//string.replace(/\s/g, "");
var name= ((document.getElementById("name").value).replace(/\s/g, ""));
var emailid= ((document.getElementById("emailid").value).replace(/\s/g, ""));
var city= ((document.getElementById("city").value).replace(/\s/g, ""));
var state= ((document.getElementById("state").value).replace(/\s/g, ""));
var zip= ((document.getElementById("zip").value).replace(/\s/g, ""));
var country= ((document.getElementById("country").value).replace(/\s/g, ""));
var phone= ((document.getElementById("phone").value).replace(/\s/g, ""));
var details_project= ((document.getElementById("details_project").value).replace(/\s/g, ""));
var captcha= document.getElementById("captcha").value;



if(name=='' || name==null)
{
document.getElementById("name_val").style.display='block';
document.getElementById("name").focus();
document.getElementById("name").style.backgroundColor=color;

return false;
}
document.getElementById("name_val").style.display='none';
 if(emailid=='' || emailid==null)
{
document.getElementById("emailid_val").innerHTML="Email address is mandatory";
document.getElementById("emailid_val").style.display='block';
document.getElementById("emailid").focus();
document.getElementById("emailid").style.backgroundColor=color;
return false;
}

document.getElementById("emailid_val").style.display='none';
 if(reg.test(emailid)==false)
{
document.getElementById("emailid_val").style.display='block';
document.getElementById("emailid").focus();
document.getElementById("emailid").style.backgroundColor=color;
return false;
}

document.getElementById("emailid_val").style.display='none';
 if(city=='' || city==null)
{
document.getElementById("city_val").style.display='block';
document.getElementById("city").focus();
document.getElementById("city").style.backgroundColor=color;
return false;
}
document.getElementById("city_val").style.display='none';
 if(state=='' || state==null)
{
document.getElementById("state_val").style.display='block';
document.getElementById("state").focus();
document.getElementById("state").style.backgroundColor=color;
return false;
}
document.getElementById("state_val").style.display='none';

 if(zip=='' || zip==null)
{
document.getElementById("zip_val").innerHTML="Zip/Postal code is mandatory";
document.getElementById("zip_val").style.display='block';
document.getElementById("zip").focus();
document.getElementById("zip").style.backgroundColor=color;
return false;
}

document.getElementById("zip_val").style.display='none';
 if(isNaN(zip) || zip.length<6)
{
document.getElementById("zip_val").style.display='block';
document.getElementById("zip").focus();
document.getElementById("zip").style.backgroundColor=color;
return false;
}
document.getElementById("zip_val").style.display='none';

 if(country=='' || country==null )
{
document.getElementById("country_val").style.display='block';
document.getElementById("country").focus();
document.getElementById("country").style.backgroundColor=color;

return false;
}document.getElementById("country_val").style.display='none';


 if(phone=='' || phone==null)
{
document.getElementById("phone_val").innerHTML="Phone number is mandatory";
document.getElementById("phone_val").style.display='block';
document.getElementById("phone").focus();
document.getElementById("phone").style.backgroundColor=color;
return false;
}document.getElementById("phone_val").style.display='none';
 if(isNaN(phone) || phone.length<10)
{
document.getElementById("phone_val").style.display='block';
document.getElementById("phone").focus();
document.getElementById("phone").style.backgroundColor=color;
return false;
}document.getElementById("phone_val").style.display='none';
 if(details_project=='' || details_project==null)
{
document.getElementById("details_project_val").style.display='block';
document.getElementById("details_project").focus();
document.getElementById("details_project").style.backgroundColor=color;
return false;
}document.getElementById("zip_val").style.display='none';
if(captcha=='' || captcha==null)
{
document.getElementById("captcha_val").style.display='block';
document.getElementById("captcha").focus();
document.getElementById("captcha").style.backgroundColor=color;
return false;
}document.getElementById("captcha_val").style.display='none';
if(document.getElementById("cpatchacheck").innerHTML!="<font>Correct.</font>")
{
	document.getElementById("captcha_val").style.display='none';
return false;
}
}

//==============================================individual checking===========================================================
function name_validation()
{
var name= ((document.getElementById("name").value).replace(/\s/g, ""));
if(name=='' || name==null)
{
document.getElementById("name_val").style.display='block';
document.getElementById("name").focus();
document.getElementById("name").style.backgroundColor=color;
return false;
}
document.getElementById("name_val").style.display='none';
}
//-----------------------------------------------------------------------------------
function emailid_validation()
{
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var emailid= ((document.getElementById("emailid").value).replace(/\s/g, ""));
if(emailid=='' || emailid==null)
{
document.getElementById("emailid_val").innerHTML="Email address is mandatory";
document.getElementById("emailid_val").style.display='block';
document.getElementById("emailid").focus();
document.getElementById("emailid").style.backgroundColor=color;
return false;
}
if(reg.test(emailid)==false)
{
document.getElementById("emailid_val").style.display='block';
document.getElementById("emailid").focus();
document.getElementById("emailid").style.backgroundColor=color;
return false;
}
document.getElementById("emailid_val").style.display='none';
}
//-------------------------------------------------------------------------------

function city_validation()
{
var city= ((document.getElementById("city").value).replace(/\s/g, ""));
if(city=='' || city==null)
{
document.getElementById("city_val").style.display='block';
document.getElementById("city").focus();
document.getElementById("city").style.backgroundColor=color;

return false;
}
document.getElementById("city_val").style.display='none';
}
//---------------------------------------------------------------------------------------
function state_validation()
{
var state= ((document.getElementById("state").value).replace(/\s/g, ""));
if(state=='' || state==null)
{
document.getElementById("state_val").style.display='block';
document.getElementById("state").focus();
document.getElementById("state").style.backgroundColor=color;

return false;
}
document.getElementById("state_val").style.display='none';
}

//----------------------------------------------------------------------------------------------

function zip_validation()
{
var zip= ((document.getElementById("zip").value).replace(/\s/g, ""));
if(zip=='' || zip==null)
{
document.getElementById("zip_val").innerHTML="Zip/Postal code is mandatory";
document.getElementById("zip_val").style.display='block';
document.getElementById("zip").focus();
document.getElementById("zip").style.backgroundColor=color;
return false;
}document.getElementById("zip_val").style.display='none';
if(isNaN(zip) || zip.length>6)
{
document.getElementById("zip_val").style.display='block';
document.getElementById("zip").focus();
document.getElementById("zip").style.backgroundColor=color;
return false;
}
document.getElementById("zip_val").style.display='none';
}
//-----------------------------------------------------------------------------------------------------
function country_validation(){
var country= ((document.getElementById("country").value).replace(/\s/g, ""));
if(country=='' || country==null )
{
document.getElementById("country_val").style.display='block';
document.getElementById("country").focus();
document.getElementById("country").style.backgroundColor=color;

return false;
}
document.getElementById("country_val").style.display='none';
}
//-----------------------------------------------------------------------------------------------------
function phone_validation(){
var phone= ((document.getElementById("phone").value).replace(/\s/g, ""));
if(phone=='' || phone==null)
{
document.getElementById("phone_val").innerHTML="Phone number is mandatory";
document.getElementById("phone_val").style.display='block';
document.getElementById("phone").focus();
document.getElementById("phone").style.backgroundColor=color;
return false;
}
if(isNaN(phone) || phone.length<10)
{
document.getElementById("phone_val").style.display='block';
document.getElementById("phone").focus();
document.getElementById("phone").style.backgroundColor=color;

return false;
}
document.getElementById("phone_val").style.display='none';
}
//-----------------------------------------------------------------------------------------------------
function details_project_validation(){
var details_project= ((document.getElementById("details_project").value).replace(/\s/g, ""));
if(details_project=='' || details_project==null)
{
document.getElementById("details_project_val").style.display='block';
document.getElementById("details_project").focus();
//document.getElementById("details_project").style.backgroundColor=color;
document.getElementById("details_project").style.backgroundColor=color;

return false;
}
document.getElementById("details_project_val").style.display='none';

}
//-----------------------------------------------------------------------------------------------------
function captcha_validation(){
var captcha= ((document.getElementById("captcha").value).replace(/\s/g, ""));
if(captcha=='' || captcha==null)
{
document.getElementById("captcha_val").style.display='block';
document.getElementById("captcha").focus();
document.getElementById("captcha").style.backgroundColor=color;

return false;
}
document.getElementById("captcha_val").style.display='none';
}
//===================================================functions for cjhange backgroud======================== 
function changebgcolor(id)
{
document.getElementById(id).style.backgroundColor='';
}
//=====================================================function for key move==========================================
function moveup(field,nextFieldID){
  if(field.value.length >= field.maxLength){
    document.getElementById(nextFieldID).focus();
  }
}

// tip box----------------------------------------------------------------------------

var TipBoxID = "TipBox";

var tip_box_id;

function findPosX(obj)
{
   var curleft = 0;
   if(obj.offsetParent)
   while(1) 
   {
      curleft += obj.offsetLeft;
      if(!obj.offsetParent)
         break;
      obj = obj.offsetParent;
   }
   else if(obj.x)
      curleft += obj.x;
   return curleft;
}

function findPosY(obj)
{
   var curtop = 0;
   if(obj.offsetParent)
   while(1)
   {
      curtop += obj.offsetTop;
      if(!obj.offsetParent)
         break;
      obj = obj.offsetParent;
   }
   else if(obj.y)
      curtop += obj.y;
   return curtop;
}

function DisplayTip(me,offX,offY,content) {
   var tipO = me;
   tip_box_id = document.getElementById(TipBoxID);
   var x = findPosX(me);
   var y = findPosY(me);
   tip_box_id.style.left = String(parseInt(x + offX) + 'px');
   tip_box_id.style.top = String(parseInt(y + offY) + 'px');
   tip_box_id.innerHTML = content;
   tip_box_id.style.display = "block";
   tipO.onmouseout = HideTip;
} // function DisplayTip()

function HideTip() { tip_box_id.style.display = "none"; }



//--------------------------------------------------------------------------------------

//----------other project type
function check()
{
 if(document.getElementById('ptyoth').checked)
 {
   document.getElementById('show').style.display='block';
 }
 else
 {
 document.getElementById('show').style.display='none';
 }
 

}
//---------------

//========================================================validation for call us file=-===========================
function call_us_validation()
{

var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
//string.replace(/\s/g, "");
var name= ((document.getElementById("name").value).replace(/\s/g, ""));
var emailid= ((document.getElementById("emailid").value).replace(/\s/g, ""));
var details_project= ((document.getElementById("details_project").value).replace(/\s/g, ""));
var captcha=((document.getElementById("captcha").value).replace(/\s/g, ""));
var phone = ((document.getElementById("phone").value).replace(/\s/g, ""));


if(name=='' || name==null)
{
document.getElementById("name_val").style.display='block';
document.getElementById("name").focus();
document.getElementById("name").style.backgroundColor=color;

return false;
}
document.getElementById("name_val").style.display='none';
 if(emailid=='' || emailid==null)
{
document.getElementById("emailid_val").innerHTML="Email address is mandatory";
document.getElementById("emailid_val").style.display='block';
document.getElementById("emailid").focus();
document.getElementById("emailid").style.backgroundColor=color;
return false;
}

document.getElementById("emailid_val").style.display='none';
 if(reg.test(emailid)==false)
{
document.getElementById("emailid_val").style.display='block';
document.getElementById("emailid").focus();
document.getElementById("emailid").style.backgroundColor=color;
return false;
}

document.getElementById("emailid_val").style.display='none';


if(isNaN(phone) || phone.length<10)
{
document.getElementById("phone_val").style.display='block';
document.getElementById("phone").focus();
document.getElementById("phone").style.backgroundColor=color;
return false;
}
 if(details_project=='' || details_project==null)
{
document.getElementById("details_project_val").style.display='block';
document.getElementById("details_project").focus();
document.getElementById("details_project").style.backgroundColor=color;
return false;
}document.getElementById("details_project_val").style.display='none';
 
 
 
if(captcha=='' || captcha==null)
{
document.getElementById("captcha_val").style.display='block';
document.getElementById("captcha").focus();
document.getElementById("captcha").style.backgroundColor=color;
return false;
}
if(document.getElementById("cpatchacheck").innerHTML!="<font>Correct.</font>")
{
	document.getElementById("captcha_val").style.display='none';
return false;
}
}

//------------------------other degree------------------------
function check_degree()
{
if(document.getElementById('degree').value=='Other')
{
document.getElementById('other_degree').style.display='block';
}
else
{
document.getElementById('other_degree').style.display='none';
}
}

//=======================================captcha check=================================

function check_captcha(){
	
	if(document.getElementById('captcha').value.length==4)
	{
	var ajaxRequest;  // The variable that makes Ajax possible!
		try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	}
	 catch (e)
	 {
		// Internet Explorer Browsers
		try
		{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}
		 catch (e)
		  {
			try
			{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e)
			{
				// Something went wrong
		
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server

	ajaxRequest.onreadystatechange = function()
	{
	
	
		if(ajaxRequest.readyState == 4)
		{
		
			var ajaxDisplay = document.getElementById('cpatchacheck');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
		else if(ajaxRequest.readyState == 1)
		{
		
		
		document.getElementById('cpatchacheck').innerHTML = "<p>Loading... </p>";
		}
	}

//-------------------------variable goes here-------------------------------------//
	
	
	var captcha=document.getElementById('captcha').value;
	

	//-----------------------------------------------------------------//
		
	var queryString = "?captcha=" + captcha;
		//document.write(queryString);
	ajaxRequest.open("GET", "captchacheck.php" + queryString, true);
	         ajaxRequest.send(null); 
			 }

}




