/*jQuery(function() {
	// show a simple loading indicator
	var loader = jQuery('<div id="loader"><img src="images/loading.gif" alt="loading..." /></div>')
		.css({position: "relative", top: "793px", left: "-50px"})
		.appendTo("body")
		.hide();
	jQuery().ajaxStart(function() {
		loader.show();
	}).ajaxStop(function() {
		loader.hide();
	}).ajaxError(function(a, b, e) {
		throw e;
	});
	var v = jQuery("#frm_contact").validate({
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				target: "#news_response"
			});
		}
	});
});*/




function dispfld(){
	if(document.frm_contact.cnt_name.value == "")
	{
		document.frm_contact.cnt_name.value = "Name";
		return false;
	}
	if(document.frm_contact.cnt_email.value == "")
	{
		document.frm_contact.cnt_email.value = "Email";
		return false;
	}
	
	if(document.frm_contact.cnt_phone.value == "")
	{
		document.frm_contact.cnt_phone.value = "Primary Phone Number";
		return false;
	}
	
	if(document.frm_contact.cnt_case.value == "")
	{
		document.frm_contact.cnt_case.value = "Please describe your case.";
		return false;
	}
	

}

//Name
function remove_cname()
{

	if(document.frm_contact.cnt_name.value == "Name")
	{
		document.frm_contact.cnt_name.value = "";
		return false;
	}
}

function display_cname()
{
	if(document.frm_contact.cnt_name.value == "")
	{
		document.frm_contact.cnt_name.value = "Name";
		return false;
	}
}
//Email
function remove_cemail()
{

	if(document.frm_contact.cnt_email.value == "Email")
	{
		document.frm_contact.cnt_email.value = "";
		return false;
	}
}
function display_cemail()
{
	if(document.frm_contact.cnt_email.value == "")
	{
		document.frm_contact.cnt_email.value = "Email";
		return false;
	}
}
//Primary Phone
function remove_cphone()
{

	if(document.frm_contact.cnt_phone.value == "Primary Phone Number")
	{
		document.frm_contact.cnt_phone.value = "";
		return false;
	}
}
function display_cphone()
{
	if(document.frm_contact.cnt_phone.value == "")
	{
		document.frm_contact.cnt_phone.value = "Primary Phone Number";
		return false;
	}
}
//Describe Case
function remove_case()
{

	if(document.frm_contact.cnt_case.value == "Please describe your case.")
	{
		document.frm_contact.cnt_case.value = "";
		return false;
	}
}
function display_case()
{
	if(document.frm_contact.cnt_case.value == "")
	{
		document.frm_contact.cnt_case.value = "Please describe your case.";
		return false;
	}
}

function validateEmail_raf(addr,man,db) {
	if (addr == '' && man) {
	   if (db)  {
	   	document.getElementById('chineseemail').value ='Enter Valid Email Address';
		document.getElementById('chineseemail').style.color ='#FF0000';
	   }
	   return false;
	}
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  if (db) {
		document.getElementById('chineseemail').value ='Enter Valid Email Address';
		document.getElementById('chineseemail').style.color ='#FF0000';

			 // alert('Email address contains invalid characters');
			 }
		  return false;
	   }
	}
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  if (db) {
			document.getElementById('chineseemail').value ='Enter Valid Email Address';
			document.getElementById('chineseemail').style.color ='#FF0000';
  
		  }
		  return false;
	   }
	}
	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   if (db) {
		    document.getElementById('chineseemail').value ='Enter Valid Email Address';
			document.getElementById('chineseemail').style.color ='#FF0000';
		   }
	   return false;
	}
	if (atPos == 0) {
	   if (db) {
		    document.getElementById('chineseemail').value ='Enter Valid Email Address';
			document.getElementById('chineseemail').style.color ='#FF0000';
		   }
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   if (db) {document.getElementById('chineseemail').value ='Enter Valid Email Address';
			document.getElementById('chineseemail').style.color ='#FF0000';
			} 
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   if (db) {document.getElementById('chineseemail').value ='Enter Valid Email Address';
			document.getElementById('chineseemail').style.color ='#FF0000';} 
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   if (db) {document.getElementById('chineseemail').value ='Enter Valid Email Address';
			document.getElementById('chineseemail').style.color ='#FF0000';} 
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   if (db) { document.getElementById('chineseemail').value ='Enter Valid Email Address';
			document.getElementById('chineseemail').style.color ='#FF0000';}
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	   if (db){document.getElementById('chineseemail').value ='Enter Valid Email Address';
			document.getElementById('chineseemail').style.color ='#FF0000';} 
	   return false;
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   if (db) {document.getElementById('chineseemail').value ='Enter Valid Email Address';
			document.getElementById('chineseemail').style.color ='#FF0000';}
	   return false;
	}
