
	var httpObj = false;
	
		try {
			  httpObj = new XMLHttpRequest();
		} catch (trymicrosoft) {
		  try {
				httpObj = new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (othermicrosoft) {
			try {
			  httpObj = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
			  httpObj = false;
			}
	  }
	}

	function SendExistRequest(Url,FieldName,Title){
		var SendUrl = Url+"&r="+Math.random(); 
		httpObj.open("GET", SendUrl, true);
		httpObj.onreadystatechange = function RecieveExistRequest(){
			if (httpObj.readyState == 4) {
				if(httpObj.responseText==1) {
					if(Title == 'Email'){
						alert("This "+Title+" Address is already registered with us. Please enter another "+Title+" Address !!");
					}else{
						alert(Title + " already exists in database. Please enter another !!");
					}
					document.getElementById(FieldName).select();
					return false;
				} else if(httpObj.responseText==0) {	 
					document.forms[0].submit();
				}else {
					alert("Error occur : " + httpObj.responseText);
					return false;
				}
			}
		};
		httpObj.send(null);
	}
	
	function SendMenuPositionExistRequest(Url,FieldName,Title){
		var SendUrl = Url+"&r="+Math.random(); 
		
		httpObj.open("GET", SendUrl, true);
		httpObj.onreadystatechange = function PositionExistRequest(){
			if (httpObj.readyState == 4) {
				if(httpObj.responseText==1) {	 
					alert(Title + " already exists in database. Please enter another !!");
					document.getElementById(FieldName).select();
					return false;
				} else if(httpObj.responseText==0) {	 
					var Url = "isRecordExists.php?PageHeading="+document.getElementById("title").value+"&editID="+ document.getElementById("editID").value;
					SendExistRequest(Url,"title","Page Title");
					return false;	
				}else {
					alert("Error occur : " + httpObj.responseText);
					return false;
				}
			}
		};
		httpObj.send(null);
	}

	function LoginSend(Url){
		var SendUrl = Url+"&r="+Math.random(); 
		document.getElementById("ReturnValue").value = '';
		httpObj.open("GET", SendUrl, true);
		httpObj.onreadystatechange = function LoginRecieve(){
			if (httpObj.readyState == 4) {
				//alert(httpObj.responseText);
				document.getElementById("ReturnValue").value = httpObj.responseText;
				//return false;
				/*
				if(document.getElementById("redUrl").value != ''){
					location.href = document.getElementById("redUrl").value;
					return false;
				}
				*/
				
				 if(httpObj.responseText==10) {	 
					//alert("Someone is already logged in with this Email Address, Please try again later !!");
					alert("You cannot login because your session is locked. Please try again later.\nTo avoid getting this message, make sure to properly logout when you are done. And do not share your login id and password with anyone. For more details see FAQs.");
					document.getElementById("Email").value='';
					document.getElementById("Password").value='';
					return false;
				 } else if(httpObj.responseText==1) {	 
					//location.href = 'index.php';
					document.forms[0].submit();
					return false;
				}  else if(httpObj.responseText==5) {	 
					//alert("Your account has been de-activated as you didn't upgraded your membership. Please contact the administrator !!");
					//location.href = 'accountSucc.php';
					document.forms[0].submit();
					return false;
				}else if(httpObj.responseText==6) {	 
					//alert("Your account is expired, Please upgrade your membership !!");
					//location.href = 'accountSucc.php';
					document.forms[0].submit();
					return false;
				}else if(httpObj.responseText==7) {	 
					//alert("Your account is about to expire, Please upgrade your membership within few days !!");
					//location.href = 'accountSucc.php';
					document.forms[0].submit();
					return false;
				}else if(httpObj.responseText==0) {	 
					alert("Invalid Email/Password!!");
					document.getElementById("Password").focus();
					return false;
				}else {
					alert("Error occur : " + httpObj.responseText);
					return false;
				}
			}
		};
		httpObj.send(null);
	}
	
	function LogoutSend(){
		 if (document.getElementById("xMousePosition").value > 950 && document.getElementById("yMousePosition").value < 10){
			//alert("Thank you for visiting LazyMaths !!");
			var SendUrl = 'logout.php?r='+Math.random(); 
			httpObj.open("GET",SendUrl, true);
			httpObj.onreadystatechange = function LogoutRecieve(){
				if (httpObj.readyState == 4) {
					//alert("You are logged out successfully !!");
				}
			};
			httpObj.send(null);
		 }
	}
	
	function ForgotPasswordQuestion(frm){
			if( ValidateForEmail(frm.forgotEmail, "Email")
				&& isEmail(frm.forgotEmail)
			){
				var SendUrl = 'forgot.php?action=1&forgotEmail='+document.getElementById("forgotEmail").value+"&r="+Math.random(); 
				httpObj.open("GET", SendUrl, true);
				httpObj.onreadystatechange = function ForgotQuestionRecieve(){
					if (httpObj.readyState == 4) {
						if(httpObj.responseText==0) {	 
							alert("This Email Address is not registered with us !!");
						}else if(httpObj.responseText==1){
							document.getElementById("MainDiv").innerHTML = '<Div class="greentxt">Your new password has been sent successfully !!</Div>';
						}else {
						alert("Error occur : " + httpObj.responseText);
					        }
						return false;
					}
				};
				httpObj.send(null);
				return false;
			}else{
				return false;
			}
		}


	

	function ForgotPasswordSend(frm){
		if( ValidateForBlank(frm.Answer, "Answer to the Security Question")
		){
			var SendUrl = 'forgot.php?action=2&Answer='+document.getElementById("Answer").value+'&forgotEmail='+document.getElementById("forgotEmail").value+'&r='+Math.random(); 
			httpObj.open("GET", SendUrl, true);
			httpObj.onreadystatechange = function ForgotPasswordRecieve(){
				if (httpObj.readyState == 4) {
					if(httpObj.responseText==1) {	 
						document.getElementById("QuestionDiv").innerHTML = '<Div class="greentxt">Your new password has been sent successfully !!</Div>';
					} else if(httpObj.responseText==0) {	 
						alert("Wrong Answer, Please Enter the Correct Answer !!");
					}else {
						alert("Error occur : " + httpObj.responseText);
					}
					return false;
				}
			};
			httpObj.send(null);
			return false;
		}else{
			return false;
		}
	}


	

	function UnsubscribeSend(frm){
		if( ValidateForEmail(frm.UnsubscribeEmail, "Email")
			&& isEmail(frm.UnsubscribeEmail)
		){
			var S_Type = frm.S_Type.value;

			if(S_Type != '') {
				SubscriptionMsg = 'Your have been subscribed for newsletters successfully !!';
			}else{
				SubscriptionMsg = 'Your have been unsubscribed successfully !!';
			}

			var SendUrl = 'ajax_member.php?UnsubscribeEmail='+frm.UnsubscribeEmail.value+"&S_Type="+S_Type+"&r="+Math.random(); 
			httpObj.open("GET", SendUrl, true);
			httpObj.onreadystatechange = function UnsubscribeRecieve(){
				if (httpObj.readyState == 4) {
					if(httpObj.responseText==1) {	 
						document.getElementById("MainDiv").innerHTML = '<Div class="greentxt">'+SubscriptionMsg+'</Div>';
					} else if(httpObj.responseText==0) {	 
						alert("Invalid Email, Please Enter a registered Email Address !!");
					}else {
						alert("Error occur : " + httpObj.responseText);
					}
					return false;
				}
			};
			httpObj.send(null);
			return false;
		}else{
			return false;
		}
	}


	