//Umbau des HTML Contents für Scroller
function setHTML(){
    var bodyObj = document.getElementsByTagName("body")[0];
    var flashcontentObj = document.getElementById("flashcontent");
    var distanceObj = document.createElement("div");
    distanceObj.id = "distance";
    bodyObj.insertBefore(distanceObj, flashcontentObj);
}

window.onload = function(){
    setHTML();
}


//Komplett parametrisiertes Popup/Browser Window
//Parameter: (targetUrl, name, width, height, positionX, positionY, location, menubar, scrollbars, status, toolbar, resize)
//targetUrl Wert: Url des neuen Fensters
//name Wert: "Fenstername", keine Leerzeichen/Sonderzeichen!
//width, height Werte: Integer oder "fullscreen"
//positionX Werte: Integer oder "center" (default), "left", "right"
//positionY Werte: Integer oder "center" (default), "top", "bottom"
//location, menubar, scrollbars, status, toolbar, resize Werte: "yes" oder "no"
function openNewWindow(targetUrl, name, width, height, positionX, positionY, location, menubar, scrollbars, status, toolbar, resize){

    var screenWidth = screen.availWidth;
    var screenHeight = screen.availHeight;
    
    //Vars, Fallback Werte
    var popTargetUrl = "index.html";
    var popName = "popupWindow";
    
    var popWidth = "fullscreen";
    var popHeight = "fullscreen";
    
    var popPositionX = "center";
    var popPositionY = "center";
    
    var popLocation = "no";
    var popMenubar = "no";
    var popScrollbars = "yes";
    var popStatus = "no";
    var popToolbar = "no";
    var popResize = "no";
    //
    
    if (targetUrl != null && targetUrl != undefined) {
    
        popTargetUrl = targetUrl;
        
    }
    
    if (name != null && name != undefined) {
    
        popName = name;
        
    }
    
    switch (width) {
    
        case null:
        case undefined:
            break;
            
        case "fullscreen":
            popWidth = screenWidth;
            break;
            
        default:
            popWidth = width;
            break;
            
    }
    
    switch (height) {
    
        case null:
        case undefined:
            break;
            
        case "fullscreen":
            popHeight = screenHeight;
            break;
            
        default:
            popHeight = height;
            break;
            
    }
    
    switch (positionX) {
    
        case null:
        case undefined:
        case "center":
            popPositionX = (screenWidth - popWidth) / 2;
            break;
            
        case "left":
            popPositionX = 0;
            break;
            
        case "right":
            popPositionX = screenWidth - popWidth;
            break;
            
        default:
            popPositionX = parseInt(positionX);
            break;
            
    }
    
    switch (positionY) {
    
        case null:
        case undefined:
        case "center":
            popPositionY = (screenHeight - popHeight) / 2;
            break;
            
        case "top":
            popPositionY = 0;
            break;
            
        case "bottom":
            popPositionY = screenHeight - popHeight;
            break;
            
        default:
            popPositionY = parseInt(positionY);
            break;
            
    }
    
    
    if (menubar != null && menubar != undefined) {
    
        popMenubar = menubar;
        
    }
    
    if (scrollbars != null && scrollbars != undefined) {
    
        popScrollbars = scrollbars;
        
    }
    
    if (status != null && status != undefined) {
    
        popStatus = status;
        
    }
    
    if (toolbar != null && toolbar != undefined) {
    
        popToolbar = toolbar;
        
    }
    
    if (resize != null && resize != undefined) {
    
        popResize = resize;
        
    }
    
    var popProperties;
    popProperties = "width=" + popWidth + ",height=" + popHeight;
    popProperties += ",left=" + popPositionX + ",top=" + popPositionY;
    popProperties += ",location=" + popLocation + ",menubar=" + popMenubar + ",scrollbars=" + popScrollbars + ",status=" + popStatus + ",toolbar=" + popToolbar + ",resize=" + popResize;
    
    var popupWin = window.open(popTargetUrl, popName, popProperties);
}



