/**
 * @author fundorado
 * Container for defaultscripts-Fundorado
 */
/**
 * Gloable variable
 * ================
 */
//dod_popup
var dod_default = 'width=600,height=400,screenX=0,screenY=0,status=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,location=no';
//infolayerAll
var layerPropsCommon = {
    award_layer_club: {
        iFrameSRC: 'http://www.fundorado.de/allgemeines/infoseiten/info_popups_free/6awards/index.html',
        positionLeft: 788,
        positionTop: 136,
        layerWidth: 150,
        layerHeight: 495,
        frameheight: 470,
        framewidth: 146,
        closePos: 56
    },
    award_layer_free: {
        iFrameSRC: 'http://www.fundorado.de/allgemeines/infoseiten/info_popups_free/6awards/index.html',
        positionLeft: 738,
        positionTop: 276,
        layerWidth: 150,
        layerHeight: 625,
        frameheight: 600,
        framewidth: 146,
        closePos: 56
    }
};
/**
 * allgemeine PopupProps
 * =====================
 */
/* Video-Popup (Exklusiv_Neu mit linkliste) */
var fnd_vidPopExkl_link = 'width=1070,height=760,status=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes';

/* Video-Popup (Exklusiv) */
var fnd_vidPopExkl = 'width=1070,height=760,status=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes';

/* Video-Popup (club) */
var fnd_vidPopClub = fnd_vidPopExkl;

/* Video-Popup (XXL) */
var fnd_vidPopXXL = fnd_vidPopExkl;

/* Bildershow-Popups (club) */
var fnd_bsPopClub = 'width=670,height=780,status=no,menubar=no,toolbar=no,scrollbars=no,resizable=no';

/* Bildershow-Popups (XXL) */
var fnd_bsPopXXL = 'width=670,height=780,status=no,menubar=no,toolbar=no,scrollbars=auto,resizable=no';

/* Bildershow-Popups (VIP)
 var fnd_bsPopVIP = 'width=670,height=780,status=no,menubar=no,toolbar=no,scrollbars=auto,resizable=no'
 /* Bildershow-Popups (club, Big Pics) */
var fnd_bsPopClubBig = 'width=670,height=780,status=no,menubar=no,toolbar=no,scrollbars=auto,resizable=no';
/* Extras-Popups */
var fnd_extras = 'width=605,height=501,screenX=0,screenY=0,status=no,menubar=no,tar=no,scrollbars=yes,resizable=no,location=no';
/**
 * script: dod_popups
 * ===================
 *
 * @param {Object} theURL
 * @param {Object} winName
 * @param {Object} features
 * @param {Object} width
 * @param {Object} height
 */
function dod_openWin(theURL, winName, features, width, height){
    if (width != "" && width != undefined) {
        if (features.search("width=") >= 0) {
            features = features.replace("(width=[0-9]+)", "width=" + width);
        }
        else {
            features = features + ",width=" + width + "";
        }
    }
    if (height != "" && height != undefined) {
        if (features.search("height=") >= 0) {
            features = features.replace("(height=[0-9]+)", "height=" + height);
        }
        else {
            features = features + ",height=" + height + "";
        }
    }
    Fenster = window.open(theURL, winName, features);
    Fenster.focus();
}

/**	
 * @param {Object} theURL
 * @param {Object} winName
 * @param {Object} features
 */
function openWin(theURL, winName, features){
    Fenster = window.open(theURL, winName, features);
    Fenster.focus();
}
function myPreloadImages(anArray){
    var preloadedNavImages = new Array();
    for (i = 0; i < anArray.length; i++) {
        preloadedNavImages[i] = new Image();
        preloadedNavImages[i].src = 'http://www.fundorado.de' + anArray[i];
    }
}
/**
 * Script: switch
 * ===============
 * 
 * @param {Object} title
 */
