// JS File für Kizashi Forms
// -------------------------

// Globale Variablen
Status_Datum = false;

function Kizashi_Check_Inner() // Check der Kizashi Formulare, Prospekt (werden nur noch Angaben zur Person gecheckt)
{
	// RegEx Objekt für Email-Prüfung erstellen
	Email_RegEx = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
	
	Status = 0;
	
		if (document.Formular.lastname.value == "")
		{    
			document.Formular.f_nachname.style.display = ''; // type funktioniert nur bei FF, deshalb style.
			document.Formular.f_nachname.disabled = true;
			document.Formular.lastname.style.border="solid red 2px";
			document.Formular.lastname.style.width="176px";
		}
		else
		{
			document.Formular.f_nachname.style.display = 'none';
			document.Formular.f_nachname.disabled = true;
			document.Formular.lastname.style.border="solid #7F9DB9 1px";
			document.Formular.lastname.style.width="177px";
			document.Formular.lastname.style.height="18px";
			Status += 1;
		}
		if (document.Formular.firstname.value == "")
		{    
			document.Formular.f_vorname.style.display = '';
			document.Formular.f_vorname.disabled = true;
			document.Formular.firstname.style.border="solid red 2px";
			document.Formular.firstname.style.width="176px";
		}
		else
		{
			document.Formular.f_vorname.style.display = 'none';
			document.Formular.f_vorname.disabled = true;
			document.Formular.firstname.style.border="solid #7F9DB9 1px";
			document.Formular.firstname.style.width="177px";
			document.Formular.firstname.style.height="18px";
			Status += 1;
		}
		if (document.Formular.street.value == "")
		{    
			document.Formular.f_strasse.style.display = '';
			document.Formular.f_strasse.disabled = true;
			document.Formular.street.style.border="solid red 2px";
			document.Formular.street.style.width="176px";
		}
		else
		{
			document.Formular.f_strasse.style.display = 'none';
			document.Formular.f_strasse.disabled = true;
			document.Formular.street.style.border="solid #7F9DB9 1px";
			document.Formular.street.style.width="177px";
			document.Formular.street.style.height="18px";
			Status += 1;
		}
		if (document.Formular.area_code.value == "")
		{    
			document.Formular.f_plz.style.display = '';
			document.Formular.f_plz.disabled = true;
			document.Formular.area_code.style.border="solid red 2px";
			document.Formular.area_code.style.width="176px";
		}
		else
		{
			document.Formular.f_plz.style.display = 'none';
			document.Formular.f_plz.disabled = true;
			document.Formular.area_code.style.border="solid #7F9DB9 1px";
			document.Formular.area_code.style.width="177px";
			document.Formular.area_code.style.height="18px";
			Status += 1;
		}
		if (document.Formular.city.value == "")
		{    
			document.Formular.f_ort.style.display = '';
			document.Formular.f_ort.disabled = true;
			document.Formular.city.style.border="solid red 2px";
			document.Formular.city.style.width="176px";
		}
		else
		{
			document.Formular.f_ort.style.display = 'none';
			document.Formular.f_ort.disabled = true;
			document.Formular.city.style.border="solid #7F9DB9 1px";
			document.Formular.city.style.width="177px";
			document.Formular.city.style.height="18px";
			Status += 1;
		}
		if (document.Formular.phone.value == "")
		{    
			document.Formular.f_telefon.style.display = '';
			document.Formular.f_telefon.disabled = true;
			document.Formular.phone.style.border="solid red 2px";
			document.Formular.phone.style.width="176px";
		}
		else
		{
			document.Formular.f_telefon.style.display = 'none';
			document.Formular.f_telefon.disabled = true;
			document.Formular.phone.style.border="solid #7F9DB9 1px";
			document.Formular.phone.style.width="177px";
			document.Formular.phone.style.height="18px";
			Status += 1;
		}
		if (document.Formular.email.value == "" || !Email_RegEx.test(document.Formular.email.value))
		{    
			document.Formular.f_email.style.display = '';
			document.Formular.f_email.disabled = true;
			document.Formular.email.style.border="solid red 2px";
			document.Formular.email.style.width="176px";
		}
		else
		{
			document.Formular.f_email.style.display = 'none';
			document.Formular.f_email.disabled = true;
			document.Formular.email.style.border="solid #7F9DB9 1px";
			document.Formular.email.style.width="177px";
			document.Formular.email.style.height="18px";
			Status += 1;
		}
	return Status;
}

