
//--------------------------------------------------------------------
// Popups
//--------------------------------------------------------------------
var popupStatus = 0;

function loadPopup(poplayer){
    //loads popup only if it is disabled
    if(popupStatus==0){
        $("#bgPop").css({"opacity": "0.7"}).fadeIn("slow");
        $(poplayer).fadeIn(1000);
        popupStatus = 1;
    }
}

function disablePopup(poplayer){
    //disables popup only if it is enabled
    if(popupStatus==1){
        $("#bgPop").fadeOut("slow");
        $(poplayer).fadeOut("slow");
        popupStatus = 0;
    }
}

function centerPopup(poplayer,xpos,ypos){
    var popupHeight = $(poplayer).height();
    var popupWidth = $(poplayer).width();
if(ypos<popupHeight){
ypos = popupHeight+40;
}
else{
    ypos =ypos;
}

    $(poplayer).css({
        "position": "absolute",
        "top": (ypos-popupHeight-20),
        "left": (xpos-popupWidth-20)
    });
    return false;
}





//--------------------------------------------------------------------
//Document Ready
//--------------------------------------------------------------------

$(function(){
    //ie6 check
    var ie6="<div style='border: 1px solid #F7941D; background: #FEEFDA; text-align: center; clear: both; height: 75px; position: relative;'>    <div style='position: absolute; right: 3px; top: 3px; font-family: courier new; font-weight: bold;'></div>    <div style='width: 640px; margin: 0 auto; text-align: left; padding: 0; overflow: hidden; color: black;'>      <div style='width: 75px; float: left;'><img src='http://www.lujong-frankfurt.de/images/ie6nomore-warning.jpg' alt='Warning!'/></div>      <div style='width: 275px; float: left; font-family: Arial, sans-serif;'>        <div style='font-size: 14px; font-weight: bold; margin-top: 12px;'>Sie verwenden einen veralteten Browser</div>        <div style='font-size: 12px; margin-top: 6px; line-height: 12px;'>Für eine bessere Erfahrung mit dieser Website finden Sie ein Upgrade auf einen modernen Webbrowser.</div>      </div>      <div style='width: 75px; float: left;'><a href='http://www.firefox.com' target='_blank'><img src='http://www.lujong-frankfurt.de/images/ie6nomore-firefox.jpg' style='border: none;' alt='Get Firefox 3.5'/></a></div>      <div style='width: 75px; float: left;'><a href='http://www.browserforthebetter.com/download.html' target='_blank'><img src='http://www.lujong-frankfurt.de/images/ie6nomore-ie8.jpg' style='border: none;' alt='Get Internet Explorer 8'/></a></div>      <div style='width: 73px; float: left;'><a href='http://www.apple.com/safari/download/' target='_blank'><img src='http://www.lujong-frankfurt.de/images/ie6nomore-safari.jpg' style='border: none;' alt='Get Safari 4'/></a></div>      <div style='float: left;'><a href='http://www.google.com/chrome' target='_blank'><img src='http://www.lujong-frankfurt.de/images/ie6nomore-chrome.jpg' style='border: none;' alt='Get Google Chrome'/></a></div>    </div>  </div>";
         if($.browser.msie && $.browser.version<"7.0"){
         $("body").empty();
         $("body").append(ie6);
        }


    //zebra
    $(".rent tr:even,.program tr:even").css("background-color", "#d0cde2");
    $(".rent tr:odd,.program tr:odd").css("background-color", "#e2e9f1");
    //--------------------------------------------------------------------
    //Popups
    //--------------------------------------------------------------------
    $("#imp").click(function(e){
        centerPopup('#popImp',e.pageX,e.pageY);
        loadPopup('#popImp');
    });

    //close 
    $(".popClose").click(function(){
        disablePopup('.pop');
    });
    //Click out event!
    $("#bgPop").click(function(){
             disablePopup('.pop');
    });
    //Press Escape event!
    $(document).keypress(function(e){
            if(e.keyCode==27 && popupStatus==1){
                   disablePopup('.pop');
            }
    });
    //bubbles
    $(".tbubble").mouseover(function(e){
                    var bubbleWidth = $(".bubble").width();
                     $(".bubble").css({
                        "position": "absolute",
                        "top": (e.pageY-100),
                        "left": (e.pageX-bubbleWidth/2)
                        }).fadeIn("slow");
                }).mouseout(function(){
                   $(".bubble").fadeOut("slow");
                });


});