return true;
}


	function GetXmlHttpObject1()
	{
		var xmlHttp=null;
		try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
		catch (e){
		// Internet Explorer
		try{
		var aVersions = [ "MSXML2.XMLHttp.5.0",
			"MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0",
			"MSXML2.XMLHttp","Msxm12.XMLHTTP","Microsoft.XMLHttp"];
			for (var i = 0; i < aVersions.length; i++) 
			{
			try
			{
			var xmlHttp = new ActiveXObject(aVersions[i]);
			return xmlHttp;
			} 
			catch (oError) 
			{
			//Do nothing
			}
		}
		}
		catch (e)
		{
		}
		}
		if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
		} 
		return xmlHttp;
	}

	
	function stateViewChanged1(){ 
		if (xmlViewHttp.readyState==1){ 
			document.getElementById("loader").style.display = "block";
		}

		if (xmlViewHttp.readyState==4){ 
			document.getElementById("loader").style.display="none";
			//alert(xmlViewHttp.responseText);
			
		
			document.getElementById('news_response').innerHTML=xmlViewHttp.responseText;	
			document.frm_contact.cnt_email.value = "Email"  ;
			document.frm_contact.cnt_phone.value = "Primary Phone Number"  ;
			document.frm_contact.cnt_case.value = "Please describe your case."  ;
			document.frm_contact.cnt_name.value = "Name"  ;
			
			
			
		}
	}
	

	function ajaxresultstmp1 () {
	
			cnt_email = document.frm_contact.cnt_email.value;
			cnt_phone = document.frm_contact.cnt_phone.value;
			cnt_case = document.frm_contact.cnt_case.value;
			cnt_name = document.frm_contact.cnt_name.value;
			
	
			if(document.frm_contact.cnt_email.value != "" || document.frm_contact.cnt_email.value != "Email")
			{
				document.getElementById('chineseemail').innerHTML='';
			}
			
			if(document.frm_contact.cnt_phone.value != "Primary Phone Number" || document.frm_contact.cnt_phone.value != "")
			{
				document.getElementById('cnt_phone_err').innerHTML='';
			}
			
			if(document.frm_contact.cnt_case.value != "Please describe your case." || document.frm_contact.cnt_case.value != "")
			{
				document.getElementById('cnt_case_err').innerHTML='';
			}
	
			if(document.frm_contact.cnt_name.value != "" || document.frm_contact.cnt_name.value != "Name")
			{
				document.getElementById('cnt_name_err').innerHTML='';
			}
	
	
	
	
		if(document.frm_contact.cnt_name.value == "" || document.frm_contact.cnt_name.value == "Name")
		{
			document.getElementById('cnt_name_err').innerHTML='Please Enter Name';
			return false;
		} 
		if(document.frm_contact.cnt_email.value == "" || document.frm_contact.cnt_email.value == "Email")
		{
			document.getElementById('chineseemail').innerHTML='Please Enter valid Email Address';
			return false;
		} 
		
		if(!validateEmail_raf(document.frm_contact.cnt_email.value,1,1)) 
		{
			return false;
		}
		
		if(document.frm_contact.cnt_phone.value == "Primary Phone Number" || document.frm_contact.cnt_phone.value == "")
		{
			document.getElementById('cnt_phone_err').innerHTML='Please Enter Phone Number ';
			return false;
		}
		if(document.frm_contact.cnt_case.value == "Please describe your case." || document.frm_contact.cnt_case.value == "")
		{
			document.getElementById('cnt_case_err').innerHTML='Please Enter Description ';
			return false;
		}
		
		else {
		
			xmlViewHttp=GetXmlHttpObject1();
			xmlViewHttp.onreadystatechange = stateViewChanged1;
			xmlViewHttp.open("GET","contact.php?cnt_name="+cnt_name+"&cnt_email="+cnt_email+"&cnt_phone="+cnt_phone+"&cnt_case="+cnt_case,true);
			xmlViewHttp.send(null);
		}
		
	}


