NumberImgMenu	= new Array();
var is4;
if(navigator.appName=="Netscape" || navigator.appName=="Microsoft Internet Explorer") {
 if (parseInt(navigator.appVersion)<4) { is4=false; }
 else {is4=true; }
}

if (is4) {
	for(var i = 1; i < 10; i++)
	{
		NumberImgMenu[i]= new Image();
		NumberImgMenu[i].src= "gifs/m"+i+"a.gif";
	}
}


function setZelleStatus(theRow, thePointerColor,pfeil) {
    var theCells = null;
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
		
		var rowCellsCnt  = theRow.cells.length;		
    var currentColor = null;
    var newColor     = null;
    // Opera does not return valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theRow.getAttribute) != 'undefined' && typeof(theRow.getAttribute) != 'undefined') {
            theRow.setAttribute('bgcolor', thePointerColor, 0);
 			     for (var c = 0; c < rowCellsCnt-1; c++) {
            theCells[c].style.backgroundColor = thePointerColor;
        	}

    }
    else {
			     for (var c = 0; c < rowCellsCnt-1; c++) {
            theCells[c].style.backgroundColor = thePointerColor;
        	}
    }

						if (pfeil<0) {
							pfeil=Math.abs(pfeil);

							menu_pfeil_gelb(pfeil)			
						} else {
							menu_pfeil_blau(pfeil)			
						}

    return true;
} // end of the 'setPointer()' function

function menuin(bild) {
	if (!is4) return;
	document.images["m"+bild].src=NumberImgMenu[bild].src;
}

function menuout(bild) {
	if (!is4) return;
	document.images["m"+bild].src="gifs/m"+bild+".gif";
}


function menu_pfeil_blau_top(bild) {
	if (!is4) return;
	document.images["p"+bild].src="gifs/pfeil-blau-h.gif";
}

function menu_pfeil_gelb_top(bild) {
	if (!is4) return;
	document.images["p"+bild].src="gifs/pfeil-gelb-h.gif";
}

function menu_pfeil_rot_top(bild) {
	if (!is4) return;
	document.images["p"+bild].src="gifs/pfeil-rot-h.gif";
}



function menu_pfeil_blau(bild) {
	if (!is4) return;
	document.images["p"+bild].src="gifs/pfeil-blau.gif";
}

function menu_pfeil_gelb(bild) {
	if (!is4) return;
	document.images["p"+bild].src="gifs/pfeil-gelb.gif";
}

function menu_pfeil_weiss(bild) {
	if (!is4) return;
	document.images["p"+bild].src="gifs/pfeil-weiss.gif";
}

function menu_pfeil_rot(bild) {
	if (!is4) return;
	document.images["p"+bild].src="gifs/pfeil-rot.gif";
}

function setRowStatus(theRow, thePointerColor)
{

    var theCells = null;
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }


    // Opera does not return valid values with "getAttribute"
    var rowCellsCnt  = theCells.length;	
    if (typeof(window.opera) == 'undefined'
        && typeof(theRow.getAttribute) != 'undefined' && typeof(theRow.getAttribute) != 'undefined') {
        for (var c = 1; c < rowCellsCnt; c++) {
            theCells[c].setAttribute('bgcolor', thePointerColor, 0);
        } // end for


    }
    else {

        for (var c = 1; c < rowCellsCnt; c++) {
            theCells[c].style.backgroundColor = thePointerColor;
        }


    }

    return true;
} // end of the 'setPointer()' function

function setRowStatusAlle(theRow, thePointerColor)
{

    var theCells = null;
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }


    // Opera does not return valid values with "getAttribute"
    var rowCellsCnt  = theCells.length;	
    if (typeof(window.opera) == 'undefined'
        && typeof(theRow.getAttribute) != 'undefined' && typeof(theRow.getAttribute) != 'undefined') {
				theRow.setAttribute('bgcolor', thePointerColor, 0);
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].setAttribute('bgcolor', thePointerColor, 0);
        } // end for


    }
    else {

        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].style.backgroundColor = thePointerColor;
        }


    }

    return true;
} // end of the 'setPointer()' function



function checkLeer(was) {
	hstr1=was.replace(/\b\s\b/g," ");
	hstr1=hstr1.replace(/\s/g,"")
	if (hstr1=="") {
		return 0;
	} else {
		return 1;	
	}
}

function checkEmail(was) {

	var checkEmailrg   = /.*\@.*\.\w+/i;
	var checkEmailrg   = /^[_\.0-9a-z-]+@([0-9a-z][_0-9a-z-]+\.)+[a-z]{2,4}$/ig;	
	if (checkEmailrg.test(was) == false){
		return 0;
	} else {
		return 1;	
	}
}

function checkZahl(was) {
	if (checkLeer(was)==0) return 0;
 if(isNaN(was) == true)  return 0;
 return 1;
}

