﻿
$(document).ready(function () {

    setUpBrowsers();

    scalePage();

    activateMenu();

});


$(window).resize(function () {
    scalePage();
});



function scalePage() {
    var content = $('div.Content');
    var footer = $('div.Footer');
    var footerH = footer.height();
    var headerH = $('div.HeaderLogo').height();
    var contentY = 0;

    var browserwidth = $(window).width();
    var browserheight = $(window).height();

    contentY = (browserheight - (headerH-120) - content.height())/2;



    if (browserheight > 695) {
        if (content.height() < 580) {
            content.css('top', contentY);
        }
    }
    else {
        content.css('top', 200);
    }


}




function setUpBrowsers() {

    var flashDetect;

    if (navigator.userAgent.indexOf("iPad") != -1) {
        activateBackgroundImage();
    }

    if (navigator.userAgent.indexOf("Android") != -1) {
        activateBackgroundImage();
    }

}





function activateMenu() {

    $('#menuCompany').mouseenter(function () {
        $('ul.subCompany').css("display", "block");
        $('ul.subPortfolio').css("display", "none");
    });

    $('ul.subCompany').mouseleave(function () {
        $(this).css("display", "none");
    });

    $('#menuPortfolio').mouseenter(function () {
        $('ul.subPortfolio').css("display", "block");
        $('ul.subCompany').css("display", "none");
    });

    $('ul.subPortfolio').mouseleave(function () {
        $(this).css("display", "none");
    });

}




function activateBackgroundImage() {

    $("#divVideo").css("visibility", "hidden");


    jQuery(function ($) {
        $.supersized({
            start_slide: 0, 	//Start slide (0 is random) //Requires multiple background images
            vertical_center: 1, 	//Vertically center background
            horizontal_center: 1, 	//Horizontally center background
            min_width: 0, //Min width allowed (in pixels)
            min_height: 0, //Min height allowed (in pixels)
            fit_portrait: 0, 	//Portrait images will not exceed browser height
            fit_landscape: 0, 	//Landscape images will not exceed browser width
            image_protect: 0, 	//Disables image dragging and right click with Javascript
            slides: [ 		//Background image
												  		{image: '/_images/backImage1.jpg' },
												  		{ image: '/_images/backImage2.jpg' },
												  		{ image: '/_images/backImage3.jpg' }
												]
        });
    });

}
