function clickButton(locale){	window.location = locale;}var hideOthers = new Array();var classIdentifier = "class";if (navigator.appName == 'Microsoft Internet Explorer'){	classIdentifier = "className";}function isIE(){	var re = new RegExp(/MSIE\s([^;]+)/ig);	var m = re.exec(window.navigator.userAgent);	if(m == null)	{		return false;	}	else	{		return m[1];	}}function getElementsByName_iefix(tag, name){	var elem = document.getElementsByTagName(tag);	var arr = new Array();	for(i = 0,iarr = 0; i < elem.length; i++) {		att = elem[i].getAttribute(classIdentifier);		if (isIE() == "8.0")		{			att = elem[i].className;		}		if(att == name) {			arr[iarr] = elem[i];			iarr++;		}	}	return arr;}function showElem(elemId){	for (var i=0; i<hideOthers.length; i++)	{		var len2 = getElementsByName_iefix("DIV", hideOthers[i]).length;		for (var t = 0; t<len2; t++)		{			getElementsByName_iefix("DIV", hideOthers[i])[t].style.visibility = "hidden";		}	}	var len = getElementsByName_iefix("DIV", elemId).length;	for (var i = 0; i<len; i++)	{		getElementsByName_iefix("DIV", elemId)[i].style.visibility = "visible";	}}function hideElem(elemId){	var len = getElementsByName_iefix("DIV", elemId).length;	for (var i = 0; i<len; i++)	{		getElementsByName_iefix("DIV", elemId)[i].style.visibility = "hidden";	}}function is_child_of(parent, child){	if( child != null )	{		while( child.parentNode )		{			if( (child = child.parentNode) == parent )			{				return true;			}		}	}	return false;}function is_sibling_of(parent, child){	if( child != null )	{		var elemId = parent.getAttribute(classIdentifier);		var childTag = child.tagName;		while (childTag != "DIV")		{			child = child.parentNode;			childTag = child.tagName;			if (child == window)			{				return false; 			}		}		var childId = child.getAttribute(classIdentifier);		if (childId == elemId)		{			return true;		}	}	return false;}function fixOnMouseOut(element, event, jscp){	var current_mouse_target = null;	if( event.toElement )	{		current_mouse_target = event.toElement;	}	else if( event.relatedTarget )	{		current_mouse_target = event.relatedTarget;	}	if( !is_child_of(element, current_mouse_target) && !is_sibling_of(element, current_mouse_target) && element != current_mouse_target )	{		eval(jscp);	}}function getNumRows(objId, getId, hOff){	if (isIE())	{		var obj = document.getElementById(objId);		var obj2 = document.getElementById(getId);		var availheight = obj2.offsetHeight;		availheight += -hOff;		var numRows = 1;		if (availheight > 0)		{			var divH = 16;			if (navigator.appVersion.indexOf("MSIE 8.0") != -1)			{				availheight += -20;			}			numRows = Math.floor(availheight/divH);		}		obj2.style.height = availheight+"px";		obj.rows = numRows;	}} 
 function ahah(url, target) {
 // document.getElementById(target).innerHTML = ' Fetching data...';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
}

function ahah2(url, target, targetFunc) {
  //document.getElementById(target).innerHTML = ' Fetching data2...';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {targetFunc(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
} 