function checkDatum(tag,monat,jahr) {
		monat=monat-1;
	  var Jetzt = new Date();
    JetztP = Date.parse(Jetzt);	
		var vglDat =new Date(jahr,monat,tag);	
    vglDatP = Date.parse(vglDat);
				
    saisonbeginnP = Date.parse(saisonbeginn);	
    saisonendeP = Date.parse(saisonende);	

		if (vglDatP>saisonendeP || vglDatP<=saisonbeginnP) return 0
		if (vglDatP<=Jetzt) return 1
		return 2

}


function checkAnfrage() {
	// return true;
	var Jetzt = new Date();
	d=document.Formular.abTag.value;
	m=document.Formular.abMonat.value;
	y=document.Formular.abJahr.value;
	if (checkZahl(d)==0) {
		alert ("Bitte geben Sie einen Tag ein!");
		document.Formular.abTag.value="";				
		document.Formular.abTag.focus();
		return false;
	} else {
		if (d<1 || d>31) {
			alert ("Bitte geben Sie einen gültigen Tag ein!");
			document.Formular.abTag.value="";					
			document.Formular.abTag.focus();
			return false;		
		}
	}
	if (checkZahl(m)==0) {
		alert ("Bitte geben Sie einen Monat ein!");
		document.Formular.abMonat.value="";				
		document.Formular.abMonat.focus();
		return false;
	} else {
		if (m<1 || m>12) {
			alert ("Bitte geben Sie einen gültigen Monat ein!");
			document.Formular.abMonat.value="";					
			document.Formular.abMonat.focus();
			return false;		
		}
	}
	if (checkZahl(y)==0) {
		alert ("Bitte geben Sie ein Jahr ein!");
		document.Formular.abJahr.value="";				
		document.Formular.abJahr.focus();
		return false;
	} else {
		if (y<Jetzt.getFullYear() || y>Jetzt.getFullYear()+1) {
			alert ("Bitte geben Sie ein gültiges Jahr ein!");
			document.Formular.abJahr.value="";					
			document.Formular.abJahr.focus();
			return false;		
		}
	}

	if (checkDatum(d,m,y)==0) {	
		alert ("Bitte geben Sie ein gültiges Datum ein!");	
		return false;		
	}
	if (checkDatum(d,m,y)==1) {	
		alert ("Bitte geben Sie ein gültiges Datum ein!");	
		return false;		
	}

	if (checkZahl(document.Formular.anzTage.value)==0) {
		alert ("Bitte geben Sie die geplante Anzahl der Tage ein!");
		document.Formular.anzTage.value="";				
		document.Formular.anzTage.focus();
		return false;
	} else {
		if (document.Formular.anzTage.value<1 || document.Formular.anzTage.value>4) {
			alert ("Eine Buchung ist nur für 1 bis 4 Tage möglich!");
			document.Formular.anzTage.value="";					
			document.Formular.anzTage.focus();
			return false;		
		}
	}

	if (checkZahl(document.Formular.anzStunden.value)==0) {
		alert ("Bitte geben Sie die geplante Anzahl der täglichen Schulungsstunden ein!");
		document.Formular.anzStunden.value="";				
		document.Formular.anzStunden.focus();
		return false;
	} else {
		if (document.Formular.anzStunden.value<1 || document.Formular.anzStunden.value>4) {
			alert ("Eine Buchung ist nur für 1 bis 4 Stunden möglich!");
			document.Formular.anzStunden.value="";					
			document.Formular.anzStunden.focus();
			return false;		
		}
	}
	k=0;
	for (i=1;i<8;i++) {
		var x=eval("document.Formular.elements['skikurs["+i+"]']");
		if (checkZahl(x.value)==1) k=1;
	}
	if (k==0) {
		alert ("Bitte wählen sie einen Skikurs!");
		document.Formular.elements['skikurs[1]'].focus();
		return false;
	
	}
	if (checkLeer(document.Formular.Name.value)==0) {
		alert ("Bitte geben Sie Ihren Namen ein!");
		document.Formular.Name.focus();
		return false;
	} 
	if (checkLeer(document.Formular.Tel.value)==0) {
		alert ("Bitte geben Sie Ihren Telefonnummer ein!");
		document.Formular.Tel.focus();
		return false;
	} 
	if (checkEmail(document.Formular.Email.value)==0) {
		alert ("Bitte geben Sie Ihre Emailadresse ein!");
		document.Formular.Email.value="";
		document.Formular.Email.focus();
		return false;
	} 
	
	return true;

}

