// .....................Lightbox main coding...................
function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getXMLHTTP(){var xmlhttp=false;	
		try{xmlhttp=new XMLHttpRequest();}
		catch(e){try{xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");}
		catch(e){try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
		catch(e1){xmlhttp=false;}}}
		return xmlhttp;}
function browser_support(){xmlHttp=getXMLHTTP(); if (xmlHttp==null) { alert("Your browser does not support AJAX!"); return; } }

function trimLeftRightSpaces(obj){strToTrim = obj.value;strTrim = strToTrim.replace(/^(\s*)|(\s*)$/g,"");return(strTrim);}
function isEmpty(obj){isValid = false;if(trimLeftRightSpaces(obj)==""){isValid = true;}return isValid;}
function trimLeftSpaces(obj){strToTrim = obj.value;strTrim = strToTrim.replace(/^(\s*)/g,"");return(strTrim);}

//............... forgetpassword coding...................

function showmain(str)
{
	browser_support();
	var windowHeight = document.body.offsetHeight;
	document.getElementById('fade').className='overlay_real';	
	document.getElementById('fade').style.height=windowHeight + 'px';
	var url="forget.php?userverificationid="+str+"&sid="+Math.random();
	//alert(url);
	xmlHttp.onreadystatechange=userforget;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function userforget() { 
	if (xmlHttp.readyState==4){
		if(xmlHttp.responseText==""){
			 document.getElementById("stat").innerHTML ="<center><img src='../images/loading-icon.gif'></center>";	
		}else{
			 document.getElementById("stat").innerHTML = xmlHttp.responseText;	
		}
		var objOverlay = document.getElementById('fade');
		var objLoadingImage = document.getElementById('alignstat');
		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();
		if (objLoadingImage) {
			objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 115 - objLoadingImage.offsetHeight) / 2) + 'px');
		}
		objOverlay.style.height = (arrayPageSize[1] + 'px');
		document.getElementById("stat").style.display='';
	}
}
/*------------------------Textbox Empty Validation----------------------------*/
function txt_emptyfp(txtControl,errControl,msg){ 
	if(document.getElementById(txtControl).value == ""){
		document.getElementById(errControl).innerHTML = msg;
	}else{
		document.getElementById(errControl).innerHTML = "";
	}
}
/*--Email Validation--*/
function email_validationfp(txt,spanid,msg,field,table)
{	var emailval = document.getElementById(txt).value;	

    if(!email_valfp(emailval,field,table)) { 
	 	document.getElementById(spanid).innerHTML=msg;
		}	
	if(email_valfp(emailval,field,table)) { 
	 	document.getElementById(spanid).innerHTML="";  }
	   
}
/*--Email Regular Expression--*/
function email_valfp(emailval,field,table)
{
  	var RegExp = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,3})(\]?)$/
    if(RegExp.test(emailval)) { showloginfp(emailval,field,table); return true; } else { return false; }
}

/*--Email Regular Expression onchange--*/
function fp_emailvalid(txt,spanid,msg,field,table)
{	var emailval = document.getElementById(txt).value;	

    if(!fpemail_val(emailval,field,table,spanid)) { 
	 	document.getElementById(spanid).innerHTML=msg;
		}	
	if(fpemail_val(emailval,field,table,spanid)) { 
	 	document.getElementById(spanid).innerHTML="";  }
	   
}
function fpemail_val(emailval,field,table,spanid)
{
  	var RegExp = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,3})(\]?)$/
    if(RegExp.test(emailval)) { return true; } else { return false; }
}

/*------------------Availability Checking Function---------------*/
function showloginfp(str,field,table){
	browser_support(); var url="availablefp.php";
	url=url+"?vemail="+str+"&field="+field+"&table="+table+"&sid="+Math.random();
	xmlHttp.onreadystatechange=resshow; xmlHttp.open("GET",url,true); xmlHttp.send(null); }

function resshow(){ 
	if(xmlHttp.readyState==4) { var msg=xmlHttp.responseText; msg = msg.split('#',5);
		if(msg[0] == "  *Available  ") { 
			document.getElementById('emailError').style.color="#ff0000";
			document.getElementById('emailError').innerHTML="Invalid EmailId..."; 
			return false;
		} else {
			sentmailfp(msg[1]);
			document.getElementById('contentArea').innerHTML="Password has been successfuly sent to your E-Mail Id";
		}
	}
}

function sentmailfp(str){
	browser_support();  
	var url="forgetMail.php";
	url=url+"?mail="+str+"&eid="+Math.random(); //alert(url);
	xmlHttp.onreadystatechange=emailChanged1fp;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function emailChanged1fp() 
{ 
	if (xmlHttp.readyState==4){
	}
}

/*-------------Edit Property-----------*/

function editoption(url,id,val) {
	browser_support();
	url=url+"?id="+id+"&val="+val;
	url=url+"&sid="+Math.random();//alert(url);
	xmlHttp.onreadystatechange=editproperty;
	xmlHttp.open("GET",url,true); xmlHttp.send(null); }
	
function editproperty(){ 
	if(xmlHttp.readyState==4) { 
	var msg = xmlHttp.responseText;
	//alert(msg);
		document.getElementById('pro_address').value=msg;
		//document.getElementById('verifydiv').innerHTML =msg; 
	}
}



/*------------------View Mail---------------*/

function getmail(url,id,id1,page) {
	browser_support();
	url=url+"?id="+id+"&id1="+id1+"&page="+page;
	url=url+"&sid="+Math.random();//alert(url);
	xmlHttp.onreadystatechange=getemail;
	xmlHttp.open("GET",url,true); xmlHttp.send(null); }
	
function getemail(){ 
	if(xmlHttp.readyState==4) { var msg = xmlHttp.responseText;
		document.getElementById('verifydiv').innerHTML="";
		document.getElementById('verifydiv').innerHTML =msg; 
	}
}