var xmlhttp = false;

try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}

catch (e){
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}

if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();
}
////////////////////////////////////
function makevisible(cur,which){
strength=(which==0)? 1 : 0.85

if (cur.style.MozOpacity)
cur.style.MozOpacity=strength
else if (cur.filters)
cur.filters.alpha.opacity=strength*100
}

//////////////////////////////////////////////////
function makerequest(serverPage, objID) {
  var obj = document.getElementById(objID);
  //fadeIn();
  xmlhttp.open("get", serverPage);
  var loadstatustext="<img src='../images/indicator.gif'>";
  xmlhttp.onreadystatechange = function() {
    document.getElementById('loading_div').innerHTML=loadstatustext;
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      document.getElementById(objID).innerHTML = xmlhttp.responseText;
      document.getElementById('loading_div').innerHTML="";
      if (window.XMLHttpRequest) {
      	dhtmlHistory.add(serverPage);
      	document.title = ":: دياموند تكس - مؤسسة الطويل للصناعات النسيجية ::" ;
      	}
    }
  }
  xmlhttp.send(null);
}
////////////////////////////////////////////////////////////////////////////
window.onload = initialize;
  function initialize() {
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(handleHistoryChange);
	var initialLocation = dhtmlHistory.getCurrentLocation();
	if (initialLocation == ""){
		initialLocation = 'main.php';
	}
	// now initialize our starting UI
	makerequest(initialLocation, 'main');
  }
  /** A function that is called whenever the user presses the back or forward buttons. This function will be passed the newLocation, as well as any history data we associated with the location. */
function handleHistoryChange(newLocation) {
	// use the history data to update our UI
  makerequest(newLocation, 'main');
}

