var curHeight=0 
var curPos=0 
var newPos=0 
var mouseStatus='up' 
var helpFrameVOffset = 120;

function stopHelpResize() {
	mouseStatus='up';

	helpFrameVOffset = 120;
	
	//accepts height of the div 
	var pane = window.parent.document.getElementById('helppane');
	if(pane != null) {
		//Get the current paneheight
		var tempHeight=pane.style.height;
		
		//these lines split the height value from the 'px' units 
		heightArray=tempHeight.split('p') 
		curHeight=parseInt(heightArray[0]) 

		//Size div grab handle so we don't lose it
		var handle = window.parent.document.getElementById('locatedrag');
		if(handle != null) {
			//Set the handle div location to the mouse position Y
			handle.style.height = 30+'px';
			handle.style.top = curHeight+helpFrameVOffset+'px';
		}
	}
}

//this function gets the original div height 
function setPos(e) { 
	//for handling events in ie vs. w3c 
	curevent=(typeof event=='undefined'?e:event) 
	
	//sets mouse flag as down 
	mouseStatus='down' 
	
	//gets position of click 
	curPos=curevent.clientY 
	
	helpFrameVOffset = 50;
	
	//accepts height of the div 
	var pane = window.parent.document.getElementById('helppane');
	if(pane != null) {
		//Get the current paneheight
		var tempHeight=pane.style.height;
		
		//these lines split the height value from the 'px' units 
		heightArray=tempHeight.split('p') 
		curHeight=parseInt(heightArray[0]) 

		//Size div grab handle so we don't lose it
		var handle = window.parent.document.getElementById('locatedrag');
		if(handle != null) {
			//Set the handle div location to the mouse position Y
			handle.style.height = '150px';
			handle.style.top = curHeight+helpFrameVOffset+'px';
		}
		else 
			alert('cant find window');
	}
	else {
	}
} 

//this changes the height of the div while the mouse button is depressed 
function getPos(e) { 
	if(mouseStatus=='down'){ 
		curevent=(typeof event=='undefined'?e:event) 
		
		//get new mouse position 
		newPos=curevent.clientY 
		
		//calculate movement in pixels 
		var pxMove=parseInt(newPos-curPos) 
	
		//determine new height 
		var newHeight=parseInt(curHeight+pxMove) 
	
		//conditional to set minimum height to 1 
		newHeight=(newHeight<1?1:newHeight) 
	
		//set the new height of the div 
		window.parent.document.getElementById('helppane').style.height=newHeight+'px' 
		
		//Move div grab handle so we don't lose it
		var handle = window.parent.document.getElementById('locatedrag');
		if(handle != null) {
			//Set the handle div location to the mouse position Y
			handle.style.top = newHeight+helpFrameVOffset+'px';
		}
	
		//Resize the iframe
		var iframe = window.parent.document.getElementById('helppanecontents');
		if(iframe != null) {
			iframe.style.height='100%';
		}
	} 
} 

/**
 * Toggles the visibility of the div with the specified ID
 * 
 */
function toggleHelpDivVisible(id,grab) {
	//Get ids for help pane and grab div
	var d = document.getElementById(id);
	var g = document.getElementById(grab);
	
	//Validate
	if(d != null && g != null) {
		if(d.style.display=='none') {
			//Make the help pane visible
			d.style.display='block';
			g.style.display='block';
			
			//Set the div handle location to the bottom of the help iframe
			var iframe = document.getElementById('helppanecontents');
			if(iframe != null) {
				var h1 = iframe.offsetHeight;
				var h2 = iframe.parentNode.offsetHeight;
				//alert('iframe bottom='+(h1+h2));
				g.style.top = h1+helpFrameVOffset+'px';
			}
		}
		else {
			d.style.display='none';
			g.style.display='none';
		}
	}
}

