(function($){
    // VERTICALLY ALIGN FUNCTION
    $.fn.vAlign = function(){
        return this.each(function(i){
            var ah = $(this).height();
            var ph = $(this).parent().height();
            var mh = (ph - ah) / 2;
            $(this).css('margin-top', mh);
        });
    };
})(jQuery);

///////////////////////////////////////////////////////////////////////////////////////////////////////
//	center images
///////////////////////////////////////////////////////////////////////////////////////////////////////
function centerImages(){
    $('div.apart_image a img').each(function(){
        $(this).vAlign();
    });
}

jQuery(document).ready(function(){
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////
    //	center images
    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    centerImages()
    setInterval("centerImages()", 500);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    //	fancybox
    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    jQuery("div.apart_image a").fancybox({
        'hideOnContentClick': true,
        'overlay': true
    });
    jQuery("div.gallery a").fancybox({
        'hideOnContentClick': true,
        'overlay': true
    });
    jQuery("div.image a").fancybox({
        'hideOnContentClick': true,
        'overlay': true
    });
    jQuery("div.apart_image a").fancybox({
        'hideOnContentClick': true,
        'overlay': true
    });
	jQuery("a.fancyBox").fancybox({
        'hideOnContentClick': true,
        'overlay': true
    });
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    //	png fix
    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    jQuery('div.apart_image').pngFix()
    jQuery('div.wysiwyg').pngFix()
	jQuery('div#intro_text').pngFix()
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    //	WSSlider
    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    jQuery('#central_banner').WSSlider({
        timeOut: 4000,
        showDescription: true
    });
	
	jQuery('#central_banner_medium').WSSlider({
        timeOut: 10000,
        showDescription: false
    });
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    //	superfish menu
    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    jQuery("ul.sf-menu").superfish().find('ul').bgIframe({
        opacity: true,
        delay: 100, 
        animation: {
            opacity: 'show',
            height: 'show'
        }, // fade-in and slide-down animation 
        speed: 'fast', // faster animation speed 
        autoArrows: false, // disable generation of arrow mark-up 
        dropShadows: true // disable drop shadows
    });
	
	jQuery('ul.sf-menu').children('li').each(function(i)
	{
		jQuery(this).css({"z-index":999-i});
	});
	
	 ///////////////////////////////////////////////////////////////////////////////////////////////////////
    //	accordion
    ///////////////////////////////////////////////////////////////////////////////////////////////////////
	jQuery('#faq_list').accordion({ 
   		autoheight: false,
		 header: "h2.question" 
	});
	
	jQuery('#attachments').accordion({
		alwaysOpen: false,
		active: false,
   		autoheight: false,
		header: "h2.title"
		
	});
	jQuery("#sitemap").WSSitemap();
});

