//  mw API v0.114
//  1 July, 2003
//  This script is (c) Michael Wood and used with permission on Zestmedia sites.  It may not be used without permission.

// ** incdicates new function
//////  MAIN
//  getObj(div): Creates cross browser object named 'obj'
//  getElement(div,f): Creates unnamed cross browser object.  f is internal
//  makeElement(div,id,cnt,obj,im): Creates new element in DOM.  Args: div: new element tag name | id: new element ID | cnt: New element Content | obj: Append to obj  [!Netscape4]- Not supported | im [Insert Method]: 1 Inserts before obj - 0 appends to obj
//  addObjAsChildOfObj(obj,tObj):  Appends obj as the last child of tObj
//  makeDivLyr(id,cnt): Creates Layer (div with Absolute positioning) with visibility set to hide/hidden
//////  READ
//  getTopOfObj(obj): Returns the distance of obj from the top of the screen.
//  getLeftOfObj(obj): Returns the distance of obj from the left edge of the screen.
//  getRightOfObj(obj): Returns the distance of obj from the right edge of the screen.  [!Netscape4]- Problems with right property
//  getHeightOfObj(obj): Returns the height of obj.
//  getWidthOfObj(obj): Returns the width of obj.
//  getMousePosition(e): Returns position of the mouse on the doument as mp_x and mp_y and the position of the mouse in the window as sp_x  and sp_y.
//  getWinSize(): Returns win_y and win_x
//  getWinSizeY(): Returns Window Height as win_y
//  getWinSizeX(): Returns Window Width as win_x
//  getScrlOfX(): Returns distance window scrolled on x axis as s_x
//  getScrlOfY(): Returns distance window scrolled on y axis as s_y
//  requestQueryString(v): Returns the value of v from the query string.  Simulates asp function in js
//////  EDIT
//  styleObj(obj,p,v): Sets style [p]roperty of obj to v..  [!Netscape4]
//  setWidthOfObj(obj,v): Set's width of obj to v.  [!Netscape4]
//  setHeightOfObj(obj,v): Set's height of obj to v.  [!Netscape4]
//  setTopOfObj(obj,v): Sets the distance of obj from the top of the screen to v.
//  setLeftOfObj(obj,v): Sets the distance of obj from the left edge of the screen to v.
//  setRightOfObj(obj,v): Sets the distance of obj from the right edge of the screen to v.  [!Netscape4]- Problems with right property
//  showObj(obj): Make obj visible
//  hideObj(obj): Make obj invisible
//  setObjToMouseX(obj,v): Sets the position of obj on the x axis to the mouse's x point.  v is offset from mouse position.
//  setObjToMouseY(obj,v): Sets the position of obj on the y axis to the mouse's y point.  v is offset from mouse position.
//  setObjToMousePos(obj,v_x,v_y): Sets the position of obj to the mouse point.  v_x and v_y is offset from mouse position.
//  setObjToRelativeMouseX(obj,v): Sets the position of obj on the x axis to the mouse's x point plus the scroll of the x axis.  v is offset from mouse position.
//  setObjToRelativeMouseY(obj,v): Sets the position of obj on the y axis to the mouse's y point plus the scroll of the y axis.  v is offset from mouse position.
//  setObjToRelativeMousePos(obj,v_x,v_y): Sets the position of obj to the mouse point plus the scroll.  v_x and v_y is offset from mouse position.
//  setInnerHTML(obj,v): Changes content of obj to v.
//  setValue(obj,v): Sets obj.value to v.  [!Netscape4]- Problems with creating object.
//  sendValueOfAtoB(objA,objB): Sets objA.value to objB.value.  [!Netscape4]- Problems with creating object.
//  swapValueOfAandB(): Sets objA.value to objB.value, Sets objB.value to objA.value.  [!Netscape4]- Problems with creating object.
//  duplicateAttribute(obj,v,v2): Loops through obj duplicating the value of v as v2
//////  MOVE
//  moveTopTo(obj,v,s): Moves obj on y axis to v.  s is speed.
//  moveRightTo(obj,v,s): Moves obj on x axis to v.  s is speed.
//  moveDownTo(obj,v,s): Moves obj on y axis to v.  s is speed.
//  moveLeftTo(obj,v,s): Moves obj on x axis to v.  s is speed.
//  moveUpBy(obj,v,s): Moves obj up on y axis by v.  s is speed.
//  moveLeftBy(obj,v,s): Moves obj left on x axis by v.  s is speed.
//  moveDownBy(obj,v,s): Moves obj down on y axis by v.  s is speed.
//  moveRightBy(obj,v,s): Moves obj right on x axis by v.  s is speed.
//////  SCROLLER- [No Net4]
//  makeScrollable(obj,h): Makes content of obj into nested element for scrolling.  hieght is h
//  scrl(obj,a,v): Scrolls the contents of Obj established by makeScrollable().  a is axis (y-only), v is speed in px
//  stopScrl(): Ends scrolling
//////  INTERNALS
//  negative(v): Doubles v and subtracts it from itself.
//  half(v): Returns half of v
//  twice(v): Returns v*2
//  move(obj,a,v): Internal movement function.
//  moveWork(obj,v,s,a): Internal movement function.
//  scrlWork(obj,a,v): Internal scrolling function

