(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("p.pedigree a").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: false
    });
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    //	superfish menu
    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    jQuery("ul.sf-menu").superfish().find('ul').bgIframe({
        opacity: true,
        delay: 200, // half second delay on mouseout 
        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
    });
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////
    //	music
    //////////////////////////////////////////////////////////////////////////////////////////////////////
	var music = "<div id=\"music\"></div>"
	jQuery("div#header").append(music);
	jQuery("div#music").flash({ 
		src: "http://www.fioccorosso.hr/_assets/_flash/mp3_player.swf",
		width: 125,
		height: 16,
		wmode: "transparent",
		version: '9.0.0' 
	});
});

function popupFlash(){
    window.open("http://www.fioccorosso.hr/_assets/_flash/index.html", "FlashPlayer", "menubar=no,width=125,height=16,toolbar=no");
}
