
var xmlHttp;
var finalElem;
var finalElem2;
//this.currentLink

if (document.images) {
   img1 = new Image();
   img1.src = "nav/load.gif";
}

function showFakeLoading() {
	var size_array = alertSize();
	var loadiconbgleft = ((size_array[0]/2)-100);	
	if ( (document.getElementById("load_icon_div"))   ) 
	document.getElementById("load_icon_div").innerHTML = "<div class='show' style='opacity:0.6; filter:alpha(opacity=60); position: fixed; top: 0; left: 0; z-index: 300; width: 100%; height: 100%;' id='load_icon'><div style='top: 40%; left: "+loadiconbgleft+"px;' class='load_icon_bg'><img src='nav/load.gif' style='position: absolute; top: 40%; left: 40%;'/></div></div>";
	var t = setTimeout("rem_el('load_icon')",500);
}

function followLink(url,final) {
	finalElem=final;
	xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null) {
      alert ("Your browser does not support AJAX!");
      return;
    } 

	url=url+"&xx="+Math.random();
	//alert(url+"   "+final);
    xmlHttp.onreadystatechange=stateChanged;
	//xmlHttp.setRequestHeader("Content-type", "application/xml");
	//xmlHttp.setRequestHeader("Cache-control", "no-cache");	
    xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	if (isItem == true) {
		//alert('attaching focus to follwlink');
		setTimeout('attachFocus()',1000);
	}

}

function followLink_no_load_div(url,final) {
	finalElem=final;
	xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null) {
      alert ("Your browser does not support AJAX!");
      return;
    }
	url=url+"&xx="+Math.random();
    xmlHttp.onreadystatechange=stateChanged_no_load_div;
    xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function multliLink(url,final,url2,final2) {
	finalElem=final;
	//finalElem2=final2;
	xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null) {
      alert ("Your browser does not support AJAX!");
      return;
    } 
	url=url+"&xx="+Math.random();
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function get(obj,url,final) {
      var poststr = "searchname=" + encodeURI( document.getElementById("searchname").value ) +
                    "&mytextarea2=" + encodeURI( document.getElementById("mytextarea2").value );
      postaction(url,final,poststr);
}
function postaction(url,final,parameters) {
	finalElem=final;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
      return;
    }
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open('POST', url, true);
      xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlHttp.setRequestHeader("Content-length", parameters.length);
      xmlHttp.setRequestHeader("Connection", "close");
      xmlHttp.send(parameters);
}
///////////////////////////////////////////////////////////////////////////////



var block_load_icon_bg = "show";

function stateChanged(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		if (xmlHttp.status == 200){
				//alert(finalElem+xmlHttp.responseText);
			document.getElementById(finalElem).innerHTML=xmlHttp.responseText;
			if (document.getElementById("loading")) 
				document.getElementById("loading").innerHTML = '';
			if (document.getElementById("sml_loading")) 
				document.getElementById("sml_loading").innerHTML = '';	
			if (document.getElementById("load")) 
				document.getElementById("load").innerHTML = '';
			if (document.getElementById("load_icon_div")) 
				document.getElementById("load_icon_div").innerHTML = '';
		} else if (xmlHttp.status == 404)
			alert("Request URL does not exist");
		else {
			//alert("Error: status code is " + xmlHttp.status);
		}
	}
	else {
		var size_array = alertSize();
		var loadiconbgleft = ((size_array[0]/2)-100);
		
		if (document.getElementById("loading")) 
			document.getElementById("loading").innerHTML = '<img src="js/indicator.gif" align="right" />';
		if (document.getElementById("sml_loading")) 		
			document.getElementById("sml_loading").innerHTML = '<img src="nav/ajax-loader.gif" />';	
		if (document.getElementById("load")) 		
			document.getElementById("load").innerHTML = '<img src="nav/load.gif" />';
		if ( (document.getElementById("load_icon_div"))   ) 
			document.getElementById("load_icon_div").innerHTML = 
				"<div class='show' style='opacity:0.6; filter:alpha(opacity=60); position: fixed; top: 0; left: 0; z-index: 300; width: 100%; height: 100%;' id='load_icon'><div style='top: 40%; left: "+loadiconbgleft+"px;' class='load_icon_bg'><img src='nav/load.gif' style='position: absolute; top: 40%; left: 40%;'/></div></div>";
//"+size_array[0]+"    //"+size_array[1]+"px
	}
}

function stateChanged_no_load_div(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		if (xmlHttp.status == 200){
			document.getElementById(finalElem).innerHTML=xmlHttp.responseText;
			if (document.getElementById("loading")) 
				document.getElementById("loading").innerHTML = '';
			if (document.getElementById("sml_loading")) 
				document.getElementById("sml_loading").innerHTML = '';	
			if (document.getElementById("load")) 
				document.getElementById("load").innerHTML = '';
		} else if (xmlHttp.status == 404)
			alert("Request URL does not exist");
		else {
			//alert("Error: status code is " + xmlHttp.status);
		}
	}
	else {
		if (document.getElementById("loading")) 
			document.getElementById("loading").innerHTML = '<img src="js/indicator.gif" align="right" />';
		if (document.getElementById("sml_loading")) 		
			document.getElementById("sml_loading").innerHTML = '<img src="nav/ajax-loader.gif" />';	
		if (document.getElementById("load")) 		
			document.getElementById("load").innerHTML = '<img src="nav/load.gif" />';
	}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  //xmlHttp.overrideMimeType('text/xml');
  //xmlHttp.overrideMimeType('application/xhtml+xml');

  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}



/*******XML******************************/

function GetXmlHttpObject_xml()
 { 
 var objXMLHttp=null
 if (window.XMLHttpRequest)
  {
  objXMLHttp=new XMLHttpRequest()
  }
 else if (window.ActiveXObject)
  {
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
 return objXMLHttp
 }	

function refreshtags(str,target) { 
	xmlHttp=GetXmlHttpObject_xml()
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url= str;
	url=url+"&sid="+Math.random();
	alert(url);
	xmlHttp.onreadystatechange=stateChangedxml;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
	
function stateChangedxml() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		xmlDoc=xmlHttp.responseXML;
		alert('asdfdsaf');
		document.getElementById("newtagname").innerHTML="tersting";
		document.getElementById("newtagid").innerHTML = xmlDoc.getElementsByTagName("newtagid")[0].childNodes[0].nodeValue+"999x";
//		document.getElementById("newtagname").innerHTML=xmlDoc.getElementsByTagName("newtagname")[0].childNodes[0].nodeValue;
		document.getElementById("newtagname").innerHTML="tersting";
	}
} 

/******* end XML**************************/