function setBackground(title){
    var aBgUrl = "";
    var aBgColor = "";
    
    switch (title) {
        case 'fd_classic':
            aBgColor = "#e488e4";
            aBgUrl = "url('/src/0.gif')";
            break;
        case 'fd_weiss':
            aBgUrl = "url('/src/DE/f.jpeg')";
            aBgColor = "#fff";
            break;
        //case 'fd_black': aBgUrl = "url('/src/DE/nadelstreifen.jpeg')";aBgColor = "#fff";break;   
        case 'fd_leo':
            aBgUrl = "url('/src/DE/leopard.jpeg')";
            aBgColor = "#fff";
            break;
        case 'fd_default':
            aBgColor = "#fff";
            aBgUrl = "url('/src/1.gif')";
            break;
            
    }
    
    //alert(aBgColor);  
    document.getElementById('fndMainBody').style.backgroundColor = aBgColor;
    document.getElementById('fndMainBody').style.backgroundImage = aBgUrl;
    
    
    if (title == "fd_leo" || title == "fd_black") {
        document.getElementById('partnerFuss').style.color = '#fff';
        element = document.getElementById('partnerFuss');
        allChilds = element.childNodes;
        for (i = 0; i < allChilds.length; i++) {
            if (allChilds[i].nodeName == "A") {
                allChilds[i].className = "fndLinkFussPartnerS";
            }
        }
    }
    else {
        document.getElementById('partnerFuss').style.color = '#000';
        element = document.getElementById('partnerFuss');
        allChilds = element.childNodes;
        for (i = 0; i < allChilds.length; i++) {
            if (allChilds[i].nodeName == "A") {
                allChilds[i].className = "fndLinkFussPartner";
            }
        }
    }
    
    
}
/**
 * aktives Stylesheet des User holen    
 */
function getActiveBackground(){
    var linkname;
    var title = "";
    bgUrl = document.getElementById('fndMainBody').style.backgroundImage;
    bgCol = document.getElementById('fndMainBody').style.backgroundColor;
    //alert("url"+bgUrl); 
    //alert("col"+bgCol);   
    if (bgUrl.indexOf('1.gif') != -1) 
        title = 'fd_default';
    if (bgUrl.indexOf('0.gif') != -1) 
        title = 'fd_classic';
    if (bgUrl.indexOf('f.jpeg') != -1) 
        title = 'fd_weiss';
    //if(bgUrl.indexOf('nadelstreifen.jpeg') != -1)title = 'fd_black';   
    if (bgUrl.indexOf('leopard.jpeg') != -1) 
        title = 'fd_leo';
    //alert('Title: '+title);       
    if (title != '') {
        return title;
    }
    else {
        return null;
    }
} 
/**
 * cookie schreiben
 * 
 * @param {Object} name
 * @param {Object} value
 * @param {Object} days
 */
function createCookie(name, value, days){
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else 
        expires = "";
    document.cookie = name + "=" + value + expires + "; path=/; domain=.fundorado.de";
}

//cookie lesen   
function readCookie(name){
    var nameEQ = name + "=";
    //alert('nameEQ: '+nameEQ);   
    var ca = document.cookie.split(';');
    //alert(ca);   
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        //alert('c: '+c);   
        while (c.charAt(0) == ' ') 
            c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) 
            return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function CSSbodyBg(){
    var aBgColor = "";
    var aBgUrl = "";
    var cookie = readCookie("f_style");
    var title = cookie ? cookie : "fd_default";
    //alert(title);
    switch (title) {
        case 'fd_classic':
            aBgColor = "#e488e4";
            aBgUrl = "url('/src/0.gif')";
            break;
        case 'fd_weiss':
            aBgUrl = "url('/src/DE/f.jpeg')";
            aBgColor = "#fff";
            break;
        case 'fd_leo':
            aBgUrl = "url('/src/DE/leopard.jpeg')";
            aBgColor = "#fff";
            break;
        case 'fd_default':
            aBgColor = "#fff";
            aBgUrl = "url('/src/1.gif')";
            break;
    }
    aString = "<style type='text/css'>body#fndMainBody {background: " + aBgColor + " " + aBgUrl + "}</style>";
    document.write(aString);
}

window.onload = function(e){
    var cookie = readCookie("f_style");
    var title = cookie ? cookie : "fd_default";
    //alert("1"+title);   
    setBackground(title);
}

