var tchAllowAd = true; // diese Variable auf false setzten, wenn Werbung generell abgeschaltet werden soll
var tchShowAd = false; // Initialisierung, wird durch Aufruf der Funktionen unten veraendert
var rnd = new Date().getTime();
var LeaderBoard;
var fullsize = 0;


function showAd() {
  return tchShowAd;
}

function setShowAd() {
  if ( (tchAllowAd == true) && (window.location.protocol != "https:") ) {
    tchShowAd = true;
  }
}

function setShowAdOnPage(pageName) {
  if ( (tchAllowAd == true) && (window.location.protocol != "https:") ) {
    if ((pageName == "Schnellsuche") || (pageName == "Reiseziele") || (pageName == "Hotelauswahl") || (pageName == "Einstiegsseite") || (pageName == "Angebote")) {
        tchShowAd = true;
    }
  }
}

function getRnd() {
    return rnd;
}

function layerad(idnameTmp,idname){
    //alert("layerad: "+idnameTmp+","+idname);
    var divAdId = document.getElementById(idnameTmp);
    divAdId.id = idname;
    //alert("layerad: "+divAdId.id+", top: "+divAdId.style.top);
    return true;
}

function movead(idnameTmp,idname,emsSkyscraperTop){
    //alert("movead: "+idnameTmp+","+idname);
    var divId = document.getElementById(idname);
    var divAdId = document.getElementById(idnameTmp);
    var divAdIdParent = divAdId.parentNode;

    var divSkycraperId = document.getElementById('skycraper_ems');
    if (divSkycraperId) {
        if (typeof(emsSkyscraperTop) == "undefined") var emsSkyscraperTop = 148;
        if (divAdId) emsSkyscraperTop += divAdId.offsetHeight;
        if (divAdId && (divAdId.offsetHeight > 10)) emsSkyscraperTop += 10;
        divSkycraperId.style.top = emsSkyscraperTop+'px';
    }

    if (divAdId && (divAdId.offsetHeight > 10)) divId.style.padding = "10px 0px 0px 10px";

    //alert("movead: move divAdId: "+divAdId.id);
    //alert("movead: remove from divAdIdParent: "+divAdIdParent.id);
    divAdIdParent.removeChild(divAdId);
    if (divId) {
        divId.appendChild(divAdId);
        divId.style.display = "block";
        //alert("movead: to divId: "+divId.id);
    }

    return true;
}

function positionad(idname,top,left,margin){
    //alert("positionad: "+idname+","+top+","+left+","+margin);
    var divId = document.getElementById(idname);
    if (divId) {
        if (margin != undefined && margin != "") {
            divId.style.margin = margin;
        }
        if (top != undefined && left != undefined && top != "" && left != "") {
            divId.style.position = "relative";
            divId.style.top = top;
            divId.style.left = left;
        }
    }
    return true;
}
