

$j = $; //jQuery.noConflict();



$j(document).ready(function(){

	

	// disable old events

	/*

	$j('li.Level0Item > ol').hide();



	$j('li.Level0Item').mouseover(function(){

		console.log('hover');

		$j('> ol', this).slideDown();

	}).mouseout(function(){

		$j('> ol', this).slideUp();

	});

	*/



	

	if (TransMenu.isSupported())

	{

		function init_transmenu_subitems(transmenu, subitems)

		{

			subitems.each(function(i){

				var link = $j('> a', this);

				var item = transmenu.addItem(link.text(), link.attr('href'), link.attr('target'));



				var subitems = $j('> ol > li', this);

				if (subitems.length)

				{

					var subtransmenu = transmenu.addMenu(transmenu.items[i], i);

					init_transmenu_subitems(subtransmenu, subitems);

				}

			});

		}



		function hide_transmenu()

		{

			TransMenuSet.registry[0].hide();

		}



		var menuitems = $j('li.Level0Item').add('li.TopMenuItem').add('#MoilHeader');



		var ms = new TransMenuSet(TransMenu.direction.down, -4, 0, TransMenu.reference.bottomLeft);



		// generate transmenu from html

		menuitems.each(function(){

			var subitems = $j('> ol > li', this);

			if (!subitems.length)

			{

				this.onmouseover = hide_transmenu;

			}

			else

			{

				var link = $j('> a', this);

				var transmenu = ms.addMenu(link[0], 0);

				

				init_transmenu_subitems(transmenu, subitems);

				

				transmenu.onactivate = function (){$j(link).addClass("over");};

				transmenu.ondeactivate = function (){$j(link).removeClass("over");};

			}

		});



		// remove menu from html

		menuitems.find('> ol').remove();



		/*

		menu.onactivate = function() {};

		menu.ondeactivate = function() {};

		*/



		// init transmenu

        var aMenuHtml = [];

        for (var i = 0, menu = null; menu = TransMenu.registry[i]; i++) {

                aMenuHtml[i] = menu.toString();

        }

        $j('body').append(aMenuHtml.join(""));



		TransMenu.initialize();

	}

	

	$('#ShadowTop, #ShadowBottom, #Main-2').ifixpng();

	$('a.image-popup').lightBox();

	

	

	// TopFlash

	var so = new SWFObject("/flash/top.swf", "top", "930", "258", "2", "#FFFFFF");

	so.addParam("wmode", "transparent");

	so.addParam("scale", "noscale");

	so.addParam("quality", "low");

	

	my_language = "de";

	

	if (site_language != "de")

		my_language = "en";

	

	so.addVariable("language",my_language);

	so.addVariable("country_url",site_url);

	

	//alert(top_image);

	

	if (show_top_flash)

		so.write("TopImage");

		

	//alert($("#TopImage")[0]);

	

});



function hide_login()

{

	$("#lev0_item_153").removeClass("over");

	$(".loginwindow:visible").slideUp("fast");

}



function show_login()

{

	if($(".loginwindow:visible").length)

		$(".loginwindow:visible").slideUp("fast",function(){$("#login_window").slideDown("fast");});

	else

		$("#login_window").slideDown("fast");

	

	$("#lev0_item_153").addClass("over");

}



function login()

{

	if ($("#login_window").is(':hidden'))

		show_login();

	else

		hide_login();

}



function open_dealer_locator()

{

	//my_window = window.open(site_url+"/shopfinder_v2.php","my_window","width=1000,height=700,status=0,toolbar=0,scrollbars=0,location=0,menubar=0");
	// Stemmer: 25.05.2011
	// Da ich keinen API-Key für löffler.at erstellen konnte, der funktioniert, wird nun der Shopfinder von loeffler.at geöffnet
	
	my_window = window.open('http://www.loeffler.at'+site_url+"/shopfinder_v2.php","my_window","width=1000,height=700,status=0,toolbar=0,scrollbars=0,location=0,menubar=0");

	my_window.focus();

}





function show_company_popup()

