function checkBrowser(){
	var brows = "";
	var agt=navigator.userAgent.toLowerCase();
	var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);
	
	var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('firefox')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
	var is_nav6 = (is_nav && (is_major == 5));
	
	var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
	var is_fireFox = (agt.indexOf('firefox')!=-1);
	//alert(is_fireFox);
	
	if(is_ie5up | is_ie5_5up){
		brows = "IE";
	}
	else if (is_nav6){
		brows = "NS";
	}
	else if (is_fireFox){
		brows = "FF";
	}
if (brows == "IE" | brows == "NS" | brows == "FF"){
	return brows;
}
else{
	alert("Your browser may not be compatible.  You must install IE 5 or higher, Netscape 6.2 or higher, or FireFox 1.4 or higher.");
	return brows;
}
}
function switchDom(loc,objName){
	//alert(checkBrowser());
	if (checkBrowser() == "NS"){
		return eval(loc).document.getElementById(objName);
	}
	else if (checkBrowser() == "FF"){
		return eval(loc).document.getElementById(objName);
	}
	else if (checkBrowser() == "IE"){
		//alert(loc + ", " + objName);
		return eval(loc).document.all(objName);
	}
	else{
		return eval(loc).document.getElementById(objName);	
	}
}
//IMBED FLASH OBJECT FUNCTION - IN RESPONSE TO ADDED IE SECURITY FOR ACTIVE X CONTROLS - KZ 04/07/06
function embedFlash(objID,FFile,fW,fH,bgc,menu,sa,fObjName,fVars,al,qua,parent,wmode){
	flashObj = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + fW + '" height="' + fH + '" id="' + fObjName + '" align="' + al + '" />' +
	'<param name="allowScriptAccess" value="' + sa + '" />' +
	'<param name="movie" value="' + FFile + '" />' +
	'<param name="menu" value="' + menu + '" />' +
	'<param name="quality" value="high" />' +
	'<param name="bgcolor" value="' + bgc + '" />' +
	'<PARAM NAME="FlashVars" VALUE="' + fVars + '" />' +
	'<PARAM NAME="quality" VALUE="' + qua + '" />' +
	'<param name="wmode" value="' + wmode + '"/>' +
	'<embed src="' + FFile + '" menu="' + menu + '" quality="high" bgcolor="' + bgc + '" width="' + fW + '" height="' + fH + '" name="' + fObjName + '" align="' + al + '" allowScriptAccess="' + sa + '" FlashVars="' + fVars + '" wmode="' + wmode + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
	'</object>'
	//alert(flashObj);
	switchDom(parent,objID).innerHTML = flashObj;
}
//EMAIL VALIDATION
function validateEmail(email) {
            // Script prepared by Answer Studios / ToUnite.com
            // Version 1.1 (Feb. 1, 2001)
            // Logic:
            // 8 steps: Preset elements, 6 error checks, write error (if appicable)
            // --- Presets
            var count = 0;
            var error = "";
            // #1 Check if email address field is blank
                        if (email == "") {
                                    error = "";
                        }
            // #1 Check for invalid characters
            // Create an arroay of invalid characters
            if (error == "") {
            var invChars = new Array(" ", "#", "$", "%", "!", "^", "~", "'", "*", "(", ")", ",", "<", ">", "/", "\\","\r","\t");
            // Loop through Array and see if there are any matches, if yes then throw and error.
            for (var i = 0; i < invChars.length; i++) {
                        if (email.indexOf(invChars[i]) >= 0) {
                                    error = error + "Email address: Invalid character found.\n";
                        }
            }
            }
            // #2 If passed previous error step  >>> Check the @ symbol (1 instance of the symbol)
            if (error == "") {
                        // Loop by character through the email string for the @ symbol, count the number of instances
                        for (var i = 0; i < email.length; i++) {
                                    if (email.charAt(i) == "@") {
                                                count = count+1;
                                    }
                        }
                        // If there is not 1 instance (0 or more than 1) then throw an error.
                        if (count != 1) {
                                    error = error + "Email address: Missing the @ symbol.\n";
                        }
            }
            // Split the email string by the @ sign, forming the name portion and the domain portion.
            if (error == "") {
                        var splitEmail = email.split("@");
                        var emailName = splitEmail[0];
                        var emailDom = splitEmail[1];
                        // #3 Verify minimum characters in name portion (minimum of 1), if not throw an error.
                        if (emailName.length<1) {
                                    error = error + "Email address: Problem with the email name.\n";
                        }
                        // #4 Verify there is a . (dot) in the domain portion
                        if (emailDom.indexOf(".")<0) {
                                    error = error + "Email address: Missing the dot for the domain name.\n";
                        } else {
                                    // #5 Verify a minimum of 2 characters before the dot, if not throw an error.
                                    // First split the domain portion by the . (dot)
                                    var splitDom = emailDom.split(".");
                                    if (splitDom[0].length<2) {
                                                error = error + "Email address: Problem with the domain name or domain name missing.\n";
                                    }
                                    // #6 Verify a minimum of 2 characters after the dot, if not throw an error.
                                    if (splitDom[1].length<2) {
                                                error = error + "Email address: Invalid domain name extension (.com).\n";
                                    }
                        }
            }
            // Associate the error number into the message array for displaying results on the screen.
            if (error != ""){
              emailerror = error
            }
            else{
              emailerror = true
            }
            return emailerror
}
/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

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;
}

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;
}

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 );
}
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
}

