function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				req = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
function trim(s) {
    return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
}

function checkEmail(emailuserval){

		var strURL="includes/ajaxlogic.php?task=findUserEmail&checkval="+emailuserval;
		var req = getXMLHTTP();
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('emailpos').innerHTML=req.responseText;
						
						
						if(trim(req.responseText) == "<span style='color:#FF0000;'>Already exists</span>"){
							document.getElementById('email_contact').value='';
							document.getElementById('email_contact').focus();
							document.getElementById('email_query').value='';
							
											
							
												
							var user=confirm("This email is already in use, do you want to login with same account?");
							if (user==true)
							  {
							  window.location="index.php?p=reporter_login";
							  }
							
							 
							
						}
						
						
						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
}