{

	var correct_flash_version = (deconcept.SWFObjectUtil.getPlayerVersion().major >= 9);

	

	var show = function(hash) {

		hash.w.fadeIn();

	};

	var hide = function(hash) {

		hash.o.remove();

		hash.w.fadeOut();

	};		

	

	html = "";

	

	if (!$('#PopupUnternehmen').length)

		$('body').prepend('<div id="PopupUnternehmen" style="width:799px; height:450px; background-color:#E3001B; border: 1px solid white;" class="jqmWindow"></div>');

	

	if(!correct_flash_version)

	{

		$('#PopupUnternehmen').css('background','url(/images/die_marke_wrong_flash.jpg)').html('<div style="border: 1px solid black;	background: white;	padding: 20px;	width: 320px;	position: absolute; bottom: 10px; right: 10px;">Diese Seite ben&ouml;tigt Flash-Player mindestens Version 8<br>und aktiviertes Javascript!<br /><br /><a target="_blank" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BUIGP">Klicken Sie hier um Adobe Flash Player zu installieren</a></div>');

	}

	else

	{

		//$('#PopupUnternehmen').html('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="799" height="450" id="die_marke_start" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="/flash/die_marke/die_marke_start.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#e3001b" />	<embed src="/flash/die_marke/die_marke_start.swf" quality="high" bgcolor="#e3001b" width="799" height="450" name="die_marke_start" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');

	

		var flashfile = "/flash/die_marke/die_marke_start.swf";

		

		if (site_id != 1)

			flashfile = "/flash/die_marke_en/die_marke_start.swf";

		

		//alert(flashfile);

	

		var so = new SWFObject(flashfile, "top", "799", "450", "2", "#FFFFFF");

		so.addParam("wmode", "window");

		so.addParam("scale", "noscale");

		so.addParam("bgcolor", "#e3001b");

		so.addParam("allowScriptAccess", "always");

		so.addParam("quality", "high");

		

		my_language = "de";

		

		if (site_language != "de")

			my_language = "en";

		

		so.addVariable("language",my_language);

		so.addVariable("country_url",site_url);	

		so.addVariable("direct_goto",direct_goto);	

		so.write('PopupUnternehmen');

	}

	

	//$.modal($('#PopupGeschichte'));

	$("#PopupUnternehmen").jqm({modal: false,onShow: show, onHide: hide}).jqmShow();	

}



function as_debug(text)

{

	alert(text);

}



function show_new_company_popup()

{

	/*

	direct_gotos:

		0=>Marke

		1=>Innovationen

		2=>Produktion

		3=>Nachhaltigkeit

		4=>Spitzensport

		5=>Chronik

	*/

	

	var correct_flash_version = (deconcept.SWFObjectUtil.getPlayerVersion().major >= 8);

	

	var show = function(hash) {

		if($j("#overlayDIV").length==0){

			$j("#overlayWholeDIV").css("display","block");

		}else{

			$("#overlayDIV").css("display","block");

		}

		hash.w.fadeIn("slow");

	}

	

	var hide = function(hash) {

		hash.o.fadeOut("slow", function(){

				$(this).remove();

				$("#overlayDIV").css("display","none");

				$("#overlayWholeDIV").css("display", "none");

				

			})

			hash.o.remove();

			hash.w.fadeOut();

	}	

	

	html = "";

	

	if (!$('#PopupUnternehmen').length)

		$('body').prepend('<div id="PopupUnternehmen" style="width:799px; height:450px; background-color:#E3001B; border: 1px solid white;" class="jqmWindow"></div>');

	

	if(!correct_flash_version)

	{

		$('#PopupUnternehmen').css('background','url(/images/die_marke_wrong_flash.jpg)').html('<div style="border: 1px solid black;	background: white;	padding: 20px;	width: 320px;	position: absolute; bottom: 10px; right: 10px;">Diese Seite ben&ouml;tigt Flash-Player mindestens Version 8<br>und aktiviertes Javascript!<br /><br /><a target="_blank" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BUIGP">Klicken Sie hier um Adobe Flash Player zu installieren</a></div>');

	}

	else

	{

		//alert(current_season);

		//$('#PopupUnternehmen').html('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="799" height="450" id="die_marke_start" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="/flash/die_marke/die_marke_start.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#e3001b" />	<embed src="/flash/die_marke/die_marke_start.swf" quality="high" bgcolor="#e3001b" width="799" height="450" name="die_marke_start" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');

	

		var flashfile = "/flash/die_marke"+CURRENT_SEASON+"/die_marke_start.swf";

		

		if (site_id != 1)

			flashfile = "/flash/die_marke"+CURRENT_SEASON+"_en/die_marke_start.swf";

		

		//alert(site_id);

		//alert(flashfile);

	

		var so = new SWFObject(flashfile, "top", "799", "450", "2", "#FFFFFF");

		so.addParam("wmode", "window");

		so.addParam("scale", "noscale");

		so.addParam("bgcolor", "#e3001b");

		so.addParam("allowScriptAccess", "always");

		so.addParam("quality", "high");

		

		my_language = "de";

		

		if (site_language != "de")

			my_language = "en";

			

			

		so.addVariable("language",my_language);

		so.addVariable("country_url",site_url);	

		so.addVariable("current_season",CURRENT_SEASON);	

		

		if (direct_goto)

			so.addVariable("direct_goto",direct_goto);	

		

		so.write('PopupUnternehmen');

	}

	

	//$.modal($('#PopupGeschichte'));

	$("#PopupUnternehmen").jqm({modal: false,onShow: show, onHide: hide}).jqmShow();	

}



