function checkTopLevel(){
if(window.top != window.parent){
	window.top.location = window.top.location;
}
}	

function ConfirmDelete(){
	return !confirm("Are you sure you wish to remove this item?");
}
		
function checkTextBoxValid(){
	var key = event.keyCode;
	// control keys
	if ((key==null) || (key==0) || (key==8) || 
		(key==9) || (key==13) || (key==27) )
			return true;

	var letter = String.fromCharCode(key);
	switch(window.event.srcElement.chars){
		case "NUMERIC":
		if ((("0123456789").indexOf(letter) > -1))
			return true;
		else
			return false;
		break;
		case "ALPHA":
		if ((("abcdefghijklmnopqrstuvwxyz").indexOf(letter) > -1))
			return true;
		else
			return false;
		break;
		case "ALPHANUMERIC":
		if ((("abcdefghijklmnopqrstuvwxyz0123456789").indexOf(letter) > -1))
			return true;
		else
			return false;
		break;
	}
	///in case its not one of the above
	return true;
}
		
function URLEncode(str){
     var result = "";
     for (var i = 0; i < str.length; i++) {
          if (str.charAt(i) == "+") result += " ";
          else result += str.charAt(i);
     }
     return escape(result);
}


function SetVis(objName, visible){
	var obj = document.getElementById(objName);
	if (obj != null){
	
	if (visible){
		obj.style.visibility = "visible";
		obj.style.display = "inline";
	}
	else{
		obj.style.display = "none";
		obj.style.visibility = "hidden";
	}
	}
	else{
		alert('Couldnt find object ' + objName);
	}
}

function IsVis(objName){
	var obj = document.getElementById(objName);
	return (obj.style.visibility != "hidden");
}

function ToggleVis(objName){
	try{
	var obj = document.getElementById(objName);
	
	var visible = (obj.style.visibility != "hidden");
	
	if (visible){
		obj.style.display = "none";
		obj.style.visibility = "hidden";
	}
	else{
		obj.style.display = "inline";
		obj.style.visibility = "visible";
	}
	
	}catch(er){
		alert(er);
	}
}

function SetComboVal(comboID, val){
		combo = document.getElementById(comboID);
		for(i=0;i < combo.options.length;i++){
			if (combo.options[i].value == val){
				combo.options[i].selected = true;
			}			
		}
}

/**
 * COMMON DHTML FUNCTIONS
 * These are handy functions I use all the time.
 *
 * By Seth Banks (webmaster at subimage dot com)
 * http://www.subimage.com/
 *
 * Up to date code can be found at http://www.subimage.com/dhtml/
 *
 * This code is free for you to use anywhere, just keep this comment block.
 */

/**
 * X-browser event handler attachment and detachment
 * TH: Switched first true to false per http://www.onlinetools.org/articles/unobtrusivejavascript/chapter4.html
 *
 * @argument obj - the object to attach event to
 * @argument evType - name of the event - DONT ADD "on", pass only "mouseover", etc
 * @argument fn - function to call
 */
function addEventXB(obj, evType, fn){
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, false);
    return true;
 } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
 } else {
    return false;
 }
}
function removeEventXB(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
}



//GVB 4 July 2003
//Sets up numField0,2,6
var x = null; //this helps the document model load....
//window.attachEvent('onload',SetupStyles);



addEventXB(window,'load',SetupStyles);
function SetupStyles() {	
var obj;	
var inputs = window.document.getElementsByTagName('input');
for (var x = 0; x < inputs.length; x++) {
obj = inputs[x];
//format all the numeric fields properly.
var foundDot = false;
var numDec = 0;
var newValue = "";
var oldValue = "";		
try {
oldValue = obj.innerText;
} catch(e) {}
try {
if (oldValue == null || oldValue == "")
oldValue = obj.value; 
} catch(e) {}
if (obj.className.toLowerCase() == "numericfield6") numDec = 6;
if (obj.className.toLowerCase() == "numericfield2") numDec = 2;	
if (oldValue != null && numDec != 0 && oldValue != "") {
for(var j=0; j < oldValue.length; j++) {	
if (oldValue.charCodeAt(j) != 46) 
newValue = newValue + oldValue.charAt(j);
else { //we have found the dot
foundDot = true;
newValue = newValue + oldValue.charAt(j); //add in the dot
for (var k=1; k <= numDec; k++) {
if (j+k < oldValue.length) 
if (oldValue.charCodeAt(j+k) != 46) newValue = newValue + oldValue.charAt(j+k);
else newValue = newValue + '0';
else newValue = newValue + '0';
}
break;
}
}//end for
oldValue = newValue;
if (!foundDot)
if (numDec == 6) 
if (oldValue == "") oldValue = "";
else oldValue = oldValue + ".000000";
else
if (oldValue == "") oldValue = "";
else oldValue = oldValue + ".00";
if (oldValue.charCodeAt(0) == 46) oldValue = "0" + oldValue;
try {
obj.innerText = oldValue;
} catch (e) {}

try {
obj.value = oldValue;
} catch (e) {}
}
if (obj.disabled) {
if (obj.className != '')
obj.className += ' disabled';
else
obj.className = 'disabled';
} 
}
} //end load

