/* =========================================================
// Author: Zaeva Biljana
// Mail: office@boanet.at
// Web: http://www.boanet.at
// Copyright (c) 2010 BOA Net
========================================================= */
// (5/webcam) PHOTO REFRESH
var BauFileN;

function holdUp() {
    aktiv = setTimeout("freshPic()", 10000);
}

function freshPic() {
    if (document.getElementById("lifewebcam") != undefined) {
        var currentPath = document.getElementById("lifewebcam").src;
        var trimmedPath = new Array();
        trimmedPath = currentPath.split("?");
        document.getElementById("lifewebcam").src = trimmedPath[0] + "?" + Math.random();
        window.clearTimeout(aktiv);
        holdUp();
    }
}

// (1-2-3) SET FLASH VARIABLE
var countval = "1";

function getFlashMovie(movieName) { // Provides the proper address for the movie depending on browser
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? window[movieName] : document[movieName];
}

function playHom() {
    getFlashMovie("planbereich").JStoASviaExternalInterface("home");
}

function playUmf() {
    getFlashMovie("planbereich").JStoASviaExternalInterface("umfeld");
}

function playMas() {
    getFlashMovie("planbereich").JStoASviaExternalInterface("masterplan");
}

function gaTrackPage(page) {
    try {
        _gaq.push(['_trackPageview', page]);
    } catch (ex) {
        // swallow
    }
}

