var containerId = '#tabs-container';
var tabsId = '#tabs';
var set_vAlign=false;
//var cwidth = window.outerWidth;
//var cheight = window.outerHeight;
$(document).ready(function(){
	// Preload tab on page load
	if($(tabsId + ' LI.current A').length > 0){
		loadTab($(tabsId + ' LI.current A'));
	}
	
    $(tabsId + ' A').click(function(){
    	if($(this).parent().hasClass('current')){ return false; }
    	
    	$(tabsId + ' LI.current').removeClass('current');
    	$(this).parent().addClass('current');
    	
    	loadTab($(this));    	
        return false;
    });

    //alert(window.innerHeight + ' - ' + $(window).height());
    resizePage();
     $(window).bind('resize', function() {
           resizePage();

          // alert($(window).innerHeight());
     }).trigger('resize');



});
function resizePage(){
         var viewportwidth;
         var viewportheight;
         var viewheight;
         // the more standards compliant browsers (mozilla/netscape/opera/IE7)
         // use window.innerWidth and window.innerHeight
         if (typeof window.innerWidth != 'undefined')
         {
              viewportwidth = window.innerWidth,
              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.clientWidth !=
             'undefined' && document.documentElement.clientWidth != 0)
         {
               viewportwidth = document.documentElement.clientWidth,
               viewportheight = document.documentElement.clientHeight
         }

         // older versions of IE
         else
         {
               viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
               viewportheight = document.getElementsByTagName('body')[0].clientHeight
         }

        /**
        #top = 150px
        footer=190px
        min height page accept =470px
        */
        viewheight = viewportheight;
        viewheight -= ( $('#header').height() +    $('#footer').height());
        var pad =0;

        viewportheight -= ( $('#header').height() +    $('#footer').height() +130);
        if(viewportheight < 350) viewportheight= 350 ;
         /*
        $('#container').css(($.browser.msie && $.browser.version < 7 ? '' : 'min-') + 'height', ( viewportheight) + 'px');
        $('#content').css(($.browser.msie && $.browser.version < 7 ? '' : 'min-') + 'height', ( viewportheight) + 'px');
        */
        $('#page').css(($.browser.msie && $.browser.version < 7 ? '' : 'min-') + 'height', ( viewportheight)+ 'px');

        if(set_vAlign){
            $('#page').css('padding', '0px');
            $('#art').vAlign();
        }

        $('.bg_wrapper_main').css('min-height',viewheight +  'px');
        /*$('#content').css('min-height',viewportheight+ 'px');
        $('#page').css('min-height',viewportheight+ 'px');*/

}
function loadTab(tabObj){
    if(!tabObj || !tabObj.length){ return; }
    $(containerId).addClass('loading');
    $(containerId).fadeOut('fast');

    $(containerId).load(tabObj.attr('href'), function(){
        $(containerId).removeClass('loading');
        $(containerId).fadeIn('fast');
    });
}
(function ($) {
    // VERTICALLY ALIGN FUNCTION
    $.fn.vAlign = function() {
    	return this.each(function(i){
    	var ah = $(this).height();
    	var ph = $(this).parent().height();
    	var mh = Math.ceil((ph-ah) / 2);
    	$(this).css('margin-top', mh);
    	});
    };
})(jQuery);