//schreibt Cookie mit vom User gewaehltem Stylesheet   
window.onunload = function(e){
    var title = getActiveBackground();
    var oldCookie = readCookie("f_style");
    if (oldCookie != title) {
        createCookie("f_style", title, 365);
        //alert('created'); 
    }
}
/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){
return false;
}return true;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;
/**
 * script: infoLayerAll
 * ====================
 *
 * @param {Object} anId
 */
function getLayerCommon(anId){

    if ($('#common_layer').css('display') == 'block') 
        $('#common_layer').css({
            display: 'none'
        });
    if ($('#theCommonFrame').attr('src') != '') 
        $('#theCommonFrame').attr({
            src: ' '
        });
    if (!document.getElementById('common_layer')) 
        $("#fndMain").append('<div id="common_layer"><div id="common_layer_head"><div id="common_close">Fenster schließen</div></div><iframe id="theCommonFrame" scrolling="no" frameborder="0"></iframe></div>');
    
    opts = layerPropsCommon[anId];
    
    fsrc = opts.iFrameSRC;
    pl = opts.positionLeft;
    pt = opts.positionTop;
    lw = opts.layerWidth;
    lh = opts.layerHeight;
    fh = opts.frameheight;
    fw = opts.framewidth;
    clp = opts.closePos;
    
    $('#common_layer').css({
        position: 'absolute'
    });
    $('#common_layer').css({
        height: lh
    });
    $('#common_layer').css({
        width: lw
    });
    $('#common_layer').css({
        left: pl
    });
    $('#common_layer').css({
        top: pt
    });
    $('#theCommonFrame').css({
        height: fh
    });
    $('#theCommonFrame').css({
        width: fw
    });
    $('#common_close').css({
        left: clp
    });
    
    $('#theCommonFrame').attr({
        src: fsrc
    });
    $('#common_layer').css({
        display: 'block'
    });
    $('#common_layer').draggable();
    $('#common_close').click(function(){
        closeCommonLayer();
    });
}

function closeCommonLayer(){
    $('#common_layer').css({
        display: 'none'
    });
}

//infolayer fundo statuskopf,login;tour naviteaser; 
function j_get_box(anObj, anID, aLeftDist, aTopDist){

    var cleft = 0;
    var ctop = 0;
    
    var offset = $(anObj).offset();
    cleft += offset.left;
    ctop += offset.top;
    
    $('#' + anID).css({
        left: cleft + aLeftDist + 'px'
    });
    
    $('#' + anID).css({
        top: ctop + aTopDist + 'px'
    });
    
}

function j_hide_box(anId){
    $('#' + anId).css({
        display: 'none'
    });
    
}