function checkAusruestung() {
//	 return true;
	var Jetzt = new Date();
	d=document.Formular.abTag.value;
	m=document.Formular.abMonat.value;
	y=document.Formular.abJahr.value;
	if (checkZahl(d)==0) {
		alert ("Bitte geben Sie einen Tag ein!");
		document.Formular.abTag.value="";				
		document.Formular.abTag.focus();
		return false;
	} else {
		if (d<1 || d>31) {
			alert ("Bitte geben Sie einen gültigen Tag ein!");
			document.Formular.abTag.value="";					
			document.Formular.abTag.focus();
			return false;		
		}
	}
	if (checkZahl(m)==0) {
		alert ("Bitte geben Sie einen Monat ein!");
		document.Formular.abMonat.value="";				
		document.Formular.abMonat.focus();
		return false;
	} else {
		if (m<1 || m>12) {
			alert ("Bitte geben Sie einen gültigen Monat ein!");
			document.Formular.abMonat.value="";					
			document.Formular.abMonat.focus();
			return false;		
		}
	}
	if (checkZahl(y)==0) {
		alert ("Bitte geben Sie ein Jahr ein!");
		document.Formular.abJahr.value="";				
		document.Formular.abJahr.focus();
		return false;
	} else {
		if (y<Jetzt.getFullYear() || y>Jetzt.getFullYear()+1) {
			alert ("Bitte geben Sie ein gültiges Jahr ein!");
			document.Formular.abJahr.value="";					
			document.Formular.abJahr.focus();
			return false;		
		}
	}

	if (checkDatum(d,m,y)==0) {	
		alert ("Bitte geben Sie ein gültiges Datum ein!");	
		return false;		
	}
	if (checkDatum(d,m,y)==1) {	
		alert ("Bitte geben Sie ein gültiges Datum ein!");	
		return false;		
	}

	if (checkZahl(document.Formular.anzTage.value)==0) {
		alert ("Bitte geben Sie die geplante Anzahl der Tage ein!");
		document.Formular.anzTage.value="";				
		document.Formular.anzTage.focus();
		return false;
	} else {
		if (document.Formular.anzTage.value<1 || document.Formular.anzTage.value>4) {
			alert ("Eine Buchung ist nur für 1 bis 4 Tage möglich!");
			document.Formular.anzTage.value="";					
			document.Formular.anzTage.focus();
			return false;		
		}
	}


	k=0;
	for (i=1;i<6;i++) {
		var x = new Array;
		x[1]=eval("document.Formular.elements['alter["+i+"]']");
		x[2]=eval("document.Formular.elements['groesse["+i+"]']");
		x[3]=eval("document.Formular.elements['gewicht["+i+"]']");
		x[4]=eval("document.Formular.elements['koennen["+i+"]']");
		x[5]=eval("document.Formular.elements['ski["+i+"]']");							
		if (checkZahl(x[1].value)!=0 || checkZahl(x[2].value)!=0 || checkZahl(x[3].value)!=0 || x[4].selectedIndex>0 || x[5].selectedIndex>0) {
			k=1;
			if (checkZahl(x[1].value)==0) {
				alert ("Bitte geben Sie für die "+i+". Person das Alter ein!");
				x[1].focus();
				return false;			
			}
			if (checkZahl(x[2].value)==0) {
				alert ("Bitte geben Sie für die "+i+". Person die Größe ein!");
				x[2].focus();
				return false;			
			}
			if (checkZahl(x[3].value)==0) {
				alert ("Bitte geben Sie für die "+i+". Person das Gewicht ein!");
				x[3].focus();
				return false;			
			}
			if (x[4].selectedIndex==0) {
				alert ("Bitte wählen Sie für die "+i+". Person das Können!");
				x[4].focus();
				return false;			
			}
			if (x[5].selectedIndex==0) {
				alert ("Bitte wählen Sie für die "+i+". Person einen Ski!");
				x[5].focus();
				return false;			
			}

		}
	}
	if (k==0) {
		alert ("Sie müssen zumindest eine Ausrüstung auswählen!");
		var x=eval("document.Formular.elements['alter[1]']");
		x.focus();
		return false;
	} 
	
	if (checkLeer(document.Formular.Name.value)==0) {
		alert ("Bitte geben Sie Ihren Namen ein!");
		document.Formular.Name.focus();
		return false;
	} 
	if (checkLeer(document.Formular.Tel.value)==0) {
		alert ("Bitte geben Sie Ihren Telefonnummer ein!");
		document.Formular.Tel.focus();
		return false;
	} 
	if (checkEmail(document.Formular.Email.value)==0) {
		alert ("Bitte geben Sie Ihre Emailadresse ein!");
		document.Formular.Email.value="";
		document.Formular.Email.focus();
		return false;
	} 
	
	return true;

}


function checkKontakt() {
	// return true;
	if (checkLeer(document.Formular.Name.value)==0) {
		alert ("Bitte geben Sie Ihren Namen ein!");
		document.Formular.Name.focus();
		return false;
	} 
	if (checkLeer(document.Formular.Tel.value)==0) {
		alert ("Bitte geben Sie Ihren Telefonnummer ein!");
		document.Formular.Tel.focus();
		return false;
	} 
	if (checkEmail(document.Formular.Email.value)==0) {
		alert ("Bitte geben Sie Ihre Emailadresse ein!");
		document.Formular.Email.value="";
		document.Formular.Email.focus();
		return false;
	} 
	
	return true;

}


