﻿// JScript File

function doAdPopup(kw, span)
{
    var ScreenBottom = getHeight() +getScrollY();   // find the y-coordinate of the bottom of the visible area of the screen
    var pos = new Array();
    pos = findPos(span)                             // get the x-y coordinates of teh span
    topPos = pos[1]+12;
    leftPos = pos[0];
    if (ScreenBottom - topPos < 80) { topPos = topPos - 103}    // check if the popup will appear off-screen, and adjust y-coord appropriately
    document.getElementById('inlineBanner').style.display = "block";
    document.getElementById('inlineBanner').style.top = topPos+'px';
    document.getElementById('inlineBanner').style.left = leftPos+'px';

    document.getElementById('inlineBanner').innerHTML = "<iframe width='120' height='80' src='/common/ad/inlinead.asp?kw="+kw+"' allowtransparency=false frameborder=0 ></iframe>";     // insert the contents into the div. just the keyword for now...


}

function doAdHide()
{
    document.getElementById('inlineBanner').style.display = "none";
}

function findPos(obj) 
{
	var curleft = curtop = 0;
	if (obj.offsetParent) 
	{
        do 
        {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
    }
return [curleft,curtop];
}


function getHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
	return myHeight;
}


function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  //return [ scrOfX, scrOfY ];
  return scrOfY;
}


/*
-----------  constantly gets current mouse position
-----------  makes the div follow the cursor
-----------  not used...

document.onmousemove=getMouseCoordinates;
function getMouseCoordinates(event)
{
ev = event || window.event;
document.getElementById('inlineBanner').style.top = (ev.pageY-100)+'px';
document.getElementById('inlineBanner').style.left = ev.pageX+'px';
}
*/

