// A reference to the currently-displayed popup window
var mdivPopup = null;
overdiv="0";

if (document.layers) {navigator.family = "nn4"}
if (document.all) {navigator.family = "ie4"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}

function ReplaceAll(varb, replaceThis, replaceBy){
    newvarbarray=varb.split(replaceThis);
    newvarb=newvarbarray.join(replaceBy);	
    return newvarb;
}

function popLayer(mystring){
var myPopTitle = "Best Buys Here!";

if (mystring.indexOf('dmnobie') != -1) 
  myPopTitle = "<div class='pop2headtd'>Best Buys Here!</div>";
else if (mystring.toLowerCase().indexOf('dmnobieblank') != -1)
  myPopTitle = "<div class='pop2headtd'>Best Buys Here!</div>";
else if (mystring.toLowerCase().indexOf('lowest price') != -1)
  myPopTitle = "<div class='pop2headtd'>Best Buys Here!</div>";
else
  myPopTitle = "<div class='pop2head2td'>Sponsored Link</div>";
mystring = ReplaceAll(mystring,"dmnobieblank", "");
mystring = ReplaceAll(mystring,"dmnobie", "'");
mystring = ReplaceAll(mystring,"dmndoubleobie", "\"");


if(!mystring){mystring="<font color=red><a href=http://www.digitalmedianet.com>http://www.digitalmedianet.com</a></font>";}

desc = 	  "<div class='pop2table'>"+myPopTitle+"\n"
	+"<div class='pop2maintd'>\n"
	+mystring
	+"\n"
	+"<a href=http://www.digitalmediaonlineinc.com/articles/abouthotlinksarticle.jsp target=_blank class='pop2what'>Add Your Link</a></div></div>";
if(navigator.family =="nn4") {
	document.object1.document.write(desc);
	document.object1.document.close();
	document.object1.left=x-185;
	document.object1.top=y-185;
	}
else if(navigator.family =="ie4"){
 
	object1.innerHTML=desc;
	object1.style.pixelLeft=x-185;
	object1.style.pixelTop=y-185;
	}
else if(navigator.family =="gecko"){
	document.getElementById("object1").innerHTML=desc;
	document.getElementById("object1").style.left=x-185;
	document.getElementById("object1").style.top=y-185;
	}
}

function hideLayer(){
if (overdiv == "0") {
	if(navigator.family =="nn4") {eval(document.object1.top="-500");}
	else if(navigator.family =="ie4"){object1.innerHTML="";}
	else if(navigator.family =="gecko") {document.getElementById("object1").style.top="-500";}
	}
}
var isNav = (navigator.appName.indexOf("Netscape") !=-1);
function handlerMM(e){
x = (isNav) ? e.pageX : event.clientX + document.body.scrollLeft;
y = (isNav) ? e.pageY : event.clientY + document.body.scrollTop;
}
if (isNav){document.captureEvents(Event.MOUSEMOVE);}
document.onmousemove = handlerMM;

/*******************************************************************************
 * Displays a popup window with the specified HTML contents.  The anchorElement
 * parameter specifies the element to which the popup is positioned.
 ******************************************************************************/
function descPopup(anchorElement, innerHTML) {
   try {

      // Remove any existing popups
      if (mdivPopup != null)
         forceHidePopup();

      // Create the popup
      mdivPopup = document.createElement('div');
      mdivPopup.style.position = 'absolute';
      mdivPopup.style.zIndex = '999999'
//      mdivPopup.style.backgroundColor = 'infobackground';
      mdivPopup.style.backgroundColor = 'FFFFCC';
//      mdivPopup.style.color = 'infotext';
      mdivPopup.style.borderStyle = 'solid';
      mdivPopup.style.borderWidth = '1px';
      mdivPopup.style.borderColor = 'red';
      mdivPopup.style.fontSize = '10pt';
      mdivPopup.style.width = '130px';
      mdivPopup.onmouseout = hidePopup;

      // Insert the content of the popup
      mdivPopup.innerHTML += "&nbsp;" + innerHTML + "&nbsp;";

      // Position the popup
      mdivPopup.style.top = getAbsoluteTop(anchorElement) + anchorElement.offsetHeight;
      mdivPopup.style.left = getAbsoluteLeft(anchorElement);

      // Show the popup
      document.body.appendChild(mdivPopup);
   }
   catch (x) {}
}


/*******************************************************************************
 * Hides a popup window that was shown via the showPopup function.  If the mouse
 * cursor is over the popup window, it is not hidden.
 ******************************************************************************/
function hidePopup() {
   try {
      if (mdivPopup != null) {
         // if (!isUnderCursor(mdivPopup))
            forceHidePopup();
      }
   }
   catch (x) {}
}


