function clickToHref(_href) {
  document.location.href = _href + ".html";
}

function selectColwTrack(nCol, sLabel, nStart, gaq) {
  selectColw (nCol);
  var sBundesland = getBundesland(nCol-nStart);
  // http://code.google.com/intl/de-DE/apis/analytics/docs/tracking/eventTrackerGuide.html
  try {
    //pageTracker._trackEvent("Bundesland", sBundesland, sLabel);
    gaq.push(['_trackEvent', 'Bundesland', sBundesland, sLabel]);
    //alert("ok");
  } catch(err) {
    //alert(err);
  }
}

function getBundesland(nCol0based) {
 switch (nCol0based) {
    case 0: return "Baden-Württemberg";
    case 1: return "Bayern";
    case 2: return "Berlin";
    case 3: return "Brandenburg";
    case 4: return "Bremen";
    case 5: return "Hamburg";
    case 6: return "Hessen";
    case 7: return "Mecklenburg-Vorpommern";
    case 8: return "Niedersachsen";
    case 9: return "NRW";
    case 10: return "Rheinland-Pfalz";
    case 11: return "Saarland";
    case 12: return "Sachsen";
    case 13: return "Sachsen-Anhalt";
    case 14: return "Schleswig-Holstein";
    case 15: return "Thüringen";
  }
}

function selectColw (nCol) {
 selectCol(nCol, "d_letztes_jahr");
 selectCol(nCol, "d_dieses_jahr");
 selectCol(nCol, "d_naechstes_jahr");
}

function selectCol (nCol, divYearId) {
  selectCol2 (nCol, divYearId, 3,3 );
}

function selectCol2(nCol, divYearId, nStartColTh, nStartColTd) {
 var nDiffTh = nStartColTd-nStartColTh;
 var oTable = document.getElementById(divYearId).getElementsByTagName("table")[0];
 var oTrs = oTable.getElementsByTagName("tr");
 for (var i=nStartColTh; i<= 15+nStartColTh; i++) {
  var oTh = oTrs[0].getElementsByTagName("th")[i];
  if ((i+nDiffTh == nCol) || (nCol == -1)) {
    oTh.style.display = '';
  } else {
    oTh.style.display = 'none';
  }
 }
 
 for(var r=1;r<oTrs.length;r++) {
   for (var i=nStartColTd; i<= 15+nStartColTd; i++) {
    var oTd = oTrs[r].getElementsByTagName("td")[i];
    if ((i == nCol) || (nCol == -1)) {
      oTd.style.display = '';
    } else {
      oTd.style.display = 'none';
    }
   }
 }
}

function displayModeElements(sElementName, nCol, divYearId, nStart) {
  //alert(sElementName);
  var nH2 = nCol-nStart;
  for (var i=0; i<= 16; i++) {
    if ((i == nH2) || ((nCol == -1) && (i == 0))) {
      document.getElementById (divYearId).getElementsByTagName(sElementName)[i].style.display = '';
    } else {
      document.getElementById (divYearId).getElementsByTagName(sElementName)[i].style.display = 'none';
    }    
  }  
}

function selectRoww (nRow) {
 selectRow(nRow, "d_letztes_jahr", 0);
 selectRow(nRow, "d_dieses_jahr", 0);
 selectRow(nRow, "d_naechstes_jahr", 0);
}

function selectRow(nOption, divYearId, nDiff) {
 var oTable = document.getElementById(divYearId).getElementsByTagName("table")[0];
 var oTrs = oTable.getElementsByTagName("tr");
 for (var i=1; i<= 16; i++) {
  var oTr = oTrs[i+nDiff];
  if ((i == nOption) || (nOption == -1)) {
    oTr.style.display = '';
  } else {
    oTr.style.display = 'none';
  }
 }
}
/*
function clickFeiertage(nOption) {
 switch (nOption) {
    case "1": window.location.replace = "/Feiertage-Baden-Wuerttemberg.php"; break;
    case "2": window.location.replace = "/Feiertage-Bayern.php"; break;
    case "3": window.location.replace = "/Feiertage-Berlin.php"; break;
    case "4": window.location.replace = "/Feiertage-Brandenburg.php"; break;
    case "5": window.location.replace = "/Feiertage-Bremen.php"; break;
    case "6": window.location.replace = "/Feiertage-Hamburg.php"; break;
    case "7": window.location.replace = "/Feiertage-Hessen.php"; break;
    case "8": window.location.replace = "/Feiertage-Mecklenburg-Vorpommern.php"; break;
    case "9": window.location.replace = "/Feiertage-Niedersachsen.php"; break;
    case "10": window.location.replace = "/Feiertage-NRW.php"; break;
    case "11": window.location.replace = "/Feiertage-Rheinland-Pfalz.php"; break;
    case "12": window.location.replace = "/Feiertage-Saarland.php"; break;
    case "13": window.location.replace = "/Feiertage-Sachsen.php"; break;
    case "14": window.location.replace = "/Feiertage-Sachsen-Anhalt.php"; break;
    case "15": window.location.replace = "/Feiertage-Schleswig-Holstein.php"; break;
    case "16": window.location.replace = "/Feiertage-Thueringen.php"; break;
  }
}
*/

