function isInteger(value, text, canBeEmpty)
{
	if(canBeEmpty && value.length==0) return true;
	
	if(canBeEmpty==false && value.length==0)
	{
		alert(text+" must be entered");
		return false;
	}

	regex = new RegExp("^\-?[0-9]+$");
	if(!regex.test(value))
	{
		alert(text+" must be a valid numberic format");
		return false;
	}
	
	return true;
}

function isFloatingPoint(value, text, canBeEmpty)
{
	if(canBeEmpty && value.length==0) return true;
	
	if(canBeEmpty==false && value.length==0)
	{
		alert(text+" must be entered");
		return false;
	}
	
	regex = new RegExp("^\-?[0-9]*[\.]?[0-9]*$");
	if((!regex.test(value)) || (value=="."))
	{
		alert(text+" must be a valid numberic format");
		return false;
	}

	return true;
}

function isFloatingPointDP(value, text, canBeEmpty, limit)
{
	if(canBeEmpty && value.length==0) return true;

	if(canBeEmpty==false && value.length==0)
	{
		alert(text+" must be entered");
		return false;
	}

	regex = new RegExp("^\-?[0-9]*[\.]?[0-9]{0,"+limit+"}$");
	if((!regex.test(value)) || (value=="."))
	{
		alert(text+" must be a valid numberic format limited to "+limit+" decimal places");
		return false;
	}

	return true;
}


function withinLength(value, minLen, maxLen, text)
{
	if((value.length < minLen) || (value.length > maxLen))
	{
		if(value.length==0) alert(text+" must be entered");
		else alert(text+" must range from "+minLen+" to "+maxLen+" characters");
		return false;
	}
	
	return true;
}

function minLength(value, minLen, text)
{
	if(value.length < minLen)
	{
		if(value.length==0) alert(text+" must be entered");
		else alert(text+" must contain "+minLen+" or more characters");
		return false;
	}
	
	return true;	
}

function maxLength(value, maxLen, text)
{
	if(value.length > maxLen)
	{
		alert(text+" can contain no more than "+maxLen+" characters");
		return false;
	}
	
	return true;	
}

function withinSelectionRange(selection, minIndex, maxIndex, text)
{
	if((selection.selectedIndex < minIndex) || (selection.selectedIndex > maxIndex))
	{
		alert(text+" must be selected");
		return false;
	}
	
	return true;
}

function isEmail(email, text)
{
	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
  	if(!regex.test(email))
	{
		alert(text);
		return false;
	}
	
	return true;
}

function booleanIsEmail(email)
{
	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	return regex.test(email);
}

var popWin = null    // use this when referring to pop-up window
var winCount = 0
var winName = "popWin"
function openPopWin(winURL, winWidth, winHeight, winFeatures)
{
	// toolbar=1,scrollbars=1,location=1,status=1,menubar=1,resizable=1
	var winLeft = (screen.availWidth - winWidth) / 2
	var winTop = (screen.availHeight - winHeight) / 2
	winName = "popWin" + winCount++			 		// unique name for each pop-up window
	closePopWin()									// close any previously opened pop-up window
	popWin = window.open(winURL, winName, "width="+winWidth+", height="+winHeight+", left="+winLeft+", top="+winTop+winFeatures);
}

function closePopWin()
{    // close pop-up window if it is open 
	if (navigator.appName != "Microsoft Internet Explorer" || parseInt(navigator.appVersion) >=4) //do not close if early IE
	if(popWin != null) if(!popWin.closed) popWin.close() 
}

function getLocation(winWidth, winHeight, winLeft, winTop)
{
	return ""
}

function openWindow(url, name, w, h, features)
{
	var left = (screen.availWidth - w) / 2
	var top = (screen.availHeight - h) / 2
	window.open(url, name, "width="+w+", height="+h+", left="+left+", top="+top+features);
}