function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}



function closeAjaxLayer(obj) {
	if(obj.parentNode.parentNode){
	obj.parentNode.parentNode.className="";
	obj.parentNode.parentNode.innerHTML="";
	}
	if(document.all && (document.getElementById("contact"))){
	//document.getElementById("contact").className="";
	}
	if (document.getElementById("ajaxLayer")){
	document.getElementById("ajaxLayer").className="";
	document.getElementById("ajaxLayer").innerHTML="";
	} 
	return (document.getElementById("ajaxLayer").innerHTML=="")?false:true;
}

function cssIsEnabled() //check that css is enabled - there's no point waisting resources and resizing the images for unstyled pages!
	{
	var testObj = document.getElementById("wrapper"); //reference to test item
	var testDisplay = (typeof document.defaultView != "undefined" && typeof document.defaultView.getComputedStyle != "undefined")?document.defaultView.getComputedStyle(testObj,"").getPropertyValue("display"):(typeof testObj.currentStyle != "undefined")?testObj.currentStyle.display:"inline";
	return (testDisplay != "inline");
	}


var scrl = "auto";
var windowname;
var wdth=750;
var hght=440;
var href;
var hasCSS;
var pos = {x:0, y:0};

function ajaxOrPopup(mylink, popwidth, popheight, scrll, windowname)
{
if (!window.focus)return true;
scrl = (scrll)?scrll:"no";
windowname = (windowname)?windowname:"blank";
wdth=(popwidth>0)?popwidth:750;
hght=(popheight>0)?popheight:440;
href=mylink.href;
hasCSS = cssIsEnabled();
if(hasCSS){//we can use the ajax function to display the tip on this page
	tryAjax(href)
} else {// no CSS, better launch it as a popup
	window.open(href, windowname, 'width='+wdth+',height='+hght+',scrollbars='+scrl+'');
}
return false;
}

/*	0	The request is not initialized
	1	The request has been set up
	2	The request has been sent
	3	The request is in process
	4	The request is complete*/
function tryAjax(tippath)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
  catch (e)
    {
    try {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
    catch (e)
      {
      //alert("Your browser does not support AJAX!");
	  window.open(tippath, windowname, 'width='+wdth+',height='+hght+',scrollbars='+scrl+'');
      return false;
      }
    }
  }
  
  //create holder for ajax content
  var ajaxLayer;
  var content = document.getElementById("content");
  if(document.getElementById("ajaxLayer")){
	  //if holder exists
  		ajaxLayer = document.getElementById("ajaxLayer");
  } else {
	  //create it
  ajaxLayer = document.createElement('div');
  ajaxLayer.id = "ajaxLayer";
  ajaxLayer.style.display="block";
  ajaxLayer.style.position="absolute";
  ajaxLayer.style.zIndex="999999";
  ajaxLayer.style.top="50%";
  ajaxLayer.style.left="50%";
	this.onmouseout=function centeraboutcursor(e){if (pos.x<10) {//just once
													pos = getPosition(e);												  
												  	ajaxLayer.style.top=pos.y+"px";}
												  }
	//alert(pos.y);
	  
  /*ajaxLayer.style.marginTop="-"+(hght/2)+"px";
  ajaxLayer.style.marginLeft="-"+(wdth/2)+"px";*/
  
  content.appendChild(ajaxLayer);
  }
	
  xmlHttp.onreadystatechange=function()
    {
	//var ajaxLayer = document.getElementById("ajaxLayer");
	if(xmlHttp.readyState>0 && xmlHttp.readyState<4){ajaxLayer.innerHTML="<img src='/baseimages/loading.gif'/>";ajaxLayer.className="on";}
    if(xmlHttp.readyState==4){			
			ajaxLayer.innerHTML="<div id=\"response\">"+xmlHttp.responseText+"</div>";
			var responseBlock = document.getElementById("response");
			//center it
			//ajaxLayer.style.marginTop="-"+(responseBlock.clientHeight/2)+"px";
			//ajaxLayer.style.marginLeft="-"+(responseBlock.clientWidth/2)+"px";
			//ajaxLayer.style.top="50%";
			//ajaxLayer.style.left="50%";
			//alert("scrollbars="+scrl);
			responseBlock.style.display="block";
  			responseBlock.style.position="absolute";
			responseBlock.style.borderWidth="8px";
  			responseBlock.style.borderStyle="solid";
  			responseBlock.style.borderColor="#ddd";
			responseBlock.style.backgroundColor="#efefef";
			responseBlock.style.padding="10px";
			responseBlock.style.width=wdth+"px";
			responseBlock.style.height=hght+"px";
			//responseBlock.style.overflow="auto";
			responseBlock.style.overflow=((scrl=="yes")?"auto":(scrl=="no")?"hidden":"inherit");
			responseBlock.style.top="-"+(responseBlock.clientHeight/2)+"px";
			responseBlock.style.left="-"+(responseBlock.clientWidth/2)+"px";
				if(document.all && (document.getElementById("contact"))){//ie
					//document.getElementById("contact").className="IE6hideSelects";
				}
			//ajaxLayer.onmouseover = function(){responseBlock.onmouseout = alert("pants");}
			//responseBlock.onmouseout = alert("pants");
			}
    }
var f=tippath+((tippath.indexOf("?")>0)?"&":"?")+"byAjax=true";
  xmlHttp.open("GET",f,true);
  xmlHttp.send(null);
  return true;
  }