// History + Hijax + Thickbox settings
(function($){

$.Hijax =
{
	hijaxControllers: new Array(),
	addController: function(controller, object)
	{
		this.hijaxControllers.push(controller);
	},

	hijaxCall: function(hash, data)
	{
		var hclength = $.Hijax.hijaxControllers.length;
		for(var i = 0; i < hclength; i++)
		{
			$.Hijax.hijaxControllers[i](hash, data);
		}
	}
};
})(jQuery);

$(document).ready(function()
{
  $.ThickBox.groupNames = ['foto', 'okno'];
  $.ThickBox.useHistory = true;
  $.Hijax.addController($.ThickBox.showImageByHash);

  $('.thickbox').ThickBox({minWidth: 480});

	$.historyInit($.Hijax.hijaxCall);
});

// Thickbox Fix
jQuery(document).ready(function(){
    jQuery('a.thickbox, area.thickbox, input.thickbox').click(function(){
        jQuery('#TB-overlay').css({'filter':'alpha(opacity=70)', '-moz-opacity':'0.7', 'opacity':'0.7'});
        jQuery('#TB-iframe').css({'filter':'alpha(opacity=0)', '-moz-opacity':'0', 'opacity':'0'});
        jQuery('#TB-window img').css({'_margin-top':'0'});
        jQuery('#TB-image').css({'zoom':'1'});

        var isMSIE6 = jQuery.browser.msie && /MSIE 6\.0/i.test(window.navigator.userAgent) && !/MSIE 7\.0/i.test(window.navigator.userAgent);

        // IE 6 hacks
        if (isMSIE6) {
            var Height_0 = document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'
            jQuery('#TB_overlay').css({'height':Height_0});

            var MarginTop_0 = 0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px';
            jQuery('#TB_window').css({'margin-top':MarginTop_0});

            var MarginTop_1 = 0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px';
            jQuery('#TB_load').css({'margin-top':MarginTop_1});

            var Height_1 = document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px';
            jQuery('#TB_HideSelect').css({'height':Height_1});
        }

        if (!isMSIE6) {
            jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
        }
        return false;
    });
});

