$(document).ready(function(){

        banner();

        $.ImageBox.init({
		loaderSRC: 'common/js/imagebox/loading.gif',
		closeHTML: '<img src="common/js/imagebox/close.jpg" />'
	});
	base();
	$("table.t-tabs td:first").addClass("active");
	$("table.t-tabs td").click(function(){
		$TabId = $(this).attr("id").split("-");
		$TabIdNum = Number($TabId[1]);
		$(this).addClass("active").siblings("td").removeClass("active");
		$("#b-tab-"+$TabIdNum).addClass("active-b-tab").siblings("div.b-tab").removeClass("active-b-tab");
	});
	$("div.b-gallery > div > a >img, tr.c-imgs > td > a > img").hover(function(){$(this).addClass("over");},function(){$(this).removeClass("over");});				
	$.fn.alignCenter = function() {
      //get margin left
      var marginLeft = Math.max(40, parseInt($(window).width()/2 - $(this).width()/2)) + 'px';
      //get margin top
      var marginTop = Math.max(40, parseInt($(window).height()/2 - $(this).height()/2)) + 'px';
      //return updated element
      return $(this).css({'margin-left':marginLeft, 'margin-top':marginTop});
   };
	tizer_show(); return false;
});

$(window).resize(function(){
	base();
        banner();
});
var $headId = "head";
var $bodyId = "body";
var $baseId = "base";

function getWindowHeight(){
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') windowHeight = window.innerHeight;
	else {
		if (document.documentElement && document.documentElement.clientHeight) windowHeight = document.documentElement.clientHeight;
		else if (document.body && document.body.clientHeight) windowHeight = document.body.clientHeight;
	}
	return windowHeight;
}

function banner(){
	$screen_w = $(window).width();
	$banner_w = $('.banner').width();
	$left = $screen_w - $banner_w;
	$('.banner').css('left', $left);
}


function base(){
	$winHeight = getWindowHeight();
	if ($("#"+$headId)) $headHeight = $("#"+$headId).height();
	else $headHeight = 0;
	$bodyHeight = $("#"+$bodyId).height();
	$baseHeight = $("#"+$baseId).height();
	$difHeight = $winHeight - ($headHeight + $bodyHeight + $baseHeight);	
	if ($difHeight > 0) $("#"+$baseId).css({"position":"absolute", "bottom":"0px", "width":"100%"});
	else $("#"+$baseId).css({"position":"static"});
}

//close pop-up box
function tizer_close()
 {
   $('#opaco').toggleClass('hidden').removeAttr('style');
   $('#popup').toggleClass('hidden').css({
   	"display" : "none"
   }).html();
   return false;
 }

//open pop-up
function tizer_show(popup_type)
 {
   //when IE - fade immediately
   if($.browser.msie)
   {
     $('#opaco').height($(document).height()).toggleClass('hidden');
   }
   else
   //in all the rest browsers - fade slowly
   {
     $('#opaco').height($(document).height()).toggleClass('hidden').fadeTo('slow', 0.7);
   }

   $('#popup')
     .alignCenter()
     .toggleClass('hidden');

   return false;
 }

