/* <h1> &copy; Marc Bufe (Airport1), http://www.airport1.de, www-js (AT) airport1.de </h1>  */

window.onerror = errAirport1;
chkContentRipOff();

var DOM = (document.getElementById) ? 1:0, 
    IE  = (navigator.appName.indexOf("Internet Explorer") > -1) ? 1:0,
    cnt=0, sc=0, sTimeOut=null, u=" Airport1.de ", t="";

function initINDEX() {
  resolveSubPage();
  chkFramesetAndReferer(true,false);
}  
function initNAVI() {
  chkFramesetAndReferer(true,true);
  if (!parent.main) top.location.href="/";
  if (IE) rotateTitle(); 
  outDateTime(); 
}
function initHOME() {
  chkFramesetAndReferer(false,true);
}

// ### funcs mixed ###

function NaviMoveTo(nr) { 
  try {
    if (parent.navi) parent.navi.MoveTo(nr); 
  }
  catch (e) {}
}

function resolveSubPage() {
  var QryStr = location.search;
  if (QryStr && parent.main) parent.main.location.href = QryStr.substring(1,QryStr.length);
}

function chkFramesetAndReferer(pCheckFrameSet, pCheckReferer) {
  var t = top.location.href, bTopIsIndex = 1;
try { 
      bTopIsIndex = t.indexOf("irport1.de")+t.indexOf("127.0.0.1")+t.indexOf("localhost")+t.indexOf("kuhlimuh"); ///index.html");
    } catch(e) {} // no permission?

  if (pCheckFrameSet) {
    try { 
      if (bTopIsIndex <= 0) top.location.href="./"; 
    } catch(e) {} // no permission?
  }
  if (pCheckReferer) {
    try {
      d = document.referrer;
      i = d.indexOf("~bufemc")+d.indexOf("www-a1")+d.indexOf("irport1.de")+d.indexOf("127.0.0.1")+d.indexOf("localhost")+d.indexOf("kuhlimuh");
      if ((d != "") && (i <= 0) && (bTopIsIndex <= 0)) { 
        top.location.href="./";
      }
    } catch (e) {} // no permission?
  } 
}

function errAirport1(message,file,line) {
  msg = "Fehler aufgetreten:\n\n Msg: "+ message +"\n File: "+ file +"\n Line: "+ line +"\n Browser: " +navigator.userAgent;	
  bSend = confirm (msg + "\n\nSoll ich diesen Fehler an Airport1 melden?");
  if (bSend) location.href= "mailto:" + getEncryptedMail('119|119|119|64|97|105|114|112|111|114|116|49|46|100|101') + "?subject=WebsiteError&body=" + msg;
  return true;
}

function rotateTitle() { // IE only
  sc++; if (sc > 8) sc=1;
  if (sc==1) t='-=\\/=-'+u+'-=\\/=-';
  if (sc==2) t='-=\\/=-'+u+'-=\\/=-';
  if (sc==3) t='=\\/=--'+u+'--=\\/=';
  if (sc==4) t='\\/=--='+u+'=--=\\/';
  if (sc==5) t='/=--=\\'+u+'/=--=\\';
  if (sc==6) t='=--=\\/'+u+'\\/=--=';
  if (sc==7) t='--=\\/='+u+'=\\/=--';
  if (sc==8) t='-=\\/=-'+u+'-=\\/=-';
  top.document.title = t;
  if (cnt < 16) {
    sTimeOut = setTimeout("rotateTitle()", 250);
    cnt = cnt+1;
  }
  else {
    cnt=0; sc=0; sTimeOut=null;
    rotateTitle();
  }
}

function outDateTime() {
  now=new Date(); 
  if (parent.main) window.defaultStatus = "© 1997-2004 AIRPORT1 ~ "+now.toLocaleString();
  window.setTimeout("outDateTime()",1000);
}

function HideNavigationBar() {
  try {
    top.location.href=top.frames[1].location.href;
  } 
  catch (e) {} // permission bug
}

function SwitchFrames() {
  if (top.frames.length > 1) 
    top.location.href="home.htm" 
  else 
    top.location.href="index.php"
}

function chkNaviLost() {
  if (top.frames.length < 1) document.write("<div align=center><font face=verdana,helvetica,arial size=2 color=red><b>ACHTUNG: Navigationsleiste fehlt! <a href='index.php'>Um sie einzublenden bitte hier klicken</a></b></font></div>");
}

function chkContentRipOff() {
  if ((window.location.protocol=="file:") & (location.href.indexOf("www-a1") < 1)) { // warn content thieves
    top.location.href="http://www.airport1.de/fs.php?ripoff1.htm?www-copy?" + self.location.pathname;
    bSend = confirm ("Potenzielle Urheberrechtsverletzung nach §4 Abs.1 UrhG! Diese Dateien wurden von www.Airport1.de kopiert.\r\n\r\nWird Content der Airport1.de – WebSite ohne mit dem Urheber getroffene Vereinbarung von anderen auf deren WebSite benützt, so wird durch diese rechtswidrige Nutzung in das Urheberrecht und Eigentumsrecht des Urhebers eingegriffen. In diesen Fällen mißbräuchlicher Verwendung der WebSite hat der Urheber, insbesondere nach den Bestimmungen des Urheberrechtsgesetzes, Anspruch auf Unterlassung und Schadensersatz.\r\n\r\nUnerlaubte Vervielfältigung ist untersagt und wird rechtlich verfolgt!\r\n\r\nFragen? Mit Klick auf OK ist das Verfassen einer eMail möglich.");
    if (bSend) location.href="mailto:" + getEncryptedMail('119|119|119|64|97|105|114|112|111|114|116|49|46|100|101') + "?subject=WebsiteCopy";
  }
}

function getEncryptedMail(EncryptedAddress) {
  var StringArray = EncryptedAddress.split("|");
  var RealMailAddress = "";
  for (var i = 0; i <= StringArray.length - 1; i++) {
    RealMailAddress = RealMailAddress + String.fromCharCode(StringArray[i]);
  }
  return RealMailAddress;
}

function getInnerHeight() {
  if (window.innerHeight)                            
	return window.innerHeight;
  else if (document.body && document.body.clientHeight)   
	return document.body.clientHeight;
  else return 0;
}

// ### BROWSER ###

function bookmarkme () { 
  window.external.AddFavorite('http://www.airport1.de','AIRPORT1 WebSite - Marc Bufe (Airport1)'); 
}

function openSidebar() {
  _search=open('http://www.airport1.de/phpmodul/xmlrss.php', '_search');
}

function openWindow(pURL, pName, pWidth, pHeight) {
  var para = "toolbar=no,directories=no,status=no,scrollbars=no,resize=no,menubar=no";
  if ((pWidth+pHeight) > 0) para = para + ",width=" + pWidth + ", height=" + pHeight;
  return window.open(pURL, pName, para);
}

function PresentFunTV() {funtv = openWindow("http://www.kuhlimuh.com/nylon/web/flash/c64s0005.htm","c64song",220,220);}
function restartMusicNonstop() {funtv = openWindow("nonstop0.htm","funtv",220,220);}
function MusicHelp() {help = openWindow("funtv.htm","help",0,0);}
function restartMp3Player() {mp3player = openWindow("extra/mp3player","mp3player",300,300);}


