/******************************************

CM_ADD-IN - hideselectboxes (last updated: 01/29/02)

IE5+ and NS6+ only - ignores the other browsers



Because of the selectbox bug in the browsers that makes 

selectboxes have the highest z-index whatever you do 

this script will check for selectboxes 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.sel=0

  makeCM.prototype.onshow+=";this.hideselectboxes(pm,pm.subx,pm.suby,maxw,maxh,pm.lev)"

  makeCM.prototype.hideselectboxes=function(pm,x,y,w,h,l){

    var selx,sely,selw,selh,i

    if(!this.sel){

      this.sel=document.getElementsByTagName("SELECT")

		  this.sel.level=0

    }

    var sel=this.sel

    for(i=0;i<sel.length;i++){

			selx=0; sely=0; var selp;

			if(sel[i].offsetParent){selp=sel[i]; while(selp.offsetParent){selp=selp.offsetParent; selx+=selp.offsetLeft; sely+=selp.offsetTop;}}

			selx+=sel[i].offsetLeft; sely+=sel[i].offsetTop

			selw=sel[i].offsetWidth; selh=sel[i].offsetHeight

			if(selx+selw>x && selx<x+w && sely+selh>y && sely<y+h){

				if(sel[i].style.visibility!="hidden"){sel[i].level=l; sel[i].style.visibility="hidden"; if(pm){ if(!pm.mout) pm.mout=""; pm.mout+=this.name+".sel["+i+"].style.visibility='visible';"}}

      }else if(l<=sel[i].level && !(pm&&l==0)) sel[i].style.visibility="visible"

    }

  }

}

/******************************************

CM_ADD-IN - pagecheck (last updated: 08/02/02)



Simple code that *tries* to keep the menus inside the

bounderies of the page.



Code updated. It's still not perfect (obviosly)

but it will now do another check to try and place 

the menus inside.





Just add this code to the coolmenus js file

or link the cm_addins.js file to your page.

*****************************************/

makeCM.prototype.onshow+=";this.pagecheck(b,pm,pm.subx,pm.suby,maxw,maxh)"

makeCM.prototype.pagecheck=function(b,pm,x,y,w,h,n){  

  l=pm.lev+1

  a=b.align; if(!n) n=1

  ok=1

  if(x<cmpage.x) {pm.align=1; ok=0;}

  else if(x+w>cmpage.x2){ pm.align=2; ok=0;}

  else if(y<cmpage.y) { pm.align=3; ok=0;}

  else if(h+y>cmpage.y2) {pm.align=4; ok=0;}

  if(!ok) this.getcoords(pm,this.l[l-1].borderX,this.l[l-1].borderY,pm.b.x,pm.b.y,w,h,this.l[l-1].offsetX,this.l[l-1].offsetY)

  x=pm.subx; y=pm.suby

	//Added check --- still not ok? --- part of the code by Denny Caldwell (thanks) -- badly immplemented by me though

  if(x<cmpage.x) {x += cmpage.x-x;}

  else if(x+w>cmpage.x2){ x = -(x+w-cmpage.x2);}

  else if(y<cmpage.y) { y = cmpage.y-y; }

  else if(h+y>cmpage.y2) {y = -(y+h-cmpage.y2);}

  if(x<cmpage.x) {x += cmpage.x-x;}

  else if(x+w>cmpage.x2){ x = -(x+w-cmpage.x2);}

  else if(y<cmpage.y) { y = cmpage.y-y;}

  else if(h+y>cmpage.y2) {y = -(y+h-cmpage.y2);}

	b.moveIt(x,y)  

}

/******************************************

CM_ADD-IN - pagecheck (last updated: 01/26/02)

Simple code that *tries* to keep the menus inside thebounderies of

the page.A more advanced version of this code will come later.

Just add this code to the coolmenus js fileor link the cm_addins.

js file to your page as well.

*****************************************/

//makeCM.prototype.onshow+=";this.pagecheck2(b,pm,x,y,maxw,maxh)"

makeCM.prototype.pagecheck2=function(b,pm,x,y,w,h){  	

	var fixX = 0	

	var fixY = 0  

	var ok=1	

	if(x+w>cmpage.x2) {

		; 

		ok=0;

	}else if(x<cmpage.x) {

		 ok=0;

	}if(y+h>cmpage.y2){

		fixY = -(y+h-cmpage.y2);

		ok=0;

	}else if(y<cmpage.y) {

		fixY = cmpage.y-y; 

		ok=0;

	}//	self.status="x:"+x+" y:" +y+ " fixX:" +fixX+ " fixY:" +fixY  

	if(!ok) {		

		self.status = x + " - " +cmpage.x + " - " + fixX + " - " + (x+fixX)

		x+=fixX; 

		y+=fixY	  

		pm.moveIt(x,y)	

		self.status = b.css.left

	}  

}
