var FullscreenrOptions = {  width: 1000, height: 650, bgID: '#bgimg' };
jQuery.fn.fullscreenr(FullscreenrOptions);

$(function()
{
	$('#scroll').jScrollPane({showArrows:true, scrollbarWidth: 25, dragMaxHeight:10});
});

$(function(){

	// Accordion
	$("#accordion").accordion({ header: "h3" });

	//hover states on the static widgets
	$('#dialog_link, ul#icons li').hover(
		function() { $(this).addClass('ui-state-hover'); },
		function() { $(this).removeClass('ui-state-hover'); }
	);

});


function filterProgram(classname) {
    $('#programtable tr').css('display', 'none');

    $('#programtable tr.' + classname + '').css('display', 'table-row');
    $('#programtable tr.header').css('display', 'table-row');
    $('#scroll').jScrollPane({showArrows:true, scrollbarWidth: 25, dragMaxHeight:10});
    
    if (classname == 'resettoall') {
        $('#programtable tr').css('display', 'table-row');
    	$('#scroll').jScrollPane({showArrows:true, scrollbarWidth: 25, dragMaxHeight:10});
    }
    return false;
}

var artistBox = {
    cache               : [],
    artistname          : '#header_right h2',
    artistdescription   : '#header_right #artistdescription',
    artistimage         : '#header_right .artistimage',
    artistinfolinks     : 'a.artistinfo',

    loadinfo : function( id ) {
        if (typeof this.cache[id] == 'undefined') {
            $.ajax({
                url: '/dconn/json/entity.get.php',
                dataType: 'json',
                data: {'id' : id, 'ent' : 'DY_ArtistInfo'},
                success: function(data, state) {
                    if (state == 'success') {
                        artistBox.cache[ data.objects[0]['id'] ] = data.objects[0];
                        artistBox.loadinfo( data.objects[0]['id'] );
                    }
                }
            });
        } else {
            if (data = this.cache[id]) {

                if (data.contentsmall && data.contentsmall.substring(0,3) != '<p>')
                    data.contentsmall = '<p>' + data.contentsmall + '</p>';

                $(this.artistdescription).html((data.contentsmall ? data.contentsmall : '') + '<p><a href="' + data.url + '" class="readmore">Lees meer</a></p>');
                $(this.artistname).html(data.title);

                if (data.goticon)
                    $(this.artistimage).css({
                        'background-image'  : 'url(' + data.icon_url + ')',
                        'display'           : 'block'
                    });
                else
                    $(this.artistimage).css({
                        'display'           : 'none'
                    });
            }
        }
    },

    init    : function()
    {
        $(this.artistinfolinks).click(function() {
            artistBox.loadinfo(this.rel);
            return false;
        });
    }
}
$(document).ready(function() {
    artistBox.init();
});
$(document).ready(function()
    {
        $("#programtable").tablesorter();
    }

);

$(window).load(function() {
	$("img").each(function () {
		if ($(this).attr("align")=='left')
			$(this).css({
				'margin' : '0 10px 0 0'
			});
		else if ($(this).attr("align")=='right')
			$(this).css({
				'margin' : '0 0 0 10px'
			});
	});
	
	$(".logoimg").each(function () {
		$(this).css({
			'margin-left' : -$(this).width()/2 ,
			'margin-top' : -$(this).height()/2
		});
	});

	$('#gallery').flickrGallery({
		api_key: 'dbf003de41bc007905dc2b9a8f672865',
		loading_msg: '<img src="/images/ajax-loader.gif" /><br/> Laden.....',
		photoset_ids: [
			'72157623459784040'
		]
	});
});