var v,rv,el,mp_x,mp_y,mp_src,win_x,win_y,sp_x,sp_y
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){	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);}	}
// Object creation functions
function makeElement(div,id,cnt,obj,im){
  var el=document.createElement(div); el.id=id; el.innerHTML=cnt; obj=eval(obj); im?obj.parentNode.insertBefore(el,obj):obj.appendChild(el); }
function makeDivLyr(id,cnt){
  !document.layers?op="<div id=\""+id+"\" style=\"position:absolute;visibility:hide;\">":op="<layer name=\""+id+"\" visibility=\"hidden\">"; op+=cnt; !document.layers?op+="</div>":op+="</layer>";document.write(op);}
// Object manipulation functions
function getTopOfObj(obj){
  document.layers?rv=obj.top:rv=obj.offsetTop;return rv}
function setTopOfObj(obj,v){
  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){
  document.layers?rv=obj.clip.height:rv=obj.offsetHeight;return rv}
function getWidthOfObj(obj){
  document.layers?rv=obj.clip.width:rv=obj.offsetWidth;return rv}
function moveTopTo(obj,v,s,a){
  cPs=getTopOfObj(obj); tPs=v; rv=cPs-tPs; if(rv<0){ rv=negative(rv);moveDownBy(obj,rv,s,a); } else{ 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){
  ax=='v'?cPs=getTopOfObj(obj):cPs=getLeftOfObj(obj)
  if(eval(tst)){move(obj,ax,s,a);ax=ax;setTimeout("moveWork(obj,"+v+","+s+",'"+ax+"','"+a+"')",25)}
  else{ax=='v'?setTopOfObj(obj,tPs):setLeftOfObj(obj,tPs);a!="undefined"?eval(a):null} }
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)) } }
// Window functions
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){
  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;
	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){ 
  document.layers?obj.clip.width=v:obj.style.width=v+'px'}
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) }

//  NOT CONFIRMED FUNCTIONING
function getClipTopOfObj(obj){
  document.layers?rv=obj.clip.top:obj.style.clipTop;return rv}
function getClipRightOfObj(obj){
  document.layers?rv=obj.clip.right:obj.style.clipRight;return rv}
function getClipBottomOfObj(obj){
  document.layers?rv=obj.clip.bottom:obj.style.clipBottom;return rv}
function getClipLeftOfObj(obj){
  document.layers?rv=obj.clip.left:obj.style.clipLeft;return rv}

//  WIP FUNCTIONS
function drag(obj){
	setLeftOfObj(obj,mp_x)
	setTopOfObj(obj,mp_y)
	}

function addObjAsChildOfObj(obj,tObj){
  tObj.appendChild(obj); }

//  FUNCTIONS TO WRITE