/* ++++++++++ Conversion Tracking */
    function trackConversion()
    {
        // Erst die Variablen definieren
        var variables = document.createElement('script');
        variables.setAttribute('language', 'javascript');
        variables.setAttribute('type', 'text/javascript');
        variables.setAttribute('id', 'ConversionTracking');
        var definition = "var google_conversion_id = 1071864936;" +
        "var google_conversion_language = 'de';" +
        "var google_conversion_format = 3;" +
        "var google_conversion_color = 'FFFFFF';" +
        "if (1) { var google_conversion_value = 1;}" +
        "var google_conversion_label = 'EWw_CMH0eRDouI3_Aw';";
        variables.text  = definition;
        document.body.appendChild(variables);
        // Dann das Conversion-Script ziehen
        var element = document.createElement('script');
        element.setAttribute('src', 'http://www.googleadservices.com/pagead/conversion.js');
        document.body.appendChild(element);
    }
/*  Funktioniert nicht zuverlässig
*/

  function erzXMLHttpRequestObject() {
    var resObject = null;
    try {
      resObject = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(Error) {
      try {
        resObject = new ActiveXObject("MSXML2.XMLHTTP");
      } catch(Error) {
        try {
          resObject = new XMLHttpRequest();
        } catch(Error) {
          // not supported
        }
      }
    }
    return resObject;
  }

  function adwordsConversionTracking(id, label) {
   trackConversion();
  }
    
  function adwordsConversionTrackingMist(id, label) {
   var xmlhttp = erzXMLHttpRequestObject();
   if (null != xmlhttp) {
     //alert ("http://www.googleadservices.com/pagead/conversion/"+id+"/?label="+label+"&amp;script=0");
     //xmlhttp.open("GET", "http://www.googleadservices.com/pagead/conversion/"+id+"/?label="+label+"&script=0", true); 
     xmlhttp.open("GET", "http://www.googleadservices.com/pagead/conversion/1071864936/?label=EWw_CMH0eRDouI3_Aw&script=0", true);
     //xmlhttp.open("GET", "http://localhost:8080/Arbeitstage-berechnen.php?id="+id+"&label="+label+"&script=0", true);
     xmlhttp.send(null);
   }
  }

/* ############# Kalender #################### */
function selectKalenderBundesland(value, nErstesJahrMitFeriendefinition, nLetztesJahrMitFeriendefinition) {
  if (value == '-1') {
   document.getElementById('schulferien1').style.display = "none";
   document.getElementById('schulferien2').style.display = "none";
  } else {
   var sJahr1 = document.getElementById('jahr1').options[document.getElementById('jahr1').selectedIndex].value;
   if ('-' == sJahr1) {
    document.getElementById('schulferien1').style.display = "none";
    document.getElementById('schulferien2').style.display = "none";
    document.getElementById('schulferien1').style.display = "none";
    document.getElementById('schulferien2').style.display = "none";    
   } else {
    var bMitSchulferien = false;
    if (('Jp0' == sJahr1) || ('Jp1' == sJahr1) || ('J-1' == sJahr1) || ('Mp0' == sJahr1)) {
     bMitSchulferien = true;
    } else {
    var nJahr = parseInt(sJahr1);
     if ((nJahr >= nErstesJahrMitFeriendefinition) && (nJahr <= nLetztesJahrMitFeriendefinition)) {
      bMitSchulferien = true;
     }
    }
    if (bMitSchulferien == true) {
     document.getElementById('schulferien1').style.display = "inline";
     document.getElementById('schulferien2').style.display = "inline";
    } else {
     document.getElementById('schulferien1').style.display = "none";
     document.getElementById('schulferien2').style.display = "none";
    }
   }
  }
}

function selectKalenderJahr(value, nErstesJahrMitFeriendefinition, nLetztesJahrMitFeriendefinition) {
//alert(value);
  if (value == '-') {
   document.getElementById('jahr2').style.display = "inline";
   document.getElementById('schulferien1').style.display = "none";
   document.getElementById('schulferien2').style.display = "none";    
  } else {
   document.getElementById('jahr2').style.display = "none";
   //document.getElementById('schulferien1').style.display = "none";
   //document.getElementById('schulferien2').style.display = "none";
   var elBundeslandOption = document.getElementById('bundesland');
   var sBundesland = 'irgendeins';
   if (null != elBundeslandOption) {
      elBundeslandOption.options[document.getElementById('bundesland').selectedIndex].value;
   } // else: Kalender für ein spezielles Bundesland
   if ('-1' == sBundesland) {
    document.getElementById('schulferien1').style.display = "none";
    document.getElementById('schulferien2').style.display = "none";
   } else {
    var bMitSchulferien = false;
    if (('Jp0' == value) || ('Jp1' == value) || ('J-1' == value) || ('Mp0' == value)) {
     bMitSchulferien = true;
    } else {
    var nJahr = parseInt(value);
     if ((nJahr >= nErstesJahrMitFeriendefinition) && (nJahr <= nLetztesJahrMitFeriendefinition)) {
      bMitSchulferien = true;
     }
    }
    if (bMitSchulferien == true) {
     document.getElementById('schulferien1').style.display = "inline";
     document.getElementById('schulferien2').style.display = "inline";
    } else {
     document.getElementById('schulferien1').style.display = "none";
     document.getElementById('schulferien2').style.display = "none";
    }
   }
  }
}  

/* ############################################## */

var soiDAY = new Array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag");
var soiMONTH = new Array("Januar", "Februar", "M&auml;rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");

if (typeof(soiWithAmPm) == "undefined") {
 soiWithAmPm = false;
}
if (typeof(soiWithClock) == "undefined") {
 soiWithClock = true;
}
if (typeof(soiWithDate) == "undefined") {
 soiWithDate = true;
}
var soiDayOld=0;
var soiTimeCurrent;
var soiTimezoneOffsetCurrent;
var soiTimerClock;
var soiTimerSyncClock;

function soiUpdateClock(){
 try {
  clearTimeout(soiTimerClock)
  soiTimerClock = setTimeout("soiUpdateClock()", 1000);
 
  var now=new Date(soiTimeCurrent);
  var utc = now.getTime() + (now.getTimezoneOffset() * 60000);
  now = new Date(utc + soiTimezoneOffsetCurrent);
 
  soiTimeCurrent += 1000;
  if (true == soiWithClock) {
    var nHour = now.getHours();
   
    var nMinute = now.getMinutes();
    nMinute = (nMinute<10)?"0"+nMinute : nMinute;
   
    var nSecond = now.getSeconds();
    nSecond = (nSecond<10) ? "0" + nSecond : nSecond;
    var sTime;
    if (true == soiWithAmPm) {
      var sAmPm = (nHour < 12) ? " AM" : " PM";
      nHour = (nHour > 12) ? nHour - 12 : nHour;
      nHour = (nHour == 0) ? 12 : nHour;
      nHour = (nHour<10)? "0"+nHour : nHour;
      sTime = nHour + ":" + nMinute + ":" + nSecond + sAmPm;
    } else {
      nHour = (nHour<10)? "0"+nHour : nHour;
      sTime = nHour + ":" + nMinute + ":" + nSecond;
    }
    
    document.getElementById("soiclock").innerHTML=sTime;
  }

  if (true == soiWithDate) {
    var day = now.getDay();
    if (soiDayOld != day) {
	    soiDayOld = day
	    var sDay = soiDAY[now.getDay()];
	    var sMonth = soiMONTH[now.getMonth()];
	    var sDate = sDay + ", " + now.getDate() + ". " + sMonth + " " + now.getFullYear();
	    document.getElementById("soidate").innerHTML=sDate;
    }
  }
 } catch (err) {
  alert(err);
 }
}
 

function soiCheckHost() {
 try {
  var soihost = window.location.hostname;
  if (soihost.indexOf('www') === 0) {
    soihost = soihost.substring(4, soihost.length);
  }
  if ((soihost != 'localhost') && (soihost != '127.0.0.1') && (soihost != 'www.schnelle-online.info')) {
    alert('Dieses JavaScript ist nur für www.schnelle-online.info gedacht. Möchten Sie etwas auf Ihrer Homepage nutzen? Bitte fragen Sie uns: so-service@schnelle-online.info');
  }
 } catch (err2) {
  alert("soiCheckHost: "+err2);
 }
}

function soiCheckUhrzeitLink() {
  var link = document.getElementById('soilinkuhrzeit');
  if (null == link) {
    alert("'Uhrzeit in Deutschland' ist kostenfrei und erwartet lediglich den Link mit der id=soilinkuhrzeit auf http://www.schnelle-online.info/Deutschland/genaue-Uhrzeit.html. (1)");
    return;
  }
  //alert(link.href);
  if (link.href != 'http://www.schnelle-online.info/Deutschland/genaue-Uhrzeit.html') {
    alert("'Uhrzeit in Deutschland' ist kostenfrei und erwartet lediglich der Link mit der id=soilinkuhrzeit auf http://www.schnelle-online.info/Deutschland/genaue-Uhrzeit.html beibehalten wird. (2)");
    return;
  }
  if (link.rel != 'follow') {
    alert("'Uhrzeit in Deutschland' ist kostenfrei und erwartet lediglich den Link mit der id=soilinkuhrzeit auf http://www.schnelle-online.info/Deutschland/genaue-Uhrzeit.html als rel=follow. (3)");
    return;
  }
  if (!((link.style.position == null) || ("" == link.style.position))) {
    alert("'Uhrzeit in Deutschland' ist kostenfrei - bitte seien Sie fair und verstecken nicht den angegebenen Link auf http://www.schnelle-online.info/Deutschland/genaue-Uhrzeit.html. (4)");
    return;
  }  
  if (!((link.style.display == null) || ("" == link.style.display))  || ("inline" == link.style.display)) {
    alert("'Uhrzeit in Deutschland' ist kostenfrei - bitte seien Sie fair und verstecken nicht den angegebenen Link auf http://www.schnelle-online.info/Deutschland/genaue-Uhrzeit.html. (5)");
    return;
  }  
  if (!((link.style.visibility == null) || ("" == link.style.visibility))  || ("visible" == link.style.visibility)) {
    alert("'Uhrzeit in Deutschland' ist kostenfrei - bitte seien Sie fair und verstecken nicht den angegebenen Link auf http://www.schnelle-online.info/Deutschland/genaue-Uhrzeit.html. (6)");
    return;
  }
  //alert(link.innerHTML);
  if ((link.innerHTML != "Uhrzeit in Deutschland") && ("Uhrzeit Deutschland" != link.innerHTML) && ("Aktuelle Uhrzeit" != link.innerHTML) && ("aktuelle Uhrzeit" != link.innerHTML) && ("Genaue Uhrzeit" != link.innerHTML) && ("genaue Uhrzeit" != link.innerHTML)) {
    alert("'Uhrzeit in Deutschland' ist kostenfrei - bitte seien Sie fair und verwenden als Linktext für den Link mit der id=soilinkuhrzeit 'Uhrzeit in Deutschland', 'Uhrzeit Deutschland', 'Aktuelle Uhrzeit' oder 'Genaue Uhrzeit'.");
    return;
  }
}


function getNewHTTPObject() {

  // IE7, Firefox, etc.
  try {
	  if (typeof XMLHttpRequest != 'undefined') {
	      return new XMLHttpRequest();
	  }
  } catch (err) {
  }
  // IE6, IE5
   try {
      return new ActiveXObject("Msxml2.XMLHTTP");
   } catch(e) {
       try {
           return new ActiveXObject("Microsoft.XMLHTTP");
       } catch(e) {
           return null;
       }
   }
}


function soiSyncClock() {
 try {
  clearTimeout(soiTimerSyncClock)
  soiTimerSyncClock = setTimeout("soiSyncClock()", 60000);
  //soiTimerSyncClock = setTimeout("soiSyncClock()", 3000);
  var url = "/Deutschland/genaue-Uhrzeit-service.html";
  xmlHttp.open('GET', url, true);
  xmlHttp.onreadystatechange = soiSyncClockCallback;
  xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  xmlHttp.send(null);
 } catch (err) {
  //alert(err);
 }
}

function soiSyncClockCallback() {
  if (xmlHttp.readyState != 4) {
    return;
  }
  var result = xmlHttp.responseText;
  var nIndex = result.indexOf(",");
  soiTimezoneOffsetCurrent = eval(result.substring(0, nIndex));
  soiTimeCurrent = eval(result.substring(nIndex+1, result.length));
  if (typeof(soiTimerClock) == "undefined") {
    soiTimerClock = setTimeout("soiUpdateClock()", 0);
  }
}