function hide_company_popup()

{

	$("#PopupUnternehmen").jqmHide();

}



function hide_radclub_popup()

{

	$("#PopupRadClub").jqmHide();

}



function show_radclub_popup(url)

{

	if (url==null)

		url="/radclub/start.php";

	

	

	//console.log('test');

	var correct_flash_version = (deconcept.SWFObjectUtil.getPlayerVersion().major >= 9);

	

	var show = function(hash) {

		if($j("#overlayDIV").length==0){

			$j("#overlayWholeDIV").css("display","block");

		}else{

			$("#overlayDIV").css("display","block");

		}

		hash.w.fadeIn("slow");

	}

	

	var hide = function(hash) {

		hash.o.fadeOut("slow", function(){

				$(this).remove();

				$("#overlayDIV").css("display","none");

				$("#overlayWholeDIV").css("display", "none");

				

			})

			hash.o.remove();

			hash.w.fadeOut();

	}



	html = "";

	

	if (!$('#PopupRadClub').length)

		$('body').prepend('<div id="PopupRadClub" style="width:868px; height:527px; margin-left: -434px; background-color:#E3001B; border: 1px solid white;" class="jqmWindow"></div>');

	

	/* if(!correct_flash_version)

	{

		$('#PopupRadClub').css('background','url(/images/die_marke_wrong_flash.jpg)').html('<div style="border: 1px solid black;	background: white;	padding: 20px;	width: 320px;	position: absolute; bottom: 10px; right: 10px;">Diese Seite ben&ouml;tigt Flash-Player mindestens Version 8<br>und aktiviertes Javascript!<br /><br /><a target="_blank" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BUIGP">Klicken Sie hier um Adobe Flash Player zu installieren</a></div>');

	}

	else

	{ */

		var html = '<iframe name="frameRadClub" scrolling="no" border="0" frameborder="0" width="868" height="527" src="'+url+'" border="0" frameborder="0" style="overflow: hidden; border:none;"></iframe>';

		$('#PopupRadClub').html(html);

	//}

	

	

	$("#PopupRadClub").jqm({modal: false,onShow: show, onHide: hide}).jqmShow();

}



var my_timeout;

function show_language_selector()

{

	clearTimeout(my_timeout);

	$('#LanguageSelector').fadeIn("slow");

	my_timeout = setTimeout('hide_language_selector()',1000);

}



function hide_language_selector()

{

	clearTimeout(my_timeout);

	

	var hide = true;

		

	$('#LanguageSelector').find('a').each(function()

	{

		//alert(this);

		if ($(this).css("color") == "white" || $(this).css("color") == "rgb(255, 255, 255)")

		{

			hide = false;

		}

		

		//if ($(this).css("background-position").indexOf("-20px") != -1)

		//	hide = false;

	});		

	

	if (hide)

		$('#LanguageSelector').fadeOut("slow");

}



var vid_window = null;

function open_video_popup(vid)

{

	my_url = site_url+"/show_video.php?video="+vid;

	

	if (vid_window != null)

		vid_window.close();

		

	vid_window = window.open(my_url, "vid_popup", "width=480,height=310,status=no,scrollbars=no,resizable=no");

	vid_window.focus();

}



var sz = null;

function showSportZeit(width,height) {
	if(!width) 
		width=1000;
	if(!height) 
		height=700;
	var correct_flash_version = (deconcept.SWFObjectUtil.getPlayerVersion().major >= 7);

	

	var show = function(hash) {

		if($j("#overlayDIV").length==0){

			$j("#overlayWholeDIV").css("display","block");

		}else{

			$("#overlayDIV").css("display","block");

		}

		hash.w.fadeIn("slow");

	}

	

	var hide = function(hash) {

		hash.o.fadeOut("slow", function(){

				$(this).remove();

				$("#overlayDIV").css("display","none");

				$("#overlayWholeDIV").css("display", "none");

				

			})

			hash.o.remove();

			hash.w.fadeOut();

	}	

	

	html = "";

	//alert(CURRENT_SEASON);

	

	if (!$('#PopupSportZeit').length)

	{

		//if(!correct_flash_version)

		//	$('body').prepend('<div id="PopupSportZeit" style="position: absolute; width:800px; height:530px; background: url(/images/sportzeit_wrong_flash.jpg); border: 1px solid white; margin-left: -400px; top: 2%" class="jqmWindow"><div style="border: 1px solid black;	background: white;	padding: 20px;	width: 320px;	position: absolute; top: 170px; left: 100px;">Diese Seite ben&ouml;tigt Flash-Player mindestens Version 7<br>und aktiviertes Javascript!<br /><br /><a target="_blank" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BUIGP">Klicken Sie hier um Adobe Flash Player zu installieren</a></div></div>');

		

		//else

			//$('body').prepend('<div id="PopupSportZeit" style="position: absolute; width:800px; height:530px; background-color:#E3001B; border: 1px solid white; margin-left: -400px; top:2%;" class="jqmWindow"><iframe src="'+site_url+'/page_flip/sportzeit_'+CURRENT_SEASON+'.php" height="530" width="800" frameborder="0" framespacing="0" srollbars="0"></iframe></div>');

		
		var fenster = window.open(site_url+'/page_flip/sportzeit_'+CURRENT_SEASON+'.php',"","location=no,menubar=no,height="+height+",width="+width+",toolbar=no,status=no");

		

	}





	

	//$.modal($('#PopupGeschichte'));

	//$("#PopupSportZeit").jqm({modal: false,onShow: show, onHide: hide}).jqmShow()

	

	

	//sz = window.open("/page_flip/demo.html","sz","resizable=yes,menubar=no,height=700,width=1000,status=false,location=false");

	//sz.focus();

}

