// ----- Browser abfrage -----
function Browser() { 
	var b = navigator.appName;
	if(b == "Netscape") this.b = "ns";
	else if(b == "Microsoft Internet Explorer") this.b = "ie";
	else this.b = b;
	this.version = navigator.appVersion;
	this.v = parseInt(this.version);
	this.ns = (this.b == "ns" && this.v >= 4);
	this.ns4 = (this.b == "ns" && this.v == 4);
	this.ns5 = (this.b == "ns" && this.v == 5);
	this.ie = (this.b == "ie" && this.v >= 4);
	this.ie4 = (this.version.indexOf('MSIE 4') > 0);
	this.ie5 = (this.version.indexOf('MSIE 5') > 0);
	this.ie55 = (this.version.indexOf('MSIE 5.5') > 0);
	this.dom = ((document.createRange && (document.createRange().createContextualFragment)) ? true : false);
	this.opera = (navigator.userAgent.toLowerCase().indexOf( "opera" ) != -1)
	this.min = (this.ns || this.ie);
	var ua = navigator.userAgent.toLowerCase();
	if (ua.indexOf("win") >- 1) this.platform="win32";
	else if (ua.indexOf("mac") >- 1) this.platform="mac";
	else this.platform = "other";
}

is=new Browser()

if(is.ns4) {
	if(is.platform == 'mac') {
		document.write('<link rel="stylesheet" href="../../css/default_ns_mac.css" type="text/css">');
		document.write('<link rel="stylesheet" href="../../css/layer_ns_mac.css" type="text/css">');
	} else { 
		document.write('<link rel="stylesheet" href="../../css/default_ns4.css" type="text/css">');
		document.write('<link rel="stylesheet" href="../../css/layer_ns4.css" type="text/css">');
	}
} else if(is.opera) {
	document.write('<link rel="stylesheet" href="../../css/default_opera.css" type="text/css">');
	document.write('<link rel="stylesheet" href="../../css/layer_opera.css" type="text/css">');
} else if(is.ns5) {
	document.write('<link rel="stylesheet" href="../../css/layer_ns6.css" type="text/css">');
} else {
	document.write('<link rel="stylesheet" href="../../css/layer.css" type="text/css">');	
}

//----- Ende Browser -----

//----- begin Pop Up -----

function wopen(url,popupname,attributes) {
	win = window.open(url,popupname,attributes);
	win.focus();
}

function openPopUpLanguage(url) {
	wopen(url,"Feldschloesschen","left=100,top=100,width=201,height=213,scrollbars=no,menubar=no,location=no,toolbar=no,resizable=no");
}

function openPopUpTeilnahmebedingung(url){
	wopen(url,"Feldschloesschen","left=100,top=100,width=389,height=213,scrollbars=no,menubar=no,location=no,toolbar=no,resizable=no");
}
function openPopWerbekampagne(url) {
	wopen(url,"Feldschloesschen","left=100,top=100,width=766,height=523,scrollbars=no,menubar=no,location=no,toolbar=no,resizable=no");
}

function openPopUpOnlineAnmelden(url){
	if(is.ns) {
		wopen(url,"Feldschloesschen","left=100,top=100,width=389,height=585,scrollbars=no,menubar=no,location=no,toolbar=no,resizable=no");
	} else {
		wopen(url,"Feldschloesschen","left=100,top=100,width=389,height=606,scrollbars=no,menubar=no,location=no,toolbar=no,resizable=no");
	}
}

function openPopUpDrivers(url){
	wopen(url,"FS_Drivers","left=100,top=100,width=589,height=435,scrollbars=no,menubar=no,location=no,toolbar=no,resizable=no");	
}


function openPopShop(){
	if(is.ns) {
		wopen("/shop/index.php","Feldschloesschen","left=100,top=100,width=770,height=465,scrollbars=no,menubar=no,location=no,toolbar=no,resizable=no");
	} else {
		wopen("/shop/index.php","Feldschloesschen","left=100,top=100,width=770,height=465,scrollbars=no,menubar=no,location=no,toolbar=no,resizable=no");
	}
}

//----- end Pop Up -----


//----- liefert gewünschte Jahreszahl, den aktuellen Monat oder den aktuellen Tag -----
//----- Parameter: value = 0 --> hol die gewünschte Jahreszahl -----
//-----			   value = 1 --> hol den aktuellen Monat -----
//-----			   value = 2 --> hol den aktuellen Tag -----
function getDatum(value) {
	TimeDate = new Date();
	if(value == 0) return TimeDate.getYear();
	if(value == 1) return TimeDate.getMonth();
	if(value == 2) return TimeDate.getDate();
}

//----- end with the functions of favorite Skihuette -----

//----- begin with Plugindetection 1.0 -----
function checkPlugin(mime_type, plugin_version, active_x_name) {
	/* Abfrage für MS Internet Explorer auf MAC, Netscape und Opera	*/
	if( ((navigator.userAgent.toLowerCase().indexOf( "mac" )!= -1) && (navigator.appName == "" || navigator.appName.indexOf( "Microsoft" )!=-1))
	    ||( navigator.userAgent.toLowerCase().indexOf( "opera" ) != -1) 
	    ||( navigator.appName.indexOf("Netscape") != -1) ){
	    if( navigator.appName.indexOf("Netscape") != -1) {navigator.plugins.refresh(false); } // diese Zeile ist nur für den Netscape
		for (i = 0; i < navigator.plugins.length; i++){
			plugin = navigator.plugins[i];
			for (j = 0; j < plugin.length; j++){
				mimetype = plugin[j];
				if (mimetype){   
					if (mimetype.type == mime_type){
						enabled = (mimetype.enabledPlugin && (mimetype.enabledPlugin.name == plugin.name))?true:false;
						expr = /\d.*/;
						version = (parseFloat(expr.exec(plugin.description)) >= plugin_version)?true:false;
						if(enabled && version) return true;						
					}
				}
			}
		}
		return false;		
	}		
	/*	Abfrage für MS Internet Explorer */
	if( navigator.appName == "Microsoft Internet Explorer"){ 
	    return chkie(active_x_name);
	}
	checkPlugin = false;
}

