	
setActiveStyleSheet('');
function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}
function getActiveStyleSheet() {
var i, a;
 for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
  if(a.getAttribute("rel").indexOf("style") != -1
  && a.getAttribute("title")
  && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

/* Ultimater's edited version of:
   http://jibbering.com/2002/4/httprequest.html
   to serve IE7 with XMLHttpRequest instead of ActiveX */

var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 	try {
 		 xmlhttp = new XMLHttpRequest();
 	} catch (e) {
 		 xmlhttp=false;
 	}
}

// Don't delete this, back supports IE
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
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;
	}
}

// Display the appraisal popup
function submitAppraisal() {
	show('apprasial_map')
	open_url('appraisal_window.php?apid='+document.download_apprasial.appraisal_id.value+'&popup=map','lyr_apprasial_map')
	hide_popup_remove_gray('appraisals_popup_div','appraisals_gray_div')
}

/* Ultimater's edited version of:
   http://javascript.internet.com/ajax/ajax-navigation.html */

var please_wait = "Please wait...";

function open_url(url, targetId) {
  if(!xmlhttp)return false;
    var e=document.getElementById(targetId);if(!e)return false;
    
    var d = new Date();
	var tm=d.getDate() + d.getHours() + d.getMinutes() + d.getMilliseconds();
	// Check to see if there is a ? in the url, then add a timestamp
	if ( url.search(/\?/)<0 ) { url += '?tm='+tm	 }
	else { url += '&tm='+tm }
    
    if(please_wait)e.innerHTML = please_wait;
    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;
    var tmp= (xmlhttp.status == 200 || xmlhttp.status == 0) ? xmlhttp.responseText : "Ooops!! A broken link! Please contact the webmaster of this website ASAP and give him the following error code: " + xmlhttp.status+" "+xmlhttp.statusText;
    var d=document.createElement("div");
    d.innerHTML=tmp;
    setTimeout(function(){
      while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
      e.appendChild(d);
    },10)
}


//modified ajax function for the appraisals page (to gray out the image and open popup
function gray_div_open_url(url, targetId, sourceId) {
	//alert('here');
	//gray the source div
	document.getElementById(sourceId).style.opacity = "0.5";
	document.getElementById(sourceId).style.filter = "alpha(opacity=50)";
	document.getElementById(targetId).style.display = "block";
	
	if ( arguments[3]  ) url += '&company_limit='+arguments[3]
	
  if(!xmlhttp)return false;
    var e=document.getElementById(targetId);if(!e)return false;
    if(please_wait)e.innerHTML = please_wait;
    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 hide_popup_remove_gray(targetId,sourceId){
	//un gray the source div
	document.getElementById(sourceId).style.opacity = "1";
	document.getElementById(sourceId).style.filter = "alpha(opacity=100)";
	document.getElementById(targetId).style.display = "none";
	document.getElementById(targetId).innerHTML = "";
}

function callRemotePage(url) {

	xmlhttp.open("GET",url, true);
  	xmlhttp.send(null);

}