var ratio_img = 0;
var ratio_video = 0;
var id_video_background = "bg_video";
var id_img_background = "bg_img";
var id_img_filter = "bg_filter";
var id_bg_sidebar = "bg_sidebar";
var adjust_left_fixe = -1;
var width_video = 0;
var frame_size=980;

function resizeVideo()
{
    var imgWidth = $(window).width() - frame_size;    
    var imgHeight = imgWidth * ratio_img;                
    if(imgHeight < $(window).height())
    {                         
        imgHeight = $(window).height() +20;
        imgWidth = (imgHeight / ratio_img) ;
    }
    
    var vidWidth = $(window).width() - frame_size ;    
    var vidHeight = vidWidth * ratio_video;                
    if(vidHeight < $(window).height())
    {                         
    	vidHeight = $(window).height() +20;
        vidWidth = (vidHeight / ratio_video);
    }
    var sidebarHeight = $(window).height();
    var sidebarWidth = $('#'+id_bg_sidebar).height() * ratio_sidebar;
    

    $('#'+id_video_background).css({position: "fixed", 'z-index': 0,width: vidWidth,height:vidHeight,'top' : ($(window).height() - vidHeight) / 2, "left" : 0 });

    
    $('#'+id_img_background).css({position: "fixed", 'z-index': 1});
    $('#'+id_img_background).css({'top' : ($(window).height() - imgHeight) / 2 /*, 'left' : ($(window).width() - imgWidth) / 2*/});      
    $('#'+id_img_background).width(imgWidth);
    $('#'+id_img_background).height(imgHeight);
    //$("#"+id_img_background).css("margin-left",frame_size);
    
    $('#'+id_bg_sidebar).css({position: "fixed", 'z-index': 2});
    $('#'+id_bg_sidebar).css({'top' : 0, 'left' : 0});      
    $('#'+id_bg_sidebar).width(sidebarWidth);
    $('#'+id_bg_sidebar).height(sidebarHeight);
    
    $('#'+id_img_filter).css({position: "fixed", 'z-index': 2});
    $('#'+id_img_filter).css({'top' : ($(window).height() - imgHeight) / 2 /*, 'left' : ($(window).width() - imgWidth) / 2*/});      
    $('#'+id_img_filter).width(imgWidth);
    $('#'+id_img_filter).height(imgHeight);
    $("#"+id_img_filter).css("margin-left",frame_size);
    
    
} 
function toggleVideo()
{
    if(playBgVid){
    $('#'+id_video_background).css({'display' : "block"});
    $('#'+id_img_background).css({'display' : "none"}); 
    }
}
function is_numeric(input){
    return typeof(input)=='number';
  }


$(window).resize(function() 
{
    resizeVideo();  
}); 
$(document).ready(function() 
{
	adjust_left_fixe =  parseInt($('#'+id_video_background).css("left").replace("px", ""));
	width_video =  $('#'+id_video_background).width();
	ratio_video = $('#'+id_video_background).height() / $('#'+id_video_background).width();
    ratio_img = $('#'+id_img_background).height() / $('#'+id_img_background).width();
    ratio_sidebar = $('#'+id_bg_sidebar).width() / $('#'+id_bg_sidebar).height();
    //alert( $(window).height() );
   // alert(ratio_video+" - "+ratio_img);
    resizeVideo();

});

function open_pop_up(path, name, width, height)
{
    var centerWidth  = (window.screen.width - width) / 2;
    var centerHeight = 200;

    window.open(path, name, 'width=' + width + ', height=' + height + ', scrollbars=yes, left=' + centerWidth + ', top=' + centerHeight);

    return false;
}