function showSportZeitResolution() {
	var show = function(hash) {
		if($j("#overlayDIV").length==0){
			$j("#overlayWholeDIV").css("display","block");
		}else{
			$("#overlayDIV").css("display","block");
		}
		hash.w.fadeIn("slow");
	}

	var hide = function(hash) {
		hash.o.fadeOut("slow", function(){
				$(this).remove();
				$("#overlayDIV").css("display","none");
				$("#overlayWholeDIV").css("display", "none");
			})
			hash.o.remove();
			hash.w.fadeOut();
	}
	
	$('body').prepend('<div id="PopupSportzeitSize" class="jqmWindow"><div id="hideDialog"><a href="#" style="color: #ffffff;text-decoration:none;" >X</a></div><div style="background: url(/images/sportzeitsize_header.jpg); height: 101px;">&nbsp;</div><div style="position: absolute; right: 0px; bottom:0px; width: 287px;height: 301px;background:url(/images/sportzeitsize_right.png)">&nbsp;</div><div style="position: absolute; left: 30px; top:154px; width: 319px;height: 120px;font-size:20px;">W&auml;hlen Sie Ihre optimale Aufl&ouml;sung<br /><br /><a href="javascript:hideSportZeitResolution();showSportZeit(1024,768)"><div style="float:left;">Standard</div><div style="margin-left: 200px;">1024x768</div></a><a href="javascript:hideSportZeitResolution();showSportZeit(1280,1024)"><div style="float:left;">Widescreen</div><div style="margin-left: 200px;">1280x1024</div></a><a href="javascript:hideSportZeitResolution();showSportZeit(1440,1050)"><div style="float:left;">Hohe Aufl&ouml;sung</div><div style="margin-left: 200px;">1440x1050</div></a></div></div>');
	$("#PopupSportzeitSize").jqm({modal: false,onShow: show, onHide: hide}).jqmShow();
	$('#PopupSportzeitSize').jqmAddClose($('#hideDialog a'));
}

function hideSportZeit()

{

	$("#PopupSportZeit").jqmHide();

}

function hideSportZeitResolution() {
	$("#PopupSportzeitSize").jqmHide();
}


function showPfNachhaltigkeit() {

	

	//hide_company_popup();

	

	

	//alert ("test"); return;

	var correct_flash_version = (deconcept.SWFObjectUtil.getPlayerVersion().major >= 7);

	

			var show = function(hash) {

		hash.w.fadeIn();

	};

	var hide = function(hash) {

		hash.o.remove();

		hash.w.fadeOut();

	};		

	

	html = "";

	//alert(site_prefix);

	

	if (!$('#PopupNachhaltigkeit').length)

	{

		if(!correct_flash_version)

			$('body').prepend('<div id="PopupNachhaltigkeit" style="position: absolute; width:800px; height:530px; background: url(/images/sportzeit_wrong_flash.jpg); border: 1px solid white; margin-left: -400px; top: 2%" class="jqmWindow"><div style="border: 1px solid black;	background: white;	padding: 20px;	width: 320px;	position: absolute; top: 170px; left: 100px;">Diese Seite ben&ouml;tigt Flash-Player mindestens Version 7<br>und aktiviertes Javascript!<br /><br /><a target="_blank" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BUIGP">Klicken Sie hier um Adobe Flash Player zu installieren</a></div></div>');

		else

			$('body').prepend('<div id="PopupNachhaltigkeit" style="position: absolute; width:800px; height:530px; background-color:#E3001B; border: 1px solid white; margin-left: -400px; top:2%; z-index:4000;" class="jqmWindow"><iframe src="'+site_url+'/page_flip/nachhaltigkeit.php" height="530" width="800" frameborder="0" framespacing="0" srollbars="0"></iframe></div>');

	}





	

	//$.modal($('#PopupGeschichte'));

	//$("#PopupNachhaltigkeit").jqm({modal: false,onShow: show, onHide: hide}).jqmShow()

	$("#PopupUnternehmen").hide();

	$("#PopupNachhaltigkeit").fadeIn();

	

	

	//sz = window.open("/page_flip/demo.html","sz","resizable=yes,menubar=no,height=700,width=1000,status=false,location=false");

	//sz.focus();

}

