// Random utility functions that could be shared between scripts.

var mouseX;
var mouseY;

// function that sets the values mouseX and mouseY with the current 
// x and y coordinates of the mouse. make sure that you add this property to
// the <body> tag of any page you want it to run on.
// onmousemove="getMouseCoords(event);"
function getMouseCoords(e) 
{ 
  if (!e) var e = window.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;
	  }
    else if (e.clientX || e.clientY) { // works on IE6,FF,Moz,Opera7
	    mouseX = e.clientX + document.body.scrollLeft;
	    mouseY = e.clientY + document.body.scrollTop;
    	  }  
  }
}

// given an element, this function tells you if the mouse currently lies within
// the bounds of the element. This is handy if you want to do an onmouseout, but
// not execute some code if the user returns their mouse to the element. 
function mouseLiesWithinElement(element) {
	var elementx = findPosX(element);
	var elementy = findPosY(element);
	var elementHeight = element.offsetHeight; 
        var elementWidth = element.offsetWidth; 
	
	if ((mouseX >= elementx) && (mouseX <= elementx + elementWidth) &&
	(mouseY >= elementy) && (mouseY <= elementy +elementHeight)) {
		return true;
	}else{
		return false;
	}	
}

// Next two were stolen from QUIRKSMODE

// finds the x coordinate of an element
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;
}

// finds the y coordinate of an element
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;
}

// This script gets style properties as 
// follows:. getStyle(element,'property);
function getStyle(oElm, strCssRule){
    var strValue = "";
    if(document.defaultView && document.defaultView.getComputedStyle){
        strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
    }
    else if(oElm.currentStyle){
        strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
            return p1.toUpperCase();
        });
        strValue = oElm.currentStyle[strCssRule];
    }
    return strValue;
}

function mySplit(stringToSplit) {
	var returnArray = new Array();
		
	
}

var popupWindow = null;
// popup stuff if needed (centered if needed as well: 'isCenter')
function OpenBrWindow(theURL,winName,features,myWidth,myHeight,isCenter) {

	// first check to see if the window already exists
	if (popupWindow != null) {
		// the window has already been created, but did the user close it?
		// if so, then reopen it. Otherwise make it the active window.
	if (!popupWindow.closed) {
		popupWindow.focus();
		return;
		}
		// otherwise fall through to the code below to re-open the window
	}
	
	if(window.screen)if(isCenter)if(isCenter=="true"){
	var myLeft = (screen.width-myWidth)/2;
	var myTop = (screen.height-myHeight)/2;
	features+=(features!='')?',':'';
	features+=',left='+myLeft+',top='+myTop;
	}
	popupWindow = window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
	popupWindow.focus(); 
}
function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}


// function for hover p.color shift for landing pages

function setColor(id,col)
{
   document.getElementById(id).style.color=col;
}

// Function for resizing flash container on new screens
function setFlashHeight(flashid, newH){
    var divid = 'INTACTV';
	document.getElementById(divid).style.height = newH+"px";
}

function lmsExit()
{
   if (parent.lmstracking)
   {
      parent.lmstracking.lmsComplete();
   }

}
