function sel_hrst(a){if(a!="-")new Ajax.Request("php/json/index.php?sec=hrst&id="+a,{method:"get",onCreate:function(){$("auto_model").update();$("auto_model").enable();elem=new Element("option",{value:"-"});elem.update("Bitte Warten...");$("auto_model").insert(elem)},onSuccess:function(b){b=b.responseText.evalJSON(true);$("auto_model").update();$("auto_model").enable();$("auto_motor").update();$("auto_motor").disable();$("selected_cat").hide();$("auto_motor").insert((new Element("option",{value:"-"})).update("Bitte Motor ausw&auml;hlen"));
$("auto_model").insert((new Element("option",{value:"-"})).update("Bitte Modell ausw&auml;hlen"));i="cars";if(typeof b[i]=="object")for(var c in b[i])b[i][c].au_id!=undefined&&$("auto_model").insert((new Element("option",{value:b[i][c].au_id})).update(b[i][c].au_name))}});else{$("auto_model").update();$("auto_model").enable();$("auto_motor").update();$("auto_motor").enable();$("auto_motor").disable();$("auto_motor").insert((new Element("option",{value:"-"})).update("Bitte Motor ausw&auml;hlen"));
$("auto_model").insert((new Element("option",{value:"-"})).update("Bitte Modell ausw&auml;hlen"))}}
function sel_hrst_top(a){if(a!="-")new Ajax.Request("php/json/index.php?sec=hrst&id="+a,{method:"get",onCreate:function(){$("auto_model_top").update();$("auto_model_top").enable();elem=new Element("option",{value:"-"});elem.update("Bitte Warten...");$("auto_model_top").insert(elem)},onSuccess:function(b){b=b.responseText.evalJSON(true);$("auto_model_top").update();$("auto_model_top").enable();$("auto_motor_top").update();$("auto_motor_top").disable();$("auto_motor_top").insert((new Element("option",
{value:"-"})).update("Bitte Motor ausw&auml;hlen"));$("auto_model_top").insert((new Element("option",{value:"-"})).update("Bitte Modell ausw&auml;hlen"));i="cars";if(typeof b[i]=="object")for(var c in b[i])b[i][c].au_id!=undefined&&$("auto_model_top").insert((new Element("option",{value:b[i][c].au_id})).update(b[i][c].au_name))}});else{$("auto_model_top").update();$("auto_model_top").enable();$("auto_motor_top").update();$("auto_motor_top").enable();$("auto_motor_top").disable();$("auto_motor_top").insert((new Element("option",
{value:"-"})).update("Bitte Motor ausw&auml;hlen"));$("auto_model_top").insert((new Element("option",{value:"-"})).update("Bitte Modell ausw&auml;hlen"))}}
function sel_mdl(a){if(a!="-")new Ajax.Request("php/json/index.php?sec=model&id="+a,{method:"get",onCreate:function(){$("auto_motor").update();$("auto_motor").enable();elem=new Element("option",{value:"-"});elem.update("Bitte Warten...");$("auto_motor").insert(elem)},onSuccess:function(b){b=b.responseText.evalJSON(true);if(b!="none"){$("auto_motor").update();$("auto_motor").enable();$("selected_cat").hide();$("auto_motor").insert((new Element("option",{value:"-"})).update("Bitte Motor ausw&auml;hlen"));
i="cars";if(typeof b[i]=="object")for(var c in b[i])b[i][c].mt_id!=undefined&&$("auto_motor").insert((new Element("option",{value:b[i][c].mt_id})).update(b[i][c].mt_name))}else{$("auto_motor").update();$("auto_motor").enable();$("selected_cat").hide();$("auto_motor").insert((new Element("option",{value:"-"})).update("Keine Motoren gefunden!"))}}});else{$("auto_motor").update();$("auto_motor").enable();$("auto_motor").insert((new Element("option",{value:"-"})).update("Bitte Motor ausw&auml;hlen"))}}
function sel_mdl_top(a){if(a!="-")new Ajax.Request("php/json/index.php?sec=model&id="+a,{method:"get",onCreate:function(){$("auto_motor_top").update();$("auto_motor_top").enable();elem=new Element("option",{value:"-"});elem.update("Bitte Warten...");$("auto_motor_top").insert(elem)},onSuccess:function(b){b=b.responseText.evalJSON(true);if(b!="none"){$("auto_motor_top").update();$("auto_motor_top").enable();$("auto_motor_top").insert((new Element("option",{value:"-"})).update("Bitte Motor ausw&auml;hlen"));
i="cars";if(typeof b[i]=="object")for(var c in b[i])b[i][c].mt_id!=undefined&&$("auto_motor_top").insert((new Element("option",{value:b[i][c].mt_id})).update(b[i][c].mt_name))}else{$("auto_motor_top").update();$("auto_motor_top").enable();$("auto_motor_top").insert((new Element("option",{value:"-"})).update("Keine Motoren gefunden!"))}}});else{$("auto_motor_top").update();$("auto_motor_top").enable();$("auto_motor_top").insert((new Element("option",{value:"-"})).update("Bitte Motor ausw&auml;hlen"))}}
function car_selection(){Effect.toggle("car_selector","Blind",{duration:0.2})}function this_cat(a,b,c){new Ajax.Request("php/json/index.php?sec=auto_cat&id="+a,{onSuccess:function(d){d=d.responseText.evalJSON(true);document.location.href=SSLpath+d[0]+"/"+d[1]+"/"+d[2]+"/"+b+"/Alle-Hersteller-m"+a+"-c"+c+"-Alle.html"}})}
function get_cat(){if(isNaN($("auto_motor").value))alert("Bitte einen Motor Ausw\u00e4hlen");else document.location.href=SSLpath+$("auto_hrst").options[$("auto_hrst").selectedIndex].innerHTML.replace(/ /g,"-")+"/"+$("auto_model").options[$("auto_model").selectedIndex].innerHTML.replace(/ /g,"-")+"/"+$("auto_motor").options[$("auto_motor").selectedIndex].innerHTML.replace(/ /g,"-")+"_m"+$("auto_motor").value+".html"}
function get_cat_top(){if(isNaN($("auto_motor_top").value))alert("Bitte einen Motor Ausw\u00e4hlen");else document.location.href=SSLpath+"/"+$("auto_hrst_top").options[$("auto_hrst_top").selectedIndex].innerHTML.replace(/ /g,"-")+"/"+$("auto_model_top").options[$("auto_model_top").selectedIndex].innerHTML.replace(/ /g,"-")+"/"+$("auto_motor_top").options[$("auto_motor_top").selectedIndex].innerHTML.replace(/ /g,"-")+"_m"+$("auto_motor_top").value+".html"}
function highlight_on_1(a){try{$("pp_"+a).style.backgroundColor="#115E97"}catch(b){}try{$("low_f_"+a).style.backgroundColor="#937115"}catch(c){}try{$("low_r_"+a).style.backgroundColor="#566474"}catch(d){}try{$("ax_f_"+a).style.backgroundColor="#937115"}catch(e){}try{$("ax_r_"+a).style.backgroundColor="#566474"}catch(f){}try{$("preis_"+a).style.backgroundColor="#115E97"}catch(g){}try{$("pp_"+a).style.color="#EEEEEE"}catch(h){}try{$("low_f_"+a).style.color="#EEEEEE"}catch(j){}try{$("low_r_"+a).style.color=
"#EEEEEE"}catch(k){}try{$("ax_f_"+a).style.color="#EEEEEE"}catch(l){}try{$("ax_r_"+a).style.color="#EEEEEE"}catch(m){}try{$("preis_"+a).style.color="#EEEEEE"}catch(n){}try{$("link_"+a).style.color="#FF0000"}catch(o){}}
function highlight_off_1(a){try{$("pp_"+a).style.backgroundColor="#CAE4F9"}catch(b){}try{$("low_f_"+a).style.backgroundColor="#F1DB9E"}catch(c){}try{$("low_r_"+a).style.backgroundColor="#E2E6E9"}catch(d){}try{$("ax_f_"+a).style.backgroundColor="#F1DB9E"}catch(e){}try{$("ax_r_"+a).style.backgroundColor="#E2E6E9"}catch(f){}try{$("preis_"+a).style.backgroundColor="#CAE4F9"}catch(g){}try{$("pp_"+a).style.color="#000000"}catch(h){}try{$("low_f_"+a).style.color="#000000"}catch(j){}try{$("low_r_"+a).style.color=
"#000000"}catch(k){}try{$("ax_f_"+a).style.color="#000000"}catch(l){}try{$("ax_r_"+a).style.color="#000000"}catch(m){}try{$("preis_"+a).style.color="#000000"}catch(n){}try{$("link_"+a).style.color="#990000"}catch(o){}}
function highlight_on_2(a){try{$("pp_"+a).style.backgroundColor="#115E97"}catch(b){}try{$("low_f_"+a).style.backgroundColor="#937115"}catch(c){}try{$("low_r_"+a).style.backgroundColor="#566474"}catch(d){}try{$("ax_f_"+a).style.backgroundColor="#937115"}catch(e){}try{$("ax_r_"+a).style.backgroundColor="#566474"}catch(f){}try{$("preis_"+a).style.backgroundColor="#115E97"}catch(g){}try{$("pp_"+a).style.color="#EEEEEE"}catch(h){}try{$("low_f_"+a).style.color="#EEEEEE"}catch(j){}try{$("low_r_"+a).style.color=
"#EEEEEE"}catch(k){}try{$("ax_f_"+a).style.color="#EEEEEE"}catch(l){}try{$("ax_r_"+a).style.color="#EEEEEE"}catch(m){}try{$("preis_"+a).style.color="#EEEEEE"}catch(n){}try{$("link_"+a).style.color="#FF0000"}catch(o){}}
function highlight_off_2(a){try{$("pp_"+a).style.backgroundColor="#A3C9E0"}catch(b){}try{$("low_f_"+a).style.backgroundColor="#EDBB54"}catch(c){}try{$("low_r_"+a).style.backgroundColor="#BAC4CD"}catch(d){}try{$("ax_f_"+a).style.backgroundColor="#EDBB54"}catch(e){}try{$("ax_r_"+a).style.backgroundColor="#BAC4CD"}catch(f){}try{$("preis_"+a).style.backgroundColor="#A3C9E0"}catch(g){}try{$("pp_"+a).style.color="#000000"}catch(h){}try{$("low_f_"+a).style.color="#000000"}catch(j){}try{$("low_r_"+a).style.color=
"#000000"}catch(k){}try{$("ax_f_"+a).style.color="#000000"}catch(l){}try{$("ax_r_"+a).style.color="#000000"}catch(m){}try{$("preis_"+a).style.color="#000000"}catch(n){}try{$("link_"+a).style.color="#990000"}catch(o){}}function changeDisplay(){if($("lieferanschrift").style.display=="none")$("lieferanschrift").style.display="block";else $("lieferanschrift").style.display="none";return true}
function update_count(){new Ajax.Request("php/json/index.php?sec=update_blue",{method:"get",onSuccess:function(a){a=a.responseText.evalJSON(true);if(a[0]!="empty"){$("blue_box").fade({duration:0.2,from:1,to:0.3});window.setTimeout('$(\'blue_box\').update(\'<img src="html/img/minibasket.png" alt="Warenkorb:" style="float:left;"/><a href="warenkorb.html" style="color:#FFF"><b>'+a[0]+"</b> Artikel im Warenkorb - Gesamt "+a[1]+" &euro; - Zum Warenkorb</a>');",250)}else{$("blue_box").fade({duration:0.2,
from:1,to:0.3});window.setTimeout("$('blue_box').update('"+a[1]+"');",250)}window.setTimeout("$('blue_box').appear({'duration':0.2});",300)}})}
function add_basket(){$("ac").value="basket_add_js";new Ajax.Request("warenkorb.html",{method:"post",parameters:$("basket_add").serialize(true),onCreate:function(){Effect.Fade("added",{duration:0});Effect.Appear("wait",{duration:0.2});Effect.Appear("wait_black",{duration:0.2})},onFailure:function(){$("msg").innerHTML="<h3>Ein Fehler ist aufgetreten, bitte versuchen Sie es erneut!</h3>";window.setTimeout("Effect.Fade('wait', { 'duration': 0.2 });",210);window.setTimeout("Effect.Appear('error', { 'duration': 0.5 });",
210)},onSuccess:function(a){if(a.responseText=="basket_added"){window.setTimeout("Effect.Fade('wait', { 'duration': 0.2 });",210);window.setTimeout("Effect.Appear('added', { 'duration': 0.5 });",210);update_count()}else if(a.responseText=="basket_car"){$("msg").innerHTML="<h3>Bitte w&auml;hlen Sie Ihren Motor aus!</h3>";window.setTimeout("Effect.Fade('wait', { 'duration': 0.2 });",210);window.setTimeout("Effect.Appear('error', { 'duration': 0.5 });",210)}}});return false}
function update_basket(a,b){if(b=="0")delete_artikel(a);else b!=""&&!isNaN(a)&&!isNaN(b)&&new Ajax.Request("php/json/index.php?sec=basket_update&amount="+b+"&id="+a,{method:"get",onSuccess:function(c){if(c.responseText!="empty"){c=c.responseText.evalJSON(true);$("gesamtbetrag").fade({duration:0.3,from:1,to:0.3});$("basket_show_gesamt_"+a).fade({duration:0.3,from:1,to:0.3});window.setTimeout("$('gesamtbetrag').innerHTML = '<u><b>"+c.gesamt+" &euro;</b></u><br />"+c.mwst+" &euro;';",450);window.setTimeout("$('basket_show_gesamt_"+
a+"').innerHTML = '"+c.artikel+"&euro;';",450);window.setTimeout("$('gesamtbetrag').appear({'duration':0.25});",500);window.setTimeout("$('basket_show_gesamt_"+a+"').appear({'duration':0.25});",500)}update_count()}})}
function delete_artikel(a){new Ajax.Request("php/json/index.php?sec=basket_delete&id="+a,{method:"get",onSuccess:function(b){update_count();if(b.responseText!="empty"){b=b.responseText.evalJSON(true);$("gesamtbetrag").innerHTML="<u><b>"+b.gesamt+" &euro;</b></u><br />"+b.mwst+" &euro;";Effect.BlindUp("basket_entry_"+a,{duration:0.3});document.setTimeout("$('basket_entry_"+a+"').remove();",350)}else if(b.responseText=="empty"){Effect.BlindUp("my_basket",{duration:0.2});window.setTimeout("$('my_basket').className = 'basket_empty';",
350);window.setTimeout("$('my_basket').innerHTML = 'Der Warenkorb ist leer';",350);window.setTimeout("Effect.Appear('my_basket');",500)}}})}
function country_sel(a){$("knt_ct").value=a;$("knt_ct_liefer").value=a;new Ajax.Request("php/json/index.php?sec=change_country&id="+a,{method:"get",onSuccess:function(b){b=b.responseText.evalJSON(true);$("added").appear({duration:0.3});$("wait_black").appear({duration:0.3});$("gesamtbetrag").fade({duration:0.3,from:1,to:0.3});window.setTimeout("$('gesamtbetrag').innerHTML = '<u><b>"+b.gesamt+" &euro;</b></u><br />"+b.mwst+" &euro;';",450);window.setTimeout("$('gesamtbetrag').appear({'duration':0.25});",
500);if($("vor_betrag")){$("vor_betrag").fade({duration:0.3,from:1,to:0.3});window.setTimeout("$('vor_betrag').innerHTML = '"+b.betrag+" &euro;'",450);window.setTimeout("$('vor_betrag').appear({'duration':0.25});",500);$("pay_betrag").fade({duration:0.3,from:1,to:0.3});window.setTimeout("$('pay_betrag').innerHTML = '"+b.payment+" &euro;'",450);window.setTimeout("$('pay_betrag').appear({'duration':0.25});",500)}if($("vrs_name")){$("vrs_name").fade({duration:0.3,from:1,to:0.3});$("vrs_betrag").fade({duration:0.3,
from:1,to:0.3});$("vrs_gesamt").fade({duration:0.3,from:1,to:0.3});window.setTimeout("$('vrs_name').innerHTML = '"+b.versand_name+" &euro;'",450);window.setTimeout("$('vrs_name').appear({'duration':0.25});",500);window.setTimeout("$('vrs_betrag').innerHTML = '"+b.versand+" &euro;'",450);window.setTimeout("$('vrs_betrag').appear({'duration':0.25});",500);window.setTimeout("$('vrs_gesamt').innerHTML = '"+b.versand+" &euro;'",450);window.setTimeout("$('vrs_gesamt').appear({'duration':0.25});",500)}update_count();
$("basket_artikel").style.display=="none"&&show_artikel()}})}function basket_fade(){$("added").fade({duration:0.2});$("wait_black").fade({duration:0.2})}function error_fade(){$("error").fade({duration:0.2});$("wait_black").fade({duration:0.2})}
function motor_selected(a){if(a==true){if($("sel_basket_car").value!="-"){$("motoren").hide();$("motor").show();$("basket_car").value=$("sel_basket_car").value;$("basket_car_desc").innerHTML=$("sel_basket_car").options[$("sel_basket_car").selectedIndex].text;$("motor_info").hide()}}else{$("motoren").show();$("motor").hide();$("motor_info").show()}}
function show_artikel(){Effect.toggle("basket_artikel","blind",{duration:0.3});Effect.toggle("show_img","blind",{duration:0.3});Effect.toggle("hide_img","blind",{duration:0.3})}
function show_big_img(a){bild=$("show_img");bild.src="sportfahrwerk-bild/full/"+a;$("wait_black").appear({duration:0.1});$("circle_ball").show();$("wait_black").onclick=function(){hide_big_img()}.bind(this);bild.onload=function(){breite=bild.width;hoehe=bild.height;$("show_img_div").style.width=breite+"px";$("show_img_div").style.height=hoehe+"px";$("show_img_div").style.marginTop="-"+(hoehe+50)/2+"px";$("show_img_div").style.marginLeft="-"+(breite+50)/2+"px";$("show_img_div").appear({duration:0.2});
$("circle_ball").hide();$("close_btn").style.position="absolute";$("close_btn").style.right="25px";$("close_btn").style.top="0px;"}.bind(this)}function hide_big_img(){$("show_img_div").fade({duration:0.2});$("wait_black").fade({duration:0.2});$("circle_ball").hide()};