function hidePfNachhaltigkeit()

{

	$("#PopupUnternehmen").fadeIn();

	$("#PopupNachhaltigkeit").hide();

}





function show_bewerben(id_job,jobname,bewerbungsformular)

{

	

	var show = function(hash) {

		hash.w.fadeIn();

	};

	var hide = function(hash) {

		hash.o.remove();

		hash.w.fadeOut();

	};

	

	html = "";

	

	if (!$('#PopupBewerben').length)

		$('body').prepend('<div id="PopupBewerben" style="width:470px; height:680px; background-color:#ffffff; border: 1px solid white; margin-left: -235px; top:50px;" class="jqmWindow"><div style="position: absolute; right: 10px; top: 6px; font-weight: bold;"><a style="text-decoration:none;" href="javascript:void(0);" onclick="hide_bewerben()">x</a></div><iframe scrolling="no" src="'+site_url+'/bewerben_'+(bewerbungsformular==1?'arbeiter':'angestellte')+'.php?id_job='+id_job+'&jobname='+jobname+'" height="680" width="470" frameborder="0" framespacing="0" srollbars="0"></iframe></div>');

	





	

	//$.modal($('#PopupGeschichte'));

	$("#PopupBewerben").jqm({modal: false,onShow: show, onHide: hide}).jqmShow()

}



function hide_bewerben()

{

	$("#PopupBewerben").jqmHide();

}



function modell_select(pl_value, mo_value, ma_value)

{

	saison = $("[name=saison]").val();

	product_line = $("[name=product_line]").val();

	modell = $("[name=modell]").val();

	material = $("[name=materials]").val();

	

	if(modell != ""){

		if(product_line != "" && material == "")

			var my_url = "products.php?saison_id="+saison+"&product_line_id="+product_line+"&modell_id="+modell+"&select=modell";

		else if(material != "" && product_line == "")

			var my_url = "products.php?saison_id="+saison+"&material_id="+material+"&modell_id="+modell+"&select=modell";

		else

			var my_url = "products.php?saison_id="+saison+"&modell_id="+modell+"&select=modell";

	}else

		var my_url = "products.php?saison_id="+saison;

	

	$("#anzeigen_button").attr("disabled","disabled");

	

	$("#product_line").children("option").each(function(x){

		$(this).remove();

	});

	$j('#product_line').append("<option value='load'>loading</option>");

	

	$("#materials").children("option").each(function(x){

		$(this).remove();

	});

	$j('#materials').append("<option value='load'>loading</option>");

	

	



	$.getJSON(my_url, function(data) {

		$j("#product_line > option[value=load]").remove();

		$j("#product_line").append(new Option("",""));

		$j("#materials > option[value=load]").remove();

		$j("#materials").append(new Option("",""));

		

		$.each(data, function(i,item) {

			if(i=="PRODUCT_LINES"){

				$.each(item, function(key, value) {

					$j('#product_line').append("<option value='"+value.id+"'>"+value.name+"</option>");

				});

			}

			if(i=="MATERIALS"){

				$.each(item, function(key, value) {

					 $j('#materials').append("<option value='"+value.id+"'>"+value.name+"</option>");

				});

			}

		});

		$("#anzeigen_button").removeAttr("disabled");

		if(product_line!="")

			$j('#product_line option[value='+product_line+']').attr('selected','selected');

		

		if(material!="")

			$j('#materials option[value='+material+']').attr('selected','selected');

	});

}



function material_select(pl_value, mo_value, ma_value)

{

	saison = $("[name=saison]").val();

	product_line = $("[name=product_line]").val();

	modell = $("[name=modell]").val();

	material = $("[name=materials]").val();

	

	if(material != ""){

		if(modell != "" && product_line == "")

			var my_url = "products.php?saison_id="+saison+"&material_id="+material+"&modell_id="+modell+"&select=material";

		else if(product_line != "" && modell == "")

			var my_url = "products.php?saison_id="+saison+"&product_line_id="+product_line+"&material_id="+material+"&select=material";

		else

			var my_url = "products.php?saison_id="+saison+"&material_id="+material+"&select=material";

	}

	else

		var my_url = "products.php?saison_id="+saison;



	$("#anzeigen_button").attr("disabled","disabled");

	

	$("#product_line").children("option").each(function(x){

		$(this).remove();

	});

	$j('#product_line').append("<option value='load'>loading</option>");

	

	$("#modell").children("option").each(function(x){

		$(this).remove();

	});

	$j('#modell').append("<option value='load'>loading</option>");

	



	$.getJSON(my_url, function(data) {

		$j("#product_line > option[value=load]").remove();

		$j("#product_line").append(new Option("",""));

		$j("#modell > option[value=load]").remove();

		$j("#modell").append(new Option("",""));

		

		$.each(data, function(i,item) {

			if(i=="PRODUCT_LINES"){

				$.each(item, function(key, value) {

					$j('#product_line').append("<option value='"+value.id+"'>"+value.name+"</option>");

				});

			}

			if(i=="MODELLE"){

				$.each(item, function(key, value) {

					 $j('#modell').append("<option value='"+value.id+"'>"+value.name+"</option>");

				});

			}

		});

		$("#anzeigen_button").removeAttr("disabled");

		if(product_line!="")

			$j('#product_line option[value='+product_line+']').attr('selected','selected');

		

		if(modell!="")

			$j('#modell option[value='+modell+']').attr('selected','selected');

	});

}



