/*
common js funcs used throughout site

Contains:
setPos(e) - used for resizing modules
getPos(e) - used for resizing modules
getMouseXPos() and getMouseYPos() for positioning floating divs

*/
var curHeight=0
var curPos=0
var curPosX=0
var newPos=0
//global var to track mouse button status
var mouseStatus='up'
var resizeableDiv;
var defaultHeight;

//set the initial position of the resize-bar
function setPos(e){
mouseStatus="down";
curevent=(typeof event=='undefined'?e:event)
curPos=curevent.clientY
curPosX=curevent.clientX
tempHeight=document.getElementById(resizeableDiv).style.height
if(tempHeight=="" || tempHeight==undefined){tempHeight=document.getElementById(resizeableDiv).clientHeight+"px"}
//alert(tempHeight)
heightArray=tempHeight.split('p')
curHeight=parseInt(heightArray[0])
}

document.onmousemove=getPos; 
document.onmouseup=setMouseStatus;

function setMouseStatus() {
	/*
	alert('ding');
	*/
	if(mouseStatus!="up"){
	mouseStatus="up";
	}
}


//reset the position of the resize-bar when the mouse moves while button down
function getPos(e){
if(mouseStatus=='down'){

	curevent=(typeof event=='undefined'?e:event)
	newPos=curevent.clientY
	var pxMove=parseInt(newPos-curPos)
	var newHeight=parseInt(curHeight+pxMove)
	newHeight=(newHeight<5?5:newHeight)
	document.getElementById(resizeableDiv).style.height=newHeight+'px'
	/*
	*/

	if(defaultHeight!="" && defaultHeight!=undefined)
		{
			if(newHeight!=defaultHeight)
			{
			document.getElementById('snap').style.display="";
			} else {
			document.getElementById('snap').style.display="none";
			}
		}
	return false; // in IE this prevents cascading of events, thus text selection is disabled
	} 
}

// Get the horizontal position of the mouse
var ns6=false;
if(navigator.appName=="Netscape"){ns6=true;}
//alert(navigator.appName+" and "+ns6);
/*
*/
function getMouseXPos(e) {
  if (document.layers||ns6) {
    return parseInt(e.pageX+10)
  } else {
    return (parseInt(event.clientX+10) + parseInt(document.documentElement.scrollLeft ?   document.documentElement.scrollLeft : document.body.scrollLeft))
  }
}
function getMouseYPos(e) {
  if (document.layers||ns6) {
    return parseInt(e.pageY)
  } else {
    return (parseInt(event.clientY) + parseInt(document.documentElement.scrollTop ?   document.documentElement.scrollTop : document.body.scrollTop))
  }
}



//this used to be in the <body> tag: onmousemove="getPos(event)" onmouseup="mouseStatus='up'"
//window.onmousemove=function(event){ getPos(event); }
//window.onmouseup=function() { mouseStatus='up';}
//document.onmousemove=getPos; 
//document.onmouseup=setMouseStatus;
