function enableall() 
{
	for (i = 0; i < document.ui.elements.length; i++) 
	{
		document.ui.elements[i].disabled = false;
	}
}

function popWaitWindow()
{
	var x,y;

	if (self.innerHeight) // all except Explorer
	{
		x = (self.innerWidth / 2) - 200;
		y = self.pageYOffset + (self.innerHeight / 2) - 67;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
		// Explorer 6 Strict Mode
	{
		x = (document.documentElement.clientWidth / 2) - 200;
		y = document.documentElement.scrollTop + (document.documentElement.clientHeight / 2) - 67;
	}
	else if (document.body) // other Explorers
	{
		x = (document.body.clientWidth / 2) - 200;
		y = document.body.scrollTop + (document.body.clientHeight / 2) - 67;
	}

	//alert('x = ' + x);
	//alert('y = ' + y);
	if(isie)
	{
		var wait = eval('document.all.pleasewaitScreen');
		wait.style.left = x;
		wait.style.top = y;
		wait.style.visibility="visible";
	}
	else if(isnavnew)
	{
		var wait = document.getElementById("pleasewaitScreen");
		wait.style.left = x;
		wait.style.top = y;
		wait.style.visibility="visible";
	}
	lyrWrt('pleasewaitScreen', waitHTML);
}

function movepic(img_name,img_src) 
{
   	document[img_name].src=img_src;
}

function checkRange(val,upper,lower,input,label)
{
	if (input.disabled != true)
	{
		if (isNaN(val))
		{
    			//var valexp = /^\d+$|^\d+\.\d*$|^\d*\.\d+$|^\s\d+$|^\s\d+\.\d*$|^\s\d*\.\d+$/
    			//var valid = valexp.test(val)
    
			//if (valid == false)
			//{
      			alert("Please input only numbers for the " + label);
      			input.select();
      			input.focus();
			return false;
    		}
		else
		{
      			if (val < parseFloat(lower) || val > parseFloat(upper))
			{
        			alert(label + " must fall between " + lower + " and " + upper);
        			input.select();
	      			input.focus();
				return false;
      			}
    		}
  	}

	return true;
}

function ReturnTrue()
{
	return true;
}

function checkBoxSwitch(checkbox, onvalue, offvalue, hiddenfld)
{
    	if(checkbox.checked)
	{
	  	hiddenfld.value = onvalue.value;
	} 
	else 
	{
	  	hiddenfld.value = offvalue.value;
	}
}

function FormatMoneyJS(num) 
{
	var sign, cents; 
	num = num.toString().replace(/\$|\,/g,''); 
	if (num == 0)
		return "Included";
	if (isNaN(num)) 
		num = "0"; 
	sign = (num == (num = Math.abs(num))); 
	num = Math.floor(num*100+0.50000000001); 
	cents = num%100; 
	num = Math.floor(num/100).toString(); 
	if(cents<10) 
		cents = "0" + cents; 
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) 
		num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3)); 
	return (((sign)?'':'-') + '$ ' + num + '.' + cents); 
}

function limitText(textArea, length) {
	if (textArea.value.length > length) {
		alert('This field is limited to ' + length + ' characters');
		textArea.value = textArea.value.substr(0,length);
	}
}

function trimString(str) {
  	while (str.charAt(0) == ' ')
    	str = str.substring(1);
  	while (str.charAt(str.length - 1) == ' ')
    	str = str.substring(0, str.length - 1);
  	return str;
}

function lyrWrt(Item, text) 
{
	if (isnavold) 
	{
/*
		var lyr = eval('document.' + Item + '.document');
		lyr.open();
		lyr.write(text);
		lyr.close();
*/
	}
	else if(isie)
	{
		var a = eval('document.all.' + Item);
		a.innerHTML = text;
	}
	else if(isnavnew)
	{
		document.getElementById(Item).innerHTML = text
	}
}			

function enforceInteger(this_object, allow_zero)
{
	valid = false;

	var upper = eval('document.ui.' + this_object.name + '_high');
	var lower = eval('document.ui.' + this_object.name + '_low');

	if (upper != null && lower != null) {
		if (!validateRange(this_object, upper.value, lower.value)) {
			return false;	
		}
	}

	if (isanint(this_object)) {
		if (allow_zero) {
			valid = true;
		}
		else {
			if ((this_object.value * 1) > 0) {
				valid = true;
			}
			else {
				valid = false;
			}
		}
	}

	if (!valid) {
		if (allow_zero) {
			alert('This field must contain a valid Integer.');
		}
		else {
			alert('This field must contain a valid Integer greater than zero.');
		}
//		this_object.focus();
		this_object.select();
		return false;
	}
	
	return true;
}

function isanint(this_object)
{
	valid = false;
	if (this_object.value.length > 0) {
		valid = true;
		for(var i=0;i<this_object.value.length;i++) {
			if ((this_object.value.substring(i,i+1) < '0') || (this_object.value.substring(i,i+1) > '9')) {
				valid = false;
				break;
			}
		}
	}
	return valid;
}

function validateRange(input,upper,lower)
{
	if (isNaN(input.value))
	{
		return false;
	}
	else if (input.value*1 < parseFloat(lower) || input.value*1 > parseFloat(upper))
	{
		return false;
	}

	return true;
}