function htmlEncode(s) {
    var str = new String(s);
    str = str.replace(/&/g, "&amp;");
    str = str.replace(/</g, "&lt;");
    str = str.replace(/>/g, "&gt;");
    str = str.replace(/"/g, "&quot;");
    return str;
}

$(document).ready(function () { //JQUERY START
    // GLOBAL VARIABLES						   
    if ($('#LangEng').length == 0) {
        var Lang = "";
        var LangEn = ""
    } else {
        var Lang = "../";
        var LangEn = "en-";
    } //for language change
    var showTextR, loadFile, Nelem;
    var ansicht; //for main navigation
    var GBN = 'W1E';
    var LB1 = '0';
    var LT1 = '-57';
    var LB2 = '15';
    var LT2 = '-42';
    var GU = "-57";
    var chlab = "1";
    var stoploop; //for gebaude view
    var CamName, CamImgName, CamLink; //for webcam
    var BauNelem, PanoName;
    var secid;

    //(1-2-3) MAIN FLASH LOAD	  	
    function mainSWF() {
        removeCont();
        $('#ContFlash:hidden').show();
        if ($('#planbereich').length == 0) {
            var swfDiv = document.getElementById("ContFlash");
            swfDiv.style.display = "block";
            var so = new SWFObject('index.swf', 'planbereich', '680', '500', '9');
            so.addVariable("var1", countval);
            so.write("ContFlash");
            countval = "1";
        }
    }
    //(5/webcam) FLASH TIME LAPSE VIDEO
    var CamName;

    function camSWF() {
        var swfDiv = document.getElementById("CamIn");
        if (swfDiv.style.display === "none") {
            swfDiv.style.display = "block";
        } else {
            swfDiv.style.display = "block";
            var so = new SWFObject(Lang + 'cam/' + CamName + '.swf', CamName, '412', '364', '7');
            so.addParam("wmode", "transparent");
            so.write("CamIn");
        }
    }
    //(4/plätze) PANORAMA FLASH VIDEO
    function panoSWF() {
        var video = '<video url="' + PanoName + '.flv"/>';
        var swfDiv = document.getElementById("GebAjax");
        if (swfDiv.style.display === "none") {
            swfDiv.style.display = "block";
        } else {
            swfDiv.style.display = "block";
            var so = new SWFObject(Lang + 'img/pano/' + PanoName + '.swf', 'Pano', '680', '480', '9');
            so.addParam("wmode", "transparent");
            so.addParam("FlashVars", "video=" + htmlEncode(video) + "&");
            so.write("GebAjax");
        }
    }

    function animSWF() {
        var swfDiv = document.getElementById("GebAjax");
        swfDiv.style.display = "block";
        var so = new SWFObject(Lang + 'animation.swf', 'anim', '680', '480', '9');
        so.addParam("wmode", "transparent");
        so.write("GebAjax");
    }

    $('.scroll').jScrollPane(); //SCROLLBAR INITIALIZE
    
    //MAIN NAVIGATION
    $('#tlHom, #NaviHom').click(function () {
        pausenavi();
        gotohom();
    });
    $('#tlUmf, #NaviUmf, #NaviSur').click(function () {
        pausenavi();
        gotoumf();
    });
    $('#tlMas, #NaviMas').click(function () {
        pausenavi();
        gotomas();
    });

    function pausenavi() {
        $('#tlHom, #NaviHom, #tlUmf, #NaviUmf, #NaviSur, #tlMas, #NaviMas').unbind('click').css({
            'cursor': 'default'
        });
        setTimeout(function () {
            $('#tlHom, #NaviHom').click(function () {
                pausenavi();
                gotohom();
            });
            $('#tlUmf, #NaviUmf, #NaviSur').click(function () {
                pausenavi();
                gotoumf();
            });
            $('#tlMas, #NaviMas').click(function () {
                pausenavi();
                gotomas();
            });
            $('#tlHom, #NaviHom, #tlUmf, #NaviUmf, #NaviSur, #tlMas, #NaviMas').css({
                'cursor': 'pointer'
            });
        }, 1500);
    }

    function gotohom() {
        if (countval == 1) {
            playHom();
        } else {
            countval = "4";
        }
        showTextR = '#TextHom';
        Nelem = '#NaviHom';
        $("#timeline").animate({
            "width": "15px"
        });
        gaTrackPage((LangEn ? '/en':'') + '/home/');
        chnContHUM();
    }

    function gotoumf() {
        if (countval == 1) {
            playUmf();
        } else {
            countval = "3";
        }
        showTextR = '#TextUmf';
        if ($('#LangEng').length == 0) {
            Nelem = '#NaviUmf';
        } else {
            Nelem = '#NaviSur';
        };
        gaTrackPage((LangEn ? '/en':'') + '/umfeld/');
        chnContHUM();
        $("#timeline").animate({
            "width": "80px"
        });
    }

    function gotomas() {
        if (countval == 1) {
            playMas();
        }
        showTextR = '#TextMas';
        Nelem = '#NaviMas';
        gaTrackPage((LangEn ? '/en':'') + '/masterplan/');
        chnContHUM();
        $("#timeline").animate({
            "width": "150px"
        });
    }
    $('#tlCam, #NaviCam, #NaviCamE, #LCamp').live('click', function () {
        countval = "2";
        showTextR = '#TextCam';
        toogleTextR();
        stoploop0 = 1;
        ansicht = "Gebs";
        loadCamp();
        $('#GebImg:hidden, #GebKnoten:hidden').show();
        $("#timeline").animate({
            "width": "550px"
        });
        $("#EXVnavi, #EXVrp, #EXVvis1").attr('style', 'display: block');
        if ($('#LangEng').length == 0) {
            Nelem = '#NaviCam';
            $(".NSbg").css("left", "435px").show();
        } else {
            Nelem = '#NaviCamE';
            $(".NSbg").css("left", "405px").width(90).show();
        };
        NClick();
    });
    $('#tlWeb, #NaviWeb, #NaviWebE, #BuildS').live('click', function () {
        countval = "2";
        showTextR = '#TextBau';
        toogleTextR();
        loadFile = LangEn + 'baustelle';
        loadAjax();
        $("#timeline").animate({
            "width": "415px"
        });
        holdUp();
        if ($('#LangEng').length == 0) {
            Nelem = '#NaviWeb';
            $(".NSbg").css("left", "582px").show();
        } else {
            Nelem = '#NaviWebE';
            $(".NSbg").css("left", "525px").width(147).show();
        };
        NClick();
        $('#LifeCamTurm, #H3Turm').addClass('Green');
        $('#LifeCamHalle, #H3Halle, #VideoCamTurm, #VideoCamHalle, #H3Hotel, #LifeCamHotel, #VideoCamHotel,#LifeCamParkhaus, #H3Parkhaus, #VideoCamParkhaus').removeClass('Green');
    });
    $('#Imp').click(function () {
        countval = "2";
        loadFile = LangEn + 'impressum';
        showTextR = '#TextImp';
        toogleTextR();
        loadAjax();
        $("#timeline").animate({
            "width": "0px"
        });
        naviOff();
        if (window.location.hash.substr(1, 4) == 'news') {
            changeHashBack();
        }
        $('#ContNewsIn > h2').removeClass().attr('style', '');
    });
    $('#Kont').click(function () {
        $("#timeline").animate({
            "width": "415px"
        });
        countval = "2";
        showTextR = '#TextContact';
        toogleTextR();
        loadFile = LangEn + 'kontakt';
        loadAjax();
        if ($('#LangEng').length == 0) {
            Nelem = '#NaviWeb';
            $(".NSbg").css("left", "582px").show();
        } else {
            Nelem = '#NaviWebE';
            $(".NSbg").css("left", "525px").width(147).show();
        };
        NClick();
    });

    reinitialiseScrollPane = function () {
        $('.scroll').jScrollPane();
    }

    function toogleTextR() { //RIGHT COLUMN (TEXT) TOOGLE
        $('#ContTextIn > div').hide();
        $(showTextR).show();
        reinitialiseScrollPane();
    }

    function chnContHUM() { //PAGE CHANGE home-umfeld-masterplan
        $('#ContNewsOut, #ContNewsOut').hide();
        $('#ContFlash').show();
        mainSWF();
        toogleTextR();
        NClick();
    }

    function removeCont() { //CALLED BY PAGE CHANGE
        if ($('#GebAjax').children().length) {
            $("#GebAjax").children().remove();
        }
        if ($('#GebKnoten').length) {
            $('#GebKnoten').hide();
        }
        if ($('#contentajax').children().length) {
            $('#contentajax').children().remove();
        }
        $('#ContNewsOut, #contentajax').hide();
        $(".NSbg").hide();
        if ($('#AjaxL').length) {
            $('#AjaxL').remove();
        }
        $('#ContNewsOut').hide();
        $('#RS_Ajax').hide();
        removeGrClass();
        $('#NSs > a').addClass('Green');
    }

    function removeGrClass() {
        $('.ContNaviSec > ul > li > ul > li > a').removeClass();
    }

    function loadAjax() {
        $('#planbereich').remove();
        removeCont();
        $('#contentajax').show();
        var url = Lang + 'txt/' + loadFile + '.html';
        $.ajax({
            url: url,
            cache: false,
            success: function (data) {
                $('#contentajax').html(data);
                if (loadFile == "baustelle" || loadFile == "en-baustelle" || loadFile == "webcam-en" || loadFile == "kontakt" || loadFile == "en-kontakt") {
                    //NAVI HOVER HIGHLIGHT
                    $('#ContNaviGal').css('opacity', 0.8);
                    $("#NSgal").hover(function () {
                        $('ul:first', this).fadeIn();
                    }, function () {
                        $('ul:first', this).fadeOut('fast');
                    });
                    $('#Baust > ul > li').mouseover(function (e) {
                        PLeft = $(this).attr('style').split(" ");
                        $(this).css({
                            'background-position': PLeft[1] + ' -20px'
                        });
                    }).mouseout(function (e) {
                        if ($(this).attr('class').length == 0) {
                            $(this).css({
                                'background-position': PLeft[1] + ' 1px'
                            });
                        }
                    })
                }
            }
        });
        gaTrackPage(url);
    }

    function removeGrClassBau() {
        $('#ContNaviGal > li > a').removeClass();
    }
    $('#NSweb').live('click', function () {
        showTextR = '#TextWeb';
        toogleTextR();
        loadFile = "WebCam";
        loadbaustelle();
        BauNelem = "#NSweb";
        bauNClick();
    });
    $('#NSinf, #IPoint').live('click', function () {
        showTextR = '#TextBauInfo';
        toogleTextR();
        loadFile = "BaustellenInfos";
        loadbaustelle();
        BauNelem = "#NSinf";
        bauNClick();
    });
    $('#NSkon, .FAQCont').live('click', function () {
        showTextR = '#TextContact';
        toogleTextR();
        loadFile = "BauKontakt";
        loadbaustelle();
        BauNelem = "#NSkon";
        bauNClick();
    });
    $('#bau-gal-O1, #bau-gal-O2, #bau-gal-LLC, #bau-gal-W1D, #bau-gal-W1E, #bau-gal-W2, #bau-gal-G, #bau-gal-FF, #bau-gal-E').live('click', function () {
        $('#BauFAQ').empty().hide();
        $('#RS_Ajax').nextAll().remove();;
        BauFileN = $(this).attr('id');
        $("#BaustelleMain").galimg();
        BauNelem = "#NSgal";
        bauNClick();
        removeGrClassBau();
        $('#' + BauFileN + ' > a').addClass('Green');
    });
    $('#NSfaq').live('click', function () {
        secid = "Proj";
        showTextR = '#TextFAQ';
        $("#BaustelleMain").empty();
        toogleTextR();
        $('#BauFAQ').load(Lang + 'txt/' + LangEn + 'faq.html').show();
        gaTrackPage(Lang + 'txt/' + LangEn + 'faq.html');
        BauNelem = "#NSfaq";
        bauNClick();
    });

    //(baustelle)
    function loadbaustelle() {
        $('#BauFAQ').empty().hide();
        $('#BaustelleMain').load(Lang + 'txt/' + LangEn + 'webcam.html #' + loadFile)
        gaTrackPage(Lang + 'txt/' + LangEn + 'webcam.html/' + loadFile);
    }

    function bauNClick() {
        if ($('.BOn').length != 0) {
            PLeft = $('.BOn').attr('style').split(" ");
            $('.BOn').css({
                'background-position': PLeft[1] + ' 1px'
            }).removeClass();
            $('#ContNaviGal > li > a').removeClass();
        }
        PLeft = $(BauNelem).attr('style').split(" ");
        $(BauNelem).addClass('BOn').css({
            'background-position': PLeft[1] + ' -20px'
        });
    }
    //FAQ 
    $('#FAQSec > h3').live('click', function () {
        $(this).addClass('FAQSecOn').siblings().removeClass();
        secid = $(this).attr('id');
        $('#Ques > div').hide();
        $('#Ques' + secid).show();
        $('#Answ > div').hide();
        $('#Answ' + secid).show();
    });
    $('#Ques > div > a').live('click', function () {
        $(this).addClass('QuesOn').siblings().removeClass();
        var quesid = $(this).attr('id');
        $('#Answ' + secid + '> div').hide();
        $('#A' + quesid).show();
    });

    //MAIN NAVIGATION HIGHLIGHTING
    $('#ContNavi > div').live('mouseover mouseout', function (event) {
        var PosLeft = $(this).attr('style').split(" ");
        if (PosLeft[2] != undefined && PosLeft[2].length > 8) {
            PosLeft = PosLeft[3];
        } else {
            PosLeft = PosLeft[1]
        };
        if ($(this).attr('class').length == 0) {
            if (event.type == 'mouseover') {
                $(this).css({
                    'background-position': PosLeft + ' 0'
                });
            } else {
                $(this).css({
                    'background-position': PosLeft + ' -25px'
                });
            }
        }
    });

    function naviOff() {
        if ($('.On').length != 0) {
            var NOn = $('.On').attr('style').split(" ");
            if (NOn[2] != undefined && NOn[2].length > 8) {
                NOn = NOn[3];
            } else {
                NOn = NOn[1]
            };
            $('.On').css({
                'background-position': NOn + ' -25px'
            }).removeClass('On');
        }
    }

    function NClick() {
        var NPosLeft = $(Nelem).attr('style').split(" ");
        if (NPosLeft[2] != undefined && NPosLeft[2].length > 8) {
            NPosLeft = NPosLeft[3];
        } else {
            NPosLeft = NPosLeft[1]
        };
        naviOff();
        $(Nelem).addClass('On').css({
            'background-position': NPosLeft + ' 0'
        });
        if (document.title.length != 9) {
            changeHashBack();
        }
        $('#ContNewsIn > h2').removeClass().attr('style', 'color:#000');
    }

    //TIMELINE HIGHLIGHTING
    $('#TimelineH > div, #TimelineH > a').mouseenter(function () {
        $(this).addClass('TimelineHover');
    });
    $('#TimelineH > div, #TimelineH > a').mouseleave(function () {
        $(this).removeClass('TimelineHover');
    });


    //NEWS
    function changeHashBack() {
        window.location.hash = '-';
        document.title = "Campus WU";
    }
    $('#ContNewsOut').hide();
    $('#ContNewsLong').load(Lang + 'cms/content/content.htm', function () {
        $('#ContNewsLong > h1').eq(0).next().prevAll().remove();
        $('#ContNewsLong > h1').eq(0).prev().nextAll().remove();
        var countnews = $("h2").length - 1;
        for (var x = 0; x <= countnews; x++) {
            if ($('#ContNewsLong > h2').eq(x).nextUntil('h2').length != 0) {
                var iddate = $('#ContNewsLong > h2').eq(x).html().substring(0, 10).split('.');
                iddate = 'news-' + iddate[0] + '-' + iddate[1] + '-' + iddate[2];
                var newseintrag = $("h2").eq(x).attr('id', iddate).clone();
            } else {
                var newseintrag = $("h2").eq(x).clone();
            }
            $('#ContNewsIn').append(newseintrag);
        }
        reinitialiseScrollPane();

        //UNIQUE URL FOR NEWS	  	
        var hash = window.location.hash;

        if (hash.substr(1, 4) == 'news') {
            $("#timeline").animate({
                "width": "0px"
            });
            showTextR = '#TextImp';
            toogleTextR();
            naviOff();
            $('#planbereich').remove();
            $('#ContNewsLong').children().hide();
            countval = 2;
            $('#ContNewsLong > #' + hash.substr(1)).show().attr('class', 'NewsTitle');
            $('#ContNewsLong > #' + hash.substr(1)).nextUntil('h2').show();
            $('#ContNewsIn > #' + hash.substr(1)).attr('class', 'Green').attr('style', 'color:#b3d634;');
            $('#ContNewsOut').show();
            reinitialiseScrollPane();
            document.title = "Campus WU: " + hash.substr(1);
        }

    });

    $('#ContNewsIn > h2').live('click', function () {
        var getid = $(this).attr('id');
        loadnews = function () {
            if (getid.length) {
                var ndate = getid;
                window.location.hash = ndate;
                document.title = "Campus WU: " + ndate;

                $('#ContNewsLong').children().hide();
                $('#ContNewsOut').show();
                $('#planbereich').remove();
                $('.NSbg').hide();
                $('#ContNewsIn > h2').attr('style', 'color:#000;').removeClass();
                if ($('#GebKnoten').length) {
                    $('#GebKnoten').hide();
                }
                if ($('#contentajax').children().length) {
                    $('#contentajax').children().remove();
                }
                $('#contentajax').hide();
                if ($('#AjaxL').length) {
                    $('#AjaxL').remove();
                }
                $("#timeline").animate({
                    "width": "0px"
                });
                showTextR = '#TextImp';
                toogleTextR();
                naviOff();
                countval = "2";

                $('#ContNewsLong > #' + getid).show().attr('class', 'NewsTitle');
                $('#ContNewsLong > #' + getid).nextUntil('h2').show();

                $('.scroll').jScrollPane();
                $('#ContNewsIn > #' + getid).attr('class', 'Green').attr('style', 'color:#b3d634;');
            }
            gaTrackPage('/news/' + getid);
        }
        loadnews();
    }).live('mouseover mouseout', function (event) {
        if (event.type == 'mouseover' & $(this).attr('class').length == 0 & $(this).attr('id').length) {
            $(this).attr('style', 'cursor:pointer; color:#777');
        }
        if (event.type == 'mouseout' & $(this).attr('class').length == 0) {
            $(this).attr('style', 'color:#000');
        }
    });

    //(campus)
    var stoploop0;

    function loadCamp() {
        $('#planbereich').remove();
        removeCont();
        $('#GebImg').load(Lang + 'txt/' + LangEn + 'cam.html #' + ansicht);
        gaTrackPage(Lang + 'txt/' + LangEn + 'cam.html/' + ansicht);
        $('#GebImg').ajaxStop(function () {
            if (stoploop0 == 1) {
                $('#map1, #map2, #map3').maphilight();
                $('#GebImg:hidden, #GebKnoten:hidden').show();
                stoploop0 = 0;
            }
        });
    }

    $('#NSs, #NSw, #NSnw').click(function () {
        ansicht = "Geb" + $(this).attr('id').substring(2);
        stoploop0 = 1;
        loadCamp();
        removeGrClass();
        $(this).children().addClass('Green'); //NAVIGATION HIGHLIGHT TOOGLE
    });
    $('#NAnim').click(function () {
        $('#GebImg').hide();
        animSWF();
        removeGrClass();
        $(this).children().addClass('Green'); //NAVIGATION HIGHLIGHT TOOGLE
    });


    //WEB CAM/VIDEO CHANGE
    function viewChange() {
        $('#TextWeb > h3, #TextWeb > div').removeClass('Green');
        $('#camhalle, #camturm, #camhotel, #camparkhaus, #ContLifewebcam').remove();
        $('#ImgCH, #ImgCT, #ImgCHo, #ImgCP').fadeOut('fast');
    }

    function chgPicture() {
        viewChange();
        $('#LifeCam' + CamName + ', #H3' + CamName).addClass('Green');
        $('#ImgC' + CamImgName).fadeIn('Slow');
        if ($('#lifewebcam').length) {
            $('#lifewebcam').attr('src', 'http://campus-' + CamLink + '.indeed.at/cgi-bin/image.jpg?' + Math.random());
        } else {
            $('#CamIn').append('<div id="ContLifewebcam"><img id="lifewebcam" src="http://campus-' + CamLink + '.indeed.at/cgi-bin/image.jpg?' + Math.random() + '"name="lifewebcam" width="412" height="337"></div>');
            freshPic();
        }
    }
    $('#LifeCamTurm').live('click', function () {
        CamName = "Turm";
        CamImgName = "T";
        CamLink = "turm";
        chgPicture();
    });
    $('#LifeCamHalle').live('click', function () {
        CamName = "Halle";
        CamImgName = "H";
        CamLink = "halleb";
        chgPicture();
    });
    $('#LifeCamHotel').live('click', function () {
        CamName = "Hotel";
        CamImgName = "Ho";
        CamLink = "hotel";
        chgPicture();
    });
    $('#LifeCamParkhaus').live('click', function () {
        CamName = "Parkhaus";
        CamImgName = "P";
        CamLink = "parkhaus";
        chgPicture();
    });

    $('#VideoCamTurm').live('click', function () {
        viewChange();
        $('#H3Turm, #VideoCamTurm').addClass('Green');
        $('#ImgCT').fadeIn('Slow');
        CamName = 'camturm';
        camSWF();
    });
    $('#VideoCamHalle').live('click', function () {
        viewChange();
        $('#H3Halle, #VideoCamHalle').addClass('Green');
        $('#ImgCH').fadeIn('Slow');
        CamName = 'camhalle';
        camSWF();
    });
    $('#VideoCamHotel').live('click', function () {
        viewChange();
        $('#H3Hotel, #VideoCamHotel').addClass('Green');
        $('#ImgCHo').fadeIn('Slow');
        CamName = 'camhotel';
        camSWF();
    });
    $('#VideoCamParkhaus').live('click', function () {
        viewChange();
        $('#H3Parkhaus, #VideoCamParkhaus').addClass('Green');
        $('#ImgCP').fadeIn('Slow');
        CamName = 'camparkhaus';
        camSWF();
    });


    //CAMPUS SEC.NAVI
    $('#ContNaviGeb, #ContNaviPlz, #ContNaviAns, #ContNaviHel').css('opacity', 0.7);
    $("ul.ContNaviSec li").hover(function () {
        $('ul:first', this).fadeIn();
    }, function () {
        $('ul:first', this).fadeOut('fast');
    });

    var pname;
    var PLeft; //NAVI HIGHLIGHT
    $('#GebKnoten > .ContNaviSec > ul > li').mouseenter(function () {
        PLeft = $(this).attr('style').split(" ");
        $(this).css({
            'background-position': PLeft[1] + ' -20px'
        }).children().css({
            'display': 'block'
        });
    }).mouseleave(function (e) {
        $(this).css({
            'background-position': PLeft[1] + ' 1px'
        }).children().css({
            'display': 'none'
        });;
    })

    $('#NSf > a, #NSp > a, #NSb > a, #NSe > a, #NSr > a, #NSl > a').mouseover(function (e) {
        pname = $(this).parent().attr('id').substr(2, 3);
        if ($('#GebImg').is(':hidden') == false) {
            $('#p' + pname).fadeIn();
        }
    }).mouseout(function (e) {
        if ($('#GebImg').is(':hidden') == false) {
            $('#p' + pname).fadeOut();
        }
    }).click(function (e) {
        $('#p' + pname).fadeOut();
    })

    //PIAZZA CHANGE
    $('#NSf').click(function () {
        PanoName = 'forum';
        loadcam();
        showTextR = '#TextF';
        toogleTextR();
        $(this).children().addClass('Green');
    });
    $('#NSp').click(function () {
        PanoName = 'patio';
        loadcam();
        showTextR = '#TextP';
        toogleTextR();
        $(this).children().addClass('Green');
    });
    $('#NSb').click(function () {
        PanoName = 'buehne';
        loadcam();
        showTextR = '#TextB';
        toogleTextR();
        $(this).children().addClass('Green');
    });
    $('#NSr').click(function () {
        PanoName = 'relax';
        loadcam();
        showTextR = '#TextR';
        toogleTextR();
        $(this).children().addClass('Green');
    });
    $('#NSe').click(function () {
        PanoName = 'expo';
        loadcam();
        showTextR = '#TextE';
        toogleTextR();
        $(this).children().addClass('Green');
    });
    $('#NSl').click(function () {
        PanoName = 'lounge';
        loadcam();
        showTextR = '#TextL';
        toogleTextR();
        $(this).children().addClass('Green');
    });

    function loadcam() {
        $('#GebImg').hide();
        removeGrClass();
        $('#GebAjax').empty();
        panoSWF();
    }

    //CONECT SEC.MENU AND BUILDING PHOTO HIGHLIGHT
    $('#NSO1 > a').mouseover(function (e) {
        $('#aO1').mouseover();
    }).mouseout(function (e) {
        $('#aO1').mouseout();
    })
    $('#NSO2 > a').mouseover(function (e) {
        $('#aO2').mouseover();
    }).mouseout(function (e) {
        $('#aO2').mouseout();
    })
    $('#NSLLC > a').mouseover(function (e) {
        $('#aLLC').mouseover();
    }).mouseout(function (e) {
        $('#aLLC').mouseout();
    })
    $('#NSW2 > a').mouseover(function (e) {
        $('#aW2').mouseover();
    }).mouseout(function (e) {
        $('#aW2').mouseout();
    })
    $('#NSW1D > a').mouseover(function (e) {
        $('#aW1D').mouseover();
    }).mouseout(function (e) {
        $('#aW1D').mouseout();
    })
    $('#NSW1E > a').mouseover(function (e) {
        $('#aW1E').mouseover();
    }).mouseout(function (e) {
        $('#aW1E').mouseout();
    })

    //FLOR CHANGE
    function chtopbind() {
        $("#exv2, #exv3, #lexv2, #lexv3, #exvZusatz").animate({
            "top": "0"
        }, "fast");
        $("#chtop").animate({
            "top": LB1 + "px"
        }, "fast");
        $("#ch2").animate({
            "top": LB2 + "px"
        }, "fast");
        $("#chZusatz").animate({
            "top": "30px"
        }, "fast");
    }

    function chZbind() {
        $("#exvZusatz").animate({
            "top": "0"
        }, "fast");
        $("#exv2, #exv3, #lexv2, #lexv3").animate({
            "top": GU + "px"
        }, "fast");
        $("#chtop").animate({
            "top": LT1 + "px"
        }, "fast");
        $("#ch2").animate({
            "top": LT2 + "px"
        }, "fast");
        $("#chZusatz").animate({
            "top": "30px"
        }, "fast");
    }

    function ch2bind() {
        $("#lexv3, #exv3, #chtop").animate({
            "top": LT1 + "px"
        }, "fast");
        $("#exv2, #lexv2, #exvZusatz").animate({
            "top": "0px"
        }, "fast");
        $("#ch2").animate({
            "top": LB2 + "px"
        }, "fast");
        $("#chZusatz").animate({
            "top": "30px"
        }, "fast")
    }

    function ch1bind() {
        $("#exv2, #exv3, #lexv2, #lexv3, #exvZusatz").animate({
            "top": GU + "px"
        }, "fast");
        $("#ch2").animate({
            "top": LT2 + "px"
        }, "fast");
        $("#chtop").animate({
            "top": LT1 + "px"
        }, "fast");
        $("#chZusatz").animate({
            "top": "-45px"
        }, "fast");
    }

    //BUILDING CHANGE
    $('#NSLLC, #aLLC, #TN1llc').live('click', function () {
        GBN = 'LLC';
        showTextR = '#TextLLC';
        gbch();
    });
    $('#TN2llc').live('click', function () {
        GBN = 'LLC';
        kch();
    });
    $('#TN3llc').live('click', function () {
        GBN = 'LLC';
        LB1 = '0';
        LT1 = '-75';
        LB2 = '15';
        LT2 = '-60';
        GU = "-75";
        lw = '70';
        lh = '49';
        lt = "115";
        imgt = "-1126";
        exvch();
    });

    $('#NSW1D, #aW1D, #TN1w1d').live('click', function () {
        GBN = 'W1D';
        showTextR = '#TextW1D';
        gbch();
    });
    $('#TN2w1d').live('click', function () {
        GBN = 'W1D';
        kch();
    });
    $('#TN3w1d').live('click', function () {
        GBN = 'W1D';
        LB0 = "top: 75px";
        LB1 = '60';
        LT1 = '5';
        LB2 = '0';
        LT2 = '0';
        GU = "-55";
        lw = '73.6';
        lh = '52';
        lt = "71.8";
        imgt = "-660";
        exvch();
    });

    $('#NSO1, #aO1, #TN1o1').live('click', function () {
        GBN = 'O1';
        showTextR = '#TextO1';
        gbch();
    });
    $('#TN2o1').live('click', function () {
        GBN = 'O1';
        kch();
    });
    $('#TN3o1').live('click', function () {
        GBN = 'O1';
        LB1 = '0';
        LT1 = '-55';
        LB2 = '15';
        LT2 = '-40';
        GU = "-55";
        lw = '74';
        lh = '52';
        lt = "118";
        imgt = "-1085";
        exvch();
    });

    $('#NSW2, #aW2, #TN1w2').live('click', function () {
        GBN = 'W2';
        showTextR = '#TextW2';
        gbch();
    });
    $('#TN2w2').live('click', function () {
        GBN = 'W2';
        kch();
    });
    $('#TN3w2').live('click', function () {
        GBN = 'W2';
        LB0 = "top: 70px";
        LB1 = '61';
        LT1 = '15';
        LB2 = '0';
        LT2 = '0';
        GU = "-46";
        lw = '78';
        lh = '56';
        lt = "56.7";
        imgt = "-482";
        exvch();
    });

    $('#NSO2, #aO2, #TN1o2').live('click', function () {
        GBN = 'O2';
        showTextR = '#TextO2';
        gbch();
    });
    $('#TN2o2').live('click', function () {
        GBN = 'O2';
        kch();
    });
    $('#TN3o2').live('click', function () {
        GBN = 'O2';
        LB0 = "top: 70px";
        LB1 = '58';
        LT1 = '15';
        LB2 = '0';
        LT2 = '0';
        GU = "-43";
        lw = '68';
        lh = '48';
        lt = "44";
        imgt = "-439";
        exvch();
    });

    $('#NSW1E, #aW1E, #TN1w1e').live('click', function () {
        GBN = 'W1E';
        showTextR = '#TextW1E';
        gbch();
    });
    $('#TN2w1e').live('click', function () {
        GBN = 'W1E';
        kch();
    });
    $('#TN3w1e').live('click', function () {
        GBN = 'W1E';
        LB1 = '0';
        LT1 = '-50';
        LB2 = '15';
        LT2 = '-35';
        GU = "-50";
        lw = '79';
        lh = '59.5';
        lt = "70.5";
        imgt = "-568";
        exvch();
    });

    function gbch() {
        $('#GebImg').hide();
        $('#GebAjax').empty().load(Lang + 'txt/' + LangEn + 'cam-rnd-' + GBN + '.html');
        gaTrackPage(Lang + 'txt/' + LangEn + 'cam-rnd-' + GBN + '.html');
        removeGrClass();
        $('#NS' + GBN + '> a').addClass('Green');
        stoploop = 1;
        gbchange();
        toogleTextR();
    }

    function exvch() {
        LinkHref = Lang + 'img/exv/' + GBN + '_lB.jpg';
        $('#GebImg').hide();
        $('#GebAjax').empty().load(Lang + 'txt/' + LangEn + 'cam-geb-' + GBN + '.html #exv' + GBN);
        gaTrackPage(Lang + 'txt/' + LangEn + 'cam-geb-' + GBN + '.html/exv' + GBN);
        stoploop = 1;
        gbchange();
    }

    function kch() {
        $('#GebAjax').empty().load(Lang + 'txt/' + LangEn + 'cam-geb-' + GBN + '.html #K' + GBN);
        gaTrackPage(Lang + 'txt/' + LangEn + 'cam-geb-' + GBN + '.html/K' + GBN);
        stoploop = 1;
        gbchange();
    }

    function gbchange() {
        $('#GebAjax').ajaxStop(function () {
            if (stoploop == 1) {
                if ($('#galcont').length == 0) {
                    $('.cloud-zoom, .cloud-zoom-gallery').CloudZoom();
                    $('#chtop').click(function () {
                        chtopbind();
                    });
                    $('#ch2').click(function () {
                        ch2bind();
                    });
                    $('#ch1').click(function () {
                        ch1bind();
                    });
                    $('#chZusatz').click(function () {
                        chZbind();
                    });
                } else {
                    $("#GebAjax").galimg();
                }

                stoploop = 0;
            }
        }).show();
        removeGrClass();
        $('#NS' + GBN + '> a').addClass('Green');
    }

    $("#GBMin").live('click', function () { //SLIDE-NAVI TOOGLE
        var contwidth = $('#NaviMap').width() - 34;
        if ($('#NaviMap').position().left == 0) {
            $('#ThirdNavi').fadeOut();
            $('#NaviMap').animate({
                "left": "-=" + contwidth + "px"
            }, 1000, function () {
                $('#GBMin').css({
                    'background-position': ' -984px -20px'
                });
                $('#EXVnavi').hide();
            });
        } else {
            $('#EXVnavi').show();
            $('#ThirdNavi').fadeIn();
            $('#NaviMap').animate({
                "left": "+=" + contwidth + "px"
            }, 1000, function () {
                $('#GBMin').css({
                    'background-position': '-984px 0'
                });
            });
        }
    });



});
