//miscellaneous functions for WBF website

//-----------------GET MOUSE POPSITION ON THE PAGE------------------------------------//

/*
============================================================
Capturing The Mouse Position in IE4-6 & NS4-6
(C) 2000 www.CodeLifter.com
Free for all users, but leave in this  header
*/

var IE = document.all ? true : false;

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) {
	document.captureEvents(Event.MOUSEMOVE);
}	

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

function getMouseXY(e) {//gets the mouse position on the page.
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the <B style="color:black;background-color:#99ff99">position</B> values in the form named Show
  // in the text fields named MouseX and MouseY
 	document.MouseX = tempX;
  	document.MouseY = tempY;
	return true;
}
//-----------------END GET MOUSE POPSITION ON THE PAGE------------------------------------//

//-----------------GET ELEMENT POPSITION ON THE PAGE------------------------------------//
function getElementPosition(elemID) {
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
}
//-----------------END GET ELEMENT POPSITION ON THE PAGE------------------------------------//

//-----------------FORM FUNCTIONS------------------------------------//
function RegExpTest(sEmail) {
	regEx = /^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$/
	return regEx.test(sEmail);
}
//-----------------END FORM FUNCTIONS------------------------------------//

//-----------------GENERIC FUNCTIONS------------------------------------//
function error(obj,msg){
	alert(msg);
	obj.focus();
	obj.select();
	return false;
}

function openWin() {
	var args=openWin.arguments;
	var height=args[2]+20;
	window.open(args[0],'newWin','width='+args[1]+', height='+height+', toolbars=no, scrollbars=no, resize=noresize');
}

function makeVisible(objName,display) {
	var elem	=	document.getElementById(objName);
	if (display!=null && display!="") {
		elem.style.display	=	display;
	}else{
		elem.style.display	=	(elem.style.display=='none') ? 'block': 'none';
	}
}
//-----------------END GENERIC FUNCTIONS------------------------------------//