//  mw API v0.111 29082002
var v,rv,el,mp_x,mp_y,mp_src,win_x,win_y,sp_x,sp_y
var cPs;
var tPs;
var tst;
var obj; 
var tO;

function negative(v){
  rv=v-(v*2);return rv}
function half(v){
  rv=v/2;return rv}
function twice(v){
  rv=v*2;return rv}
function getObj(div){var obj=getElement(div);return obj; }
function getElement(div,f){
	if(document.layers){f=(f)?f:self;var V=f.document.layers;if(V[div])return V[div];for(var W=0;W<V.length;)t=getElement(div,V[W++]);return t;}
	if(document.all && !document.getElementById){return document.all[div];}
	if(document.getElementById){return document.getElementById(div);}	}
function makeElement(div,id,cnt,obj){
  var el=document.createElement(div); el.id=id; el.innerHTML=cnt; obj=eval(obj); obj.appendChild(el); }

function getTopOfObj(obj){
  if(document.layers){
		rv=obj.top;
	} else {
	
		if(obj!=undefined){
			if(obj.offsetTop){
				rv=obj.offsetTop;
			} else {
				rv=1;
			}
		} else {
			rv = 1;
			//alert("Just setting to 1 cos obj is undefined")	
		}
	}
	return rv;
}
	
function setTopOfObj(obj,v){
	//alert("setTopOfObj function:" + obj.id);
  	document.layers?obj.top=v:obj.style.top=v+'px'}
function getLeftOfObj(obj){
  document.layers?rv=obj.left:rv=obj.offsetLeft;return rv}
function setLeftOfObj(obj,v){
  document.layers?obj.left=v:obj.style.left=v+'px'}
function getHeightOfObj(obj){
//	alert("obj in getHeightOfObj is:" + obj)
  if(document.layers){
	rv=obj.clip.height
  } else { 
	rv=obj.offsetHeight
  }
  return rv
}
function getWidthOfObj(obj){
  if (document.layers){
	//alert("BP1");
	rv=obj.clip.width
	} else {
	//alert("BP2:"+obj.id);
	rv=obj.offsetWidth;
		if(obj.id==undefined){
			rv = 152;
		}
	}
	//alert("RV:" + rv);
	return rv
}

function moveTopTo(obj,v,s,a){

//alert("moveTopTo function:" + obj.id);

  cPs=getTopOfObj(obj); 
  tPs=v; 
  rv=cPs-tPs; 

//alert("this far:" + rv );

  if(rv<0){ 
		
		//alert("part one");
		
		rv=negative(rv);
		
		//alert("rv now:" + rv);
		
		moveDownBy(obj,rv,s,a); 
	} else { 
		
		alert("part two");
		
		moveUpBy(obj,rv,s,a)
	}
}

function moveRightTo(obj,v,s,a){
  moveLeftTo(obj,v,s,a)}
  
function moveDownTo(obj,v,s,a){
  moveTopTo(obj,v,s,a)}

function moveLeftTo(obj,v,s,a){
  cPs=getLeftOfObj(obj); tPs=v; rv=cPs-tPs; if(rv<0){ rv=negative(rv);moveRightBy(obj,rv,s,a); } else{ moveLeftBy(obj,rv,s,a) } }
function moveUpBy(obj,v,s,a){
  v>0?v=negative(v):null;s>0?s=negative(s):null;
  cPs=getTopOfObj(obj);tPs=cPs+v;tst="cPs>=tPs-s";moveWork(obj,v,s,'v',a) }
function moveLeftBy(obj,v,s,a){
  v>0?v=negative(v):null;s>0?s=negative(s):null;
  cPs=getLeftOfObj(obj);tPs=cPs+v;tst="cPs>=tPs-s";moveWork(obj,v,s,'h',a) }

function moveDownBy(obj,v,s,a){

  cPs=getTopOfObj(obj);
  tPs=cPs+v;
  tst="cPs<=tPs-s";
  moveWork(obj,v,s,'v',a) 
 
 }

function moveRightBy(obj,v,s,a){
  cPs=getLeftOfObj(obj);tPs=cPs+v;tst="cPs<=tPs-s";moveWork(obj,v,s,'h',a) }
function move(obj,ax,v,a){
  document.layers?ax=='h'?obj.left=parseInt(getLeftOfObj(obj)+v):obj.top=parseInt(getTopOfObj(obj)+v):ax=='h'?obj.style.left=parseInt(getLeftOfObj(obj)+v)+'px':obj.style.top=parseInt(getTopOfObj(obj)+v)+'px'}

function moveWork(obj,v,s,ax,a){
	//alert("obj is:" + obj);
	//alert("tst is:" + tst);

	if(ax=='v'){
		cPs=getTopOfObj(obj)
	} else {
		cPs=getLeftOfObj(obj)
	}
  
	//alert("After first conditional obj is:" + obj);
  
  	if(eval(tst)){
		
		move(obj,ax,s,a);
		
		//alert("after call to move() obj is:" + obj);
		
		ax=ax;
		
		//when we call this obj suddenly becomes undefined !!!
		//setTimeout("moveWork(obj,"+v+","+s+",'"+ax+"','"+a+"')",25);
		//so let's try just calling it
		moveWork(obj,v,s,ax,a)
		//that gets the menu on screen at least - must reset obj for each call via setTimeout I guess
	}
	else{
		//alert("to here 2");
		ax=='v'?setTopOfObj(obj,tPs):setLeftOfObj(obj,tPs);a!="undefined"?eval(a):null
	}
//alert("finished moveWork");
}

function showObj(obj){
  document.layers?obj.visibility='show':obj.style.visibility='visible'}
