var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 	try {
 		 xmlhttp = new XMLHttpRequest();
 	} catch (e) {
 		 xmlhttp=false;
 	}
}

/*@cc_on @*/
/*@if (@_jscript_version >= 5)
if (!xmlhttp){
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
}
@end @*/

if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
var please_wait = "<div style='width:100%; text-align:center; padding-top:25%;'><img id='loadAni' src='/admin/images/ajax-loader.gif' align='center'></div>"

function open_url(url, targetId) {
  if(!xmlhttp)return false;
    var e=document.getElementById(targetId);
	if(!e)return false;
    if(please_wait)e.innerHTML = please_wait;	
  	//e.style.backgroundColor='#C2CEC2';
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() { response(url, e); }
    try{
      xmlhttp.send(null);
    }catch(l){
    while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
    e.appendChild(document.createTextNode("request failed"));	
  }
}

function response(url, e) {
  if(xmlhttp.readyState != 4)return;
	e.innerHTML = "<div style='width:100%; text-align:center; padding-top:26%; font-weight:bold;'>Loading Complete</div>";
	var tmp= (xmlhttp.status == 200 || xmlhttp.status == 0) ? xmlhttp.responseText :  "<div style='width:100%; text-align:center; padding-top:26%; font-weight:bold;'>Content Not Available</div>";
    var d=document.createElement("div");
    d.innerHTML=tmp;
    setTimeout(function(){
      while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way	  
 	  //e.style.background='none';
      e.appendChild(d);
    },0500)
}
