// JavaScript Document
/*********************************************************************************************************/
/*
   someObject = function()
   {
      this.OnSuccess = function()
      {
         document.getElementById('TextDiv').innerHTML = this.GetResponseXML();		 
      }

      this.GetData = function()
      {
         this.InitializeRequest('POST', 'someAJAX.php');
         this.Commit(null);
      }
   }
  */
  // someObject.prototype = new ajax();

  // myObject = new someObject();
/*********************************************************************************************************/  
function stateChanged() 
{ 
if(xmlHttp.readyState < 4) {		
	/*	document.getElementById('loading').style.top = (Page.top + Page.height/2)-100;
		document.getElementById('loading').style.left = Page.width/2-75;
		document.getElementById('loading').style.position = "absolute";
		document.getElementById('loading').innerHTML = "<table border=0 cellpadding=0 cellspacing=1 width=160 bgcolor=gray><tr><td align=center class=loading height=45 bgcolor=#ffffff><img src='snake_transparent.gif'/></td></tr></table>";  */
}
if (xmlHttp.readyState==4)
{ 
//	document.getElementById("testAjax").innerHTML=xmlHttp.responseText;
//	alert(xmlHttp.responseText);
	if(flag==1)
		document.getElementById("ChainCombo").innerHTML=xmlHttp.responseText;
	else
		document.getElementById("spnVille").innerHTML=xmlHttp.responseText;
	flag = 0;
	/*
		if(xmlHttp.status == 200)
		{
			document.getElementById('loading').innerHTML = "<table border=0 cellpadding=0 cellspacing=1 width=160 bgcolor=gray><tr><td align=center class=loaded height=45 bgcolor=#ffffff><img src='snake_transparent.gif'/></td></tr></table>";
			setTimeout('Page.loadOut()',2000);
			return true;
		}
		else
		{
			document.getElementById('loading').innerHTML = "HTTP " + xmlHttp.status;
		}
	*/
}
}


var Page = new Object();
Page.width;
Page.height;
Page.top;

Page.loadOut = function ()
{
	document.getElementById('loading').innerHTML ='';	
}

Page.getPageCenterX = function ()
{
		var fWidth;
		var fHeight;		
		//For old IE browsers 
		if(document.all) 
		{ 
		fWidth = document.body.clientWidth; 
		fHeight = document.body.clientHeight; 
		} 
		//For DOM1 browsers 
		else if(document.getElementById &&!document.all)
		{ 
		fWidth = innerWidth; 
		fHeight = innerHeight; 
		} 
		else if(document.getElementById) 
		{ 
		fWidth = innerWidth; 
		fHeight = innerHeight; 		
		} 
		//For Opera 
		else if (is.op) 
		{ 
		fWidth = innerWidth; 
		fHeight = innerHeight; 		
		} 
		//For old Netscape 
		else if (document.layers) 
		{ 
		fWidth = window.innerWidth; 
		fHeight = window.innerHeight; 		
		}
	Page.width = fWidth;
	Page.height = fHeight;
	Page.top = window.document.body.scrollTop;
}

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 showHint(str)
{
if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="process2.php";
url=url+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;

//Page.getPageCenterX();

xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

/*********************************************************************************************************/		
		
		function WriteValues_ville(responseText)
		{		
				
			var formatText ='';
			formatText += '<label for="fldcityid">Ville :</label>';			
			formatText +=  responseText;
			return formatText;
		}
		
var flag;
function ajaxQueryCall(selValue,cmbNumber,DefaultIndex)
{
//	Combo.SetCombo(subCombo);
	requestQuery = "?method=getText&selValue="+selValue+"&cmbNumber="+cmbNumber+"&DefaultIndex";
	showHint(requestQuery);	
	flag = cmbNumber;
	//Ajax.Request(requestQuery, Ajax.Response);
}
/*********************************************************************************************************/
function ajaxQueryCall_aid(selValue,fldarchipelagoid2,cmbNumber,DefaultIndex)
{
//	Combo.SetCombo(subCombo);
	requestQuery = "?method=getText&selValue="+selValue+"&cmbNumber="+cmbNumber+"&DefaultIndex&fldarchipelagoid2="+fldarchipelagoid2;
	//alert(fldarchipelagoid2);
	showHint(requestQuery);
	flag = cmbNumber;
	//Ajax.Request(requestQuery, Ajax.Response);
}
/*********************************************************************************************************/

