jQuery.fn.hasClassB = function(c) {
	return this.is('.'+c)
};
jQuery.fn.loadmain = function() {
	 $(this).bind("click", function(){
			$.get($(this).attr("lnk"), { solo: "true" },function(data){$("#id5").html(data);$(".list",$("#id5")).ajaxify();$("div.main").bilder();$("div.main").globlinx();});
			$.get($(this).attr("lnk"), { solo:"true", page: "GET /menue[template='/templates/topline.xslt']" },function(data){$("h2",$("#id4")).html(data);});
});};
jQuery.fn.ajaxify = function() {
	if($('#id0').html()==''){
		$('a', $(this)).each(function(){
			$(this).attr({lnk: $(this).attr('href')}).attr({href:'#main'}).loadmain();
		});
		flashdetect();
	}
};
function flashdetect(){
	$('.media').each(function(){
		$(this).html("").flash({
			src: $(this).attr('href'),
			width: $(this).css('width'),
			height: $(this).css('height')
			//wmode: "transparent"
		});
		$(this).removeClass('media');
		$(this).addClass('flashbox');
	});
}
jQuery.fn.lupe = function() {
	var gallery = false;
	if( $(this).hasClassB('gallery') ){
		gallery = true;
	}
	if(gallery)
		$('img',$(this)).lightBox();
	
	$('img',$(this)).each(function(){
		l = $(this).css('margin-left');
		t = $(this).css('margin-top');
		ri = $(this).css('margin-right');
		b = $(this).css('margin-bottom');
		f = $(this).css('float');
		w = $(this).attr('width');
		h = $(this).attr('height');
		alt = $(this).attr('alt');
		title =	$(this).attr('title');
		 
		$(this).css({ cursor: 'pointer', float: 'none', display: 'inline', margin: '0', padding: '0' });
		$(this).wrap('<div class="img_frame" height="'+h+'" style="margin-bottom:'+b+';margin-top:'+t+';margin-right:'+ri+';margin-left:'+l+';float:'+f+';width:'+w+';height:'+h+';display:block;position:relative;padding:0;"></div>');
		$(this).wrap('<div class="img_inner" height="'+h+'" style="border:0;margin:0;padding:0;width:'+w+';height:'+h+';"></div>');
		$(this).after('<a class="lupe" title="'+title+'" alt="'+alt+'" height="'+h+'" style="border:0;padding:0;margin:0;width:'+w+';height:'+h+';"><span style="border:0;padding:0;margin:0;width:'+w+';height:'+h+';" class="lupebig" >&nbsp;</span>&nbsp;</a>')
		if(!gallery)
			$(this).lightBox();
	});
	if($.browser.msie){                             
		$('a.lupe',$(this)).hover(
	    		 function () {
				 $(this).addClass('hover');                                                                   
			 }, 
			 function () {
				 $(this).removeClass('hover');
			 }
		).click(function(){$('img',$(this).parent()).click()});
	} else {
		$('a.lupe',$(this)).click(function(){$('img', $(this).parent()).click()});
	}
}
$('document').ready(function(){
		$('div.html').find(':first').each(function(){
			if(this.nodeName == 'P'){
				$('img', $(this)).addClass('first');
				$(this).replaceWith("<div class='first'>" + $(this).html() + "</div>");
				//$(this).addClass('first');
			}
			else if(this.nodeName == 'IMG')
				$(this).addClass('first');
		});
		flashdetect();
		$('#menu1').superfish({pathClass:'activ'});
		$('#main ul.list').lupe();
		$('#main div.html').lupe();
		$('.multimedia').media(
			{ width: 546, height: 420,caption:   false  }
		);
});

