/**
 * @author adriano
 */

var myurl = document.location.protocol + "//" + document.location.hostname;
var xmlHttp;
var mainDiv;

function goAjax(url, divName, waitMsg,img, style) 
{
	xmlHttp=GetXmlHttpObject();
 	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX! We recommend using Mozilla Firefox.");
		return;
	} 
	
	if (img === undefined) {
		img  = "images/wait.gif";
	}

	if (style === undefined) {
		style = "";
	}
	
	mainDiv = divName;	
	document.getElementById(divName).innerHTML ="<img src='" + img + "' " + style + " /> " + waitMsg; 
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function stateChanged() 
{	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(mainDiv).innerHTML=xmlHttp.responseText;
	}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function checkField(f) 
{
	if (trim(f) == "") throw new Error("Error Occured.");
}

function check_email(email,div)
{
	goAjax("pages/check_email.php?email="+email,div,"Checking e-mail address ...");
}

function client_check_email(email,div)
{
	goAjax("../control/client_check_email.php?email="+email,div,"Checking e-mail address ...","../images/wait.gif");
}

function show_resident(id) 
{	
	goAjax("pages/resi/resi_source.php?sub="+id,"resi_info","");
}