if( navigator.appName == "Microsoft Internet Explorer") {
	document.writeln('<script language="VBScript">');
	document.writeln('function chkie(active_x_name)');
	document.writeln('Err.Clear');
	document.writeln('On Error Resume Next');
	document.writeln('Dim plugin');
	document.writeln('set plugin = CreateObject(active_x_name)');
	document.writeln('if Err.Number <> 0 then');
	document.writeln('chkie = false');
	document.writeln('else');
	document.writeln('chkie = true');
	document.writeln('end if');
	document.writeln('end function');
	document.writeln('</script>');
} 

//----- end with Plugindetection 1.0 -----

//----- begin with checkForm of online Anmelden -----

var ErrMessage = new Array(10)
var firstFocus = 0;

//----- Setzt das Eingabefeld wieder zurück, wenn eine falsche Eingabe gemacht wurde -----
function resetDate(Obj) {
	Obj.value = "";
	if(!firstFocus) {
		Obj.focus(); firstFocus++;
	}		
}

//----- check ob eine gültige Email-Adresse eingegeben wurde -----
function isEmail(string) {
	if(string.indexOf("@") == -1) return false;
	else {
		firstPart = string.split("@")
		if(firstPart[0].length < 2) return false;
		else if(firstPart[1].indexOf(".") == -1) return false;
		else return true;
	}
}

//----- check ob eine gültige Nummer eingegeben wurde -----
function isNumber(obj) {
	if(isNaN(obj.value)) return false;
	else if(obj.value == "") return false;
	else if(obj.value <= 0) return false;
	else return true;
}

//----- die Default-Fehlermeldungen für die einzelnen Eingabefelder -----
function setDefaultErrMessage() {
	ErrMessage['txtGroup'] = unescape("Bitte geben Sie an, ob Sie eine Firma, einen Verein oder eine Gruppe sind.\n")
	ErrMessage['txtSize'] = "Bitte geben Sie die Anzahl Teilnehmer an.\n"
	ErrMessage['txtVisitDate'] = unescape("Bitte geben Sie das gew%FCnschte Besuchsdatum ein.\n")
	ErrMessage['txtRunaroundDate'] = unescape("Bitte geben Sie das gew%FCnschte Ausweichdatum ein.\n")
	ErrMessage['txtName'] = "Bitte geben Sie einen Name ein.\n"
	ErrMessage['txtStreet'] = "Bitte geben Sie eine Strasse ein.\n"
	ErrMessage['txtOrt'] = "Bitte geben Sie ein Postleitzahl und einen Ort ein.\n"
	ErrMessage['txtTelFaxDay'] = unescape("Bitte geben Sie eine korrekte Telefon-/Faxnnummer an (B%FCrozeiten).\n")
	ErrMessage['txtEmail'] = "Bitte geben Sie eine korrekte E-Mail-Adresse an.\n"
}

//----- check ob es ein gültiges Datum ist -----
function checkDate(year, month, day) {
  // take care of the gregorian correction of 1582
    
  if(year==null || isNaN(year)) return false;
  else year = Number(year);
  if(month==null || isNaN(month)) return false;
  else month = Number(month);
  if(day==null || isNaN(day)) return false;
  else day = Number(day);

  if( (month<1) || (month>12) ) return false;

  if( (month==1) && ( (day<1) || (day>31) ) ) return false;

  isleap = ( (year % 4)==0 );
  if(year > 1582) {
    if(isleap) isleap = ( (year % 100)!= 0 );
    if(!isleap) isleap = ( (year % 400)== 0 );
  }
  i = (isleap) ? 29 : 28;
  if( (month==2) && ( (day<1) || (day>i) ) ) return false;

  if( (month==3) && ( (day<1) || (day>31) ) ) return false;
  if( (month==4) && ( (day<1) || (day>30) ) ) return false;
  if( (month==5) && ( (day<1) || (day>31) ) ) return false;
  if( (month==6) && ( (day<1) || (day>30) ) ) return false;
  if( (month==7) && ( (day<1) || (day>31) ) ) return false;
  if( (month==8) && ( (day<1) || (day>31) ) ) return false;
  if( (month==9) && ( (day<1) || (day>30) ) ) return false;
  if( (month==10) && ( (day<1) || (day>31) ) ) return false;
  if( (month==11) && ( (day<1) || (day>30) ) ) return false;
  if( (month==12) && ( (day<1) || (day>31) ) ) return false;

  if( (year==1582) && (month==10) && ( (day>4) && (day<15) ) ) return false;
    
//----- kontrollieren ob das Datum in der Zukunft liegt -----
  if(getDatum(0) < year) { return true; }
  else if(getDatum(0) == year) {
    if((getDatum(1)+1) < month) { return true; }
	else if((getDatum(1)+1) == month) {
      if(getDatum(2) < day) { return true; }
	  else { return false; }
	} else { return false; }
  } else { return false; }
}

//----- end with checkForm of online Anmelden -----