var browserType;
if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {browserType= "gecko"}

function getObject(id_name) {
	var strE = "document.getElementById('"+id_name+"')";
	var strS = "document.all['"+id_name+"']";
	var strP = "document.layers['"+id_name+"']";
	
	if (browserType == "gecko" ) document.poppedLayer = eval(strE);
    else if (browserType == "ie") document.poppedLayer = eval(strS);
    else document.poppedLayer = eval(strE);
	return document.poppedLayer; 
}

function hideDIV(id_name) {	
    var pLayer = getObject(id_name);
    if( pLayer.style.visibility == "hidden") return;
   
    pLayer.style.visibility = "hidden";
    pLayer.style.position = "absolute";    
}


function showDIV(id_name) {		
    var pLayer = getObject(id_name);
    if( pLayer.style.visibility == "visible") return;
    
    pLayer.style.visibility = "visible";
    pLayer.style.position = "";    
}

function OpenLinkIfConfirm( link, message ) {
	if( !message || confirm(message) ) 
		window.location.href =link;
}

function blankSpace(count) {
	html = "";
	for( var i=0; i<count; i++) html += "&nbsp;";
	return html;
}

function showDeep( deep ) {
	html ="";
	for( var i=0; i<deep; i++ )
		html += "<img src=\"/mr_icons/deep.png\" border=0 >";
	return html;
}

function userInputToInteger( value ) {
	var safeValue ="";
	for( var i=0; i<value.length; i++ ) {
		v = parseInt( value[i] );
		if( v >= 0 && v <= 9) safeValue += value[i];
	}

	return safeValue;
}

function getURLContent( link ) {
	var http_request = false; 
	if(window.XMLHttpRequest) http_request=new XMLHttpRequest();
	else if (window.ActiveXObject) http_request = new ActiveXObject("Microsoft.XMLHTTP");	
	if( !http_request ) return false; 
	
	window.status = "Please wait...";
	http_request.open('GET', link, false); 
	http_request.send("empty"); 
	window.status = ""; 
	
	if (http_request.readyState == 4 && http_request.status == 200 ) return http_request.responseText; 
	else return false;
}

function popupDiv( divName, title, content, mouseX, mouseY ) {
	var s = "<B><A href=\"javascript:hideDIV('"+divName+"');\"><font color=\"black\">[X]</font></a><B> | " + title;
	s = "<table cellpadding=1 cellspacing=1> <tr><Td bgcolor=white><table cellpadding=2 cellspacing=1 bgcolor=\'#9d8777\'><tr><Td style=\'font-size:9px; font-family:verdana;color:white;\'>&nbsp; "+ s + "</TD></tr><tr bgcolor=white><td>";
	s += content;
	s += "<BR></td></tr></table></TD></tr></table>";

	var hintDiv = getObject( divName );
	hintDiv.innerHTML = s;
		
	hintDiv.style.visibility = "visible";
	hintDiv.style.position = "absolute";
	
	hintDiv.style.left = mouseX;
	hintDiv.style.top  = mouseY;
}

/*
function getMouseXY(e) // works on IE6,FF,Moz,Opera7
{ 
  if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

  if (e)
  { 
    if (e.pageX || e.pageY)
    { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
      mousex = e.pageX;
      mousey = e.pageY;
      algor = '[e.pageX]';
      if (e.clientX || e.clientY) algor += ' [e.clientX] '
    }
    else if (e.clientX || e.clientY)
    { // works on IE6,FF,Moz,Opera7
      mousex = e.clientX + document.body.scrollLeft;
      mousey = e.clientY + document.body.scrollTop;
      algor = '[e.clientX]';
      if (e.pageX || e.pageY) algor += ' [e.pageX] '
    }  
  }
}


// MOUSE
var gMouseX = 0
var gMouseY = 0

var IE = document.all ? true : false
if (!IE) document.captureEvents(Event.MOUSEMOVE)

document.onmousemove = getMouseXY;
function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    gMouseX = event.clientX + document.body.scrollLeft
    gMouseY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    gMouseX = e.pageX
    gMouseY = e.pageY
  }  

  return true
}

*/