/*******************************************************************************
 * Hides a popup window that was shown via the showPopup function, regardless of
 * whether the cursor is still over the popup window.
 ******************************************************************************/
function forceHidePopup() {
   try {
      if (mdivPopup != null) {
         document.body.removeChild(mdivPopup);
         mdivPopup = null;
      }
   }
   catch (x) {}
}


/*******************************************************************************
 * Provides a safe way to obtain an element reference.
 ******************************************************************************/
function safeGetElement(elementID) {
   try {
      return document.getElementById(elementID);
   }
   catch (x) {
      return null;
   }
}


/*******************************************************************************
 * Toggles the display property of the specified HTML element
 ******************************************************************************/
function toggleDisplay(element) {
   try {
      element.style.display = element.style.display == 'none' ? '' : 'none';
   }
   catch (x) {}
}


/*******************************************************************************
 * Toggles the visibility property of the specified HTML element
 ******************************************************************************/
function toggleVisibility(element) {
   try {
      element.style.visibility = element.style.display == 'visible' ? 'hidden' : 'visible';
   }
   catch (x) {}
}


/******************************************************************************
 * Returns true if the mouse cursor is currently over the specified element;
 * otherwise, returns false.
 *****************************************************************************/
function isUnderCursor(element) {
   try {
      var intTop = getAbsoluteTop(element) - document.body.scrollTop;
      var intLeft = getAbsoluteLeft(element) - document.body.scrollLeft;
      var intBottom = intTop + element.offsetHeight + 1;
      var intRight = intLeft + element.offsetWidth + 1;

      if (((event.clientX >= intLeft) && (event.clientX <= intRight))
      && ((event.clientY >= intTop) && (event.clientY <= intBottom)))
         return true;
      else
         return false;
   }
   catch (x) {}
}


/******************************************************************************
 * Returns the absolute position of the left edge of the specified element.
 *****************************************************************************/
function getAbsoluteLeft(element) {
   try {
      var intLeft = 0;
      var objParent = element;

      do {
         intLeft += objParent.offsetLeft;
         objParent = objParent.offsetParent;
      }
      while (objParent != null);

      return intLeft;
   }
   catch (x) {}
}


/******************************************************************************
 * Returns the absolute position of the top edge of the specified element.
 *****************************************************************************/
function getAbsoluteTop(element) {
   try {
      var intTop = 10;
      var objParent = element;

      do {
         intTop += objParent.offsetTop;
         objParent = objParent.offsetParent;
      }
      while (objParent != null);

      return intTop;
   }
   catch (x) {}
}


/******************************************************************************
 * Hides all windowed elements that are beneath the specified element.
 *****************************************************************************/
function hideOverlappingWindowedElements(element) {
   hideOverlappingElements(element, "select");
   hideOverlappingElements(element, "applet");
   hideOverlappingElements(element, "iframe");
   hideOverlappingElements(element, "object");
}


/******************************************************************************
 * Makes all windowed elements visible.
 *****************************************************************************/
function showWindowedElements() {
   showElements("select");
   showElements("applet");
   showElements("iframe");
   showElements("object");
}


/******************************************************************************
 * Hides all elements with the specified tagName that that overlap the
 * specified element.
 *****************************************************************************/
function hideOverlappingElements(element, tagName) {
   try {
      var intElementTop = getAbsoluteTop(element) - document.body.scrollTop;
      var intElementLeft = getAbsoluteLeft(element) - document.body.scrollLeft;
      var intElementBottom = intElementTop + element.offsetHeight;
      var intElementRight = intElementLeft + element.offsetWidth;

      var arrElements = document.getElementsByTagName(tagName);
      for (var i = 0; i < arrElements.length; i++) {
         var intSelectTop = getAbsoluteTop(arrElements[i]) - document.body.scrollTop;
         var intSelectLeft = getAbsoluteLeft(arrElements[i]) - document.body.scrollLeft;
         var intSelectBottom = intSelectTop + arrElements[i].offsetHeight;
         var intSelectRight = intSelectLeft + arrElements[i].offsetWidth;

         if (((intElementTop <= intSelectBottom) && (intElementBottom >= intSelectTop))
         && ((intElementLeft <= intSelectRight) && (intElementRight >= intSelectLeft)))
            arrElements[i].style.visibility = "hidden";
      }
   }
   catch (x) {}
}


/******************************************************************************
 * Makes all elements with the specified tagName visible.
 *****************************************************************************/
function showElements(tagName) {
   try {
      var arrElements = document.getElementsByTagName(tagName);
      for (var i = 0; i < arrElements.length; i++) {
         arrElements[i].style.visibility = "visible";
      }
   }
   catch (x) {}
}
