// JavaScript Document


function replaceUmlaute(curText) {
        if (typeof curText != "number" && typeof curText != "string" ) {
                alert("Sie versuchen Text auszugeben, der kein Text ist sondern: "+typeof curText);
                return "err";
        }
        if (curText == "") return "";
        if (typeof curText == "number") curText = String(curText);
        var result = curText;
        result=result.replace(/\u00fc/g, "ue");
        result=result.replace(/\u00f6/g, "oe");
        result=result.replace(/\u00e4/g, "ae");
        result=result.replace(/\u00dc/g, "Ue");
        result=result.replace(/\u00d6/g, "Oe");
        result=result.replace(/\u00c4/g, "Ae");
        result=result.replace(/\u00df/g, "ss");
        result=result.replace(/ü/g, "ue");
        result=result.replace(/ö/g, "oe");
        result=result.replace(/ä/g, "ae");
        result=result.replace(/Ü/g, "Ue");
        result=result.replace(/Ö/g, "Oe");
        result=result.replace(/Ä/g, "Ae");
        result=result.replace(/ß/g, "ss");
        result=result.replace(/ /g, "_");
		$('umlautreplaced').innerHTML = '<br><small>Umlaute und Leerzeichen werden automatisch ge&auml;ndert.</small>';
        return result;
}

function unameumlautcheck(unamestr) {
        var unamefeld = document.getElementById('reguname');
        unamefeld.value = replaceUmlaute(unamefeld.value);
}


function fadewholesite()
{
	new Effect.SwitchOff('mainouter');
}


function showlivehilfe()
{
	var hilfevis = document.getElementById('livehilfe').style.display;
	if(hilfevis == "none")
	{
		//new Effect.BlindDown('livehilfe', { duration: 0.5 });
	}
	else
	{
		//new Effect.BlindUp('livehilfe', { duration: 0.5 });
	}
}

function resellerRegShow(myvalue)
{
		new Effect.BlindDown('resellerreg');
}

function isreseller(ister)
{
	// Ist angehakt?
	var checked = $('amreseller').checked;
	if(checked == true)
	{
		// Ist Händler
		$('resellertext').show();
		$('resellertext').innerHTML = '<p>Danke. Wir werden Ihnen zeitnah die H&auml;ndlerfunktionen freischalten.';
	}
	else
	{
		// Kein Händler
		$('resellertext').hide();
	}
}

function loadschnellcontact()
{
	var topcamsvis = document.getElementById('livehilfe').style.display;
	if(topcamsvis == "none")
	{
		new Effect.BlindDown('livehilfe', { duration: 0.5 });
		new Ajax.Updater('livehilfe', '_modules/mod_schnell_contact.php');
	}
	else
	{
		new Effect.BlindUp('livehilfe', { duration: 0.5 });
	}
}

function showtopcams()
{
	var topcamsvis = document.getElementById('livehilfe').style.display;
	if(topcamsvis == "none")
	{
		new Effect.BlindDown('livehilfe', { duration: 0.5 });
		new Ajax.Updater('livehilfe', '_modules/mod_topcam.php');
	}
	else
	{
		new Effect.BlindUp('livehilfe', { duration: 0.5 });
	}
}

function refreshtopcams()
{
	new Ajax.Updater('livehilfe', '_modules/mod_topcam.php');
}

function mehrletztefzg()
{
	new Ajax.Updater('ndletztefzg', '_modules/mod_nd_front_latest.php');
}


function schnell_getmodelle(marke) {
        new Ajax.Updater('smodelle', "ajax/schnellsuche_getmodelle.php?&marke="+marke);
    }
    
    function schnell_ergebnisse(modell) {
		$('schnellsuche_bottom').show();
        new Ajax.Updater('schnellsuche_bottom', "ajax/schnellsuche_ergebnisse.php?&modell="+modell);
    }
    
    function close_schnellsuche() {
		//$('schnellsuche_bottom').hide();
		new Effect.BlindUp('schnellsuche_bottom');
		
	}

// Per Highlight auf die Startseitensuche aufmerksam machen
function highlightschnellsuche()
{
	new Effect.BlindDown('schnellsuche', { duration: 0.5 });
	new Effect.Highlight('schnellsuche', { startcolor: '#ffff99', endcolor: '#e5e5e5' });
	schnell_getmodelle('Opel');
}


function suchemodelle(marke) {
	new Ajax.Updater('neuesuchemodelle', '../ajax/getautos.php?sa=getmodelle&marke='+marke);
	zeigeergebnisse(marke, "alle");
}

function zeigeergebnisse(marke, suchen) {
	if(suchen == "alle") {
		new Ajax.Updater('suchergebnisse', '../ajax/getautos.php?sa=showresults&marke='+marke+'&modell=%');
	} else {
		var modell = $('modell').value;
		new Ajax.Updater('suchergebnisse', '../ajax/getautos.php?sa=showresults&marke='+marke+'&modell='+modell);
	}
}

function detpicchange(foto, fzgid) {
	new Ajax.Updater('detpic', "_modules/ajax_show_photo.php?fzgid="+fzgid+"&foto="+foto);	
}

function getfarbenbymarke(marke) {
	new Ajax.Updater('sfarbe', "ajax/getfarben.php?t=marke&marke="+marke);
	new Ajax.Updater('scat', "ajax/getvarianten.php?t=marke&marke="+marke);
	new Ajax.Updater('stueren', "ajax/gettueren.php?t=marke&marke="+marke);
	new Ajax.Updater('sfueltype', "ajax/getkraftstoff.php?t=marke&marke="+marke);
}

function getmodelle(marke) {
	new Ajax.Updater('smodelle', "ajax/getmodelle.php?&marke="+marke);
	new Effect.Highlight('smodelle', { startcolor: '#ffff99', endcolor: '#ffffff' });
}

function getfarbenbymodell(modell) {
	new Ajax.Updater('sfarbe', "ajax/getfarben.php?t=modell&modell="+modell);
	new Ajax.Updater('scat', "ajax/getvarianten.php?t=modell&modell="+modell);
	new Ajax.Updater('stueren', "ajax/gettueren.php?t=modell&modell="+modell);
	new Ajax.Updater('sfueltype', "ajax/getkraftstoff.php?t=modell&modell="+modell);
	new Ajax.Updater('farbbeispiele', "ajax/farbbeispiele.php?t=modell&modell="+modell);
}

function getfarbenbyvariante(variante) {
	var modell	=	$('modell').value;
	new Ajax.Updater('farbbeispiele', "ajax/farbbeispiele.php?t=modell&modell="+modell+"&variante="+variante);
}

function updatesfarbe(farbe) {
	$('farbe').value=farbe;	
}

function displaymessage(mymessage)
{
	new Effect.Appear('mainmessage');
	new Effect.Highlight('mainmessage', { startcolor: '#ffff99', endcolor: '#e5e5e5' });
	$('mainmessage').innerHTML = mymessage+'<p><span onclick="new Effect.Fade(\'mainmessage\')" style="color:#069; cursor:pointer;">Schlie&szlig;en</span>';
}