//ajax call invoking
	function ajaxRequest(url, handler)
	{
		xmlHttp = GetXmlHttpObject(handler);
		xmlHttp.open("GET", url , true);
		xmlHttp.send(null);
	}
//ajax call initialisation
	function GetXmlHttpObject(handler)
	{
		var objXmlHttp = null;
		try {
			objXmlHttp = new XMLHttpRequest();
			objXmlHttp.onreadystatechange = handler;
			return objXmlHttp;
		} catch(e) {
			try {
				objXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
				objXmlHttp.onreadystatechange = handler; 
				return objXmlHttp;
			} catch (e) { 
				try {
					objXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
					objXmlHttp.onreadystatechange = handler; 
					return objXmlHttp;
				} catch (e) {
					return false;
				}
			}
		}
		return false;
	}

// ajax call end


// signin ajax start
	function ajaxSignIn()
	{
		if(signInValidation())
		{
			var pass = hex_md5(document.forms.signInForm.password.value);
			url = "Ajax.php?login=1&email=" + document.forms.signInForm.emailId.value + "&password=" + pass;
			ajaxRequest(url, handelSignIn);
		}
	}
	function handelSignIn()
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState =="complete")
		{
			res = xmlHttp.responseText;
			if(res==0 || res == "")
			{	
				if(document.getElementById('errid'))		
					document.getElementById('errid').style.display ="block"
			}
			else
			{
				//location.reload(true);
				window.location.href="update.php";
			}
		}
	}
// signin ajax ends
function resetPass(id){
	var asyt = hex_md5(id);
	url = "Ajax.php?cpea="+asyt+"&aid="+id;
	ajaxRequest(url, handelSignIn);
}

function handelSignIn()
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState =="complete")
		{
			res = xmlHttp.responseText;
			if(res==1)
			{	
				//location.reload(true);
				window.location.href="update.php";
			}
			else
			{
				if(document.getElementById('errid'))		
					document.getElementById('errid').style.display ="block"
			}
		}
	}
	
function ajaxNotificationEmailAdd() {
	var itemValue='';
    if (document.getElementById("sucessId")) {
        document.getElementById("sucessId").style.display = "none"
    }
    if (document.getElementById("errorId")) {
        document.getElementById("errorId").style.display = "none"
    }
    if (emailValidation()) {
		myForm = document.forms.notifyMailForm;
		for (var i=0; i<myForm.metype.length; i++)
		{
		   if (myForm.metype[i].checked)
		   {
			  itemValue = myForm.metype[i].value;
			  optionSelected = i;
		   }
		}
        url = "Ajax.php?notification=1&notifyMail=" + myForm.mailId.value+'&fname='+myForm.fname.value+'&lname='+myForm.lname.value+'&job='+myForm.job.value+'&addr='+myForm.addr.value+'&addr2='+myForm.addr2.value+'&city='+myForm.city.value+'&state='+myForm.state.value+'&country='+myForm.country.value+'&post='+myForm.post.value+'&heard='+myForm.heard.value+'&comments='+myForm.comments.value+'&phone='+myForm.phone.value+'&company='+myForm.company.value+'&type='+itemValue;
		ajaxRequest(url, handelNotification)

    }
}
function handelNotification() {
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
        res = xmlHttp.responseText;
        if (res == 0 || res == "") {
            if (document.getElementById("sucessId")) {
                document.getElementById("sucessId").style.display = "block"
            }
            document.forms.notifyMailForm.mailId.value = "";
			document.forms.notifyMailForm.fname.value = "";
			document.forms.notifyMailForm.lname.value = "";
			document.forms.notifyMailForm.job.value = "";
			document.forms.notifyMailForm.addr.value = "";
			document.forms.notifyMailForm.addr2.value = "";
			document.forms.notifyMailForm.city.value = "";
			document.forms.notifyMailForm.state.value = "";
			document.forms.notifyMailForm.country.value = "";
			document.forms.notifyMailForm.city.value = "";
			document.forms.notifyMailForm.post.value = "";
			document.forms.notifyMailForm.heard.value = "";
			document.forms.notifyMailForm.comments.value = "";
			document.forms.notifyMailForm.phone.value = "";
			document.forms.notifyMailForm.company.value = "";
        } else {
            if (document.getElementById("errorId")) {
                document.getElementById("errorId").style.display = "block"
            }
        }
    }
};

	