function Kizashi_Check_Inner2() // Check der Kizashi Formulare, Probefahrt (werden nur noch Angaben zur Person gecheckt)
{
	// RegEx Objekt für Email-Prüfung erstellen
	Email_RegEx = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
	
	Status = 0;
	
		if (document.Formular.lastname.value == "")
		{    
			document.Formular.f_nachname.style.display = ''; // type funktioniert nur bei FF, deshalb style.
			document.Formular.f_nachname.disabled = true;
			document.Formular.lastname.style.border="solid red 2px";
			document.Formular.lastname.style.width="176px";
		}
		else
		{
			document.Formular.f_nachname.style.display = 'none';
			document.Formular.f_nachname.disabled = true;
			document.Formular.lastname.style.border="solid #7F9DB9 1px";
			document.Formular.lastname.style.width="177px";
			document.Formular.lastname.style.height="18px";
			Status += 1;
		}
		if (document.Formular.firstname.value == "")
		{    
			document.Formular.f_vorname.style.display = '';
			document.Formular.f_vorname.disabled = true;
			document.Formular.firstname.style.border="solid red 2px";
			document.Formular.firstname.style.width="176px";
		}
		else
		{
			document.Formular.f_vorname.style.display = 'none';
			document.Formular.f_vorname.disabled = true;
			document.Formular.firstname.style.border="solid #7F9DB9 1px";
			document.Formular.firstname.style.width="177px";
			document.Formular.firstname.style.height="18px";
			Status += 1;
		}
		if (document.Formular.street.value == "")
		{    
			document.Formular.f_strasse.style.display = '';
			document.Formular.f_strasse.disabled = true;
			document.Formular.street.style.border="solid red 2px";
			document.Formular.street.style.width="176px";
		}
		else
		{
			document.Formular.f_strasse.style.display = 'none';
			document.Formular.f_strasse.disabled = true;
			document.Formular.street.style.border="solid #7F9DB9 1px";
			document.Formular.street.style.width="177px";
			document.Formular.street.style.height="18px";
			Status += 1;
		}
		if (document.Formular.area_code.value == "")
		{    
			document.Formular.f_plz.style.display = '';
			document.Formular.f_plz.disabled = true;
			document.Formular.area_code.style.border="solid red 2px";
			document.Formular.area_code.style.width="176px";
		}
		else
		{
			document.Formular.f_plz.style.display = 'none';
			document.Formular.f_plz.disabled = true;
			document.Formular.area_code.style.border="solid #7F9DB9 1px";
			document.Formular.area_code.style.width="177px";
			document.Formular.area_code.style.height="18px";
			Status += 1;
		}
		if (document.Formular.city.value == "")
		{    
			document.Formular.f_ort.style.display = '';
			document.Formular.f_ort.disabled = true;
			document.Formular.city.style.border="solid red 2px";
			document.Formular.city.style.width="176px";
		}
		else
		{
			document.Formular.f_ort.style.display = 'none';
			document.Formular.f_ort.disabled = true;
			document.Formular.city.style.border="solid #7F9DB9 1px";
			document.Formular.city.style.width="177px";
			document.Formular.city.style.height="18px";
			Status += 1;
		}
		if (document.Formular.phone.value == "")
		{    
			document.Formular.f_telefon.style.display = '';
			document.Formular.f_telefon.disabled = true;
			document.Formular.phone.style.border="solid red 2px";
			document.Formular.phone.style.width="176px";
		}
		else
		{
			document.Formular.f_telefon.style.display = 'none';
			document.Formular.f_telefon.disabled = true;
			document.Formular.phone.style.border="solid #7F9DB9 1px";
			document.Formular.phone.style.width="177px";
			document.Formular.phone.style.height="18px";
			Status += 1;
		}
		if (document.Formular.email.value == "" || !Email_RegEx.test(document.Formular.email.value))
		{    
			document.Formular.f_email.style.display = '';
			document.Formular.f_email.disabled = true;
			document.Formular.email.style.border="solid red 2px";
			document.Formular.email.style.width="176px";
		}
		else
		{
			document.Formular.f_email.style.display = 'none';
			document.Formular.f_email.disabled = true;
			document.Formular.email.style.border="solid #7F9DB9 1px";
			document.Formular.email.style.width="177px";
			document.Formular.email.style.height="18px";
			Status += 1;
		}
		if (document.Formular.datum_kizashi.value == "")
		{    
			document.Formular.f_modell.style.display = '';
			document.Formular.f_modell.disabled = true;
			document.Formular.datum_kizashi.style.border="solid red 2px";
			document.Formular.datum_kizashi.style.width="176px";
		}
		else
		{
			document.Formular.f_modell.style.display = 'none';
			document.Formular.f_modell.disabled = true;
			document.Formular.datum_kizashi.style.border="solid #7F9DB9 1px";
			document.Formular.datum_kizashi.style.width="177px";
			document.Formular.datum_kizashi.style.height="18px";
			Status += 1;
		}
	return Status;
}

// Hauptfunktionen für Form Checks
function KizashiCheck(Status) // Prospekt
{
	if (Kizashi_Check_Inner() == 7)
	{
		Schicken = true;
		return Schicken;
	}
	else
	{
		Schicken = false;
		return Schicken;
	}
}

function KizashiCheck2(Status) // Probefahrt
{
	if (Kizashi_Check_Inner2() == 8)
	{
		Schicken = true;
		return Schicken;
	}
	else
	{
		Schicken = false;
		return Schicken;
	}
}

// ------------------------------------------------------------------------------------------------------------- 
// Evtl easy löschbar

function Clear_Hint() // Allgemeiner Hinweis bei Modellwahl entfernen
{
	document.Formular.f_modell.style.display = 'none';
	document.Formular.f_modell.disabled = true;
}

function WT_Kizashi () // Dient zur Einblendung des Datepickers mit disabled Textfeld, falls Probefahrt gewünscht ist.
{
	if (document.Formular.probefahrt_kizashi.checked == true)
	{
		document.Formular.datum_kizashi.style.display = '';
		document.Formular.wt_kizashi_date.style.display = '';
	}
	else
	{
		document.Formular.datum_kizashi.style.display = 'none';
		document.Formular.wt_kizashi_date.style.display = 'none';
		document.Formular.datum_kizashi.value = '';
		document.Formular.datum_kizashi.style.border="solid #7F9DB9 1px";
		document.Formular.datum_kizashi.style.width="144px";
		document.Formular.datum_kizashi.style.height="18px";
	}
}

