﻿var wWidth, wHeight;
var IniHeightLogo, IniWidthLogo;
var RatioImgLogo;
var LoadImages = false;


(function ($) {
    $(document).ready(function () 
    {           
        IniSize();
    }
    );
}
)(jQuery);


(function ($) 
{
    $(window).resize(function () 
    {       
       if (LoadImages) RedimWindow();
    });
}
)(jQuery);

function IniSize()
{
   //Comprobamos si la imagen de fondo se ha cargado
   if (document.getElementById("ImgFondo").complete)
   {   
     IniWidthLogo = document.getElementById("ImgLogo").clientWidth;
     IniHeightLogo = document.getElementById("ImgLogo").clientHeight;
     RatioImgLogo = Math.round((IniHeightLogo / IniWidthLogo) * 100) / 100;

     LoadImages = true;
     RedimWindow();
   }
   else
   {
     setTimeout("IniSize();", 100);
   }

}

function RedimWindow() 
{
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        wWidth = window.innerWidth;
        wHeight = window.innerHeight;
    }
    else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        wWidth = document.documentElement.clientWidth;
        wHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        wWidth = document.body.clientWidth;
        wHeight = document.body.clientHeight;
    }

    if (wHeight < wWidth) 
    {   
        var NewImgHeight = Math.round((wHeight * 0.12) * 100) / 100;
        $("#ImgLogo").css("height", NewImgHeight);
        var NewImgWidth = Math.round((NewImgHeight / RatioImgLogo) * 100) / 100;
        $("#ImgLogo").css("width", NewImgWidth);

    }
    else 
    {   
        
        var NewImgHeight = Math.round((wWidth * 0.12) * 100) / 100;
        $("#ImgLogo").css("height", NewImgHeight);
        var NewImgWidth = Math.round((NewImgHeight / RatioImgLogo) * 100) / 100;
        $("#ImgLogo").css("width", NewImgWidth);

    }    
    
    var widthDiv = document.getElementById("MsgContent").clientWidth;    
    $("#lblErrorG").css("font-size", Math.round(wWidth / 60));
    $("#lblErrorP").css("font-size", Math.round(wWidth / 70));

    $("#ImgFondo").css("visibility", "visible");
    $("#ImgLogo").css("visibility", "visible");
    $("#MsgContent").css("visibility", "visible");

}
