
var test = window.location.pathname;
var suche = test.indexOf("findex");

if(suche > 0){
	$gfxpath = "gfx/ci/";
}
else
{
	$gfxpath = "../gfx/ci/";
}

$(document).ready(function () {
	
/* Vorname */
	$("#vname").keydown(function(){
		if($(this).val() != "")
		{
			$("#vname_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			$(this).removeClass("formerror");
		}
		else
		{
			$(this).addClass("formerror");
			$("#vname_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}
	});
	
/* Nachname */
	$("#nname").keyup(function(){
		if($(this).val() != "")
		{
			$("#nname_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			$(this).removeClass("formerror");
		}
		else
		{
			$(this).addClass("formerror");
			$("#nname_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}		
	});
	
/* Strasse */
	$("#strasse").keyup(function(){
		if($(this).val() != "")
		{
			$(this).removeClass("formerror");
		}
		else
		{
			$(this).addClass("formerror");
		}
		
		if($(this).val() != "" && $("#hausnr").val() != "")
		{
			$("#strasse_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			$("#hausnr_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
		}
		else
		{
			
			$("#strasse_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
			$("#hausnr_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}	
	});
	
/* Hausnr */
	$("#hausnr").keyup(function(){
		if($(this).val() != "")
		{
			$(this).removeClass("formerror");
		}
		else
		{
			$(this).addClass("formerror");
		}
		
		if($(this).val() != "" && $("#strasse").val() != "")
		{
			$("#hausnr_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			$("#strasse_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
		}
		else
		{
			$("#hausnr_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
			$("#strasse_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}	
	});	
	
/* Plz */
	$("#plz").keyup(function(){
		if($(this).val() != "" && checkplz($(this).val()) == true )
		{
			$(this).removeClass("formerror");
			if($("#ort").val() != "")
			{
				$("#plz_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
				$("#ort_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			}
		}
		else
		{
			$(this).addClass("formerror");
			$("#plz_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
			$("#ort_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}
	
	});
	
/* Ort */
	$("#ort").keyup(function(){
		if($(this).val() != "")
		{
			$(this).removeClass("formerror");
			if(checkplz($("#plz").val()) == true )
			{
				$("#ort_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
				$("#plz_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			}
		}
		else
		{
			$(this).addClass("formerror");
			$("#ort_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
			$("#plz_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}
		
	});
	
/* Telefon */
	$("#telefon").keyup(function(){
		if($(this).val() != "" && checktel($(this).val()) == true)
		{
			$("#telefon_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			$(this).removeClass("formerror");
		}
		else
		{
			$(this).addClass("formerror");
			$("#telefon_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}		
	});
	
/* EMail */
	$("#email").keyup(function(){
		if($(this).val() != "" && checkemail($(this).val()) == true)
		{
			$("#email_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			$(this).removeClass("formerror");
		}
		else
		{
			$(this).addClass("formerror");
			$("#email_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}	
	});	

/* REMail */
	$("#remail").keyup(function(){
		if($(this).val() != "" && checkemail($(this).val()) == true)
		{
			$("#remail_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			$(this).removeClass("formerror");
		}
		else
		{
			$(this).addClass("formerror");
			$("#remail_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}	
	});

/* Konto */
	$("#konto").keyup(function(){
		if($(this).val() != "" && checkkonto($(this).val()) == true)
		{
			$("#konto_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			$(this).removeClass("formerror");
		}
		else
		{
			$(this).addClass("formerror");
			$("#konto_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}	
	});
	
/* Blz */
	$("#blz").keyup(function(){
		if($(this).val() != "" && checkblz($(this).val()) == true)
		{
			$("#blz_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			$(this).removeClass("formerror");
		}
		else
		{
			$(this).addClass("formerror");
			$("#blz_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}	
	});
	
/* Prämien Vorname */
	$("#wvname").keydown(function(){
		if($(this).val() != "")
		{
			$("#wvname_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			$(this).removeClass("formerror");
		}
		else
		{
			$(this).addClass("formerror");
			$("#wvname_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}
	});

/* Prämien Nachname */
	$("#wnname").keyup(function(){
		if($(this).val() != "")
		{
			$("#wnname_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			$(this).removeClass("formerror");
		}
		else
		{
			$(this).addClass("formerror");
			$("#wnname_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}		
	});
/* Prämien Strasse */
	$("#wstrasse").keyup(function(){
		if($(this).val() != "")
		{
			$(this).removeClass("formerror");
		}
		else
		{
			$(this).addClass("formerror");
		}
		
		if($(this).val() != "" && $("#whausnr").val() != "")
		{
			$("#wstrasse_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			$("#whausnr_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
		}
		else
		{
			
			$("#wstrasse_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
			$("#whausnr_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}	
	});
	
/* Prämien Hausnr */
	$("#whausnr").keyup(function(){
		if($(this).val() != "")
		{
			$(this).removeClass("formerror");
		}
		else
		{
			$(this).addClass("formerror");
		}
		
		if($(this).val() != "" && $("#wstrasse").val() != "")
		{
			$("#whausnr_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			$("#wstrasse_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
		}
		else
		{
			$("#whausnr_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
			$("#wstrasse_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}	
	});	
	
/* Prämien Plz */
	$("#wplz").keyup(function(){
		if($(this).val() != "" && checkplz($(this).val()) == true )
		{
			$(this).removeClass("formerror");
			if($("#wort").val() != "")
			{
				$("#wplz_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
				$("#wort_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			}
		}
		else
		{
			$(this).addClass("formerror");
			$("#wplz_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
			$("#wort_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}
	
	});
	
/* Prämien Ort */
	$("#wort").keyup(function(){
		if($(this).val() != "")
		{
			$(this).removeClass("formerror");
			if(checkplz($("#wplz").val()) == true )
			{
				$("#wort_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
				$("#wplz_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			}
		}
		else
		{
			$(this).addClass("formerror");
			$("#wort_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
			$("#wplz_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}
		
	});	
	
/* Prämien E-mail */
	$("#wemail").keyup(function(){
		if($(this).val() != "" && checkemail($(this).val()) == true)
		{
			$("#wemail_img").html("<img src='"+$gfxpath+"greencheck.gif' width='19' height='19' alt='check' />");
			$(this).removeClass("formerror");
		}
		else
		{
			$(this).addClass("formerror");
			$("#wemail_img").html("<img src='"+$gfxpath+"redx.gif' width='19' height='19' alt='error' />");
		}	
	});	

});


function checktel(phone)
{
	$error = false;
	
	if(!(Math.ceil(phone)>9999999 && Math.ceil(phone)<=999999999999999999))
	{
		$error = true;
	}
	
	if($error == true)
	{
		return false;
	}
	else
	{
		return true;
	}
}
	
function checkplz(plz)
{	
	$error = false;
	
	if(plz.length != 5 )
	{
		$error = true;
	}
	if(!(Math.ceil(plz)>999 && Math.ceil(plz)<=99999))
	{
		$error = true;
	}
	
	if($error == true)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function checkemail(email)
{	
	$error = false;
	
	var filter =/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;

	if (!filter.test(email)) 
	{
		$error = true;
	}
	
	if($error == true)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function checkkonto(konto)
{	
	$error = false;
	
	if(!(Math.ceil(konto)>9 && Math.ceil(konto)<=999999999999))
	{
		$error = true;
	}
	
	if($error == true)
	{
		return false;
	}
	else
	{
		return true;
	}
}
function checkblz(blz)
{	
	$error = false;
	
	if(!(Math.ceil(blz)>9999999 && Math.ceil(blz)<=99999999))
	{
		$error = true;
	}
	
	if($error == true)
	{
		return false;
	}
	else
	{
		return true;
	}
}
