//Written by Joss Wickson for Dataline Software Ltd

//setup vars for ajax call

	var bustcachevar=1; //bust potential caching of external pages after initial request? (1=yes, 0=no)
	var loadedobjects="";
	var rootdomain="http://"+window.location.hostname;
	var bustcacheparameter="";

//Setup request for ajax call

function ajaxpage(url, containerid){
	var page_request = false;
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
	page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
	try {
	page_request = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch (e){
	try{
	page_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch (e){}
	}
	}
	else
	return false;
	page_request.onreadystatechange=function(){
	loadpage(page_request, containerid);
	}

//if bustcachevar set kill the caching of the page
	if (bustcachevar) //if bust caching of external page
	bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime();
	page_request.open('GET', url+bustcacheparameter, true);
	page_request.send(null);
}

//Load content of page

function loadpage(page_request, containerid){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
	{
			var html = page_request.responseText

//Rip form out of page to kill any page references built by i5

			var ind = html.toUpperCase().indexOf('FORM')-1;
			var ind2 = html.toUpperCase().lastIndexOf('MYACCOUNTCLOSE')+45;
			html = html.substring(ind,ind2);

			document.getElementById(containerid).innerHTML = html;

			document.Login.dfAccessCode.focus();
	}
}

//Open Window containing Ajax got elements form i5page passing in correct vars


//To stop event bubbling on div, so that I can fire onmouseout correctly

function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}


//ajaxpage(pagetoopen, 'floatcontainer');