function urlencode (str) {
    // URL-encodes string  
    // 
    // version: 911.718
    // discuss at: http://phpjs.org/functions/urlencode    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brett-zamir.me)    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Lars Fischer    // +      input by: Ratheous
    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Joris
    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
    // %          note 1: This reflects PHP 5.3/6.0+ behavior    // %        note 2: Please be aware that this function expects to encode into UTF-8 encoded strings, as found on
    // %        note 2: pages served as UTF-8
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
    // *     example 2: urlencode('http://kevin.vanzonneveld.net/');    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
    str = (str+'').toString();
        // Tilde should be allowed unescaped in future versions of PHP (as reflected below), but if you want to reflect current
    // PHP behavior, you would need to add ".replace(/~/g, '%7E');" to the following.
    return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
                                                                    replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}

function html_entity_decode (string, quote_style) {
    // Convert all HTML entities to their applicable characters  
    // 
    // version: 912.1423
    // discuss at: http://phpjs.org/functions/html_entity_decode    // +   original by: john (http://www.jd-tech.net)
    // +      input by: ger
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman    
    // +   improved by: marc andreu
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Ratheous
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Nick Kolosov (http://sammy.ru)    // +   bugfixed by: Fox
    // -    depends on: get_html_translation_table
    // *     example 1: html_entity_decode('Kevin &amp; van Zonneveld');
    // *     returns 1: 'Kevin & van Zonneveld'
    // *     example 2: html_entity_decode('&amp;lt;');    
    // *     returns 2: '&lt;'
    var hash_map = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {        return false;
    }
 
    // fix &amp; problem
    // http://phpjs.org/functions/get_html_translation_table:416#comment_97660    delete(hash_map['&']);
    hash_map['&'] = '&amp;';
 
    for (symbol in hash_map) {
        entity = hash_map[symbol];        tmp_str = tmp_str.split(entity).join(symbol);
    }
    tmp_str = tmp_str.split('&#039;').join("'");
    
    return tmp_str;
}

function trim (str, charlist) {
    // Strips whitespace from the beginning and end of a string  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/trim    
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: mdsjack (http://www.mdsjack.bo.it)
    // +   improved by: Alexander Ermolaev (http://snippets.dzone.com/user/AlexanderErmolaev)
    // +      input by: Erkekjetter
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)    
    // +      input by: DxGx
    // +   improved by: Steven Levithan (http://blog.stevenlevithan.com)
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // *     example 1: trim('    Kevin van Zonneveld    ');    // *     returns 1: 'Kevin van Zonneveld'
    // *     example 2: trim('Hello World', 'Hdle');
    // *     returns 2: 'o Wor'
    // *     example 3: trim(16, 1);
    // *     returns 3: 6    
    var whitespace, l = 0, i = 0;
    str += '';
    
    if (!charlist) {
        // default list        
        whitespace = " \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000";
    } else {
        // preg_quote custom list
        charlist += '';
        whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '$1');    }
    
    var l = str.length;
    for (var i = 0; i < l; i++) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {            
        	str = str.substring(i);
            break;
        }
    }
        l = str.length;
    for (i = l - 1; i >= 0; i--) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(0, i + 1);
            break;        }
    }
    
    return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}

// Gets an request-parameter from the url
function getRequestParam(name)
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  
  if( results == null )
    return "";
  else
    return results[1];
}

// Changes the url parameter 
function ChangeLanguage(string)
{
	var actURL=document.URL;
		if(getRequestParam('lang')!=""){
			window.location=actURL.replace("lang="+getRequestParam('lang'),"lang="+string);
		}else if(actURL.indexOf("?")!=-1){
			window.location=actURL+"&lang="+string;
		}else{
			window.location=actURL+"?&lang="+string;
		}
}

// Translates the text to the current language if neccessary
function TranslateLanguage(string) 
{
	if(string!=null && typeof TranslationTable[string.toLowerCase()] != "undefined") {
		var Parts = explode('|',TranslationTable[string.toLowerCase()]);
		
		if(Parts != null && Parts.length > 0)
			return (Language == "german") ? Parts[0] : Parts[1];
	}
	return (string == "undefined") ? "undefined" : string;
}


// function to check the username on register
function checkUsername() {
	var username = jQuery(".textinput[name=username]").val();
	var match = /^[a-zA-Z0-9]+$/; // Matching a-z,A-Z and 0-9
	
	if(match.test(username)) { // That username is okay
		jQuery("#username_limitation").fadeOut("normal");
		return true;
	} else { // That username is not okay
		jQuery("#username_limitation").fadeIn("normal"); 
		return false;
	}
		
	return false;
}

/**
 * Callback Function for the Album Slider
 * Adds controls etc
 */
