jQuery(function( $ ){
    
    var title = $(this).attr("title").split("_");
    $(this).attr("title", title[0]);
    
	$("#navigation li:last").addClass("last");
	$("#subnavigation li:last").addClass("last");
	$("#footer li:last").addClass("last");
	
    $("a[target^='thickbox']").each(function() {
        var tmp1 = $(this).attr("class");
        var tmp = tmp1.split('x');
        this.href = "javascript:tb_show('"+this.title+"', '"+this.href+"?type=7&width="+tmp[0]+"&height="+tmp[1]+"', '');";
        $(this).removeClass(tmp1);
        $(this).addClass(this.target);
        this.target = "";
    });
    
    $("a[target^='textbox']").each(function() {
        var tmp = $(this).attr("title").split('_');
        this.title = tmp[0];
        $(this).addClass('thickbox');
        var tmp = tmp[1].split('x');
        this.href = "javascript:tb_show('"+this.title+"', '"+this.href+"?type=7&width="+tmp[0]+"&height="+tmp[1]+"', '');";
        this.target = "";
    });

    $("a[rel='colorbox']").each(function(){
        $(this).attr("href",$(this).attr("href")+"?type=7&height=820&width=690");
    });
    $("a[title^='thickbox']").each(function() { 
        this.href = "javascript:tb_show('', '"+this.href+"?type=7&width=690&height=820', '');";
        this.target = "";
    });
    
    // printlinks
    $("#printlink a").each(function(){
        $(this).attr("href", window.location.href+"?no_cache=1&print=1");
        $(this).attr("target", "_blank");
    });


	$('a.lightbox-link').each(function(){
		var href = $(this).attr('href');
		var href = href.split("&");
		if(href.length==1){
			var separator = '?';
		} else {
			var separator = '&';
		}
		var title = $(this).attr('title').split("_");
		$(this).attr('href',$(this).attr('href')+separator+'type=7');
		$(this).attr('title',title[0]);
		
		tb_init(this);
	});

});
