//Ajax function
function XHConn()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();
    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}

function checkUser(frmSec)
{
	
	var myConn = new XHConn();
	var email;
	email = document.getElementById('txtEmail').value;
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ 
//alert(oXML.responseText);	
	if(oXML.responseText == 0 ){
		
	//alert("Email Already Exists, Please Choose a different Email");
	document.getElementById('txtEmail').style.background='red';
	document.getElementById('txtEmail').style.color='white';
	document.getElementById('err').innerHTML = '<font color="red" size="1">We can not find that email. Please try again.!</font>';
//	document.getElementById('err').className = 'reveal';
	//document.frmSec.txtEmail.focus();
	document.getElementById('next').disabled = true;
    document.frmSec.txtEmail.focus();
	//return false;
	}
	else
	{
	document.getElementById('txtEmail').style.background='white';
	document.getElementById('txtEmail').style.color='black';
	document.getElementById('err').innerHTML = '';
	document.getElementById('next').disabled = false;
	//return true;
	}
	};
	myConn.connect("CHKUSR.html", "GET", "email="+email, include_terminado);
}

function getUser(form3)
{
	
	var myConn = new XHConn();
	var email;
	email = document.getElementById('email').value;
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ 
//alert(oXML.responseText);	
	if(oXML.responseText >= 1 ){
		
	//alert("Email Already Exists, Please Choose a different Email");
	document.getElementById('email').style.background='red';
	document.getElementById('email').style.color='white';
	document.getElementById('err').innerHTML = '<font color="red" size="1">This email already exists!</font>';
//	document.getElementById('err').className = 'reveal';
	document.form3.email.focus();
	document.getElementById('submit').disabled = true;
    //document.getElementById('imgsubmit').enabled=false;
	document.form3.email.focus();
	}
	else
	{
	document.getElementById('email').style.background='white';
	document.getElementById('email').style.color='black';
	document.getElementById('err').innerHTML = '';
	document.getElementById('submit').disabled = false;
	}
	};
	myConn.connect("CHKUSR.html", "GET", "user="+email, include_terminado);
}

function checkEmailNew()
{
	var email;
	email = document.getElementById('emailNew').value;
	//alert(email);
	
	var myConn = new XHConn();
	
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ 
	if(oXML.responseText == '1'){
	document.getElementById('emailNew').style.background='red';
	document.getElementById('emailNew').style.color='white';
	document.getElementById('err').innerHTML = '<font color=red>Email all ready exist in database</font>';
	document.getElementById('err').className = 'reveal';
	document.getElementById('imgsubmit').disabled = true;
	}
	else
	{
	document.getElementById('emailNew').style.background='white';
	document.getElementById('emailNew').style.color='black';
	document.getElementById('err').innerHTML = '';
	document.getElementById('err').className = 'hidden';
	document.getElementById('imgsubmit').disabled = false;
	}
	};
	myConn.connect("checkemail.html", "GET", "email="+email, include_terminado);
}

function chkEmail(email){
if ((email.value==null)||(email.value=="")){
		alert("Please Enter your Email ID")
		email.focus()
		return false
}
if (echeck(email.value)==false){
email.value=""
email.focus()
return false
}
}
function chkPassword(pass){
if ((pass.value==null)||(pass.value=="")){
		alert("Please Enter your Password")
		pass.focus()
		return false
}
}

//email validation script
function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
 		 return true					
}
function deleteMultipl()
{
	
	if(confirm("Do you Really want to Delete?")==true)
	{
		//CheckIsSelected();
		
		document.location.href="property.html";
		return true;
	}
   else
   return false;
	
}
function deleteeventMultipl()
{
	
	if(confirm("Do you Really want to Delete?")==true)
	{
		//CheckIsSelected();
		
		document.location.href="event.html";
		return true;
	}
   else
   return false;
	
}
/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;
/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   integer  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function xmlhttpPost(strURL,callerFunction) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('get', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            switch(callerFunction)
			{
				case 1 : upd_cal(self.xmlHttpReq.responseText); break;
		
			}	
        }
    }
    self.xmlHttpReq.send(null);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
