jQuery.noConflict();

var fullscreenWin;

/**
 *
 */
function set_fullscreen() {
    if (window.name == "fullscreen") {       
        window.opener.location = window.location;
        window.close();  
    } else {
        h = screen.availHeight;
        w = screen.availWidth;
        fullscreenWin = window.open(window.location, 'fullscreen', 'width='+w+',height='+h+',left=0,top=0,fullscreen=yes, scrollbars=auto');
        fullscreenWin.focus();
    }
}

/**
 * Die Rechte Seite in der Größe anpassen
 */
function adjust_geometry() {
    var img_height = jQuery("#background").css("height"),
        img_width = jQuery("#background").css("width"),
        window_width = getWindowSize().width;

 h = jQuery(window).height();
    delta = parseInt(h, 10) - parseInt(img_height, 10);
    //jQuery("#text").html("h:" + h +  "h-img" + img_height +  " delta:" + delta).show();
    if (delta >= 80) {
       jQuery("#bottom_menu_wrapper").css("top", img_height);
       jQuery("#bottom_menu_wrapper").css("bottom", "0px");

    } else {
       jQuery("#bottom_menu_wrapper").css("top", "").css("position","fixed");
    }



    if (window_width > img_width) {
        img_width = window_width;
    }

    jQuery("#right_content").css("height", img_height);
    if (isMobile()) {
        adjust_for_mobile();
    } else {
        var w = parseInt(img_width, 10) - parseInt(jQuery("#right_content").css("left"), 10);
        jQuery("#right_content").css("width", w + "px");
    }

    // Unteres Menu nach oben verschieben
   
    
//    jQuery("#bottom_menu_wrapper").css("width", img_width);
//    jQuery("#bottom_menu_wrapper").css("bottom", "0px");
   // jQuery("#text").html("h:" + img_height + ", w:" + img_width);
}

/**
 *
 */
function preload_background_image(loader_image) {
    jQuery.preload("#background",
        {placeholder: loader_image,
        onComplete: function (data) {
        },
        onFinish: function () {
            adjust_geometry();            
        }
    });
}

/**
 *
 */
function adjust_for_mobile() {
    if (isMobile()) {
        var h = "617";
        set_iphone_orientation();
        jQuery("#background").css("width", "980px");
        jQuery("#background").css("height", h + "px");
        if (isiPad() && set_iphone_orientation() == "landscape") {
            h = h - 30;
        }
        jQuery("#bottom_menu_wrapper").css("top", (h) + "px");
        jQuery("#right_content").css("height", h);
    }
}


/*******************************************************************************
 * 
 */

jQuery(document).ready(function() {

    
    // Scroll-Pane for left content
    jQuery(function() {
        jQuery('.scroll-pane').jScrollPane({
            verticalGutter: 0,
            arrowScrollOnHover: true,
            showArrows: true
        });
        jQuery('.jspHorizontalBar').hide();
    });

    // if browser zooming occurs
    window.onresize = adjust_geometry;

    // für iphone/ipad
    if (isMobile()) {
        window.onload = function initialLoad() {
            adjust_for_mobile();
        };
        addEventListener("load", function(){
            setTimeout(adjust_for_mobile, 0);
        }, false);
        setInterval(adjust_for_mobile, 400);

        

    } else {
        // Telefonnummern Link wieder weg
        jQuery(".telno").each(
            function() {
                jQuery(this).replaceWith(jQuery(this).text());
            });

        
        


    }


    // Timer, um in jedem Fall right_content correkt zu haben
    setTimeout(adjust_geometry, 0);
    setInterval(adjust_geometry, 100);

});



