var xmlHttp 
function CheckEmail()
{
		if(document.getElementById("txtEmail").value=='' || document.getElementById("txtEmail").value=="Enter your email")
		{
			alert("please enter your email");
			return;
		}
		else
		{
			   var val= document.getElementById('txtEmail').value;
			   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
					if(reg.test(val) == false)
					 {
					  alert('Invalid Email Address');
					  return false;
					}
		}
	var email = document.getElementById("txtEmail").value;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) 
	{
		alert("Browser does not support HTTP Request")
		return
	}
	var url="components/com_index/ajax/checkEmail.php";
	url=url+"?val="+email
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedEmail
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedEmail(v) 
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
	{
		var cbo = xmlHttp.responseText;
		var result = cbo.split("####");
		var output1 = result[0].replace(/^\s+|\s+$/g,"");
		var output2 = result[1].replace(/^\s+|\s+$/g,"");
			if(output1 == "yes")
			{
				//document.getElementById("message").innerHTML='Newsletter Subscription successfull !'; 
				document.getElementById('spanForErrorsEmail').innerHTML ='<div class=success style="padding-left:25px;"><span class="content_blue_b_green">Newsletter Subscription successfull !</span></div>';
			}
		if(output1 == "no")
		{
				document.getElementById('spanForErrorsEmail').innerHTML ='<div class="systemerror" style="padding-left:25px;">You are already subscribed</div>';
		}
	}
}
function getState(countryId) 
{
	if(countryId==9999)
	{
		document.getElementById('cboOtherCountry').style.display='inline';
	}
	else
	{
		document.getElementById('cboOtherCountry').style.display='none';
	}
	
	var strURL="components/com_jobseeker/ajax/findState.php?country="+countryId;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp) {
			
			xmlHttp.onreadystatechange = function() {
				if (xmlHttp.readyState == 4) {
					// only if "OK"
					if (xmlHttp.status == 200) {						
						document.getElementById('statediv').innerHTML=xmlHttp.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + xmlHttp.statusText);
					}
				}				
			}			
			xmlHttp.open("GET", strURL, true);
			xmlHttp.send(null);
		}		
}

function GetXmlHttpObject() 
{
	var objXMLHttp=null
	if (window.XMLHttpRequest) 
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject) 
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}
