	// The following code is used to support the small popups that
	// give the full description of an event when the user move the
	// mouse over it.

var NS4		=	(document.layers) ? 1 : 0;
var IE4		=	(document.all) ? 1 : 0;
var GEBI	=	(document.getElementById)?1:0;

function show(name) {
	//x = currentX;
	y = currentY + 20;
	if(NS4) {
		//Position popup correctly
		var docWidth=document.width;   //width of current frame
		var docHeight=document.height;  //height of current frame
		var layerWidth=document.layers[name].clip.width;  //width of popup layer
		var layerHeight=document.layers[name].clip.height; //height of popup layer
		if((currentX+layerWidth)>=docWidth) {
			x=(currentX-layerWidth);
		} else {
			x=currentX;
		}

	/********************
	  if((currentY+layerHeight)>=docHeight)
	  {
		y=(currentY-layerHeight-20);
	  }
	  else {
		y=currentY+20;
	  }
	*********************/
		document.layers[name].xpos = parseInt ( x );
		document.layers[name].left = parseInt ( x );
		document.layers[name].ypos = parseInt ( y );
		document.layers[name].top = parseInt ( y );
		document.layers[name].visibility = "show";
	} else if (IE4) {
		var docHeight=document.body.offsetHeight;
		var docWidth=document.body.offsetWidth;
		var layerWidth=document.all[name].offsetWidth;
		var layerHeight=document.all[name].offsetHeight;
		if((currentX+layerWidth)>docWidth) {
		  x=(currentX-layerWidth);
		} else {
		  x=currentX;
		}
		if((currentY+layerHeight)>=docHeight) {
		   y=(currentY-layerHeight-0);
		} else {
		  y=currentY+0;
		}

		document.all[name].style.left = parseInt ( x );
		document.all[name].style.top = parseInt ( y );
		document.all[name].style.visibility = "visible";
	} else {
  var docHeight=document.body.offsetHeight;
  var docWidth=document.body.offsetWidth;
  if (document.getElementById(name)) {
	var layerWidth=document.getElementById(name).offsetWidth;
	var layerHeight=document.getElementById(name).offsetHeight;
	if((currentX-layerWidth-document.body.scrollLeft)>0) {
		x=(currentX-layerWidth);
	} else {
		x=currentX;
	}
	if((currentY-layerHeight-document.body.scrollTop)>0) {
		y=(currentY-layerHeight-0);
	} else {
		y=currentY+0;
	}

	document.getElementById(name).style.left = parseInt (x);
	document.getElementById(name).style.top = parseInt (y);
	document.getElementById(name).style.visibility = "visible";
  }
}

}// end function definition


function hide(name) {
	if(NS4) {
		document.layers[name].visibility = "hide";
	} else if (IE4) {
		document.all[name].style.visibility = "hidden";
	} else {
		if (document.getElementById(name)) {
			document.getElementById(name).style.visibility = "hidden";
		}
	}
}

function unhide(name) {
	if(NS4) {
		document.layers[name].visibility = "visible";
	} else if (IE4) {
		document.all[name].style.visibility = "visible";
	} else {
		if (document.getElementById(name)) {
			document.getElementById(name).style.visibility = "visible";
		}
	}
}

currentX = currentY = 0;

function grabEl(e) {
	if( NS4 ) {
		currentX = e.pageX;
		currentY = e.pageY;
	} else if (IE4) {
		currentX = event.x + document.body.scrollLeft;
		currentY = event.y + document.body.scrollTop;
		//currentX = event.x;
		//currentY = event.y;
	} else {
		currentX = e.pageX;
		currentY = e.pageY;
	}
}

if(NS4) {
	document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
}

document.onmousemove = grabEl;

/// End the dhtml mouse over functions

function submit_form() {
	document.forms[0].run_query.value = 0;
	document.forms[0].submit();
}

function open_window(url,width,height) {
	window.open(url,"wind",'toolbar=0,location=0,directories=0,status=1,menubar=0,resizable=1,width='+ width +',height='+ height +',scrollbars=yes');
}

// open a popup window with basic params
function open_popup(url,width,height,target, scroll, resize)
{
window.open(url,target,'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable='+resize+',width='+ width +',height='+ height +',scrollbars='+scroll);
}


function open_assc_window() {
	window.open('assc_users.php',"wind",'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,width=630,height=425,scrollbars=no');
}

function open_ecom_window(url) {
	window.open(url,"ecom",'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,width=770,height=500,scrollbars=yes');
}

function open_attachment(url, width, height, option) {
	window.open(url,"attachment",'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=' + option + ',width='+ width +',height='+ height +',scrollbars=' +  option);
}

// confirm then redirect to input url
function conf_redir(url,msg) {
	if(confirm(msg)) {
		document.location = url;
		return true;
	}
}

function setfocus(element) {
	element.focus();
	element.select();
}

function pfriendly_links() {
	for(i = 0; i < document.links.length; i++) {
		document.links[i].href="javascript: alert('All links are disabled in printer friendly mode.')";
	}
}

// gets the title from the user
function get_title()
{
	if(IE4)
	{
		title = prompt('Please Enter a title for this document','');
		if(!title)
			title = '';
		printtitle.innerText = title;
		return true;
	}
	if(GEBI)
	{
		title = prompt('Please Enter a title for this document','');
		if(!title)
			title = '';
		document.getElementById("printtitle").innerHTML = title;
		return true;
	}
}

// Rollover effect for href
function flip(name, image) {
	document[name].src = image;
}

// Rollover effect for input buttons
function submit_flip(input, image) {
	input.src = image;
}

//setTimeout("window.focus()", 500);


function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function doElBlink(obj) {
	// Blink, Blink, Blink...
	var blink = obj;
	blink.style.visibility = blink.style.visibility == "" ? "hidden" : ""
}

function startBlink(obj) {
	obj.style.backgroundColor = "red";
	//obj.style.visibility = "visible";
}

function stopBlink(obj){
	obj.style.backgroundColor = "white";
	//obj.style.visibility = "hidden";
}


function endBlink(obj) {
	obj.style.visibility = "visible";
	obj.style.backgroundColor = "";
}

function doBlink(obj) {
	if (obj) {
		for (var i=500; i<3000;i=i+1000) {
			setTimeout("startBlink(obj)", i);
			setTimeout("stopBlink(obj)", i+500);
		}
		setTimeout("endBlink(obj)", 4000);
	}
}

function jumpToElement($element_id) {
	with( document ) {
		obj = document.getElementById($element_id);
		if (obj) {
			var newX = findPosX(obj) - 400;
			var newY = findPosY(obj) - 200;
			scrollTo(newX,newY);
		}
	}
}

function jumpAndBlink(obj) {
	if (obj) {
		var newX = findPosX(obj) - 400;
		var newY = findPosY(obj) - 200;
		scrollTo(newX,newY);
		doBlink(obj);
	}
}

function openChild(file,window) {
	childWindow = open(file, window,'toolbar=0,location=0,directories=0,status=1,menubar=0,resizable=1,width=800,height=600,scrollbars=yes');
	if (childWindow.opener == null) childWindow.opener = self;
	childWindow.focus();
}
