/*******************************************************************************

	CSS on Sails Framework
	Title: Soroe Kunstmuseum
	Author: XHTMLized (http://www.xhtmlized.com/)
	Date: September 2011

*******************************************************************************/

$.fn.extend({
	equalHeights: function(h){

		var tallest= 0; 
		if(!h) {
			h = 'min-height';
		}

		$(this).each(function(){
			if($(this).height() > tallest){
				tallest = $(this).height();
			}
		}).css(h, tallest);

		if($.browser.msie && parseInt($.browser.version, 10) === 6) {
			$(this).height(tallest);
			return this;
		}
	}

});

$(document).ready(function() {       
    
    // note: don't use eqal heights since the lines should not have same height as content
    // $('#sidebar, #content, #sidebar .navTreeLevel0').equalHeights();

    // tooltips: http://flowplayer.org/tools/tooltip/index.html
    $(".imageviewer .imageWrapper [title]").tooltip({
       'position': "center center"
       // ,'relative' : true
    }); // dont make global

    // some listing tweaks
    $('.template-folder_summary_view .tileItem:even').addClass('even');

    // some box tweaks
    $('#content .column .box:first').addClass('first');
    // $('#content .column .box .box-inner p').last().addClass('last');
    $('#content .column .box:first p').last().addClass('last');

    // some tools tweaks
    $('#tools ul li:last').addClass('language');

    var boxes_rel = $("#content .column .box .box-inner[rel]");
    if (boxes_rel.length) {    
        // http://flowplayer.org/tools/overlay/index.html
        $("#content .column .box .box-inner[rel]").overlay({
                // top: "center",
                // left: "center",
                speed: 800        
        });
    }; // end if boxes_rel.length
    
    var imageviewer_tabs = $("#content .imageviewer .slidetabs");
    if (imageviewer_tabs.length) {    
    
        // based upon http://goo.gl/VvWQj
        // http://flowplayer.org/tools/tabs/slideshow.html
        imageviewer_tabs.tabs("#content .imageviewer .item", {
            // start from the beginning after the last tab
            // rotate: true
    
        // use the slideshow plugin. It accepts its own configuration
        }).slideshow({clickable: false});    
        // add overlay based on each sorrunding image link
        // nb new versions of jquery tools dosnt have the gallery feature any longer
        // http://flowplayer.org/tools/forum/40/40584
        var imageviewer_items = $("#content .imageviewer .item .imageWrapper a");
    
        if (imageviewer_items.length) {
            $("#content .imageviewer .item .imageWrapper a[rel]").overlay({
             // each trigger uses the same overlay with the id "gallery"
    
            // mask don't play well in ie
            // // some mask tweaks suitable for modal dialogs
            //         mask: {
            //          color: '#000000',
            //          loadSpeed: 'fast',
            //          opacity: 1 //0.9 
            //         },
    
             // target: '#gallery',
             top: "center",
             left: "center"
                
            });
        }; // end if imageviewer_items.length
    };
    // end if imageviewer_tabs.length
    
    
}); // end document ready

