(function($)
{
	var settings;
	$.fn.pixrepBrowser = function(callerSettings)
	{
		settings = $.extend(
		{
			transformer: function(id)
			{
			    var arr = id.split("_");
			    return arr[arr.length-1];
				
			}
		}, callerSettings || {});
		
		settings.current = -1;
		//settings.thumbnails = $("#imageslist img")
		
		settings.thumbnails = $("#imageslist div.OuterImageWrap")
	        
	        .click(function()
	        { 
	            showPhoto(this.index);
	        })
	        
	        .mouseover( function()
		    {$(this).addClass("overrow");}).mouseout(function(){$(this).removeClass("overrow");});
		
		settings.thumbnails.each(function(n)
		{
		    this.index = n;
		    this.imageID = settings.transformer( this.id );
		    
		    // $(this).parent().parent().imageID = this.imageID;
		    // $(this).parent().parent().index = n;
		    
		});
		
		$("#imageslist img").each(function(n)
		{
		    this.index = n;
		    this.imageID = settings.transformer( this.id );
		    
		});
		
		
/*
        $(".OuterImageWrap").mouseover( function()
		    {$(this).addClass("overrow");}).mouseout(function(){$(this).removeClass("overrow");});
*/		
		
		this.browse = function( dir )
	    {
		    var num = settings.current + dir;
		    num = Math.max( num, 0 );
		    num = Math.min( num, settings.thumbnails.length-1 );
		    
		    if( num != settings.current )
    		     showPhoto( num );
	    }
	    this.getListStatus = function( currentID )
	    {
	        var num = settings.thumbnails.filter('[imageID*=' + currentID + ']').attr( "index" );
	        
	        if( num <= 0 )
	            return 1;
	        else if( num >= settings.thumbnails.length-1 )
	            return -1;
	        else
	            return 0;
	    }

		return this;
	};
	var showPhoto = function(index) 	
	{
	    settings.current = index;
	    var c = settings.thumbnails;
		var w = window.open( "ViewOne.aspx?id=" + settings.thumbnails[index].imageID, "bild",
            "width=680,height=600,status=1,location=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0" );
        w.focus();
	};
}
)(jQuery);


(function($)
{
	$.fn.pixrepTree = function()
	{
		$('li', this.get(0)).each(
			function()
			{
				subbranch = $('ul', this);
				if (subbranch.size() > 0) {
					if (subbranch.eq(0).css('display') == 'none') {
						$(this).prepend('<img src="include/treeimages/plus.gif" width="16" height="16" class="expandImage" />');
					} else {
						$(this).prepend('<img src="include/treeimages/minus.gif" width="16" height="16" class="expandImage" />');
					}
				} else {
					$(this).prepend('<img src="include/treeimages/spacer.gif" width="16" height="16" class="expandImage" />');
				}
				
				$(this).addClass( "treeItem" );
			}
		);
		$('img.expandImage', this.get(0)).click(
			function()
			{
				if (this.src.indexOf('spacer') == -1) {
					subbranch = $('ul', this.parentNode).eq(0);
					if (subbranch.css('display') == 'none') {
						subbranch.show();
						this.src = 'include/treeimages/minus.gif';
					} else {
						subbranch.hide();
						this.src = 'include/treeimages/plus.gif';
					}
				}
			}
		);
		
	}
})(jQuery);