function product_select(pl_value, mo_value, ma_value)

{

	saison = $("[name=saison]").val();

	product_line = $("[name=product_line]").val();

	modell = $("[name=modell]").val();

	material = $("[name=materials]").val();

	

	if(product_line != ""){

		if(modell != "" && material == "")

			var my_url = "products.php?saison_id="+saison+"&product_line_id="+product_line+"&modell_id="+modell+"&select=product_line";

		else if(material != "" && modell == "")

			var my_url = "products.php?saison_id="+saison+"&product_line_id="+product_line+"&material_id="+material+"&select=product_line";

		else

			var my_url = "products.php?saison_id="+saison+"&product_line_id="+product_line+"&select=product_line";

	}

	else

		var my_url = "products.php?saison_id="+saison;

	

	$("#anzeigen_button").attr("disabled","disabled");

	

	$("#modell").children("option").each(function(x){

		$(this).remove();

	});	

	$j('#modell').append("<option value='load'>loading</option>");

	

	$("#materials").children("option").each(function(x){

		$(this).remove();

	});

	$j('#materials').append("<option value='load'>loading</option>");

	

	



	$.getJSON(my_url, function(data) {

		$j("#materials > option[value=load]").remove();

		$j("#materials").append(new Option("",""));

		$j("#modell > option[value=load]").remove();

		$j("#modell").append(new Option("",""));

		$.each(data, function(i,item) {

			if(i=="MODELLE"){

				$.each(item, function(key, value) {

					$j('#modell').append("<option value='"+value.id+"'>"+value.name+"</option>");

				});

			}

			if(i=="MATERIALS"){

				$.each(item, function(key, value) {

					 $j('#materials').append("<option value='"+value.id+"'>"+value.name+"</option>");

				});

			}

		});

		$("#anzeigen_button").removeAttr("disabled");

		if(material!="")

			$j('#materials option[value='+material+']').attr('selected','selected');

		

		if(modell!="")

			$j('#modell option[value='+modell+']').attr('selected','selected');

	});

}



function saison_select(pl_value, mo_value, ma_value, change, next)

