/****************************************\ * Author: Fabio R. Panettieri * * Date: 05-08-2008 * * Email: frenzo.panettieri@concatel.com * * CVT Argentina * * -------------------------------------- * * Namespace containing general purpose * * functions * \****************************************/ if (typeof Common == 'undefined') { var Common = {}; /** * Return the max height that can be used to display something in screen */ Common.getBrowserHeight = function() { var viewportheight = 0; // the more standards compliant browsers if (typeof window.innerHeight != 'undefined'){ viewportheight = window.innerHeight; } // IE6 in standards compliant mode // (i.e. with a valid doctype as the first line in the document) else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientHeight != 'undefined' && document.documentElement.clientHeight != 0){ viewportheight = document.documentElement.clientHeight; } // older versions of IE else{ viewportheight = document.getElementsByTagName('body')[0].clientHeight; } return viewportheight; } Common.getBrowserWidth = function() { var viewportwidth = 0; // the more standards compliant browsers if (typeof window.innerWidth != 'undefined'){ viewportwidth = window.innerWidth; } // IE6 in standards compliant mode // (i.e. with a valid doctype as the first line in the document) else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0){ viewportwidth = document.documentElement.clientWidth; } // older versions of IE else{ viewportwidth = document.getElementsByTagName('body')[0].clientWidth; } return viewportwidth; } Common.completeSize = function(size) { var retSize = String(size); /* Check if it's a valid size */ if( retSize.indexOf('%') == -1 && retSize.indexOf('px') == -1 && retSize != "centered"){ retSize += 'px'; } return retSize; } Common.centerPopup = function() { var bw = Common.getBrowserWidth(); var bh = Common.getBrowserHeight(); $('.popup-container .popup-body[@hc="true"]').each(function(){ var left = (bw - $(this).width()) / 2; $(this).css('left', Common.completeSize(left)); }); $('.popup-container .popup-body[@vc="true"]').each(function(){ var top = (bh - $(this).height()) / 2; $(this).css('top', Common.completeSize(top)); }); } window.onresize = Common.centerPopup; }