/*****************************************************************************
FILENAME: cms_cm_addins.asp
DESC: Bigbridge CMS  add-in file for Coolmenus to gain more advanced featuers.
Copyright (c) Marty Portier (marty@bigbridge.com.au)

REVISIONS:
$Log: cms_cm_addins.js,v $
Revision 1.1  2003/01/17 04:58:09  marty
- INITIAL VERSION

******************************************************************************/



/******************************************
Function: hidemediaelement()
Written By: Marty E. Portier
Adapted loosely off code created by Thomas Brattli (webmaster@dhtmlcentral.com) ...THNX  :)
IE5+ and NS6+ only - ignores the other browsers

Active Media Content in browsers have what appears to be
the highest z-index whatever you do this script will check 
for media specified divs that interfear with your menu items
and then hide them. 

Just add this code to the coolmenus js file
or link the cm_addins.js file to your page as well.
*****************************************/
if(bw.dom&&!bw.op5&&!bw.op6){
  makeCM.prototype.media=0
  makeCM.prototype.onshow+=";this.hidemediaelement(pm,pm.subx,pm.suby,maxw,maxh,pm.lev)"
  makeCM.prototype.hidemediaelement=function(pm,x,y,w,h,l){
    var mediax,mediay,mediaw,mediah,i
    if(!this.media){
      this.media=document.getElementsByName("mediaelement")
		  this.media.level=0
    }
    var media=this.media
    for(i=0;i<media.length;i++){
    	

		mediax=0; 
		mediay=0; 
		var mediap;
		if(media[i].offsetParent){
			mediap=media[i]; 
			while(mediap.offsetParent){
				mediap=mediap.offsetParent;
				mediax+=mediap.offsetLeft;
				mediay+=mediap.offsetTop;
			}
		}
		mediax+=media[i].offsetLeft; 
		mediay+=media[i].offsetTop;
		mediaw=media[i].offsetWidth; 
		mediah=media[i].offsetHeight;
		if(mediax+mediaw>x && mediax<x+w && mediay+mediah>y && mediay<y+h){
			if(media[i].style.visibility!="hidden"){
				media[i].level=l; 
				media[i].style.visibility="hidden"; 
				if(pm){ 
					if(!pm.mout) pm.mout=""; 
					pm.mout+=this.name+".media["+i+"].style.visibility='visible';"
				}
			}
  		}else if(l<=media[i].level && !(pm&&l==0)) 
  			media[i].style.visibility="visible"

    }
  }
}

if(bw.dom&&!bw.op5&&!bw.op6){
  makeCM.prototype.swf=0
  makeCM.prototype.onshow+=";this.hideswfelement(pm,pm.subx,pm.suby,maxw,maxh,pm.lev)"
  makeCM.prototype.hideswfelement=function(pm,x,y,w,h,l){
    var swfx,swfy,swfw,swfh,i
    if(!this.swf){
      this.swf=document.getElementsByName("swfelement")
		  this.swf.level=0
    }
    var swf=this.swf
    for(i=0;i<swf.length;i++){
    	
		swfx=0; 
		swfy=0; 
		var swfp;
		if(swf[i].offsetParent){
			swfp=swf[i]; 
			while(swfp.offsetParent){
				swfp=swfp.offsetParent;
				swfx+=swfp.offsetLeft;
				swfy+=swfp.offsetTop;
			}
		}
		swfx+=swf[i].offsetLeft; 
		swfy+=swf[i].offsetTop;
		swfw=swf[i].offsetWidth; 
		swfh=swf[i].offsetHeight;
		if(swfx+swfw>x && swfx<x+w && swfy+swfh>y && swfy<y+h){
			if(swf[i].style.visibility!="hidden"){
				swf[i].level=l; 
				swf[i].style.visibility="hidden"; 
				if(pm){ 
					if(!pm.mout) pm.mout=""; 
					pm.mout+=this.name+".swf["+i+"].style.visibility='visible';"
				}
			}
  		}else if(l<=swf[i].level && !(pm&&l==0)) 
  			swf[i].style.visibility="visible"
    }
  }
}