Event.observe(window, 'load', function() { 
	var onload = $('onload').getValue();
	if(onload == 1) {
		
		var car = $('car').getValue();
		var step = 'stossdaempfer';	 
		var s1 = $('s1').getValue();
		var s2 = $('s2').getValue();
		var s3 = $('s3').getValue();
		var s4 = $('s4').getValue();
		var hrst = $('hrst').getValue();
		new Ajax.Request('/php/ajax/art_list.ajax.php',
			{
			method:'post',
			parameters: {step:step,car:car, s1:s1,s2:s2,s3:s3,s4:s4,hrst:hrst},
			onSuccess: function(transport){
			  var response = transport.responseText;
			  $('art_list_stossdaempfer').update(response);
			},
			onFailure: function(){ alert('Something went wrong...') }
		});
	}
});

function load_art_liste(car) {
	$('art_list_stossdaempfer').update('<center><br><br><img src="html/img/ajax-loader2.gif"><br><br>&nbsp;</center>');
	var step = 'stossdaempfer';	 
	var s1 = $('s1').getValue();
	var s2 = $('s2').getValue();
	var s3 = $('s3').getValue();
	var s4 = $('s4').getValue();
	var hrst = $('hrst').getValue();
	new Ajax.Request('/php/ajax/art_list.ajax.php',
		{
		method:'post',
		parameters: {step:step,car:car, s1:s1,s2:s2,s3:s3,s4:s4,hrst:hrst},
		onSuccess: function(transport){
		  var response = transport.responseText;
		  $('art_list_stossdaempfer').update(response);
		},
		onFailure: function(){ alert('Something went wrong...') }
	});
}

function reload_schr() {
	$('schr_list').update('<center><br><br><img src="html/img/ajax-loader2.gif"><br><br>&nbsp;</center>');
	var hrst = $('schr_hrst').getValue();
	var art = $('schr_art').getValue();
	var kopf = $('schr_kopf').getValue();
	var schaft = $('src_schaft').getValue();
	var weite = $('src_sl_weite').getValue();
	var gewinde = $('src_gewinde').getValue();
	
	
	new Ajax.Request('/php/ajax/schrauben.ajax.php',
		{
		method:'post',
		parameters: {hrst:hrst,art:art,kopf:kopf,schaft:schaft,weite:weite,gewinde:gewinde},
		onSuccess: function(transport){
		  var response = transport.responseText;
		  $('schr_list').update(response);
		},
		onFailure: function(){ alert('Something went wrong...') }
	});
}