function albumslider_initCallback(carousel) {
    /*jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

    jQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });*/

    jQuery('body.gal .albumlist .btn .next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('body.gal .albumlist .btn .prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

// Adds the "singlecol"-Class to .row.mainbody on doc.ready
function MakeSingleColLayout() {
	jQuery(function() { 
		jQuery('div#main div.row.mainbody').addClass('singlecol'); 
	});
}

// Adds the "cols-33-66"-Class to .row.mainbody on doc.ready
function Make33_66ColLayout() {
	jQuery(function() {
		jQuery('div#main div.row.mainbody').addClass('cols-33-66');
	});
}

// Creates a EC Layout from the regular thumbnail overview
function MakeECLayout() {
	// Check if container is available
	jQuery('.images').each(function() {
		// Get the html of the first item and remove it
		var splash_html = jQuery('<div>').append(jQuery('.images>#img_col_0>.item:first').eq(0).remove().clone()).html();
		
		// Create two cols to split the content for layouting
		jQuery('.images').prepend('<div id="split_col_one" class="col"></div><div id="split_col_two" class="col"></div>');
		
		// Get the split cols
		var col_one = jQuery('#split_col_one');
		var col_two = jQuery('#split_col_two');
		
		// Split the content and append 2 imgcols each splitcol + clr
		jQuery(col_one).append(jQuery('#img_col_3').removeClass('last')).append(jQuery('#img_col_0')).append('<div class="clr"></div>');
		jQuery(col_two).append(jQuery('#img_col_1')).append(jQuery('#img_col_2').addClass('last')).append('<div class="clr"></div>');
		
		// Prepend the splash to .images
		var splash = jQuery(col_one).prepend(splash_html).children('.item').eq(0);
		var splash_img = jQuery(splash).find('img');
		
		// Arrange the splash layout
		jQuery(splash).css({ 
			//backgroundColor:'red', 
			width:'470px',
			//display: 'inline',
			clear: 'both',
			border: '2px solid #ccc',
			marginBottom: '15px',
			padding: '5px'
		})
		
		// Arrange the splash img 
		jQuery(splash_img).attr('src',jQuery(splash_img).attr('src').replace('thumb2_','')).width(470);
	});
}

// Creates a two column layout
function Make2ColumnLayout() {
	// Check if pictures are present
	if(jQuery('.images').size() == 1) {
	    // 1. Fetch items
	    var col0_items = jQuery('#img_col_0 .item');
	    var col1_items = jQuery('#img_col_1 .item');
	    var col2_items = jQuery('#img_col_2 .item');
	    var col3_items = jQuery('#img_col_3 .item');
	
	    // 2. Reduce and clear cols; add class "last" to col 1
	    jQuery('#img_col_0, #img_col_1').empty();
	    jQuery('#img_col_2, #img_col_3').remove();
	    jQuery('#img_col_1').addClass('last');
	    
	
	    // 3. Reinsert items
	    // First and Third into First
	    for(var i = 0; i < min(col0_items.length, col2_items.length); i++) {
	        jQuery('#img_col_0').append(col0_items[i]);
	        jQuery('#img_col_0').append(col2_items[i]);
	    }
	    // Add rest
	    var bigger_i = (col0_items.length > col2_items.length) ? col0_items : col2_items;
	    var rest_i = bigger_i.slice(i);
	    jQuery(rest_i).each(function() {
	        jQuery('#img_col_0').append(jQuery(this));
	    });
	
	    // Second and Forth into Second
	    for(var j = 0; j < min(col1_items.length, col3_items.length); j++) {
	        jQuery('#img_col_1').append(col1_items[j]);
	        jQuery('#img_col_1').append(col3_items[j]);
	    }
	    // Add rest
	    var bigger_j = (col1_items.length > col3_items.length) ? col1_items : col3_items;
	    var rest_j = bigger_j.slice(j);
	    jQuery(rest_j).each(function() {
	        jQuery('#img_col_1').append(jQuery(this));
	    });
	
	    // 4. Fix items
	    jQuery(".images .item").each(function () {
	        jQuery(this).css('width', '484px');
	        var img = jQuery(this).find('img');
	        jQuery(img).css('width', '484px');
	        jQuery(img).css('overflow', 'hidden');
	        jQuery(img).css('height', '323px');
	        jQuery(img).attr('src', jQuery(img).attr('src').replace('thumb2_',''));
	    });
	}
}

// Changes the current Headline to the given string
function Change_HDL(headline) {
	jQuery(function() {
		// Put through translator
		HeadlineText = TranslateLanguage(headline);
		
		oldLink = jQuery('div#main .row.mainbody .blockhdl .hdl img').attr('src');
		
		pos = oldLink.indexOf('text=') + 5;
		//length = 
		
		newLink = jQuery('div#main .row.mainbody .blockhdl .hdl img').attr('src').replace('%20', HeadlineText.toUpperCase());
		
		// Set the final headline
		jQuery('div#main .row.mainbody .blockhdl .hdl img').attr('src',newLink);
	});
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Fixes APAIS-IMG Width (called onLoad)
function CheckAPAIS(me) {
	if(jQuery(me).width() > 505)
		jQuery(me).css('width','505px');
}

/*
 * void ptx_columnize(targetquery, itemclass, numcols, numrows, columnclass = 'column')
 *
 * Gets all elements with {itemclass} in {targetquery} and splits them into {numcols} columns
 * with {numrows} elements per column
 *
 * Returns the items that were not put into a column
 *
 * NOTE: Amount of items in the target should be equal or above the result of numcols*numrows
 *
 * @author bbartels
 */
function ptx_columnize(targetquery, itemclass, numcols, numrows, columnclass) {
	/* TARGET */
	// Getting the target element
	var target = jQuery(targetquery);
	
	// Target available?
	if(target === null) return false;
	
	/* ITEMS */
	// Assembling items query
	var itemsquery = targetquery+' .'+itemclass;
	// Array
	var items = new Array();
	// Getting the number of items
	var num_items = jQuery(targetquery+' .'+itemclass).size();
	
	// Items available?
	if(jQuery(itemsquery) === null) return false;
	
	// Iterate all items and fetch their HTML into items array
	var tmp_html = '';
	jQuery(itemsquery).each(function() {
		// Get the outer HTML
		tmp_html = jQuery('<div>').append(jQuery(this).eq(0).clone()).html();
		
		// Push into items array
		if(tmp_html !== null)
			items.push(tmp_html);
	});
	
	jQuery(targetquery).html('');
	
	
	/* HTML GENERATION */
	
	// Columnclass
	columnclass = (typeof columnclass !== 'undefined') ? columnclass : 'column';
	
	// Generation of the columns
	for(var x = 0; x < numcols; x++) {
		// Class (first/last)
		addclass = (x == 0) ? 'first ' : (x == numcols-1) ? 'last ' : '';
		
		// Column start
		jQuery(targetquery).append('<div id="img_col_'+x+'" class="'+addclass+columnclass+'">\n</div>\n');
	}
	
	// Add clearfix to the target container (Solves bottommenu bug on less than 4 pics)
	jQuery(targetquery).append('<div class="clr"></div>');
	
	// Rows
	var current_col = 0;
	for(var i = 0; i < items.length; i++) {
		// Add an item
		if(typeof items[i] !== 'undefined')
			jQuery('div#img_col_'+current_col).append(items[i]);
			
		current_col++;
		if(current_col > 3) current_col = 0;
	}
}

/* LOG IF CONSOLE EXISTS */
function consolelog(string) {
	if(console)
		console.log(string);
}

/* <LANGUAGE> */
//Language = getRequestParam('lang')== undefined ? "english" : getRequestParam('lang');
var Language = LFI_LANGUAGE;
/* </LANGUAGE> */


// NEW MASTERSHOT ALBUM: ADD ID HERE TOO!
var MASTERSHOTALBUMS = new Array('-2775','-2776','-2777','-3138','-3301','-3426','-3589','-3707','-8788','-10813','-18150');


/* FOR THE DYNAMIC HEADLINES */
/*###########################*/
/* <TRANSLATION TABLE>       */

// Initialisation
var TranslationTable = new Array();

/* General Headlines */
TranslationTable['notset'] = 'Willkommen|Welcome';

TranslationTable['lastup'] = 'Neueste|Latest';
TranslationTable['topn'] = 'Click List|Click List';
TranslationTable['mygallery'] = 'Meine Gallerie|My Gallery';
TranslationTable['imgupload'] = 'Bilderupload|Images Upload';
TranslationTable['login'] = 'Login|Login';
TranslationTable['logout'] = 'Logout|Logout';
TranslationTable['register'] = 'Registrieren|Register';
//TranslationTable['random'] = 'Zuf&auml;llige Bilder|Random Images';
TranslationTable['random'] = 'Willkommen|Welcome';
TranslationTable['random_cat'] = 'Zuf&auml;llige Kategorie|Random Category';
TranslationTable['category_list'] = 'Kategorien|Categories';
TranslationTable['photographers'] = 'Fotografen|Photographers';
TranslationTable['profile'] = 'Benutzerprofil|Userprofile';
TranslationTable['profile_edit'] = 'Benutzerprofil Eingabe|Userprofile Entry';
TranslationTable['portfolio_manager'] = 'Album Manager|Album Manager';
TranslationTable['upload_approval'] = 'Upload Best&auml;tigung|Upload Approval';
TranslationTable['ecard'] = 'E-Card|E-Card';

TranslationTable['wm'] = 'WM 2010 VORBEREITUNG - DIE DEUTSCHE NATIONALMANNSCHAFT VON MICHAEL AGEL|WM 2010 PREPARATION - THE GERMAN NATIONAL SOCCER TEAM BY MICHAEL AGEL';

TranslationTable['editors_choice'] = 'Bild der Woche|Picture of the week';
TranslationTable['apais'] = 'Photo Stories|Photo Story';
TranslationTable['apais_thumbs'] = 'Photo Stories|Photo Stories';
TranslationTable['apais_info']='Photo Story Info|Photo Story Info';
TranslationTable['updating'] = 'Updaten...|Updating...'; 

TranslationTable['comp_8993'] = 'Leica Weihnachtskarte|Leica Seasonal Greetings';
TranslationTable['comp_9177'] = '35 mm Weitwinkel - TOP 100 Shortlist|35 mm wide angle - TOP 100 Shortlist';
TranslationTable['compinfo_seasons'] = 'Leica Weihnachtskarte - Info|Leica Seasonal Greetings - Info';
TranslationTable['compinfo_35mm'] = '35 mm Weitwinkel - Info|35 mm wide angle - Info';
TranslationTable['compwinner_seasons'] = 'Leica Weihnachtskarte - Gewinner 2009|Leica Seasonal Greetings - Winner 2009';
TranslationTable['compwinner_35mm'] = '35 mm Weitwinkel - Gewinner|35 mm wide angle - Winners';

var CompetitionCategories = new Array('47','48');
TranslationTable['compcat_47'] = '35 mm Weitwinkel - TOP 50|35 mm wide angle - TOP 50';
TranslationTable['compcat_48'] = '35 mm Weitwinkel - Finalisten|35 mm wide angle - Finalists';

TranslationTable['cw_admin'] = 'Kalenderwochen Administration|Calendarweeks Administration';
TranslationTable['pow'] = 'Kalenderwochen Auswahl|Calendar Week Collection';
TranslationTable['cpow'] = 'Aktuelle Kalenderwoche|Current Calendar Week';
TranslationTable['spow'] = 'Spezifische Kalenderwoche(Admin Only) - $|Specific Calendar Week(Admin Only) - $';

TranslationTable['obp_special'] = 'Oskar Barnack Preis 2010|Oskar Barnack Award 2010';

/* Mastershot Headlines */
// NEW MASTERSHOT ALBUM: Add new album ids below (Don't forget to add the id a few lines below! (Marked too, as "NEW MASTERSHOT ALBUM") )
TranslationTable['mastershots_M9'] = 'M9 Master Shots|M9 Master Shots';
TranslationTable['mastershots_-2775'] = 'M8 Master Shots|M8 Master Shots';
TranslationTable['mastershots_-2776'] = 'D-LUX Master Shots|D-LUX Master Shots';
TranslationTable['mastershots_-2777'] = 'C-LUX Master Shots|C-LUX Master Shots';
TranslationTable['mastershots_-3138'] = 'DIGILUX Master Shots|DIGILUX Master Shots';
TranslationTable['mastershots_-3301'] = 'DMR Master Shots|DMR Master Shots';
TranslationTable['mastershots_-3426'] = 'V-LUX Master Shots|V-LUX Master Shots';
TranslationTable['mastershots_-3589'] = 'M-ANALOG Master Shots|M-ANALOG Master Shots';
TranslationTable['mastershots_-3707'] = 'R-ANALOG Master Shots|R-ANALOG Master Shots';
TranslationTable['mastershots_-8788'] = 'M9 Master Shots|M9 Master Shots';
TranslationTable['mastershots_-10813'] = 'S2 Master Shots|S2 Master Shots';
TranslationTable['mastershots_-18150'] = 'X1 Master Shots|X1 Master Shots';
TranslationTable['mastershots_info'] = 'Master Shots Info|Master Shots Info';
// Category 4

/* </TRANSLATION TABLE> */
/*###########################*/

// DOCUMENT READY
jQuery(document).ready(function(){
	/* COLUMNIZE */
	if(jQuery('body.gal .mainbody .images').size() > 0 && getRequestParam('nocols') == "")
		ptx_columnize('body.gal .mainbody .images', 'item', 4, 4, 'col column');

	/* EC SPLASH */
	if(window.location.search.indexOf('editors_choice') !== -1 && parseInt(jQuery(document).getUrlParam('page')) == 1)
		MakeECLayout();

	/* GALERIE */
	// Thumbview hover stuff
	jQuery('body.gal .mainbody .images .item').each(function() {
		// Hover Editmenu if own pic/albums or admin
		if(GALLERY_ADMIN_MODE || (USER_ADMIN_MODE && jQuery(document).getUrlParam('cat') == MY_GALLERY)) {
			jQuery(this).hover(
				function(){
					jQuery(this).find('.controlbar').fadeIn('fast');
				},
				function(){
					jQuery(this).find('.controlbar').fadeOut('slow');
				}
			);
		}
	});

	// Album Slider Hide/Show
	jQuery('body.gal .actions')
		.toggle(
			function(){
				jQuery('body.gal .albumlist').slideDown(100);
				jQuery(this).addClass('open');
			},
			function(){
				jQuery('body.gal .albumlist').slideUp(100);
				jQuery(this).removeClass('open');
			}
		);
		
	// Initialisation of the Album Slider
	jQuery("body.gal .albumlist .albums ul").each(function() {
		jQuery(this).jcarousel({
	        scroll: 1,
	        initCallback: albumslider_initCallback,
	        // This tells jCarousel NOT to autobuild prev/next buttons
	        buttonNextHTML: null,
	        buttonPrevHTML: null
	     });
    });
    
    // Menu Fix: Category Menu
    jQuery("#category_spacer").each(function() {
    	var ul = jQuery(this).siblings('.genfont.galmenu.lvl-1');
    	var ul_height = jQuery(ul).height();
    	/*console.log(ul_height);*/
    	
    	jQuery(this).height(ul_height+16);
    });
	
	/* HEADLINE PROCESSING*/
	// Preset/Default value
	var HeadlineText = 'notset';
	var HeadlineFinal = false;
	
	var URLParts = window.location.href.split('/');
	var URLFile = URLParts[URLParts.length-1];
	
	URLFile = (URLFile.indexOf('?') !== -1) ? URLFile.split('?')[0].replace('#','') : URLFile.replace('#','');
	
	/* ##### INDEX.PHP ##### */	
	if(URLFile.toUpperCase() == 'INDEX.PHP') {
		// Get Breadcrumb
		var breadcrumb = jQuery('#LFI_BREADCRUMB_CONTENT').html();
	
		// Headline
		HeadlineText = USER_ID > 0 && breadcrumb!==null ? breadcrumb : "random";
		// Bodyclass
		SwitchBodyClass('user');
		
		
		// PHOTOGRAPHERS OVERVIEW SWITCH
		if(jQuery(document).getUrlParam("cat") != null && jQuery(document).getUrlParam("cat") != MY_GALLERY && jQuery(document).getUrlParam("cat") != 16611) {
			HeadlineText = TranslateLanguage("photographers")+" - "+jQuery('div.photographer_name:first').text();
			// Bodyclass
			SwitchBodyClass('user');
			// Menu
			jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(1)>ul>li:last').addClass('active');
			// Final
			HeadlineFinal = true;
		}
				
		if(window.location.search.indexOf('cat=16611') !== -1) {
			// Headline
			HeadlineText = "S2 master shots";
			// Bodyclass
			SwitchBodyClass('user');
			// Menu
			jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(0)>ul>li:eq(0)>ul>li:eq(0)').addClass('active');
		}
		// Other
		else if(jQuery(document).getUrlParam("cat")==="1") {
			// Headline
			HeadlineText = "photographers";
			// Bodyclass
			SwitchBodyClass('photographers');
			// Menu
			jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(1)>ul>li:last').addClass('active');
		}
		// CATEGORY SWITCH
		if(window.location.search.indexOf('category') !== -1 && getRequestParam('category') != "") {
			// Get Breadcrumb
			var breadcrumb = jQuery('#LFI_BREADCRUMB_CONTENT').html();
			
			// Headline
			HeadlineText = breadcrumb;
			
			// CompetitionCats exception
			var cat = getRequestParam('category');
			if(in_array(cat, CompetitionCategories)) {
				HeadlineText = 'compcat_'+cat;
				
				// Bodyclass
				SwitchBodyClass('competition');
				// Menu
				jQuery('a.compcat_'+cat).parent('li').addClass('active');
				
			} else {
				// Bodyclass
				SwitchBodyClass('category');
				// Menu
				jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(1)>ul>li:eq(1)').addClass('active');
				// Show category submenu
				jQuery('div#category_menu_list_wrapper').show();
			}
		}
		// CATEGORY_LIST SWITCH
		if(window.location.search.indexOf('category_list') !== -1)
		{
			// Headline
			HeadlineText = "category_list";
			// Bodyclass
			SwitchBodyClass('user');
			// Menu
			jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(1)>ul>li:eq(1)').addClass('active');		
		}
		// EDITORS_CHOICE SWITCH
		if(window.location.search.indexOf('editors_choice') !== -1)
		{
			// Headline
			HeadlineText = "editors_choice";
			// Bodyclass
			SwitchBodyClass('editors_choice user');
			//Menu
			jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(1)>ul>li:first').addClass('active');
		}
		// APAIS SWITCH
		if(window.location.search.indexOf('APAIS') !== -1)
		{
			// Headline
			HeadlineText = "apais";
			// Bodyclass
			SwitchBodyClass('apais');
			// Menu
			jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:first>ul>li:eq(1)>ul>li:first').addClass('active');
			
			// APAIS: Date HDL
			/*jQuery('#APAIS_CREATE_DATE').each(function() {
				// Get the date
				var date = jQuery(this).text();
				
				// Set the date
				jQuery('#main .row.mainbody .blockhdl .datehdl img').attr('src',
					jQuery('#main .row.mainbody .blockhdl .datehdl img').attr('src').replace('{DATE}',date)
				).parent().show();
			});*/
		}
	}
	/* ##### COMPETITION THUMBNAILS #####*/
	//thumbnails.php?album=lastup&cat=-8993
	else if(Math.abs(parseInt(jQuery(document).getUrlParam('cat'))) == 8993) {
		// Check if winner photo
		//http://gallery.lfi-online.de/gallery/displayimage.php?album=lastup&cat=-8993&pos=188 
		if(parseInt(jQuery(document).getUrlParam('pos')) == 189) {
			// Headline
			HeadlineText = "compwinner_seasons";
			// Bodyclass
			SwitchBodyClass('user');
			// Menu
			jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(2)>ul>li:eq(1)>ul>li:eq(0)').addClass('active');
			// Final
			HeadlineFinal = true;
		} else {
			// Headline
			HeadlineText = "comp_"+Math.abs(parseInt(jQuery(document).getUrlParam('cat')));
			// Bodyclass
			SwitchBodyClass('user');
			// Menu
			jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(2)>ul>li:eq(1)>ul>li:eq(1)').addClass('active');
			// Final
			HeadlineFinal = true;
		}
	}
	/* ##### COMPETITION THUMBNAILS ##### */
	//thumbnails.php?album=lastup&cat=-9177
	else if(Math.abs(parseInt(jQuery(document).getUrlParam('cat'))) == 9177) {
		// Headline
		HeadlineText = "comp_"+Math.abs(parseInt(jQuery(document).getUrlParam('cat')));
		// Bodyclass
		SwitchBodyClass('user');
		// Menu //                                                                 2
		jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(2)>ul>li:eq(0)>ul>li:eq(2)').addClass('active');
		// Final
		HeadlineFinal = true;
	}
	/* ##### CALENDARWEEK.PHP ##### */
	if(URLFile.toUpperCase() == 'CALENDARWEEK.PHP') {
		// Headline
		HeadlineText= "cw_admin";
		// Bodyclass
		SwitchBodyClass('calendarweek');
	}
	/* #### DISPLAYIMAGE.PHP #### */
	if(URLFile.toUpperCase() == 'DISPLAYIMAGE.PHP' && jQuery(document).getUrlParam('cat') != null && !in_array(jQuery(document).getUrlParam("cat"), MASTERSHOTALBUMS)) {
		HeadlineText = TranslateLanguage("photographers")+" - "+jQuery('div.photographer_name:first').text();
        // Bodyclass
        SwitchBodyClass('user');
        // Menu
        jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(1)>ul>li:last').addClass('active');
	}
	/* #### DISPLAYIMAGE.PHP 2 #### */
	if(URLFile.toUpperCase() == 'DISPLAYIMAGE.PHP' && jQuery(document).getUrlParam('album') != null && parseInt(jQuery(document).getUrlParam('album')) != 19957 && jQuery(document).getUrlParam('pos') != null && jQuery(document).getUrlParam('cat') == null)
	{
		// Menu
		jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(1)>ul>li:last').addClass('active');
	}
	/* ##### PROFILE.PHP ##### */
	if(URLFile.toUpperCase() == 'PROFILE.PHP') {
		// Check if own profile
		if(jQuery(document).getUrlParam('op') == 'edit_profile') {
			// Headline
			HeadlineText = "profile_edit";
			// Bodyclass
			SwitchBodyClass('profile_edit');
			// Menu
			jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(4)>ul>li:eq(2)').addClass('active');
		} else {
			// Headline
			HeadlineText = "profile";
			// Bodyclass
			SwitchBodyClass('profile');
		}
	}
	/* ##### APAIS_INFO.PHP ##### */
	if(URLFile.toUpperCase() == 'APAIS_INFO.PHP') {
		// Headline
		HeadlineText = "apais_info";
		// Bodyclass
		//SwitchBodyClass('apais');
		// Menu
		jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(0)>ul>li:eq(1)>ul>li:last').addClass('active');
	}
	/* #### 35MM_WINNER.PHP #### */
	if(URLFile.toUpperCase() == '35MM_WINNER.PHP') {
		HeadlineText = "compwinner_35mm";
        // Bodyclass
        SwitchBodyClass('user');
        // Menu
        jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(2)>ul>li:first>ul>li:first').addClass('active');
	}
	/* #### OSKAR_BARNACK_2010.PHP #### */
    if(URLFile.toUpperCase() == 'OSKAR_BARNACK_2010.PHP') {
        HeadlineText = "obp_special";
        // Bodyclass
        SwitchBodyClass('user');
        // Menu
        //jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(2)>ul>li:first>ul>li:first').addClass('active');
    }
	/* ##### MASTERSHOTSINFO.PHP ##### */
	if(URLFile.toUpperCase() == 'MASTERSHOTSINFO.PHP') {
		// Headline
		HeadlineText = "mastershots_info";
		// Bodyclass
		SwitchBodyClass('user');
		// Menu
		jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(0)>ul>li:eq(0)>ul>li.last').addClass('active');
	}
	/* ##### COMPINFO_SEASONS.PHP ##### */
	if(URLFile.toUpperCase() == 'COMPINFO_SEASONS.PHP') {
		// Headline
		HeadlineText = "compinfo_seasons";
		// Bodyclass
		SwitchBodyClass('user');
		// Menu
		jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(2)').addClass('active').find('ul>li:eq(1)>ul>li:last').addClass('active');
	}
	/* ##### COMPETITION INFO 35MM ##### */
	if(URLFile.toUpperCase() == 'COMPINFO_35MM.PHP') {
		// Headline
		HeadlineText = 'compinfo_35mm';
		// FINAL!
		HeadlineFinal = true;
		// Bodyclass
		SwitchBodyClass('user');
		jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(2)').addClass('active').find('ul>li:eq(0)>ul>li:last').addClass('active');
	} 
	/* ##### FAQ.PHP ##### */
	if(URLFile.toUpperCase() == 'FAQ.PHP') {
		// Headline
		HeadlineText= "faq";
		// Bodyclass
		SwitchBodyClass('user');
		// Menu
		jQuery('#top-menu ul.topmenu-one>li.last').addClass('active');
	}
	/* ##### ECARD.PHP #####*/
	if(URLFile.toUpperCase() == 'ECARD.PHP') {
		// Headline
		HeadlineText = "ecard";
		// Bodyclass
		SwitchBodyClass('ecard');
		// FINAL!
		HeadlineFinal = true;
	}
	/* ##### DB_INPUT.PHP ##### */
	if(URLFile.toUpperCase() == 'DB_INPUT.PHP') {
		// Headline
		HeadlineText = "updating";
		// Bodyclass
		SwitchBodyClass('db_input');
	}
	/* ##### UPLOAD.PHP ##### */
	if(URLFile.toUpperCase() == 'UPLOAD.PHP') {
		// Headline
		HeadlineText = "imgupload";
		// Bodyclass
		SwitchBodyClass('upload');
		// Menu
		jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:last>ul>li:eq(1)').addClass('active');
	} 
	/* ##### LOGIN.PHP ##### */
	if(URLFile.toUpperCase() == 'LOGIN.PHP') {
		// Headline
		HeadlineText = "login";
		// Bodyclass
		SwitchBodyClass('login'); 
	} 
	/* ##### LOGOUT.PHP ##### */
	if(URLFile.toUpperCase() == 'LOGOUT.PHP') {
		// Headline
		HeadlineText = "logout";
		// Bodyclass
		SwitchBodyClass('logout');
	} 
	/* ##### REGISTER.PHP ##### */
	if(URLFile.toUpperCase() == 'REGISTER.PHP') {
		// Headline
		HeadlineText = "register";
		// Bodyclass
		SwitchBodyClass('register');
		
	// MASTERSHOTS: Add new album ids below too!
	} 
	/* ##### ALBMGR.PHP ##### */
	if(URLFile.toUpperCase() == 'ALBMGR.PHP') {
		// Headline
		HeadlineText = "portfolio_manager";
		// HDLFinal
		HeadlineFinal = true;
		// Bodyclass
		SwitchBodyClass('portfoliomgr');
		// Menu
		jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:last>ul>li:first>ul>li:last').addClass('active');
	}
	/* ##### EDITPICS.PHP - UPLOAD APPROVAL ##### */
	if(URLFile.toUpperCase() == 'EDITPICS.PHP' && window.location.search.indexOf('upload_approval') !== -1) {
		// Headline
		HeadlineText = "upload_approval";
		// Bodyclass
		SwitchBodyClass('upload_approval');
		// FINAL!
		HeadlineFinal = true;
	}
	/* ##### DISPLAYIMAGE.PHP ##### */
	if(URLFile.toUpperCase() == 'DISPLAYIMAGE.PHP' && !HeadlineFinal) {
		// Headline
		HeadlineText = jQuery("#LFI_BREADCRUMB_CONTENT").children('a:last').prev('a').text() + " - " + jQuery("#LFI_BREADCRUMB_CONTENT").children('a:last').text();
		// FINAL!
		HeadlineFinal = true;
		
		// Bodyclass
		SwitchBodyClass('einzelbild');
	} 
	/* ##### THUMBNAILS.PHP ##### */
	if(URLFile.toUpperCase() == 'THUMBNAILS.PHP' && parseInt(jQuery(document).getUrlParam('album')) != 19957 && window.location.search.indexOf('album') !== -1 && parseInt(jQuery(document).getUrlParam('album')) > 0 && parseInt(jQuery(document).getUrlParam('album')) != 6960 && !in_array(getRequestParam('album'), PHOTOTOURSALBUMS) && parseInt(jQuery(document).getUrlParam('cat')) != MY_GALLERY && !HeadlineFinal) {
		// Headline
		HeadlineText = jQuery("#LFI_BREADCRUMB_CONTENT").children('a:last').prev('a').text() + " - " + jQuery("#LFI_BREADCRUMB_CONTENT").children('a:last').text();
		// FINAL!
		HeadlineFinal = true;
		
		// Bodyclass
		SwitchBodyClass('user');
		
		// HDLLink
		var href = jQuery("#LFI_BREADCRUMB_CONTENT").children('a:last').prev('a').attr('href');
		jQuery('.row.mainbody .blockhdl .hdl').attr('href',href);
		
		// Menu
		jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(1)>ul>li:eq(2)').addClass('active');
	}
        /* ##### WM SPECIAL THUMBNAILS #####*/
    else if(parseInt(getRequestParam('album')) == 19957) {
        // Headline
        HeadlineText = "wm";


//jQuery("#LFI_BREADCRUMB_CONTENT").children('a:last').prev('a').text() + " - " + jQuery("#LFI_BREADCRUMB_CONTENT").children('a:last').text();
        // FINAL!
       HeadlineFinal = true;
       
        // Bodyclass
        SwitchBodyClass('user');
       
        // HDLLink
        var href = jQuery("#LFI_BREADCRUMB_CONTENT").children('a:last').prev('a').attr('href');
        jQuery('.row.mainbody .blockhdl .hdl').attr('href',href);
       
        // Menu
        jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(0)>ul>li:eq(2)>ul>li:eq(0)').addClass('active');
    }
	/* ##### APAIS THUMBNAILS #####*/
	else if(parseInt(getRequestParam('album')) == 6960) {
		// Headline
		HeadlineText = "apais_thumbs";
		// Bodyclass
		SwitchBodyClass('user');
		// Menu
		jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(0)>ul>li:eq(1)>ul>li:eq(1)').addClass('active');
		// Final
		HeadlineFinal = true;
	}
	
	// ##### CALENDARWEEK COLLECTION SWITCH #####
	if(URLFile.toUpperCase() == 'THUMBNAILS.PHP' && jQuery(document).getUrlParam('album').toUpperCase() == 'CPOW')
	{
		// Bodyclass
		SwitchBodyClass('cpow user');
		//Menu
		jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(1)>ul>li:first>ul>li:eq(1)').addClass('active');
	}
	// ##### CURRENT CALENDARWEEK SWITCH #####
	if(URLFile.toUpperCase() == 'THUMBNAILS.PHP' && jQuery(document).getUrlParam('album').toUpperCase() == 'POW')
	{
		// Bodyclass
		SwitchBodyClass('pow user');
		//Menu
		jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(1)>ul>li:first>ul>li:eq(2)').addClass('active');
	}
	/* ##### MASTERSHOTS ##### */
	if(in_array(getRequestParam('cat'), MASTERSHOTALBUMS)) {
		// Headline
		HeadlineText = 'mastershots_'+getRequestParam('cat');
		// Menu
		jQuery('.MasterMenu_'+getRequestParam('cat')).parent().addClass('active');
		// Bodyclass		
		SwitchBodyClass('user');
		// Final
		HeadlineFinal = true;
	} 
	/* ##### PHOTO TOURS ##### */
	if(in_array(getRequestParam('album'), PHOTOTOURSALBUMS)&&URLFile.toUpperCase() === 'THUMBNAILS.PHP' ) {
		// Menu
		jQuery('#phototours').siblings('a').children('img').hide();
		jQuery('#phototours').siblings('a').children('img[src$=_a.png]').show();
		
		jQuery('#phototours').parent('li').parent('ul').removeClass('invisible');
		jQuery('#phototours').parent('li').parent('ul').siblings('a').children('img').hide();
		jQuery('#phototours').parent('li').parent('ul').siblings('a').children('img[src$=_a.png]').show();
		
		jQuery('#phototours').removeClass('invisible');
		jQuery('#fancy_outer').attr('name','only_height');
		
		jQuery('.blockhdl .iframe a img[src$=_a.png]').hide();
		// IFrame Menue
		jQuery(jQuery('.blockhdl .iframe.invisible a')[0]).fancybox({'centerOnScroll':false,'titleShow':false,'overlayShow':false,'frameWidth':620,'frameHeight':1320,'callbackOnClose':function(){
			jQuery('.blockhdl .iframe a img').show();
			jQuery('.blockhdl .iframe a img[src$=_a.png]').hide();
			},'callbackOnStart':function(){
				jQuery('#fancy_outer').appendTo(jQuery('div.images'));
				jQuery('#fancy_title').remove();
			},
			'callbackOnShow':function(){
				jQuery('#fancy_outer').css({'position':'absolute','right':0,'top':389,'left':319});
				jQuery('#fancy_inner').css('border','1px solid #CCC');
				jQuery('#fancy_close').css({'right':0,'top':0});
				jQuery('#fancy_bg_nw').remove();
				jQuery('#fancy_bg_n').remove();
				jQuery('#fancy_bg_e').remove();			
				jQuery('#fancy_bg_ne').remove();
				jQuery('#fancy_bg_se').remove();
			}
		});	
		jQuery(jQuery('.blockhdl .iframe.invisible a')[1]).fancybox({'centerOnScroll':false,'titleShow':false,'overlayShow':false,'frameWidth':620,'frameHeight':1400,'callbackOnClose':function(){
			jQuery('.blockhdl .iframe a img').show();
			jQuery('.blockhdl .iframe a img[src$=_a.png]').hide();
			},'callbackOnStart':function(){
				
				jQuery('#fancy_outer').appendTo(jQuery('div.images'));
				jQuery('#fancy_title').remove();
			},
			'callbackOnShow':function(){
				jQuery('#fancy_outer').css({'position':'absolute','right':0,'top':389,'left':319});
				jQuery('#fancy_inner').css('border','1px solid #CCC');
				jQuery('#fancy_close').css({'right':0,'top':0});
				jQuery('#fancy_bg_nw').remove();
				jQuery('#fancy_bg_n').remove();
				jQuery('#fancy_bg_e').remove();			
				jQuery('#fancy_bg_ne').remove();
				jQuery('#fancy_bg_se').remove();
			}
		});
		jQuery(jQuery('.blockhdl .iframe.invisible a')[2]).fancybox({'centerOnScroll':false,'titleShow':false,'overlayShow':false,'frameWidth':620,'frameHeight':950,'callbackOnClose':function(){
			jQuery('.blockhdl .iframe a img').show();
			jQuery('.blockhdl .iframe a img[src$=_a.png]').hide();
			},'callbackOnStart':function(){
				jQuery('#fancy_outer').appendTo(jQuery('div.images'));
				jQuery('#fancy_title').remove();
			},
			'callbackOnShow':function(){
				jQuery('#fancy_outer').css({'position':'absolute','right':0,'top':389,'left':319});
				jQuery('#fancy_inner').css('border','1px solid #CCC');
				jQuery('#fancy_close').css({'right':0,'top':0});
				jQuery('#fancy_bg_nw').remove();
				jQuery('#fancy_bg_n').remove();
				jQuery('#fancy_bg_e').remove();			
				jQuery('#fancy_bg_ne').remove();
				jQuery('#fancy_bg_se').remove();
			}
		});		
		jQuery('.blockhdl .iframe.invisible').removeClass('invisible');
		
		// Remove image informtion
		//jQuery('.photographer_name,.image_title').remove();

		// Set HeadlineText
		HeadlineText=jQuery('#phototours').siblings('a').children('img').attr('alt')+" - reise";
		
		// Bodyclass
		SwitchBodyClass('user');
	}
	/* ##### ELSE ##### */
	else if(!HeadlineFinal) {
		// Overwrite if a album is set (Lastup or Topn)
		HeadlineText = (getRequestParam('album')) ? getRequestParam('album') : HeadlineText;
		// Overwrite if a category is set (My Gallery only)
		HeadlineText = (getRequestParam('cat') == MY_GALLERY) ? "mygallery" : HeadlineText;
	}
	
	// Put through translator and modify
	HeadlineText = TranslateLanguage(HeadlineText);
	HeadlineText = trim(HeadlineText);
	HeadlineText = html_entity_decode(HeadlineText);
	HeadlineText = HeadlineText.toUpperCase();
	HeadlineText = urlencode(HeadlineText);
	
	// Set the final headline
	jQuery('div#main .row.mainbody .blockhdl .hdl img').attr('src',jQuery('div#main .row.mainbody .blockhdl .hdl img').attr('src').replace('%20',HeadlineText));
	
	
	/* CATEGORY_LIST CODE */ 
	jQuery('.photo-list-item').each(function() {
		// ImgPath
		var imgpath = 'categoryThumbs/'+jQuery(this).children('a').attr('rel')+'_'+(1+parseInt(Math.random()*3))+'.jpg';
		// Hover
		jQuery(this).hover(
			function() {
				// Show
			    jQuery('#photo-preview').children('img').attr('src',imgpath).show();
			},
			function() {
				// Hide
			    jQuery('#photo-preview').children('img').attr('src','&nbsp;').hide();
			}
		);
	});
	
	/*jQuery('.col.one #galmenu').parent().after('<div id="category_list">'+jQuery('#photo-list').html()+'</div>');
	jQuery('#photo-list').html('');
	jQuery('.photo-list-item').css('float','left');*/
	
	
	/* MENU CODE */
	// MY GALLERY - Highlighting
	if(getRequestParam('cat') == MY_GALLERY && URLFile.toUpperCase() != 'ALBMGR.PHP')
		jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:last>ul>li:first>ul>li:first').addClass('active');
	// CLICKLIST/TOPN - Highlighting
	if(getRequestParam('album').toLowerCase() == "topn" && getRequestParam('cat') == '')
	{
		jQuery('.blockhdl .topmenu-one>li:first>a>img:visible').hide();
		jQuery('.blockhdl .topmenu-one>li:first>a>img[src$=_a.png]').show();
	}
	// NEWEST/LASTUP - Highlighting
	if(getRequestParam('album').toLowerCase() == "lastup" && getRequestParam('cat') == '')
	{
		jQuery('.blockhdl .topmenu-one>li:eq(1)>a>img:visible').hide();
		jQuery('.blockhdl .topmenu-one>li:eq(1)>a>img[src$=_a.png]').show();
	}
	// [NOTE] PHP-FILE SPECIFIC HIGHLIGHTING CAN BE FOUND ABOVE AT THE HEADLINE PROCESSING [NOTE]
		
	// Mark menu entry
	jQuery('#galmenu li.active').each(function() {
		// Mark
		jQuery(this).children('a').children('img').hide();
		jQuery(this).children('a').children('img[src$=_a.png]').show();

		// Show submenu if existent
		jQuery(this).children('ul').show().removeClass('invisible');
		
		// Show parentmenu if existent
		jQuery(this).parents('.galmenu').not('.lvl-1').each(function() {
			// Show the parentmenu
			jQuery(this).show().removeClass('invisible');
			
			// Mark the menu entry
			if(jQuery(this).prev('a').children('img').length>1){
				jQuery(this).prev('a').children('img').hide();
				jQuery(this).prev('a').children('img[src$=_a.png]').show();
			}
		});
	});
	
	// LVL2: A.OpenSubmenuOnly: Onclick submenu opening and self-marking
	jQuery('.genfont.galmenu.lvl-1 a.opensubmenuonly').not('.genfont.galmenu.lvl-2 a.opensubmenuonly').click(function() {
		
		// Check if invisible, show then
		if(jQuery(this).next('.genfont.galmenu.lvl-2').hasClass('invisible')) 
		{
			// Hide all maybe visible submenus
			jQuery('.genfont.galmenu.lvl-2, .genfont.galmenu.lvl-3').fadeOut('fast').removeClass('invisible').addClass('invisible');
			jQuery('#category_menu_list_wrapper').slideUp('normal')
			// Fade in our submenu
			jQuery(this).next('.genfont.galmenu.lvl-2').fadeIn('normal').removeClass('invisible');
			
			// Unmarking all others
			jQuery('.genfont.galmenu.lvl-1 li a').not('.genfont.galmenu li.active a').each(function() {
				jQuery(this).children('img').show();
				jQuery(this).children('img[src$=_a.png]').hide();
			});
			// Self marking
			if(jQuery(this).children('img').length>1){
				jQuery(this).children('img').hide();
				jQuery(this).children('img[src$=_a.png]').show();
			}
			
			// Specialised Categories marking
			if(jQuery(this).siblings('ul.galmenu.lvl-2').find('.categories').size() == 0) {
				jQuery('#category_menu_list_wrapper').slideUp('normal');
			} 
			else if(jQuery(this).siblings('ul.galmenu.lvl-2').find('.categories').size() > 0 && jQuery(this).siblings('ul.galmenu.lvl-2').find('.categories').parents('li').hasClass('active')) {
				jQuery('#category_menu_list_wrapper').slideDown('normal');
			}
			
		// Hide otherwise
		} else {
			// Hide our submenu
			jQuery(this).next('.genfont.galmenu.lvl-2').add('.genfont.galmenu.lvl-2 .lvl-3').fadeOut('normal').addClass('invisible');
			
			// Hide category menu
			if(jQuery('.categories').is(':visible')) {// && jQuery(this).siblings('ul.galmenu.lvl-2').find('.categories').size() == 0) {
				jQuery('#category_menu_list_wrapper').slideUp('normal');
			} 
			
			// Self un-marking
			jQuery(this).children('img').show();
			jQuery(this).children('img[src$=_a.png]').hide();
			
		}
		
		return false;
	});
	
	// LVL3: A.OpenSubmenuOnly: Onclick submenu opening and self-marking
	jQuery('.genfont.galmenu.lvl-1 .genfont.galmenu.lvl-2 a.opensubmenuonly').click(function() {
		// Check if invisible, show then
		if(jQuery(this).next('.genfont.galmenu.lvl-3').hasClass('invisible')) 
		{
			// Hide all maybe visible submenus
			jQuery('.genfont.galmenu.lvl-3').fadeOut('fast').removeClass('invisible').addClass('invisible');
			jQuery('#category_menu_list_wrapper').slideUp('normal')
			// Fade in our submenu
			jQuery(this).next('.genfont.galmenu.lvl-3').fadeIn('normal').removeClass('invisible');
			
			// Unmarking all others
			jQuery('.genfont.galmenu.lvl-2 li a').not('.genfont.galmenu li.active a').each(function() {
				jQuery(this).children('img').show();
				jQuery(this).children('img[src$=_a.png]').hide();
			});
			// Self marking
			jQuery(this).children('img').hide();
			jQuery(this).children('img[src$=_a.png]').show();
			
			
		// Hide otherwise
		} else {
			// Hide our submenu
			jQuery(this).next('.genfont.galmenu.lvl-3').fadeOut('normal').addClass('invisible');
			
			// Self un-marking
			jQuery(this).children('img').show();
			jQuery(this).children('img[src$=_a.png]').hide();
			
		}
		
		return false;
	});
	
	
/*WORKAROUND*/	// WORKAROUND: Removes the first image area(plus pager) if there are two  
/*WORKAROUND*/	if(jQuery('.images').length > 1) {
/*WORKAROUND*/		jQuery('.images:first').each(function() {
/*WORKAROUND*/			jQuery(this).next().remove();
/*WORKAROUND*/			jQuery(this).remove();
/*WORKAROUND*/		}); 
/*WORKAROUND*/	}

	
	// PAGER: Clone from bottom to top
	if(jQuery('td span.tabbg').length>1&&getRequestParam('cat')!=1){
			jQuery('table tr td span.tabbg').parent().parent().parent().parent().clone().appendTo('div.row.mainbody div.blockhdl').andSelf().attr({'style':'border:none;float:right;width:auto;margin-top:-5px','width':''}).find('td').each(function(){jQuery(this).attr({'width':''}).css('border','none');});
	}else if(jQuery('td span.tabbg').length<2&&getRequestParam('cat')!=1){
			jQuery('table tr td span.tabbg').parent().parent().parent().parent().remove();
	}

	// MENU: Open master shots by default 
	/*
	if(jQuery('div#galmenu').find('li.active').size()==0){
			jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(0)>a:eq(0)>img').attr('src',jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(0) a:eq(0) img').attr('src').replace('999999','000000'));
			jQuery('ul.genfont.galmenu.lvl-2>li:eq(1)>a>img').attr('src',jQuery('ul.genfont.galmenu.lvl-2>li:eq(1)>a>img').attr('src').replace('999999','000000'));
			jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(0) ul.genfont.galmenu.lvl-2').show();
			jQuery('div#galmenu ul.genfont.galmenu.lvl-1>li:eq(0) ul.genfont.galmenu.lvl-2>li:eq(1)>ul.genfont.galmenu.lvl-3').show();
	}*/
	
	// Remove m9 user
	jQuery('div.item>div.photographer_name').each(function(){
		if(jQuery(this).text()==="M9")
			jQuery(this).hide();
	});
	
	// Check if albumlist/slider is already there
	if(jQuery('div.albumlist').length>1)
		jQuery('div.albumlist:last').remove();
		
	/* ADMIN: Upload Approval */
	// Some fix for the images
	if(jQuery('body').hasClass('upload_approval')) {
		jQuery('.form_picinfo_wrapper').each(function() {
			jQuery(this).css("min-height",jQuery(this).parent().height());
		});
	}
	
	
	/* APAIS: Next/Prev Buttons */
	if(typeof APAIS_NumPages !== "undefined" && typeof APAIS_CurrPage !== "undefined") 
	{
		// Show NextLink
		if(APAIS_CurrPage > 1) jQuery('.apais_controls .nextlink').parent().show();
		// Show PrevLink
		if(APAIS_NumPages > APAIS_CurrPage) jQuery('.apais_controls .prevlink').parent().show();
	}
	
	/* APAIS: Dynamic rescale if image is too wide */
	jQuery('#apais_splash a img').each(function() {
		if(jQuery('#apais_splash a').width() > 505)
			jQuery('#apais_splash a img').width(505);
		//else
			//console.log(jQuery('#apais_splash a img').width());
	});
	
	/* APAIS: Move picinfo-container */
	jQuery('#APAIS_PIC_INFO').each(function() {
		var html = jQuery('#APAIS_PIC_INFO').remove().html();
		jQuery('#apais_splash .info').append(html);
	});
	
	/* APAIS: Move controls */
	jQuery('#APAIS_CONTROLS').each(function() {
		var html = jQuery('#APAIS_CONTROLS').remove().html();
		jQuery('div.row.mainbody .blockhdl span.controls').append(html).removeClass('invisible').show();
	});
	
	
	/* Single Picture View Dynamic rescale if image is too wide */
	if(jQuery('body.lfi.gal.einzelbild'))
		if(jQuery('div.img img').width()>640)
			jQuery('div.img img').width(640);
			
	/* BREADCRUMB */
	/*jQuery('#LFI_BREADCRUMB_CONTENT').each(function() {
		if(jQuery(this).html() != '') {
			var html = jQuery(this).html();
		}
	});*/
	
	/* Menu: Categories List */
	if(jQuery('#category_menu_list_wrapper').size() > 0) {
		// Prepare the categories-menu
		jQuery.getJSON("index.php", 
       		{ category_list:"", AJAX:"" },
       		function(returned_data)
         	{
         		if(returned_data != '') {
         		
         			// Prepare HTML
         			var html = '<ul id="category_menu_list">';
         		
         			// Iterate and concatinate
         			jQuery.each(returned_data, function(key, value) {
         				var href = 'index.php?category='+value.pcid+'&page=1';
         				var name = urlencode(html_entity_decode((LFI_LANGUAGE == 'german') ? value.name_de : value.name_en).toUpperCase());
         				
         				// Decide pointsize
         				var point = 13;
         				if((value.pcid == 32 && LFI_LANGUAGE == "german") || (value.pcid == 39 && LFI_LANGUAGE == "english"))
         					point = 14;
         				
         				// Add
         				html += '<li class="category_'+value.pcid+'">'
         					html += '<a href="'+href+'" class="link_wrap"><img class="genfont" src="http://www.lfi-online.de/ceemes/base.php?genfont/show/1/text='+name+'/color=999999/points='+point+'/background=ffffff" alt="'+name+'" />';
         					
         					// Add comma 				
         					if(key < returned_data.length-1) {
         						html += '<img class="comma genfont" src="http://www.lfi-online.de/ceemes/base.php?genfont/show/1/text=,/color=999999/points=13/background=ffffff" alt="," />&nbsp;&nbsp;';
         					}
         				html += '</a></li>';
         			});
         		
         			// Close UL
         			html += '<div style="clear:both;"></div></ul>';
         		
         			// Set HTML
         			jQuery('#category_menu_list_wrapper').html(html)/*.parents('#galmenu').css('height','140px')*/;
         			
         			// Get active cat
         			var cat = getRequestParam('category');
			
					// Set <li> active
					jQuery('.category_'+cat).addClass('active');
					
					//
					var src = jQuery('.category_'+cat+'>a>img.genfont:not(.comma)').attr('src');
					if(typeof src !== "undefined") {
						var source = src.replace('999999','000000');
						jQuery('.category_'+cat+'>a>img.genfont:not(.comma)').attr('src',source);
					}
         		}
         	}
        );
	}
	
	// CW Calendarpicker
	/*if(jQuery('.cw_datepicker.to').size() > 0) {
		jQuery('.cw_datepicker.to').datepicker(
			{
				dateFormat: 'dd.mm.yy',
				altFormat: '@',
				altField: '#to'
			}
		);
	}
	if(jQuery('.cw_datepicker.from').size() > 0) {
		jQuery('.cw_datepicker.from').datepicker(
			{
				dateFormat: 'dd.mm.yy',
				altFormat: '@',
				altField: '#from'
			}
		);
	}*/
	
	/* Menu: PHOTOTOURS */
        jQuery.get('ajax.php',
        	{mode:'getalbs',user:jQuery('#phototours').parent('li').attr('id')},
        	function(html) {
	        	jQuery('#phototours').html(html);
	        	// Get active album
         		var album = getRequestParam('album');
			
				// Set iframe links
				jQuery('#phototours_info').attr('href',jQuery('#phototours_info').attr('href')+jQuery('.genfont.galmenu.lvl-2 li a img[src$=_a.png]:visible').attr('alt')+'_'+jQuery('#phototours li .phototours_'+album).parent().attr('id')+"_info");
				jQuery('#phototours_route').attr('href',jQuery('#phototours_route').attr('href')+jQuery('.genfont.galmenu.lvl-2 li a img[src$=_a.png]:visible').attr('alt')+'_'+jQuery('#phototours li .phototours_'+album).parent().attr('id')+"_route");
				jQuery('#phototours_buchung').attr('href',jQuery('#phototours_buchung').attr('href')+jQuery('.genfont.galmenu.lvl-2 li a img[src$=_a.png]:visible').attr('alt')+'_'+jQuery('#phototours li .phototours_'+album).parent().attr('id')+"_buchung");
				
				jQuery('.row.mainbody .blockhdl .hdl img.genfont').attr('src',jQuery('.row.mainbody .blockhdl .hdl img.genfont').attr('src').replace('REISE',jQuery('#phototours li .phototours_'+album).parent().attr('id')));
				/*
				jQuery('.blockhdl .iframe a img').each(function(){
					jQuery(this).click(function(){
						jQuery(this).attr('src',jQuery(this).attr('src').replace('999999','000000'));
						});
				});
				*/ 
				// Menue Iframe/About highlightning
				
				jQuery('.blockhdl .iframe a img,#phototours_about a img').each(function(){
					jQuery(this).click(function(){
						jQuery('.blockhdl .iframe a img,#phototours_about a img').show();					
						jQuery('.blockhdl .iframe a img[src$=_a.png],#phototours_about a img[src$=_a.png]').hide();
						jQuery(this).hide();
						jQuery('.blockhdl .iframe a img[src*='+jQuery(this).attr('src').replace('.png','_a.png')+'],#phototours_about a img[src*='+jQuery(this).attr('src').replace('.png','_a.png')+']').show();
					});
				}); 
	
				
				// fancy up the about link
				jQuery('#phototours_about a').fancybox({'centerOnScroll':false,'titleShow':false,'overlayShow':false,'frameWidth':620,'frameHeight':870,'callbackOnClose':function(){
					jQuery('#phototours_about a img').attr('src',jQuery('#phototours_about a img').attr('src').replace('000000','999999'));
					},'callbackOnStart':function(){
						jQuery('#fancy_outer').appendTo(jQuery('div.images'));
						jQuery('#fancy_title').remove();
					},
					'callbackOnShow':function(){
						jQuery('#fancy_outer').css({'position':'absolute','right':0,'top':389,'left':319});
						jQuery('#fancy_inner').css('border','1px solid #CCC');
						jQuery('#fancy_close').css({'right':0,'top':0});
						jQuery('#fancy_bg_e').remove();			
						jQuery('#fancy_bg_ne').remove();
						jQuery('#fancy_bg_se').remove();
					}
				});	
				// Highlight menue entry
				var src = jQuery('a.phototours_'+album+' img.genfont').attr('src');
				if(typeof src !== "undefined") {
					var source = src.replace('999999','000000');
					jQuery('a.phototours_'+album+' img.genfont').attr('src',source);
				}	
	        }
		);
		
		// Assing onClick to categories-entry
		jQuery('.galmenu .categories').toggle(function() {
			// ENABLE
			jQuery('#category_menu_list_wrapper').slideDown('normal');
			jQuery('.galmenu .categories img').hide();
			jQuery('.galmenu .categories img[src$=_a.png]').show();
		},function() {
			// DISABLE
			jQuery('#category_menu_list_wrapper').slideUp('normal')
			jQuery('.galmenu .categories img').show();
			jQuery('.galmenu .categories img[src$=_a.png]').hide();
		});
		
		// Create two column layout if wanted
		if(jQuery(document).getUrlParam('2column') != null) {
			Make2ColumnLayout();
		}
		
		// TEMP: Add a message for the 35mm Top 10
		if(jQuery(document).getUrlParam('35mmt10msg') != null) {
			var msg = (LFI_LANGUAGE == 'german') ? 'Die Reihenfolge der gezeigten Bilder ist zuf&auml;llig und sagt nichts &uuml;ber die sp&auml;teren Gewinner des Wettbewerbs aus.<br/> In der kommenden LFI 3/2010 gibt die Leica/LFI-Jury bekannt, welche drei Fotografen jeweils eine Leica X1 gewinnen!' : 'The order in which the pictures appear is random and does not give any indication as to the eventual winners of the competition. <br/>In LFI3/2010, the Leica/LFI jury will announce which three photographers have won a Leica X1!';
			
			jQuery('.images').before('<div style=" color:#777; font-family:arial,helvetica; font-weight:normal; padding:8px; margin-bottom:20px; font-size:14px;">'+msg+'</div>');
		}
		
		// PoW/CW: Change HDL
		/*if(jQuery('#cw_name').size() > 0 && jQuery('.row.mainbody .blockhdl .hdl').size() > 0) {
			var cw_name = jQuery('#cw_name').html();
			var img = jQuery('.row.mainbody .blockhdl .hdl img');
			var img_src = jQuery(img).attr('src')
			var new_img_src = '';
			
			if(cw_name != '') {
				new_img_src = img_src.replace('%24', cw_name);
				jQuery(img).attr('src', new_img_src);
			}
		}*/

//tst was here
	// Hides items without photographer name
        if(window.location.search.indexOf('editors_choice') !== -1) {
            jQuery('.item').each(function() {
                if(jQuery(this).find('.photographer_name').text() == "") {
                    jQuery(this).remove();
                }
            });
        }
});
