// --------------------------------------------------------------------------
// JavaScript- Funktionen (C) Thomas Jähnel 2001-2004 Projekt ADLERHOME
// --------------------------------------------------------------------------
// Globale Variablen:
// --------------------------------------------------------------------------
// Allgemeine Funktionen:
// --------------------------------------------------------------------------
function start(a){
// Standard- Frameseite:
  if(a == 0){
    rightclick();
    frametest();
  }
// Startseite INDEX.HTML, keine Frame-Prüfung
  if(a == 1){
  rightclick();
  }
// Mitgliederseiten, geschützter Bereich, keine Anzeige, rechter Mausklick wegen Download aktiv
  if(a == 2){
    frametest();
    // alert("Privatbereich");
  }
}
// --------------------------------------------------------------------------
function frametest(){
  if(parent.frames.length == 0 && screen.width >= "640"){
  alert("Diese Seite ist Teil eines Frame-Set. Sie finden unsere Startseite unter www.adlerhome.de");
  }
}
// --------------------------------------------------------------------------
// Code verstecken:
// --------------------------------------------------------------------------
function right(e) {
	if (document.layers && (e.which==3 || e.which==2))  {
		window.status="Rechte Maustaste ist abgeschaltet!"
		return false;
	}
	else if (document.all && (event.button==2 || event.button==3)) {
		window.status="Rechte Maustaste ist abgeschaltet!"
		openclosewindow()
		return false;
	}
}
function openclosewindow() {
	var windownews=window.open("", "", "status=no,location=no,toolbar=no,menubar=no,resizable=no,scrollbars=no,width=50,height=50,top=20000,left=200");
	windownews.close()
}
function rightclick(){
  if (document.all) {
	document.onmouseup=right;
	window.onmouseup=right;
  }
  if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=right;
  }
}
// --------------------------------------------------------------------------
// PreLoad Images
// --------------------------------------------------------------------------
var myimages=new Array();
function preloadimages(){
  for (i=0;i<preloadimages.arguments.length;i++){
    myimages[i]=new Image()
    myimages[i].src=preloadimages.arguments[i]
  }
}
// --------------------------------------------------------------------------
// Adlerhome - Code - wird nicht verwendet!! Ersetzt Grafik bei Mouse over.
// --------------------------------------------------------------------------
//<body onLoad="PreloadImages1('images/b1_home.gif','images/b1_wohnung.gif','images/b1_preise.gif','images/b1_anreise.gif','images/b1_umgebung.gif','images/b1_freizeit.gif','images/b1_kontakt.gif')">
//<a href="wohnung.htm" target="main" onMouseOut="SwapImgRestore()" onMouseOver="SwapImage('b_wohnung','','images/b1_wohnung.gif',1)"><img src="images/b_wohnung.gif" name="b_wohnung" width="119" height="31" border="0" alt="Wohnung"></a>

function SwapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function PreloadImages1() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=PreloadImages1.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function FindObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=FindObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function SwapImage() { //v3.0
  var i,j=0,x,a=SwapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=FindObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// --------------------------------------------------------------------------
function Go(x){
  if(x == "nothing"){
    document.forms[0].reset();
    document.forms[0].elements[0].blur();
    return;}
  else
    if(x == "end") top.location.href = parent.frames[1].location;
    else{
      parent.frames[1].location.href = x;
      document.forms[0].reset();
      document.forms[0].elements[0].blur();}
}
// --------------------------------------------------------------------------
// Begruessung
// --------------------------------------------------------------------------
function gruss(){ 
       today = new Date()
        if(today.getMinutes() < 10){
        pad = "0"}
        else
        pad = "";
        document.write ;if((today.getHours() >=6) && (today.getHours() <=11)){
        document.write(" auf alle, die schon so früh aufgestanden sind, um unsere Homepage zu besuchen!") //nach 6 Uhr bis 11 Uhr
        }
        if((today.getHours() >=12) && (today.getHours() <=16)){
        document.write(" und einen schönen guten Tag auf unserer Homepage!") // nach 12 Uhr bis 16 Uhr
        }
        if((today.getHours() >=17) && (today.getHours() <=23)){
        document.write(" und einen schönen guten Abend auf unserer Homepage!") //nach 17 Uhr bis 23 Uhr
        }
        if((today.getHours() >=0) && (today.getHours() <=4)){
        document.write(" auf alle, die noch zu so später Stunde unsere Homepage besuchen!")
        }
        if((today.getHours() >=4) && (today.getHours() <=6)){
        document.write(" auf alle, die noch vor dem Aufstehen unsere Homepage besuchen!")
        }
}
// --------------------------------------------------------------------------
// Newsticker
// --------------------------------------------------------------------------
var id,pause=0,position=0;
function ticker() {
  var spc50="                                                  "
  //var i,k,msg=spc50+"+++   Der Kartenvorverkauf beginnt am 14.01.2002.   +++   Kartenvorverkaufsstellen und Online - Verkauf unter >Veranstaltungen<   +++"+spc50;
  //var i,k,msg=spc50+"+++   In diesem Jahr werden wir das Rathaus am 11.11. um 17:17 erstürmen   +++   Wir hoffen auf rege Anteilnahme!   +++"+spc50;
  //var i,k,msg=spc50+"+++   Wir begrüssen alle Gäste auf unseren Webseiten!   +++"+spc50;
  //var i,k,msg=spc50+"+++   Bitte beachten sie die Veranstaltungstermine der Saison 2003/04!   +++"+spc50;
  var i,k,msg=spc50+"+++   Es sind noch Ferientermine frei - buchen sie so schnell wie möglich!   +++"+spc50;
        // increase msg
        k=(600/msg.length)+1;
        for(i=0;i<=k;i++) msg+=" "+msg;
        // show it to the window
        document.ticker.newsticker.value=msg.substring(position,position+600); //600=Laenge
        // set new position
        if(position++==600) position=0;
        // repeat at entered speed 
        id=setTimeout("ticker()",50); //50=Geschwind.
}
// --------------------------------------------------------------------------
// CountDown
// --------------------------------------------------------------------------
var DT_msPerDay, DT_msPerHour, DT_msPerMinute, DT_msPerSecond;
var DT_TimerOn, DT_TimerId;

function DT_showCount(dateBegin, dateEnd, boxB){
  var timeDiff=dateEnd.getTime()-dateBegin.getTime();
  if (timeDiff<=0){
    boxB.value=" "; return(false);}
  else{
    var dd=Math.floor(timeDiff/DT_msPerDay);
    timeDiff=timeDiff-dd*DT_msPerDay;
    var hh=Math.floor(timeDiff/DT_msPerHour);
    timeDiff=timeDiff-hh*DT_msPerHour;
    var mm=Math.floor(timeDiff/DT_msPerMinute);
    timeDiff=timeDiff-mm*DT_msPerMinute;
    var ss=Math.floor(timeDiff/DT_msPerSecond);
    hh=(hh>=10?hh:"0"+hh);
    mm=(mm>=10?mm:"0"+mm);
    ss=(ss>=10?ss:"0"+ss);

    //if (dd <= 1) boxB.value=dd+" Tag "+hh+" Stunde(n) "+mm+" Minute(n) "+ss+" Sekunde(n)"; 
    //else boxB.value=dd+" Tage, "+hh+" Stunde(n) "+mm+" Minute(n) "+ss+" Sekunde(n)";
    //if (dd == 0) boxB.value=dd+" Tage, "+hh+" Stunde(n) "+mm+" Minute(n) "+ss+" Sekunde(n)";

    if (dd <= 1) boxB.value=dd; 
    else boxB.value=dd;
    if (dd == 0) boxB.value=dd;
    
    return(true);
  }
}

function DT_showDate(dateD, boxB){
  // nicht benötigt
  var y=dateD.getYear();
  var m=dateD.getMonth()+1;
  var d=dateD.getDate();
  var hh=dateD.getHours();
  var mm=dateD.getMinutes();
  var ss=dateD.getSeconds();
  m=(m>=10?m:"0"+m);
  d=(d>=10?d:"0"+d);
  hh=(hh>=10?hh:"0"+hh);
  mm=(mm>=10?mm:"0"+mm);
  ss=(ss>=10?ss:"0"+ss);
  boxB.value=d+"."+m+"."+y+"  "+hh+" Stunde(n) "+mm+" Minute(n) "+ss+" Sekunde(n)";
}

function DT_stopTimer(){
  if (DT_TimerOn){
    clearTimeout(DT_TimerId);
    DT_TimerOn=false;}
}

function DT_startTimer(){
  var dateNow=new Date();
  var dateEOT=new Date(countdown_datum);
  var On=DT_showCount(dateNow, dateEOT, document.ausgabe.tage);
  if (On){
    DT_TimerId=setTimeout("DT_startTimer()", 1000);
    DT_TimerOn=true;}
  else DT_stopTimer();
}

function DT_initTimer(){
  DT_msPerDay=24*60*60*1000;
  DT_msPerHour=60*60*1000;
  DT_msPerMinute=60*1000;
  DT_msPerSecond=1000;
  DT_TimerOn=false;
  DT_TimerId=null;
  DT_stopTimer();
  DT_startTimer();
}

function countdown()
{DT_initTimer();}

var countdown_datum='02/23/2004 23:59:00';
//var countdown_datum='March 03, 2003 19:30:00';
//var countdown_datum='November 11, 2002 17:17:00';
// --------------------------------------------------------------------------
// Testfunktionen/ Beispiele
// --------------------------------------------------------------------------
function testfunction1(){
  alert('Click to continue...');
  if (confirm('Do you want to open two small windows?')){
  open('test.htm','_blank','width=150,height=150');
  open('test.htm','_blank','width=100,height=100');
  }
  else{
  alert('Canceled...');
  }
}
// --------------------------------------------------------------------------
function back(){
  var xy=window.history.back();
}
function gehezu(form){
  var myindex=form.dest.selectedIndex
  window.location.replace(form.dest.options[myindex].value);
}
// --------------------------------------------------------------------------