//Auslesen von URL Parametern
function getURLParam(strParamName){
    var strReturn = "";
    var strHref = window.location.href;
    var bFound = false;
    
    var cmpstring = strParamName + "=";
    var cmplen = cmpstring.length;
    
    if (strHref.indexOf("?") > -1) {
        var strQueryString = strHref.substr(strHref.indexOf("?") + 1);
        var aQueryString = strQueryString.split("&");
        for (var iParam = 0; iParam < aQueryString.length; iParam++) {
            if (aQueryString[iParam].substr(0, cmplen) == cmpstring) {
                var aParam = aQueryString[iParam].split("=");
                strReturn = aParam[1];
                bFound = true;
                break;
            }
        }
    }
    if (bFound == false) 
        return null;
    return strReturn;
}


//ALT? 

//Auswahlseite
function openNewUrlWindow(plain, lan){
    posX = 0;
    posY = 0;
    satWidth = document.all ? screen.availWidth : screen.availWidth;
    satHeight = (document.all ? screen.availHeight : screen.availHeight) - 54;
    
    eval("sff = open('/site/index.php?shopID=" + plain + "&L=" + lan + "', 'steiff', 'toolbar=no,scrollbars=no,resizable=no,statusbar=no,menubar=no,screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + ",width=" + satWidth + ",height=" + satHeight + "');");
    if (sff) {
        sff.focus();
    }
    
}

//Teddybär Konfigurator Popup
function openKonfiguratorWindow(plain){
    posX = (screen.availWidth / 2) - 500;
    posY = (screen.availHeight / 2) - 400;
    satWidth = 1000;
    satHeight = 700;
    eval("steiffkonfigurator = open('/fileadmin/extern/configurator/" + plain + "', 'steiffpopup', 'toolbar=no,scrollbars=no,resizable=no,statusbar=no,menubar=no,screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + ",width=" + satWidth + ",height=" + satHeight + "');");
    if (steiffkonfigurator) {
        steiffkonfigurator.focus();
    }
}

//Lagerfeld Special Popup
function openLagerfeldWindow(plain){
    posX = (screen.availWidth / 2) - 512;
    posY = (screen.availHeight / 2) - 384;
    satWidth = 1024;
    satHeight = 768;
    eval("steifflagerfeld = open('/site/SWF/lagerfeld/" + plain + "', 'steiffpopup', 'toolbar=no,scrollbars=no,resizable=no,statusbar=no,menubar=no,screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + ",width=" + satWidth + ",height=" + satHeight + "');");
    if (steifflagerfeld) {
        steifflagerfeld.focus();
    }
}

//Lagerfeld Special Popup
function openLagerfeldWindowDe(){
    posX = (screen.availWidth / 2) - 512;
    posY = (screen.availHeight / 2) - 384;
    satWidth = 1024;
    satHeight = 768;
    eval("steifflagerfeld = open('/site/SWF/lagerfeld/index.php', 'steiffpopup', 'toolbar=no,scrollbars=no,resizable=no,statusbar=no,menubar=no,screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + ",width=" + satWidth + ",height=" + satHeight + "');");
    if (steifflagerfeld) {
        steifflagerfeld.focus();
    }
}

//Lagerfeld Special Popup
function openLagerfeldWindowEn(){
    posX = (screen.availWidth / 2) - 512;
    posY = (screen.availHeight / 2) - 384;
    satWidth = 1024;
    satHeight = 768;
    eval("steifflagerfeld = open('/site/SWF/lagerfeld/index.php?L=4', 'steiffpopup', 'toolbar=no,scrollbars=no,resizable=no,statusbar=no,menubar=no,screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + ",width=" + satWidth + ",height=" + satHeight + "');");
    //  if(steifflagerfeld){steifflagerfeld.focus();}
}

//Selection Special Popup
function openSelectionDe(){
    posX = (screen.availWidth / 2) - 512;
    posY = (screen.availHeight / 2) - 384;
    satWidth = 1000;
    satHeight = 680;
    eval("steiffselection = open('/site/SWF/selection/index.php', 'steiffpopup', 'toolbar=no,scrollbars=no,resizable=no,statusbar=no,menubar=no,screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + ",width=" + satWidth + ",height=" + satHeight + "');");
    //  if(steiffselection){steiffselection.focus();}
}

//Selection Special Popup
function openSelectionEn(){
    posX = (screen.availWidth / 2) - 512;
    posY = (screen.availHeight / 2) - 384;
    satWidth = 1000;
    satHeight = 680;
    eval("steiffselection = open('/site/SWF/selection/index.php?L=4', 'steiffpopup', 'toolbar=no,scrollbars=no,resizable=no,statusbar=no,menubar=no,screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + ",width=" + satWidth + ",height=" + satHeight + "');");
    //  if(steiffselection){steiffselection.focus();}
}

//Popup mit fester Größe
function openWindow(target){
    posX = (screen.availWidth / 2) - 512;
    posY = (screen.availHeight / 2) - 384;
    satWidth = 1000;
    satHeight = 680;
    eval("steiffwindow = open(target, 'steiffwindow', 'toolbar=no,scrollbars=no,resizable=no,statusbar=no,menubar=no,screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + ",width=" + satWidth + ",height=" + satHeight + "');");
    //  if(steiffselection){steiffselection.focus();}
}

//K.A.
function loadShopLocator(){
    posX = 0;
    posY = 0;
    satWidth = document.all ? screen.availWidth : screen.availWidth;
    satHeight = (document.all ? screen.availHeight : screen.availHeight) - 54;
    
    var language;
    if (getURLParam("L")) {
        language = getURLParam("L");
    }
    else {
        language = 0;
    }
    
    var properties = "toolbar=no,scrollbars=no,resizable=no,statusbar=no,menubar=no,screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + ",width=" + satWidth + ",height=" + satHeight + "";
    if (window.opener != null && !window.opener.closed) {
        if (opener.location.href.indexOf("shopID=59") == -1) {
            opener.location.href = "/site/index.php?&shopID=59&L=" + language;
        }
        window.close();
    }
    else {
        window.open("http://www.steiff.de/site/index.php?&shopID=59&L=" + language, "popup", properties);
        window.close();
    }
}


function loadImprint(){
    posX = 0;
    posY = 0;
    satWidth = document.all ? screen.availWidth : screen.availWidth;
    satHeight = (document.all ? screen.availHeight : screen.availHeight) - 54;
    
    var language;
    if (getURLParam("L")) {
        language = getURLParam("L");
    }
    else {
        language = 0;
    }
    var properties = "toolbar=no,scrollbars=no,resizable=no,statusbar=no,menubar=no,screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + ",width=" + satWidth + ",height=" + satHeight + "";
    if (window.opener != null && !window.opener.closed) {
        if (opener.location.href.indexOf("shopID=8100") == -1) {
            opener.location.href = "/site/index.php?&shopID=8100&L=" + language;
        }
        window.close();
    }
    else {
        window.open("http://www.steiff.de/site/index.php?&shopID=8100&L=" + language, "popup", properties);
        window.close();
    }
}


function closeWindow(){
    posX = 0;
    posY = 0;
    satWidth = document.all ? screen.availWidth : screen.availWidth;
    satHeight = (document.all ? screen.availHeight : screen.availHeight) - 54;
    
    var language;
    if (getURLParam("L")) {
        language = getURLParam("L");
    }
    else {
        language = 0;
    }
    var properties = "toolbar=no,scrollbars=no,resizable=no,statusbar=no,menubar=no,screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + ",width=" + satWidth + ",height=" + satHeight + "";
    if (window.opener != null && !window.opener.closed) {
        //if (opener.location.href.indexOf("shopID=1000") == -1) {
            opener.location.href = "/redirect.php?id=selection";
        //}
        window.close();
    }
    else {
        window.open("/redirect.php?id=selection", "popup", properties);
        window.close();
    }
}