{

	saison = $("[name=saison]").val();

	product_line = $("[name=product_line]").val();

	modell = $("[name=modell]").val();

	material = $("[name=materials]").val();

	

	if(change=="all"){

		saison_select(pl_value, mo_value, ma_value, "saison", 1);

	}



	if(change=="saison"){

		var my_url = "products.php?saison_id="+saison;

		

		$("#anzeigen_button").attr("disabled","disabled");

		

		$("#product_line").children("option").each(function(x){

			$(this).remove();

		});

		//$j("#product_line").append(new Option("loading ...","load"));

		$j('#product_line').append("<option value='load'>loading</option>");

		

		$("#materials").children("option").each(function(x){

			$(this).remove();

		});

		//$j("#materials").append(new Option("loading ...","load"));

		$j('#materials').append("<option value='load'>loading</option>");

		

		$("#modell").children("option").each(function(x){

			$(this).remove();

		});

		//$j("#modell").append(new Option("loading ...","load"));

		$j('#modell').append("<option value='load'>loading</option>");

		

		if(saison!=""){

			$.getJSON(my_url, function(data) {

				x = 0;

				$j("#product_line > option[value=load]").remove();

				$j("#product_line").append(new Option("",""));

				$j("#modell > option[value=load]").remove();

				$j("#modell").append(new Option("",""));

				$j("#materials > option[value=load]").remove();

				$j("#materials").append(new Option("",""));

				$.each(data, function(i,item) {

					if(i=="PRODUCT_LINES"){

						$.each(item, function(key, value) {

							$j('#product_line').append("<option value='"+value.id+"'>"+value.name+"</option>");

						});

					}

					if(i=="MODELLE"){

						$.each(item, function(key, value) {

							 $j('#modell').append("<option value='"+value.id+"'>"+value.name+"</option>");

						});

					}

					if(i=="MATERIALS"){

						$.each(item, function(key, value) {

							 $j('#materials').append("<option value='"+value.id+"'>"+value.name+"</option>");

						});

					}

				});

				$("#anzeigen_button").removeAttr("disabled");

				if(pl_value!=""){

					$j("#product_line option[value="+pl_value+"]").attr('selected', 'selected');

				}

				if(ma_value!=""){

					$j("#materials option[value="+ma_value+"]").attr('selected', 'selected');

				}

				if(mo_value!=""){

					$j("#modell option[value="+mo_value+"]").attr('selected', 'selected');

				}

				//$j("#materials").append(new Option("Bitte zuerst Saison auswählen", ""));

				//$j("#modell").append(new Option("Bitte zuerst Saison auswählen", ""));

				/*$j("#materials > option[value=load]").remove();

				$j("#materials").append(new Option("",""));

				$j('#materials').append("<option value=''>Bitte zuerst Modell auswählen</option>");

				$j("#modell > option[value=load]").remove();

				$j("#modell").append(new Option("",""));

				$j('#modell').append("<option value=''>Bitte zuerst Produktlinie auswählen</option>")

				if(next)

					saison_select(pl_value, mo_value, ma_value, "product_line", 1);*/

			});

		}else{

			//$j("#product_line").append(new Option("Bitte zuerst Saison auswählen", ""));

			//$j("#materials").append(new Option("Bitte zuerst Saison auswählen", ""));

			//$j("#modell").append(new Option("Bitte zuerst Saison auswählen", ""));

			$j("#materials > option[value=load]").remove();

			$j("#materials").append(new Option("",""));

			$j("#modell > option[value=load]").remove();

			$j("#modell").append(new Option("",""));

			$j("#product_line > option[value=load]").remove();

			$j("#product_line").append(new Option("",""));

			$j('#materials').append("<option value=''>Bitte zuerst Saison auswählen</option>");

			$j('#modell').append("<option value=''>Bitte zuerst Saison auswählen</option>");

			$j('#product_line').append("<option value=''>Bitte zuerst Saison auswählen</option>");

		}

	}

	

	/*if(change=="product_line"){

		var my_url = "products.php?saison_id="+saison+"&product_line_id="+product_line;

		

		$("#materials").children("option").each(function(x){

			$(this).remove();

		});

		$j("#materials").append(new Option("loading ...","load"));

		

		$("#modell").children("option").each(function(x){

			$(this).remove();

		});

		$j("#modell").append(new Option("loading ...","load"));

		if(product_line!=""){

			$.getJSON(my_url, function(data) {

				$j("#modell > option[value=load]").remove();

				$j("#modell").append(new Option("",""));

				$.each(data, function(i,item) {

					if(i=="MODELLE"){

						$.each(item, function(key, value) {

							//$j("#modell").append(new Option(value.name, value.id));

							 $j('#modell').append("<option value='"+value.id+"'>"+value.name+"</option>");

						});

					}

				});

				if(mo_value!=""){

					$j("#modell option[value="+mo_value+"]").attr('selected', 'selected');

				}

				//$j("#materials").append(new Option("Bitte zuerst Saison auswählen", ""));

				$j("#materials > option[value=load]").remove();

				$j("#materials").append(new Option("",""));

				$j('#materials').append("<option value=''>Bitte zuerst Modell auswählen</option>");

				

				if(next)

					saison_select(pl_value, mo_value, ma_value, "modell", 1);

			});

		}else{

			//$j("#materials").append(new Option("Bitte zuerst Saison auswählen", ""));

			//$j("#modell").append(new Option("Bitte zuerst Saison auswählen", ""));

			$j("#materials > option[value=load]").remove();

			$j("#materials").append(new Option("",""));

			$j("#modell > option[value=load]").remove();

			$j("#modell").append(new Option("",""));

			$j('#materials').append("<option value=''>Bitte zuerst Modell auswählen</option>");

			$j('#modell').append("<option value=''>Bitte zuerst Produktlinie auswählen</option>");

		}

	}

	

	if(change=="modell"){

		var my_url = "products.php?saison_id="+saison+"&product_line_id="+product_line+"&modell_id="+modell;

		

		$("#materials").children("option").each(function(x){

			$(this).remove();

		});

		$j("#materials").append(new Option("loading ...","load"));

		

		if(modell!=""){

			$.getJSON(my_url, function(data) {

				$j("#materials > option[value=load]").remove();

				$j("#materials").append(new Option("",""));

				$.each(data, function(i,item) {

					if(i=="MATERIALS"){

						$.each(item, function(key, value) {

							//$j("#materials").append(new Option(value.name, value.id));

							 $j('#materials').append("<option value='"+value.id+"'>"+value.name+"</option>");

						});

					}

				});

				if(ma_value!=""){

					$j("#materials option[value="+ma_value+"]").attr('selected', 'selected');

				}

			});

		}else{

			//$j("#materials").append(new Option("Bitte zuerst Saison auswählen", ""));

			$j("#materials > option[value=load]").remove();

			$j("#materials").append(new Option("",""));

			$j('#materials').append("<option value=''>Bitte zuerst Modell auswählen</option>");

		}

	}*/

}



