

$(function(){

	var _fadeTo = $(this).parents('li').is('.active') ? '1' : '0.6';
	//var _fadeTo = $(this).parents('a').is('.first_active') ? '1' : '1';
	//var _fadeTo = $(this).is('.act') ? '1' : '0.6';
	var body_width = $('html').width();
	
	$(".image #ft").css({display:'none',opacity:1}).fadeIn(3000);
	
	
	
	
	$(".mainmenu img").css({display:'none',opacity:_fadeTo}).fadeIn(500);
	
	//$(".mainmenu li").hover(
		//function() { var li = $(this);li.not('.active').children().children('img').fadeTo(1,1);},
		//function() { var li = $(this);li.not('.active').children().children('img').fadeTo(1,0.3);}
	//);	
	
	if($(".mainmenu li").hasClass('active') )
		{
			var li = $(".mainmenu li.active");
			li.children().children('img').fadeTo(1,1);
		} 

		
		
    $('.mainmenu li').hover(function() {
        var currentImg = $(this).children().children('img').attr('src');
		
        $(this).children().children('img').attr('src', $(this).children().children('img').attr('hover'));
        $(this).children().children('img').attr('hover', currentImg);
		$(this).children().children('img').fadeTo(1,1);
		
    }, function() {
	
		var li = $(this);
        var currentImg = $(this).children().children('img').attr('src');
		li.not('.active').each(function(){
			$(this).children().children('img').attr('src', $(this).children().children('img').attr('hover'));
			$(this).children().children('img').attr('hover', currentImg);
			$(this).children().children('img').fadeTo(1,0.6);
		});
    });











	
		$('#p1').css({width:((body_width > 1074) ? 87 : 87-((1074-body_width) / 2))});
		$('#p2').css({width:((body_width > 1059) ? 255 : 255-((1059-body_width) / 2))});
		
	$(window).resize(function() {
		var body_width = $('html').width();
		$('#p1').css({width:((body_width > 1074) ? 87 : 87-((1074-body_width) / 2))});
		$('#p2').css({width:((body_width > 1059) ? 255 : 255-((1059-body_width) / 2))});
		
	});
	
		$('.img_header').css({width:$('.img').width()});
		$('.img_header').css({height:$('.img').height()});
	
	
	
	

	
	
	
	
	
	
	

	
 	$("#thumbnail img").mouseover(function(){
		if(!$(this).parents('li').hasClass('active')){
			$(".loadImage").css({display:'block'});
			$("#large img.img").hide().attr({"src": $(this).attr("rel"), "title": $("> img.img", this).attr("title")});
			//$("#large a").attr({"href": $(this).attr("href")});
		}	
		$(this).parents('li').siblings('.active').removeClass('active');
		$(this).parents('li').addClass('active');
		//$("#large").removeClass('loading');
		return false;
	});
				
 	$("#large>img.img").load(function(){
		$("#large>img.img:hidden").fadeIn(200);
		$(".loadImage").css({display:'none'});
	});	
	 	
	
	
	
	


	
	
	
});







function popup(datei,name,breite,hoehe,noresize)
{ 
	var posX=(screen.availWidth-breite)/2;
	var posY=(screen.availHeight-hoehe)/2;
	var resizable = (noresize==1) ? 0 : 1;
	window.open(datei,name,"resizable="+resizable+",scrollbars=1,width=" + breite + ",height=" + hoehe + "screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + "");
}


function galpop(datei,name,breite,hoehe,noresize)
{ 
	var posX=(screen.availWidth-breite)/2;
	var posY=(screen.availHeight-hoehe)/2;
	var resizable = (noresize==1) ? 0 : 1;
	var scrollbar = (document.all) ? 0 : 1;
	window.open(datei,name,"resizable="+resizable+",scrollbars="+scrollbar+",width=" + breite + ",height=" + hoehe + "screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + "");
}


function textCounter(field, countfield, maxlimit)
{ 
	if (field.value.length > maxlimit)
	{ 
		field.value = field.value.substring(0, maxlimit);
	} else { 
		countfield.value = maxlimit - field.value.length;
	}
}


function elemX (element) {
	var x = 0;
	while (element) {
		x += element.offsetLeft;
		element = element.offsetParent;
	}
	return x;
}

function elemY (element) {
	var y = 0;
	while (element) {
		y += element.offsetTop;
		element = element.offsetParent;
	}
	return y;
}

function getWidth (element) {
	return element.offsetWidth;
}

function getHeight (element) {
	return element.offsetHeight;
}

function elemObj(elementId) {
	if (document.all)
		return document.all[elementId];
	else if (document.getElementById)
		return document.getElementById(elementId);
	else
		return null;
}
