var ns4 = (document.layers)? true:false
var ie4 = (document.all)? true:false
var x = 0, y = 0, snow = 0, sw = 0, cnt = 0, offsetx = 10, offsety = 10;

if ( (ns4) || (ie4) ) {
	if (ns4) over = document.overDiv
	if (ie4) over = overDiv.style
	document.onmousemove = mouseMove
	if (ns4) document.captureEvents(Event.MOUSEMOVE)
}

// Microsoft Check.
if (ie4) 
{
	if (navigator.userAgent.indexOf('MSIE 5')>0 || navigator.userAgent.indexOf('MSIE 6')>0) 
	{
		ie5 = true;
	} 
	else 
	{
		ie5 = false; 
	}
} 
else 
{
		ie5 = false;
}

// this function is added by Praful sharma to detect the user version of browser; ie8/7.0 as the app doesn't perform with higher browsers editions.
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
{ //test for MSIE x.x;
 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
 if (ieversion>=8)
 {
  ie8 = true;
  //document.write("You're using IE8 or above")
 }
 else if (ieversion>=7)
 {
  ie7 = true;
  //document.write("You're using IE7.x")
 } 
}


// Simple popup right
function drs(text) {
	dts(text);
}

// Clears popups if appropriate
function nd() {
	if ( cnt >= 1 ) { sw = 0 };
	if ( (ns4) || (ie4) ) {
		if ( sw == 0 ) {
			snow = 0;
			hideObject(over);
		} else {
			cnt++;
		}
	}
}

// Simple popup
function dts(text) {
	txt = "<TABLE WIDTH=500 BORDER=0 CELLPADDING=1 CELLSPACING=0 BGCOLOR=#333399>" + 
	"<TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=#CCCCFF>" + 
	"<TR><TD><FONT FACE=Arial,Helvetica COLOR=#000000 SIZE=-2>" + text + "</FONT></TD></TR></TABLE></TD></TR></TABLE>";
	layerWrite(txt);
	disp();
}

// Common calls
function disp() {
	if ( (ns4) || (ie4) ) {
		if (snow == 0) {
			moveTo(over,x+offsetx,y+offsety);
			showObject(over);
			snow = 1;
		}
	}
}

// Moves the layer
function mouseMove(e) {
	if (ns4) {x=e.pageX; y=e.pageY;}
	if (ie4) {x=event.x; y=event.y;}
	if (ie5) {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}
	if (ie7 || ie8) // added by praful sharma to cater to the fix requested by Icon Administration team.
	{	    
		x=event.x+(document.body.scrollLeft - document.body.clientLeft);
		y=event.y+(document.body.scrollTop  - document.body.clientTop);
    }

	if (snow) {
		moveTo(over,x+offsetx,y+offsety);
	}
}

// Writes to a layer
function layerWrite(txt) {
	if (ns4) {
		var lyr = document.overDiv.document
		lyr.write(txt)
		lyr.close()
	}
	else if (ie4) document.all["overDiv"].innerHTML = txt
}

// Make an object visible
function showObject(obj) {
	if (ns4) obj.visibility = "show"
	else if (ie4) obj.visibility = "visible"
}

// Hides an object
function hideObject(obj) {
	if (ns4) obj.visibility = "hide"
	else if (ie4) obj.visibility = "hidden"
}

// Move a layer
function moveTo(obj,xL,yL) {
	obj.left = xL
	obj.top = yL
}
