/* all functions by randy bacon.  permission given to site for use */
function checkFloat(numberVal){
	if (isNaN(numberVal) || numberVal == "") {
		return false;
	}else{
		return true;
	}
}

function checkInt(numberVal){
	if (isNaN(numberVal) || numberVal == "")
	{
		return false;
	}
	else
	{
		if (numberVal.indexOf('.') != -1)
		{
			return false;
		}
		else
		{
			if(numberVal>=0)
				return true;
			else
				return false;
		}
	}
}

function checkRealInt(numberVal)
{
	if (isNaN(numberVal) || numberVal == "")
	{
		return false;
	}
	else
	{
		if (numberVal.indexOf('.') != -1)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
}

function validDate(year,month,day){
	if(checkRealInt(year) && checkRealInt(month) && checkRealInt(day))
	{
		//trim off leading zeros
		month = parseInt(month, 10);
		day = parseInt(day, 10);
		//based on code from dynamicdrive.com
		/* Validation leap-year / february / day*/
		if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0))
			leap = 1;
		else
			leap = 0;
		if ((month == 2) && (leap == 1) && (day > 29)) {
			return false;
		}else if ((month == 2) && (leap != 1) && (day > 28)) {
			return false;
		}else if ((day > 31) && ((month == "1") || (month == "3") || (month == "5") || (month == "7") || (month == "8") || (month == "10") || (month == "12"))) {
			return false;
		}else if ((day > 30) && ((month == "4") || (month == "6") || (month == "9") || (month == "11"))) {
			return false;
		}else{
			return true;
		} 
	}
	else
	{
		return false;
	}	
}


function openWindow(URL, widthIn, heightIn, scrollsIn, reSize){
	var browser=new Object(); //this object used to figure out the browser version number and vender
	browser.version=parseInt(navigator.appVersion);
	//change options below - 0 false 1 true
	options="toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=" + reSize + ",scrollbars=" + scrollsIn;
	//change width and height below
	set_width=widthIn;
	set_height=heightIn;
	//change the following to the url of the window you want to open
	options = options + "," + "width="+set_width + "," + "height=" +set_height;
	add_win = window.open (URL,"newsite",options);
	if(!((navigator.appName== 'Microsoft Internet Explorer' && browser.version
== 4 )&& (navigator.platform == 'MacPPC' || navigator.platform ==
'Mac68k'))){//mac ie 4 doesn't support this method
		if(add_win.focus)add_win.focus();
	}
}

function checkZip(zipCode,country){
	//checks for a valid zip code base on country
	if((country.toUpperCase() == "UNITED STATES" || country.toUpperCase() == "USA" || country.toUpperCase() == "US") && (isNaN(zipCode.substr(0,5)) || zipCode.length<5 || zipCode.length>5)){
		return false;
	}else if((country.toUpperCase() == "CANADA" || country.toUpperCase() == "CA") && (zipCode.length < 6 || zipCode.length > 6)){
		return false;
	}else{
		return true;
	}
}

function confirmDel(itemName)
{
	if(confirm('Are you sure you want to delete the selected ' + itemName + '?\nThe action CANNOT be undone.'))
	{
		return true;
	}
	else
	{
		return false;
	}
}
