document.write('<style type="text/css">.hideIfNoScript{display:block;}.showIfNoScript{display:none;}</style>');

$(document).ready(function(){
	if ($.browser.msie && parseInt($.browser.version) == 6) {
		$("p + p").addClass("ie6fix1");
		$("ul + p").addClass("ie6fix1");
		$("ol + p").addClass("ie6fix1");
		$("ul + ul").addClass("ie6fix1");
		$("ul + ol").addClass("ie6fix1");
		$("ol + ul").addClass("ie6fix1");
		$("ol + ol").addClass("ie6fix1");
		$("ul + h4").addClass("ie6fix1");
		$("ol + h4").addClass("ie6fix1");
		$("p + ul").addClass("ie6fix4");
		$("p + ol").addClass("ie6fix4");
		$("li + li").addClass("ie6fix2");
		$("h1 + a + h2").addClass("ie6fix3");
		$("h4 + ul").addClass("ie6fix5");
		$("h4 + ol").addClass("ie6fix5");		
		$(".dokumentenliste + .linkliste").addClass("ie6fix4");
	}
	if ($.browser.msie) {
		$("hr:not(.hide)").before('<br class="hr"/>').remove();
	}
	
	$(".hideIfNoScript").show();
	$(".showIfNoScript").hide();
	
	$(".vorlage_ajax[href]").each(function(){
		$(this).attr("href",$(this).attr("href")+"&vorlage=ajax");
	});
	
	$("#keylink").attr("href","/wecos/admin.html");
	$("#keylink").attr("target","_blank");
	
	$(".warndialog").css("position","absolute").css("left","76%").css("width","50%");
	$(".warndialog").find("a.ok").css("display","block");
	
	if (!($.browser.msie && parseInt($.browser.version) == 6)) { // NOT IE6
		$("#menu > ul > li > div.nav").each(function(){
				$(this).css({backgroundPosition:(parseInt($(this).parent().width()/2)-60)+'px 0px'});
				if ($(this).parent().position().left>475) { //rechts von der Mitte?
					$(this).css("left","auto").css("right",(950-$(this).parent().position().left-$(this).parent().width()) + "px").css({backgroundPosition:(62+$(this).innerWidth()-parseInt($(this).parent().width()/2))+'px 0px'}).addClass("navR");
				}
			});
		var menuTimeout,pNav;
		$("#menu").removeClass("hover");
		$("#menu > ul > li").mouseover(function(){ 
				window.clearTimeout(menuTimeout);
				pNav = $(this).find("div.nav");
				menuTimeout = window.setTimeout(function(){
					$("div.nav").hide();
					$(pNav).show();
					$("a.international").parent("li").attr("class","mHide").find(".sprachwahl").hide();
				},100);
			});
		$("#menu > ul > li").mouseout(function(){ 
				window.clearTimeout(menuTimeout);
				menuTimeout = window.setTimeout(function(){
					$("div.nav").hide();
				},100);
			});
	} else { // IE6
		$("#menu > ul > li > div.nav").each(function(){
				$(this).css({backgroundPosition:(parseInt($(this).parent().width()/2)-60)+'px 0px'});
				if ($(this).parent().position().left>470) { //rechts von der Mitte?
					$(this).css({backgroundPosition:(62+$(this).innerWidth()-parseInt($(this).parent().width()/2))+'px 0px'}).addClass("navR");
				}
			});
	}
	$("#menu > ul > li > div.nav > ul > li.JSremoveSubmenu").parents("div.nav").remove();
	$(".mOver").removeClass("hover").find("a.international").click(function(){
		if ($(this).parent("li").attr("class") == "mShow") {
			$(this).parent("li").attr("class","mHide").find(".sprachwahl").hide();
		} else {
			$(this).parent("li").attr("class","mShow").find(".sprachwahl").show();
		}
		return false;
	});
	$("body").click(function(){ 
		$("a.international").parent("li").attr("class","mHide").find(".sprachwahl").hide();
		$("#lay-merkliste:visible").fadeOut();
		if($("#lay-downloads:visible").not(".blocker").size()>0){
			$("#lay-downloads:visible").not(".blocker").fadeOut();
			$(".control > ul").removeClass("akt-downloads");
		}
	});
	
	$(".cycle").cycle({
		fx : 'fade', //Überblendungseffekt
		speed: 2000,
		timeout: 1,
		delay: 1,
		autostop: 0
	});
	
	jQuery.fn.extend({ 
		check: function() { 
			return this.each(function() { this.checked = true; }); 
		}, 
		uncheck: function() { 
			return this.each(function() { this.checked = false; }); 
		},
		select: function() { 
			return this.each(function() { this.selected = true; }); 
		}, 
		unselect: function() { 
			return this.each(function() { this.selected = false; }); 
		} 
	}); 
	
	jQuery.fn.extend({ 
		autoclear: function() { 
			return this.each(function(){
				if($(this).val()==""&&$(this).attr("title")!=""){
					$(this).val($(this).attr("title"));
					$(this).focus(function(){
						$(this).addClass("focus");
						if($(this).val()==this.title) $(this).val("");
					});
					$(this).blur(function(){
						$(this).removeClass("focus");
						$(this).autoclear();
					});
				}
			}); 
		} 
	});	
	$(".autoclear").parents("form").submit(function(){
		$(this).find(".autoclear").each(function(){
			if($(this).val()==$(this).attr("title")) {
				$(this).val("");
			}
		});
		return true;
	});
	$(".autoclear").autoclear();
	
	if($("#sliderthumbs img").size()>0){
		$("#sliderthumbs").jCarouselLite({
			btnPrev: "#sliderbtn-zur",
			btnNext: "#sliderbtn-vor",
			speed: 200,
			circular: false,
			visible: 4
		});
	} else {
		$(".slider,.label").hide();
	}
	
	$(".detailinfos").tabs({
		show: function() { //Lupen neu positionieren
			$("span.lupe").each(function(){
				$(this).css({
						'display': 'block',
						'left': $(this).parent().find("img").position().left+$(this).parent().find("img").width()-12+'px',
						'top': $(this).parent().find("img").position().top+$(this).parent().find("img").height()-12+'px'
					});
			});
		},
		fx: { opacity: "toggle" }
	});
	
	$("img.lupe").each(function(){
		$(this).after("<span></span>").next("span").addClass("lupe").css({
				'display': 'block',
				'left': $(this).parent().find("img").position().left+$(this).parent().find("img").width()-18+'px',
				'top': $(this).parent().find("img").position().top+$(this).parent().find("img").height()-18+'px'
			});
	});
	$("img.videobutton").each(function(){
		$(this).after("<span></span>").next("span").addClass("videobutton").css({
				'display': 'block',
				'left': $(this).parent().find("img").position().left+($(this).parent().find("img").width()/2)-20+'px',
				'top': $(this).parent().find("img").position().top+($(this).parent().find("img").height()/2)-20+'px'
			});
	});
	
	if ($(".seitennav > ul.pfeile > li > a.vor").not(".inakt").size()>0) {
		$(".programmtitel > ul > li > a.link_naechstesmodell").attr("href",	$(".seitennav > ul.pfeile > li > a.vor").attr("href"));
	} else {
		$(".programmtitel > ul > li > a.link_naechstesmodell").parent().hide();
	}
	
	$("a.ctrl-downloads").click(function(){
		$("#lay-downloads").fadeIn().css({
			"left": ($("a.ctrl-downloads").position().left+54)+"px",
			"top": ($(window).scrollTop()>300) ? ((488-$("#lay-downloads").height())+($(window).scrollTop()-300))+"px" : (488-$("#lay-downloads").height())+"px"
		});
		$(".control > ul").addClass("akt-downloads");
		return false;
	});
	$("#lay-downloads").mouseover(function(){ $(this).addClass("blocker"); });
	$("#lay-downloads").mouseout(function(){ $(this).removeClass("blocker"); });
	
	/* === Betreffs Formulare === */
	
	/* FUNKTION: An alle unsichtbaren <legend> wird eine sichtbare h5 gehaengt. <legend> ist bisher nicht sauber formatierbar.*/
	$(".formular fieldset legend").each( function () {
		$(this).after("<h5>" + $(this).html() + "<\/h5>");	
	});
	
	/* LISTENER: OK-Button bei Fehlermeldungs-Overlay. */
	$("a.ok").click( function () {
		$(this).blur();
		$(".formular fieldset select").css("visibility","visible");//IE6-spezifisch
		$('.warndialog').hide();
		return false;
	});
	
	$(".box-produktfinder").css("cursor","pointer").click(function(){$(this).find("a.button").click();});
	
	$(".modusanzeige").each(function(){
		$(this).find("big").css({
			'font-size': '19px',
			'font-family': 'Times New Roman',
			'font-weight': 'bold',
			'padding': '0 4px',
			'color': '#994800'
		});
		$(this).css({
			'display': 'block',
			'position': 'fixed',
			'zIndex': '1000000',
			'top': '0',
			'left': '0',
			'background': '#fee768',
			'border': '1px solid #ecc101',
			'borderTop': 'none',
			'color': '#000',
			'padding': '3px 6px',
			'cursor': 'pointer',
			'font-size': '11px',
			'font-family': 'tahoma,arial,helvetica,sans-serif',
			'opacity': '0.5',
			'width': '14px',
			'overflow': 'hidden',
			'whiteSpace': 'nowrap',
			'textAlign': 'center',
			'-moz-border-radius-bottomright': '1em',
			'-webkit-border-bottom-right-radius': '1em',
			'border-bottom-right-radius': '1em'
		}).click(function(){
			if($(this).css('opacity')!=1) {
				$(this).animate({opacity:1, width:'100%'},300).find("big").css('color','#fee768');
			} else {
				$(this).animate({opacity:0.5, width: '14px'},300).find("big").css('color','#994800');
			}
		});
	});
	
});

BurgDruckPopup = function(pTarget, pMenue, pWidth, pHeight) {
	if (pMenue == '') { pMenue = 'top=0,left=0,menubar=yes,location=no,status=yes,toolbar=no,directories=no,resizable=yes,scrollbars=yes'; }
	if ((pWidth == '') && (pHeight == '')) return;
	if (pHeight == '') {
		pHeight = screen.availHeight - 10;
		if (document.all) pHeight = pHeight - 20;
	}
	winDruck = window.open('', pTarget , pMenue + ',width=' + pWidth + ',height=' + pHeight); 
	winDruck.resizeTo(pWidth, pHeight);
	return winDruck;
}