// Shows a box if it wasn't shown yet or is hidden   
// or hides it if it is curre   
function j_show_hide_box(anObj, options, selector){
    var layerBox = "";
    var html_frame = "";
    var boxID = $(anObj).attr('id') + 'Kind';
    var boxExist = document.getElementById(boxID);
    
    $(anObj).mouseout(function(){
        j_hide_box(boxID);
    });
    
    if (boxExist != null) {
        if ($('#' + boxID).css('display') == 'none') {
            // seltectoren fuer die Layer  
            // 1 = infoLayer 
            // 2 = CamKastenelement 
            // 3 = tour Layer in Linkliste(navi) 
            switch (selector) {
                case 1:
                    j_get_box(anObj, boxID, 0, 10);
                    break;
                case 2:
                    j_get_box(anObj, boxID, 125, -2);
                    break;
                case 3:
                    j_get_box(anObj, boxID, 155, -102);
                    break;
                case 4:
                j_get_box(anObj, boxID, -145, -2);
                break;
            }
                        
            $('#' + boxID).css({
                display: 'block'
            });
            return false;
        }
    }
    else {
    
        layerBox = '<div id=\"' + boxID + '\" ></div>';
        $('body').append(layerBox);
        
        switch (selector) {
            case 1:
                html_frame = '<iframe id=\"frameStage' + $(anObj).attr('id') + '\" scrolling="no" frameborder="0" src=\"' + options.source + '\" />';
                $('#' + boxID).append(html_frame);
                $('#frameStage' + $(anObj).attr('id')).css({
                    height: options.height + 'px'
                });
                $('#frameStage' + $(anObj).attr('id')).css({
                    width: options.width + 'px'
                });
                $('#' + boxID).css({
                    textAlign: 'right'
                });
                break;
            case 2:
                html_img = '<img class=\"fndCamImgOnlineKE\" id=\"bild' + $(anObj).attr('id') + '\" alt=\"bild' + $(anObj).attr('id') + '\" border="0" src=\"' + options.source + '\" />';
                $('#' + boxID).append(html_img);
                $('#' + boxID).css({
                    textAlign: 'center'
                });
                break;
            case 3:
                html_img = '<img id=\"bild' + $(anObj).attr('id') + '\" alt=\"bild' + $(anObj).attr('id') + '\" border="0" src=\"' + options.source + '\" />';
                $('#' + boxID).append(html_img);
                $('#' + boxID).css({
                    textAlign: 'center'
                });
                $('#bild' + $(anObj).attr('id')).css({
                    border: 'solid 1px #000'
                });
                break;
            case 4:
                html_img = '<img class=\"fndCamImgOnlineKE\" id=\"bild' + $(anObj).attr('id') + '\" alt=\"bild' + $(anObj).attr('id') + '\" border="0" src=\"' + options.source + '\" />';
                $('#' + boxID).append(html_img);
                $('#' + boxID).css({
                    textAlign: 'center'
                });
                break; 
        }
        
        $('#' + boxID).css({
            position: 'absolute'
        });
        $('#' + boxID).css({
            height: options.height + 'px'
        });
        $('#' + boxID).css({
            width: options.width + 'px'
        });
        $('#' + boxID).css({
            background: options.background
        });
        $('#' + boxID).css({
            border: options.border
        });
        $('#' + boxID).css({
            padding: options.padding
        });
        $('#' + boxID).css({
            zIndex: options.zindex
        });
        $('#' + boxID).css({
            display: 'block'
        });
        
        switch (selector) {
            case 1:
                j_get_box(anObj, boxID, 0, 10);
                break;
            case 2:
                j_get_box(anObj, boxID, 125, -2);
                break;
            case 3:
                j_get_box(anObj, boxID, 155, -102);
                break;
            case 4:
                j_get_box(anObj, boxID, -145, -2);
                break;
 
        }
    }
}
function getNaviEntries(options){
	var resurl ="/PHP/getCamNavi.php";
	var paramString = '';
	
	var cnv_cookie = readCookie("cnv");
	
	if(cnv_cookie && !options.param3){
		paramString = 'base='+options.param1+'&wich=' + cnv_cookie;	
	}
	else{
		paramString = 'base='+options.param1+'&wich=' + options.param2;
		createCookie("cnv", options.param2, 365);
	}
   	
	$.ajax({
		type: "GET",
		async: true,
		url: resurl,
		data: paramString,
		success: function(data){
                        //alert(data);
			$('#fndCams_naviBlock').html(data);
		}
	});
}
/**
 * Initial wenn Seite geladen
 * ==========================
 */
$(function(){

    /**
     * script: DE_noSource
     * ===================
     */
    $(document).bind("contextmenu", function(e){
        return false
    });
    
    if (document.getElementById('fndHeadLayer')) {
        $('#fndHeadLayer').click(function(){
            getLayerCommon('award_layer_club');
        });
    }
    
    if (document.getElementById('fndLinkAwardLayerFree')) {
        $('#fndLinkAwardLayerFree').click(function(){
            getLayerCommon('award_layer_free');
        });
    }
    
    
    $('#infoLogLnk').click(function(){
        var anObj = $(this);
        j_show_hide_box(anObj, infoLog, 1);
    });
    
    $('#infoNickLnk').click(function(){
        var anObj = $(this);
        j_show_hide_box(anObj, infoNick, 1);
    });
    
    $('.fndILclick').click(function(){
        var anObj = $(this);
        j_show_hide_box(anObj, infoTarif, 1);
    });
	
	//myPreloadImages(navImages);
	
});


