
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function Setup(var1)
{
	var1 = 1;
}
function setup(var1)
{
	var1 = 1;
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//Author:	Matt Mikkalson
//Last Mod: 	06/03/2005
//fn name:	Double_House_Keeper
//Desc:		Cancels Keystroke if not numeric/decimal
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
function Double_House_Keeper()
{
	var asciiVal = window.event.keyCode;

	if ((asciiVal > 31 && asciiVal < 48) || (asciiVal > 57 && asciiVal < 127))
	{
		if (asciiVal == 46)
			return true
		else		
			return false;
	}
	else
	{
		return true;
	}
	/*
	//if(asciiVal < 48 || asciiVal >57)
	{
		// KEY STROKE WAS NOT A NUMBER
		// IF CHECK TO SEE IF IT WAS A DECIMAL
		if(asciiVal == 46 || asciiVal == 9 || asciiVal ==8 || asciiVal ==14 || asciiVal ==15 || asciiVal ==13 || asciiVal ==17 || asciiVal ==18 || asciiVal ==19 || asciiVal ==20 || asciiVal ==16)
		{
			// KEY WAS A DECIMAL, BACKSPACE OR TAB ACCEPT KEY STROKE
			return true;
		}
		else
		{
			// KEY WAS NOT A DECIMAL, BACKSPACE OR TAB CANCEL KEY STROKE
			return false;
		}
	}
	else
	{
		// KEY STROKE WAS A NUMBER
		return true;
	}
	*/
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//Author:	Matt Mikkalson
//Last Mod: 	07/28/2005
//fn name:	Zip_House_Keeper
//Desc:		Cancels Keystroke if not numeric
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
function Zip_House_Keeper()
{
	// CHECK KEYSTROKE FOR - OR NUMBER IF NOT
	// ONE OF THESE KEYS THEN CANCEL KEYSTROKE
	var asciiVal = window.event.keyCode;
	
	if ((asciiVal > 31 && asciiVal < 48) || (asciiVal > 57 && asciiVal < 127))
	{
		if (asciiVal == 45)
			return true
		else		
			return false;
	}
	else
	{
		return true;
	}
	/*
	if(asciiVal < 48 || asciiVal >57)
		if (asciiVal == 45 || asciiVal == 9 || asciiVal == 8 || asciiVal ==14 || asciiVal ==15 || asciiVal ==13 || asciiVal ==17 || asciiVal ==18 || asciiVal ==19 || asciiVal ==20 || asciiVal ==16) 
		{
			return true;
		} 
		else 
		{
			return false; 
		}
	else
	{
		return true;
	}
	*/
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//Author:	Matt Mikkalson
//Last Mod: 	06/03/2005
//fn name:	Integer_House_Keeper
//Desc:		Cancels Keystroke if not numeric
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
function Integer_House_Keeper()
{
	var asciiVal = window.event.keyCode;

	if ((asciiVal > 31 && asciiVal < 48) || (asciiVal > 57 && asciiVal < 127))
	{
		return false;
	}
	else
	{
		return true;
	}
	

}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//Author:	Matt Mikkalson
//Last Mod: 	06/03/2005
//fn name:	Date_House_Keeper
//Desc:		Cancels Keystroke if not numeric/forward slash
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
function Date_House_Keeper()
{
	var asciiVal = window.event.keyCode;
	
	if ((asciiVal > 31 && asciiVal < 48) || (asciiVal > 57 && asciiVal < 127))
	{
		if (asciiVal == 47)
			return true
		else		
			return false;
	}
	else
	{
		return true;
	}
	/*
	// CHECK KEYSTROKE FOR / OR NUMBER IF NOT
	// ONE OF THESE KEYS THEN CANCEL KEYSTROKE
	if(asciiVal < 47 || asciiVal >57)
	{
		if (asciiVal == 9 || asciiVal == 8 || asciiVal ==14 || asciiVal ==15 || asciiVal ==13 || asciiVal ==17 || asciiVal ==18 || asciiVal ==19 || asciiVal ==20 || asciiVal ==16) 
		{
			return true;
		} 
		else 
		{
			return false; 
		}
	}
	else
	{
	return true;
	}*/
}

//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//Author:	Matt Mikkalson
//Last Mod: 	06/19/2005
//fn name:	isInteger
//Desc:		Returns true if all char are numbers
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//Author:	Matt Mikkalson
//Last Mod: 	06/19/2005
//fn name:	stripCharsInBag
//Desc:		Removes from string all characters in the bag array
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//Author:	Matt Mikkalson
//Last Mod: 	06/19/2005
//fn name:	daysInFebruary
//Desc:		Given Year returns the total number of days in February
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//Author:	Matt Mikkalson
//Last Mod: 	06/19/2005
//fn name:	DaysArray
//Desc:		Loops thru n and puts max days in for each month
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//Author:	Matt Mikkalson
//Last Mod: 	06/19/2005
//fn name:	isDate
//Desc:		Validates the date is in a correct format.
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)

	if (pos1==-1 || pos2==-1){
		return "format"
	}
	if (strMonth.length<1 || month<1 || month>12){
		return "month"
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return "day"
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return "year"
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		return "format"
	}
return ""
}
function ReplaceAllChars(sString)
{
	var nLenString;
	var nCount;
	var vTemp;
	var sTempString="";

	nLenString = sString.length;
	
	for(nCount=0; nCount<nLenString; nCount++)
	{
		vTemp = parseInt(sString.charAt(nCount));

		if(!(isNaN(vTemp)))
		{
			sTempString = sTempString + vTemp;
		}
	}
	sString = sTempString;
	return sString;
	
}

function ProperPhoneNumber(i)
{
	var str;
	
	str = i.value;
	
	if(str.length < 10 && str.length > 1)
	{
		alert("Please enter a valid phone number with area code.");
		
		i.focus();
		
		return;
	}
	else
	{
		if (str.length > 1)
		{
			str = ReplaceAllChars(str);
	
			str = "(" + str.substring(0,3) + ") " + str.substring(3,6) + "-" + str.substring(6, 10);
	
			i.value = str;
		}
	}
}
function CalPop(sInputName)
{
	//Author:	Matt Mikkalson
	//Last Mod: 	08/16/2005
	//fn name:	CalPop 
	//Desc:		Opens Calendar form
	window.open('Calendar.asp?N=' + escape(sInputName) + '&DT=' + escape(window.eval(sInputName).value), 'CalPop', 'toolbar=0,width=378,height=225');
}

function LocPop()
{
	//Author:	Matt Mikkalson
	//Last Mod: 	02/21/2006
	//fn name:	LocPop 
	//Desc:		Opens Calendar form

	window.open('Location_Add.asp', 'Locations', 'toolbar=0,width=500,height=350');
}

var message="";

function toggleBox(szDivID)
{
	var changeStr;
	var ImgStr;
	var theObj;
	var ImgObj;
              
	if (document.all) 
	{
		changeStr = "document.all['" + szDivID + "']";
		theObj = eval(changeStr);

		if (theObj) 
		{

			if (theObj.style.display == "none" || theObj.style.display == "")
			{
				theObj.style.display = "inline";
			}
			else
			{
				theObj.style.display = "none";
			}
		}
	} 
	else if (document.layers) 
	{
		changeStr = "document.layers['" + szDivID + "']";
		theObj = eval(changeStr);
		if (theObj) 
		{
			if (theObj.visibility == "show")
			{
				theObj.visibility = "hide";
			}
			else
			{
				theObj.visibility = "show";
			}
		}
	} 
	else if (document.getElementById) 
	{
		changeStr = "document.getElementById('" + szDivID + "')";
		theObj = eval(changeStr);
		if (theObj) 
		{
			if (theObj.style.display == "")
			{
				theObj.style.display = "block";
			}
			else
			{
				theObj.style.display = "";
			}
		}
	}
}

function OpenWindow(pag, nom)
{
	window.open (pag, nom, "location=0,status=0,scrollbars=1,resizable=1");
}