var htmlContent = "";
function ahahDone(url, target) 
{
  if (req.readyState == 4) 
  { // only if req is "loaded"
    if (req.status == 200) 
	{ // only if "OK"
		var reqStr = req.responseText;
		
		var regE = /[.|\s|\S]*(<link[^>]+>)[.|\s|\S]*<div\sid=\"drawLayer\">([.|\s|\S]*)<\/div><\/div><\/body><\/html>/;
		reqStr = reqStr.replace(regE, "$1$2");
		var linkStr = reqStr;
		//reqStr = reqStr.replace(/id=\"hitcss\"/, "id=\"sub_hitcss");
		//reqStr = reqStr.replace(/id=\"divtag/g, "sub_divtag");
		reqStr = reqStr.replace(/id=\"/g, 'id="sub_');
     	
		

		
		var regE2 = /[.|\s|\S]*<link\sid=\"hitcss\"[.|\s|\S]*href=\"([^\"]+)\"\stype=\"text\/css"[.|\s|\S]*/;
		linkStr = linkStr.replace(regE2, "$1");

		
		
		reqStr = reqStr.replace(/<link[^>]+>/, "");
		
		
		htmlContent = reqStr;
		
		
		//get the CSS first...
		ahah2(linkStr, target, readCSS);
		
		//document.getElementById(target).innerHTML = reqStr;
    } 
	else 
	{
      //document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText;
    }
  }
}

function destroyElem(elemId)
{
	
	var len = getElementsByName_iefix2("DIV", elemId).length;
	
	for (var i = 0; i<len; i++)
	{		
	//alert(getElementsByName_iefix2("DIV", elemId)[i].parentNode);
		getElementsByName_iefix2("DIV", elemId)[i].innerHTML = "";
		//parent.removeChild(child);
		//getElementsByName_iefix2("DIV", elemId)[i].parentNode.removeChild(getElementsByName_iefix2("DIV", elemId)[i]);
	}
}


function readCSS(url, target) 
{
  if (req.readyState == 4) 
  { // only if req is "loaded"
    if (req.status == 200) 
	{ // only if "OK"
		var reqStr = req.responseText;
		
		//reqStr = reqStr.replace(/id=\"hitcss\"/, "id=\"sub_hitcss");
		reqStr = reqStr.replace(/#(\w+\s)/g, "#sub_$1 ");
		
		htmlContent = "<style>"+reqStr+"</style>" + htmlContent;
		if (doreplace == true)
		{
			document.getElementById(target).innerHTML = htmlContent;
		}
		else
		{
     		document.getElementById(target).innerHTML += "<div id=\"popout\" style=\"position:relative; left:"+offsetX+"px;\" onmouseout=\"javascript:fixOnMouseOut2(this, event, destroyElem);\">"+htmlContent+"</div>";
		
			
		}
    } 
	else 
	{
      //document.getElementById(target).innerHTML=" AHAH Error:url:("+url+") \n"+ req.status + "\n" +req.statusText;
    }
  }
}


var classIdentifier = "class";
function getElementsByName_iefix2(tag, name)
{
	var elem = document.getElementsByTagName(tag);
	var arr = new Array();
	
	//var nameList = "";
	
	for(i = 0,iarr = 0; i < elem.length; i++) {
		att = elem[i].getAttribute(classIdentifier);
		if (isIE() == "8.0")
		{
			att = elem[i].className;
		}
		att = elem[i].id;
		//nameList += att+", ";
		if(att == name) {
			arr[iarr] = elem[i];
			iarr++;
		}
	}
	//alert(nameList);
	return arr;
}
function is_child_of2(parent, child)
{
	if( child != null )
	{
		while( child.parentNode )
		{
			if( (child = child.parentNode) == parent )
			{
				return true;
			}
		}
	}
	return false;
}

function is_sibling_of2(parent, child)
{
	if( child != null )
	{
		var elemId = parent.id;//parent.getAttribute(classIdentifier);
		var childTag = child.tagName;
		while (childTag != "DIV")
		{
			child = child.parentNode;
			childTag = child.tagName;
			if (child == window)
			{
				return false; 
			}
		}
		var childId = child.id;//child.getAttribute(classIdentifier);
		if (childId == elemId)
		{
			return true;
		}
	}
	return false;
}

function fixOnMouseOut2(element, event, jscp)
{
	var current_mouse_target = null;
	
	if( event.toElement )
	{
		current_mouse_target = event.toElement;
	}
	else if( event.relatedTarget )
	{
		current_mouse_target = event.relatedTarget;
	}
	
	//alert("CMT = "+current_mouse_target.id);
	if( !is_child_of2(element, current_mouse_target) && !is_sibling_of2(element, current_mouse_target) && element != current_mouse_target )
	{
		//alert("go = "+event);
		jscp(element.id);
		//eval(jscp);
	}
}




var offsetX = 0;
var doreplace = false;
var checkDestroy = false;

function setDestroy()
{
	//alert("setDestroy");
	checkDestroy = true;
}

var cTarg = null;
var origLink = "";
function setDestroyFix()
{
	var currMouseTarg = event.currentTarget;
	
	if( event.toElement )
	{
		currMouseTarg = event.toElement;
	}
	else if( event.relatedTarget )
	{
		currMouseTarg = event.relatedTarget;
	}
	
	if( !is_child_of2(cTarg, currMouseTarg) && !is_sibling_of2(cTarg, currMouseTarg) && cTarg != currMouseTarg && origLink != currMouseTarg)
	{
		setDestroy();
	}
}

function loadHTMLtoDIV(name, div, event) {
	//offsetX = offX;
	var currMouseTarg = null;
	
	if( event.toElement )
	{
		currMouseTarg = event.toElement;
	}
	else if( event.relatedTarget )
	{
		currMouseTarg = event.relatedTarget;
	}

	currMouseTarg.parentNode.onmouseout = setDestroy;
	//alert(currMouseTarg);
	cTarg = currMouseTarg;
	origLink = event.currentTarget;
	
	if (checkDestroy == true)
	{
		destroyElem("popout");
		checkDestroy = false;
	}
	
	ahah(name,div);
	
	return false;
}
