﻿
/***********************************************
* Pop-it menu- © Dynamic Drive 
***********************************************/

var ie5=document.all && !window.opera
var ns6=document.getElementById

if (ie5||ns6)	
    document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')

function iecompattest(){
    return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}

/// Show Dynamic Menu 
function showmenu(obj, which, e, cntID, optWidth)
{
    if (!document.all&&!document.getElementById)
    return
    clearhidemenu()

    which=replaceAll( which,'$','"');
    which=replaceAll( which,'#',";");

    var ctrlLeftPos=getLeftPos(obj);
    var ctrlTopPos=getTopPos(obj);
		
    ///menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")  
    menuobj=document.getElementById("popitmenu");
    menuobj.className="dropmenuContainer";    
    menuobj.innerHTML=which    
    //menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth    
    menuobj.contentwidth=menuobj.offsetWidth
    menuobj.contentheight=menuobj.offsetHeight

    popupObjectWidth=menuobj.offsetWidth; 
    
    var optbgColor='#F0F7FF';
    
    menuobj.style.backgroundColor=paramexists(optbgColor)? optbgColor : floatiebgcolor    
    menuobj.style.display="";
    menuobj.style.position = "absolute";    
    menuobj.style.left=(ctrlLeftPos + 3)+ 'px';
    menuobj.style.top= (ctrlTopPos + 25 )+  'px'; 
    //disableMouseEvent(e, menuobj.offsetWidth);   
        
    eventX=ie5? event.clientX : e.clientX
    eventY=ie5? event.clientY : e.clientY        
    menuobj.style.visibility="visible"
    //slowhigh(menuobj)
    return false
}

var optbgColor='#fff';
var floatiebgcolor="#F0F7FF" //default bgcolor of floatie
var fadespeed=70; //speed of fade (5 or above). Smaller=faster.

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
if (window.menuobj)
menuobj.style.visibility="hidden"
}

function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}

function delayhidemenu(Objhintbox){
delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}

if (ie5||ns6)
document.onclick=hidemenu

function getTopPos(inputObj)
{		
 var returnValue = inputObj.offsetTop;
 while((inputObj = inputObj.offsetParent) != null){
    if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
 }
  return returnValue;
}
//gets left position of Object
function getLeftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
  }
  return returnValue;
}

//JavaScript function ReplaceAll, written by Kim Kjaersulf, www.salgslisten.dk
function replaceAll (streng, soeg, erstat)
{ var st = streng;
  if (soeg.length == 0)
     return st;
  var idx = st.indexOf(soeg);
  while (idx >= 0)        
  {  st = st.substring(0,idx) + erstat + st.substr(idx+soeg.length);
     idx = st.indexOf(soeg);
  }
  return st;
}

function paramexists(what){
return(typeof what!="undefined" && what!="")
}

function slowhigh(which2){

if(which2.style.dispaly=='')
return false;
imgobj=which2

browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
highlighting=setInterval("gradualfade(imgobj)",fadespeed)
}

function instantset(degree){
cleartimer()
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}


function disableMouseEvent(e, ctrlWiddth)
{
    if (!e) var e = window.event;
    var submenu = null;
    if (document.getElementById)
    submenu = document.getElementById('popitmenu');
    for (var i=0; i<submenu.childNodes.length; i++)
    {   
        if (submenu.childNodes[i].addEventListener) {
        // this code is for Mozilla and Opera
        submenu.childNodes[i].addEventListener('mouseout',
        disableEventPropagation, false);}
        
        else if (submenu.childNodes[i].attachEvent) {
        // this code is for IE
        submenu.childNodes[i].attachEvent('onmouseout',
        disableEventPropagation);
        }
    }
}