function isDate(dtStr){
	var dErr = "";
	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){
		dErr = "The date format should be : mm/dd/yyyy.";
		return dErr;
	}
	if (strMonth.length<1 || month<1 || month>12){
		dErr = "Please enter a valid month.";
		return dErr;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		dErr = "Please enter a valid day.";
		return dErr;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		dErr = "Please enter a valid 4 digit year between "+minYear+" and "+maxYear + ".";
		return dErr;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		dErr = "Please enter a valid date";
		return dErr;
	}
return true;
}
//employment application validation
function signupSubmit(){
	var msg = "";
	if (switchDom(this,"Full_Name").value == ""){
		msg = msg + "Please enter your full name.\n";
	}
	if (switchDom(this,"Birthday").value == ""){
		msg = msg + "Please enter your birthday.\n";
	}
	else if (isDate(switchDom(this,"Birthday").value) != true){
		msg = msg + isDate(switchDom(this,"Birthday").value) + "\n";
	}
	if (switchDom(this,"Address").value == ""){
		msg = msg + "Please enter your address.\n";
	}
	else if ((switchDom(this,"Address").value.length < 2) | (switchDom(this,"Address").value.length > 100)){
		msg = msg + "The address field must contain at least 2 characters and no more than 100.\n";	
	}
	if (switchDom(this,"City").value == ""){
		msg = msg + "Please enter your city.\n";
	}
	else if ((switchDom(this,"City").value.length < 2) | (switchDom(this,"City").value.length > 100)){
		msg = msg + "The city field must contain at least 2 characters and no more than 100.\n";	
	}
	if (switchDom(this,"State").value == ""){
		msg = msg + "Please select your state.\n";
	}
	if (switchDom(this,"ZIP_Code").value == ""){
		msg = msg + "Please enter your zip code.\n";
	}
	else if (isNaN(switchDom(this,"ZIP_Code").value)){
		msg = msg + "The zip code can contain only numbers.\n";
	}
	else if (switchDom(this,"ZIP_Code").value.length < 5){
		msg = msg + "The zip code must contain at least 5 digits.\n";
	}
	if (switchDom(this,"Email").value == ""){
		msg = msg + "Please enter your email address.\n";
	}
	else{
		if (validateEmail(switchDom(this,"Email").value) == true){
			
		}
		else{
			msg = msg + validateEmail(switchDom(this,"Email").value);
		}
	}
	if (switchDom(this,"Phone_Number").value == ""){
		msg = msg + "Please enter your phone number.\n";
	}
	else if (isNaN(switchDom(this,"Phone_Number").value)){
		msg = msg + "The phone number can contain only numbers.\n";
	}
	else if (switchDom(this,"Phone_Number").value.length < 10){
		msg = msg + "The phone number must contain at least 10 digits.\n";
	}
	if (msg == ""){
		return true;
		//switchDom(this,"newsSignup").submit();
	}
	else{
		msg = "Please correct the data below: \n\n" + msg;
		alert(msg);
		return false;
	}
}
//league registration validation
function leagueRegSubmit(){
	var msg = "";
	if (switchDom(this,"Name").value == ""){
		msg = msg + "Please enter your full name.\n";
	}
	if (switchDom(this,"Address").value == ""){
		msg = msg + "Please enter your address.\n";
	}
	else if ((switchDom(this,"Address").value.length < 2) | (switchDom(this,"Address").value.length > 100)){
		msg = msg + "The address field must contain at least 2 characters and no more than 100.\n";	
	}
	if (switchDom(this,"City").value == ""){
		msg = msg + "Please enter your city.\n";
	}
	else if ((switchDom(this,"City").value.length < 2) | (switchDom(this,"City").value.length > 100)){
		msg = msg + "The city field must contain at least 2 characters and no more than 100.\n";	
	}
	if (switchDom(this,"State").value == ""){
		msg = msg + "Please select your state.\n";
	}
	if (switchDom(this,"ZIP_Code").value == ""){
		msg = msg + "Please enter your zip code.\n";
	}
	else if (isNaN(switchDom(this,"ZIP_Code").value)){
		msg = msg + "The zip code can contain only numbers.\n";
	}
	else if (switchDom(this,"ZIP_Code").value.length < 5){
		msg = msg + "The zip code must contain at least 5 digits.\n";
	}
	if (switchDom(this,"Email").value == ""){
		msg = msg + "Please enter your email address.\n";
	}
	else{
		if (validateEmail(switchDom(this,"Email").value) == true){
			
		}
		else{
			msg = msg + validateEmail(switchDom(this,"Email").value);
		}
	}
	if (switchDom(this,"Day_Phone").value == ""){
		msg = msg + "Please enter your day time phone number.\n";
	}
	else if (isNaN(switchDom(this,"Day_Phone").value)){
		msg = msg + "The day time phone number can contain only numbers.\n";
	}
	else if (switchDom(this,"Day_Phone").value.length < 10){
		msg = msg + "The day time phone number must contain at least 10 digits.\n";
	}
	if (switchDom(this,"Evening_Phone").value == ""){
		msg = msg + "Please enter your evening phone number.\n";
	}
	else if (isNaN(switchDom(this,"Evening_Phone").value)){
		msg = msg + "The evening phone number can contain only numbers.\n";
	}
	else if (switchDom(this,"Evening_Phone").value.length < 10){
		msg = msg + "The evening phone number must contain at least 10 digits.\n";
	}
	if (switchDom(this,"Team_Member_Count").value == ""){
		msg = msg + "Please select the number of team members.\n";
	}
	if (!switchDom(this,"Mens_League").checked & !switchDom(this,"Ladies_League").checked & !switchDom(this,"Coed_League").checked & !switchDom(this,"Senior_League").checked & !switchDom(this,"Youth_League").checked & !switchDom(this,"Adult_Youth_League").checked){
		msg = msg + "Please check the type of league.\n";
	}
	if (msg == ""){
		return true;
		//switchDom(this,"newsSignup").submit();
	}
	else{
		msg = "Please correct the data below: \n\n" + msg;
		alert(msg);
		return false;
	}
}
//birthday party signup validation
function bdayRegSubmit(){
	var msg = "";
	if (switchDom(this,"your_name").value == ""){
		msg = msg + "Please enter your name.\n";
	}
	if (switchDom(this,"childs_name").value == ""){
		msg = msg + "Please enter the birthday child's name.\n";
	}
	if (switchDom(this,"Email").value == ""){
		msg = msg + "Please enter your email address.\n";
	}
	else{
		if (validateEmail(switchDom(this,"Email").value) == true){
			
		}
		else{
			msg = msg + validateEmail(switchDom(this,"Email").value);
		}
	}
	if (switchDom(this,"area_code").value == ""){
		msg = msg + "Please enter an area code.\n";
	}
	else if (isNaN(switchDom(this,"area_code").value)){
		msg = msg + "The area code can contain only numbers.\n";
	}
	else if (switchDom(this,"area_code").value.length < 3){
		msg = msg + "The area code must contain at least 3 digits.\n";
	}
	if (switchDom(this,"phone_number").value == ""){
		msg = msg + "Please enter your phone number.\n";
	}
	else if (isNaN(switchDom(this,"phone_number").value)){
		msg = msg + "The phone number can contain only numbers.\n";
	}
	else if (switchDom(this,"phone_number").value.length < 7){
		msg = msg + "The phone number must contain at least 7 digits.\n";
	}
	if (switchDom(this,"child_age").value == ""){
		msg = msg + "Please enter the child's age.\n";
	}
	else if (isNaN(switchDom(this,"child_age").value)){
		msg = msg + "The child's age can contain only numbers.\n";
	}
	if (switchDom(this,"how_many_children").value == ""){
		msg = msg + "Please enter the number of children.\n";
	}
	else if (isNaN(switchDom(this,"how_many_children").value)){
		msg = msg + "The number of children can contain only numbers.\n";
	}
	if (switchDom(this,"how_many_adults").value == ""){
		msg = msg + "Please enter the number of adults.\n";
	}
	else if (isNaN(switchDom(this,"how_many_adults").value)){
		msg = msg + "The number of adults can contain only numbers.\n";
	}
	if (switchDom(this,"preferred_date_of_party").value == ""){
		msg = msg + "Please enter the preferred date of the party.\n";
	}
	else if (isDate(switchDom(this,"preferred_date_of_party").value) != true){
		msg = msg + isDate(switchDom(this,"preferred_date_of_party").value) + "\n";
	}
	if (switchDom(this,"package_selection").value == ""){
		msg = msg + "Please select a preferred package.\n";
	}
	if (msg == ""){
		return true;
	}
	else{
		msg = "Please correct the data below: \n\n" + msg;
		alert(msg);
		return false;
	}
}
//lane reservations validation
function laneResSubmit(){
	var msg = "";
	if (switchDom(this,"Name").value == ""){
		msg = msg + "Please enter your full name.\n";
	}
	if (switchDom(this,"Address").value == ""){
		msg = msg + "Please enter your address.\n";
	}
	else if ((switchDom(this,"Address").value.length < 2) | (switchDom(this,"Address").value.length > 100)){
		msg = msg + "The address field must contain at least 2 characters and no more than 100.\n";	
	}
	if (switchDom(this,"City").value == ""){
		msg = msg + "Please enter your city.\n";
	}
	else if ((switchDom(this,"City").value.length < 2) | (switchDom(this,"City").value.length > 100)){
		msg = msg + "The city field must contain at least 2 characters and no more than 100.\n";	
	}
	if (switchDom(this,"State").value == ""){
		msg = msg + "Please select your state.\n";
	}
	if (switchDom(this,"Zip_Code").value == ""){
		msg = msg + "Please enter your zip code.\n";
	}
	else if (isNaN(switchDom(this,"Zip_Code").value)){
		msg = msg + "The zip code can contain only numbers.\n";
	}
	else if (switchDom(this,"Zip_Code").value.length < 5){
		msg = msg + "The zip code must contain at least 5 digits.\n";
	}
	if (switchDom(this,"Email").value == ""){
		msg = msg + "Please enter your email address.\n";
	}
	else{
		if (validateEmail(switchDom(this,"Email").value) == true){
			
		}
		else{
			msg = msg + validateEmail(switchDom(this,"Email").value);
		}
	}
	if (switchDom(this,"Daytime_Phone").value == ""){
		msg = msg + "Please enter your day time phone number.\n";
	}
	else if (isNaN(switchDom(this,"Daytime_Phone").value)){
		msg = msg + "The day time phone number can contain only numbers.\n";
	}
	else if (switchDom(this,"Daytime_Phone").value.length < 10){
		msg = msg + "The day time phone number must contain at least 10 digits.\n";
	}
	if (switchDom(this,"Evening_Phone").value == ""){
		msg = msg + "Please enter your evening phone number.\n";
	}
	else if (isNaN(switchDom(this,"Evening_Phone").value)){
		msg = msg + "The evening phone number can contain only numbers.\n";
	}
	else if (switchDom(this,"Evening_Phone").value.length < 10){
		msg = msg + "The evening phone number must contain at least 10 digits.\n";
	}
	if (switchDom(this,"Day_Wanted").value == ""){
		msg = msg + "Please enter the desired date.\n";
	}
	else if (isDate(switchDom(this,"Day_Wanted").value) != true){
		msg = msg + isDate(switchDom(this,"Day_Wanted").value) + "\n";
	}
	if (switchDom(this,"Time_Wanted").value == ""){
		msg = msg + "Please enter the desired time.\n";
	}
	else if (switchDom(this,"Time_Wanted").value.length < 3 | switchDom(this,"Time_Wanted").value.length > 20){
		msg = msg + "The desired time must contain between 3 and 20 characters.\n";
	}
	if (switchDom(this,"Number_Of_People").value == ""){
		msg = msg + "Please enter the number of people.\n";
	}
	else if (isNaN(switchDom(this,"Number_Of_People").value)){
		msg = msg + "The number of people can contain only numbers.\n";
	}
	if (msg == ""){
		return true;
		//switchDom(this,"newsSignup").submit();
	}
	else{
		msg = "Please correct the data below: \n\n" + msg;
		alert(msg);
		return false;
	}
}
