//use for ALL generic windows
function openWin(URL, winName, width, height)
{
	//This launches a new window and then
	//focuses it if window.focus() is supported.
	win = window.open(URL, winName, "width=" + width + ",height=" + height + ",scrollbars=yes,toolbar=no,left=50,top=1");

	//delay a bit here because IE4 encounters errors
	//when trying to focus a recently opened window
 	setTimeout('win.focus();',250);

}

function openWinNoScroll(URL, winName, width, height)
{
	//This launches a new window and then
	//focuses it if window.focus() is supported.
	win = window.open(URL, winName, "width=" + width + ",height=" + height + ",scrollbars=no,toolbar=no,left=50,top=1");

	//delay a bit here because IE4 encounters errors
	//when trying to focus a recently opened window
 	setTimeout('win.focus();',250);	

}

//confimation box to delete items
function delItem(pstrItemName){
	if(!pstrItemName)
		pstrItemName = "item";

	 if (confirm("Are you sure you want to delete this "+pstrItemName+"?")){
	 return true;
	 }
	 else{
	 return false;
	 }
}

//confimation box to set items active status
function current(){

	 if (confirm("Are you sure you want to make this material current for this document?")){
	 return true;
	 }
	 else{
	 return false;
	 }
}


function moveToNextField(pobjCurrentField, pobjNextField, intAmount){
	//var objString = new String(pobjCurrentField.value)
	//if (objString.length ==  intAmount){
		//pobjNextField.focus();
	//}
	
	if (isNaN(pobjCurrentField.value)) {
		alert("You can only enter numbers in this field")
		pobjCurrentField.focus()
	}
}

function openMenu(menuName) {
	document.getElementById(menuName).style.display = "inline";
}

function closeMenu(menuName){
	document.getElementById(menuName).style.display = "none";
}

function getPosition(obj, pstrType){
 try {
 //alert(obj.offsetLeft)
  var position = {x:0,y:0};
  do{
   position.x += obj.offsetLeft;
   position.y += obj.offsetTop;
   obj = obj.offsetParent;
  } while(obj)
  	if (pstrType == "top"){
		return position.y;
  	}
	else{
		return position.x;
	}
 } catch (e) {
 }
}

function setPosition(menuName, pintLeft, pintTop, pstrMenuType, pintSpacingDistance){
	if (pstrMenuType == "vertical"){
		var intNewTop = parseInt(pintTop) - pintSpacingDistance;
		var intNewLeft = pintLeft;
	}
	else if(pstrMenuType == "both"){
		var intNewTop = parseInt(pintTop) - pintSpacingDistance;
		var intNewLeft = parseInt(pintLeft) - 200;
	}
	else{
		var intNewTop = pintTop
		var intNewLeft = parseInt(pintLeft) + pintSpacingDistance;
	}
	document.getElementById(menuName).style.left = intNewLeft + "px"
	document.getElementById(menuName).style.top = intNewTop + "px"
}

//submits the form when the enter key is pressed
function submitForm(pstrControl){

	if (window.event.keyCode == 13){
		eval("__doPostBack('"+ pstrControl +"','')");
	}
}

//trims the extra space on strings
function trim(theString){ 
    theString = theString.replace(/^\s+/, "");    // LTrim 
    theString = theString.replace(/\s+$/, "");    // RTrim 
    return(theString); 
} 




