/******************************************
CM_ADD-IN - pagecheck (last updated: 08/02/02)

Simple code that *tries* to keep the menus inside the
bounderies of the 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){  
  var l=pm.lev+1,a=b.align; if(!n) n=1
  var 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
  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.
*****************************************/
//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
	}  
}

/******************
CM_ADD-IN - slide (last updated: 01/26/02)

This function shows the submenus in a sliding
effect. If you use this add-in you get two 
new level properties called "slidepx" and
"slidetim". You have to specify this for
the levels you want this to happen on 
(these properties will also be inherited though)

slidepx is the number of pixels you want the
div to slide each setTimout, while "slidetim"
is the setTimeout speed (in milliseconds)

Example setting:
oCMenu.level[3].slidepx=10
oCMenu.level[3].slidetim=20

*****************/
makeCM.prototype.onshow+="; if(c.l[pm.lev].slidepx){b.moveIt(x,b.y-b.h); b.showIt(); b.tim=null; b.slide(y,c.l[pm.lev].slidepx,c.l[pm.lev].slidetim,c,pm.lev,pm.name)}"
makeCM.prototype.going=0
cm_makeObj.prototype.tim=10;
cm_makeLevel.prototype.slidepx=null
cm_makeLevel.prototype.slidetim=30
cm_makeObj.prototype.slide=function(end,px,tim,c,l,name){
  if(!this.vis || c.l[l].a!=name) return
	if(this.y<end-px){
		if(this.y>(end-px*px-px) && px>1) px-=px/5; this.moveIt(this.x,this.y+px)
		this.clipTo(end-this.y,this.w,this.h,0)
		this.tim=setTimeout(this.obj+".slide("+end+","+px+","+tim+","+c.name+","+l+",'"+name+"')",tim)
	}else{this.moveIt(this.x,end)}
}