function clear_select(){

	$("#modell").children("option").each(function(x){

		$(this).remove();

	});

	$("#materials").children("option").each(function(x){

		$(this).remove();

	});

	$("#product_line").children("option").each(function(x){

		$(this).remove();

	});

	$j("#materials").append(new Option("",""));

	$j("#modell").append(new Option("",""));

	$j("#product_line").append(new Option("",""));

	$j('#materials').append("<option value=''>Bitte zuerst Saison auswählen</option>");

	$j('#modell').append("<option value=''>Bitte zuerst Saison auswählen</option>");

	$j('#product_line').append("<option value=''>Bitte zuerst Saison auswählen</option>");

	$("[name=saison] option:first").attr('selected', 'selected');

}



function showVideoPopup(url, width, height,org_video,download_text, error)

{

	$("#VideoPopup .download a").attr("href", '/download/?'+url);

	var correct_flash_version = (deconcept.SWFObjectUtil.getPlayerVersion().major >= 9);

	

	if(!correct_flash_version)

	{

		alert(error);

		return;

	}

	var html = "<div id=\"VideoPopup\"><div class=\"head\"><a href=\"javascript: void(0);\" onClick=\"javascript: hideVideoPopup();\">";

	html += "<img src=\"/images/lightbox/lightbox-btn-close.gif\" /></a></div>";

	html += "<div id=\"Video\"></div><div class=\"download\"><a href=\"/download/?file="+org_video+"\">"+download_text+"</a></div></div>";

	

	if ($("#VideoPopup").length)

	{

		$("#VideoPopup").remove();

	}

	$("body").append(html);

	

	var width_ratio = parseFloat(width/800);

	var height_ratio = parseFloat(height/600);

	if(width_ratio>1 || height_ratio>1)

	{

		if(width_ratio>height_ratio)

		{

			width = 800;

			height = Math.ceil(height/width_ratio);

		}

		else

		{

			height = 600;

			width = Math.ceil(width/height_ratio);

		}

	}

	//width = 400;

	//height = 400;

	//alert(url);

	

	var so = new SWFObject("/flash/video.swf?q="+(Math.random()*1000000), "video_popup", width, height, "1", "#ffffff");

	so.addParam('wmode', 'transparent');

	so.addParam('scale','noborder');

	so.addParam('quality','high');

	

	so.addVariable('video_source',url);

	

	var show = function(hash) {

		if($j("#overlayDIV").length==0){

			$j("#overlayWholeDIV").css("display","block");

		}else{

			$("#overlayDIV").css("display","block");

		}

		hash.w.fadeIn("slow");

	}

	var hide = function(hash) {

		hash.w.fadeOut("slow", function(){

				$(this).find("#Video").html("");

				//$(this).find(".download a").attr('href', 'javascript: void(0);');

			});

		hash.o.fadeOut("slow", function(){

				$(this).remove();

				$("#overlayDIV").css("display","none");

				$("#overlayWholeDIV").css("display", "none");

				

			})

		$("#VideoPopup").remove();

	}

	$("#VideoPopup #Video").css({"width":width+"px","height":height+"px"});

	$("#VideoPopup").css({"left":"50%", "margin-left":-(width/2)+"px"}).jqm({"onShow": show, "onHide": hide}).jqmShow();

	so.write('Video');

}



function hideVideoPopup()
{
	$("#VideoPopup").jqmHide();
}

function showGewinnspiel() {
	if($("#PopupGewinnspiel").length==0)
		$("body").append('<div id="PopupGewinnspiel"><iframe src="/popup_gewinnspiel_2011.php" width="500" scrolling="no" height="680" frameborder="0"></iframe></div>');
	
	var show = function(hash) {
		hash.w.fadeIn("slow");
	}
	
	var hide = function(hash) {
		hash.w.fadeOut("slow", function(){
			$("#PopupGewinnspiel iframe").attr("src", "/popup_gewinnspiel_2011.php");
		});
		hash.o.fadeOut("slow",function(){
			hash.o.remove();
		});
	};
	
	$("#PopupGewinnspiel").jqm({onShow: show, onHide: hide}).jqmShow();
	
	$(".jqmOverlay").insertBefore("#PopupGewinnspiel");
	$(".jqmOverlay").css("position","fixed");
	
}

function hideGewinnspiel()
{
	$("#PopupGewinnspiel").jqmHide();
}