function hideObj(obj){
  document.layers?obj.visibility='hide':obj.style.visibility='hidden'}
function setInnerHTML(obj,v){
  if(document.layers){obj.document.open();obj.document.write(v);obj.document.close();}
  else{obj.innerHTML=v;} }
function setObjToMouseX(obj,v){
  v=parseInt(mp_x+v);setLeftOfObj(obj,v)}
function setObjToMouseY(obj,v){
  v=parseInt(mp_y+v);setTopOfObj(obj,v)}
function setObjToMousePos(obj,v_x,v_y){
  setObjToMouseX(obj,v_x);setObjToMouseY(obj,v_y)}
function setObjToRelativeMouseX(obj,v){
  v=parseInt(mp_x+v);v+getWidthOfObj(obj)+negative(getScrlOfX())>getWinSizeX()?v_x=getWinSizeX()-getWidthOfObj(obj)+getScrlOfX():v_x=v;setLeftOfObj(obj,v_x);}
function setObjToRelativeMouseY(obj,v){
  v=parseInt(mp_y+v);v+getHeightOfObj(obj)+negative(getScrlOfY())>getWinSizeY()?v_y=getWinSizeY()-getHeightOfObj(obj)+getScrlOfY():v_y=v;setTopOfObj(obj,v_y);}
function setObjToRelativeMousePos(obj,v_x,v_y){
  setObjToRelativeMouseX(obj,v_x);setObjToRelativeMouseY(obj,v_y)}
function duplicateAttribute(obj,v,v2){
	for(n=0;n<obj.length;n++){ obj[n].setAttribute(v2,obj[n].getAttribute(v)) } }
function getWinSize(){
  getWinSizeY();getWinSizeX();}
function getWinSizeY(){
  if(document.body){ win_y=document.body.clientHeight}
  if(win_y==0 || isNaN(win_y)){ win_y=window.innerHeight}
  return win_y}
function getWinSizeX(){
  if(document.body){ win_x=document.body.clientWidth}
  if(win_x==0 || isNaN(win_x)){ win_x=window.innerWidth}
  return win_x}
function getScrlOfX(){
  document.layers?s_x='nv':s_x=document.documentElement.scrollLeft+document.body.scrollLeft;
  if(isNaN(s_x)){s_x=window.pageXOffset}
	return s_x }
function getScrlOfY(){
  document.layers?s_y='nv':s_y=document.documentElement.scrollTop+document.body.scrollTop;
  if(isNaN(s_y)){s_y=window.pageYOffset}
	return s_y }
function requestQueryString(v){
  return location.search.slice(location.search.indexOf("?"),location.search.length).slice(location.search.indexOf(v)+v.length+1,location.search.indexOf("&",location.search.indexOf(v))!=-1?location.search.indexOf("&",location.search.indexOf(v)):location.search.length) }
function getMousePosition(e){
	mp_x=(window.event)?(document.getElementById && document.all)?event.clientX+getScrlOfX():event.clientX:e.pageX;
	mp_y=(window.event)?(document.getElementById && document.all)?event.clientY+getScrlOfY():event.clientY:e.pageY; 
	sp_x=(window.event)?event.clientX:e.clientX;
	sp_y=(window.event)?event.clientY:e.clientY; }
if(document.captureEvents){ document.captureEvents(Event.MOUSEMOVE); }
document.onmousemove=getMousePosition;

//  NOT FUNCTIONING IN NET4
function setWidthOfObj(obj,v){
	if(v!=-1){
		document.layers?obj.clip.width=v:obj.style.width=v+'px'
	} else {
		document.layers?obj.clip.width=0:obj.style.width='0px'
	}
}
	
function setHeightOfObj(obj,v){
  document.layers?obj.clip.height=v:obj.style.height=v+'px'}
function setValue(obj,v){
  obj.value=v;}
function sendValueOfAtoB(objA,objB){
  objB.value=objA.value;}
function swapValueOfAandB(){
  var t=objA.value;objA.value=objB.value;objB.value=t;}
function getRightOfObj(obj){
  document.layers?rv=obj.right:rv=obj.offsetRight;return rv}
function setRightOfObj(obj,v){
  document.layers?obj.left=parseInt(screen.width-v):obj.style.right=v+'px'}
function styleObj(obj,p,v){
  document.layers?obj.p=v:obj.style.p=v}
function makeScrollable(obj,h){
  obj.style.height=h+'px';obj.style.overflow='hidden';
  iHTML=obj.innerHTML;obj.innerHTML='';
  makeElement("div",obj.id+'_scrLyr',iHTML,obj)
  nObj=getObj(obj.id+'_scrLyr');nObj.style.position='absolute';}
function scrl(obj,a,v){
  sObj=getObj(obj.id+'_scrLyr')
  scrlWork(sObj,a,v) }
function scrlWork(obj,a,v){
	setTopOfObj(sObj,getTopOfObj(sObj)+a)
  tO=window.setTimeout("scrlWork(sObj,"+a+",\'"+v+"\')",25) }
function stopScrl(){
  clearTimeout(tO) }

function getTarget(e){
	if(window.event){e=window.event.srcElement}
	theSrc=e
  alert(theSrc)
  }
function NEW_getMousePosition(e){
  if(e){mp_src=e.target} else if(window.event){mp_src=window.event.srcElement}
	mp_x=(window.event)?(document.getElementById && document.all)?event.clientX+getScrlOfX():event.clientX:e.pageX;
	mp_y=(window.event)?(document.getElementById && document.all)?event.clientY+getScrlOfY():event.clientY:e.pageY; }