
var p = [
"01000,19999,1",
"20000,22999,2",
"23000,23999,1",
"24000,28999,2",
"29000,29999,1",
"30000,33999,2",
"34000,36399,3",
"36400,36499,1",
"37000,39999,1",
"40000,49999,2",
"50000,57999,3",
"58000,59999,2",
"60000,61999,3",
"63000,63696,3",
"63700,63939,4",
"64000,64999,4",
"65000,67999,3",
"68000,69999,4",
"70000,95999,4",
"96000,96499,4",
"96500,96529,1",
"97000,97999,4",
"98000,99999,1"
];

var c = [
	"Bitte geben sie eine gültige Postleitzahl ein!",
	"ungurean",
	"molina",
	"piplica",
	"fruth"
];

var d = [
	"Bitte geben sie eine gültige Postleitzahl ein!",
	'<b>Volkmar Ungurean</b><br>PLZ: 01-19,23,29,36400-36499,37,38,39,96500-96529,98,99<br>Mobil: +49 (0) 178 3438802 - E-Mail: <a href="mailto:volkmar.ungurean@bisley.de">volkmar.ungurean@bisley.de</a>',
	'<b>Juan Molina</b><br>PLZ: 20-22,24-28,30-33,40-49,58-59<br>Mobil.: +49 (0) 178 3438803 - E-Mail: <a href="mailto:juan.molina@bisley.de">juan.molina@bisley.de</a>',
	'<b>Nediljko Piplica</b><br>PLZ: 50-57,34000-36399,60,61,63000-63696,65,66,67<br>Mobil.: +49 (0) 178 3438805 - E-Mail: <a href="mailto:nediljko.piplica@bisley.de">nediljko.piplica@bisley.de</a>',
	'<b>Sascha Fruth</b><br>PLZ: 63700-63939,64,68,69,7,8,90-95,96 ohne 96500 bis 96529,97, Österreich<br>Mobil: +49 (0) 178 3438801 - E-Mail: <a href="mailto:sascha.fruth@bisley.de</a>">sascha.fruth@bisley.de</a>',
	"molina",
	"piplica",
	"fruth"
];

function glv(t) {	
	/*
	$('#glv').text(c[t]);
	$('#glv').text($('#'+c[t]).text());
	*/
	$('#glv').html(d[t]);
	$('#glv').show();
	return false;	
}

function plzcheck(v) {
	ret = false;
	var item;
	
	jQuery.each(p,function(i) {	
		item = p[i];
		item = item.split(",");
		if ( v >= item[0] && v <= item[1] ) {	
			ret = parseFloat(item[2]);
		}

	});
	return ret;
}

function plzsuche() {

	var o = parseFloat($('#plzsuche').val());
	
	if ( !o ) return glv(0);
	if ( o < 1000 || o > 99999 ) return glv(0);
	vc = plzcheck(o);
	
	if ( vc ) return glv(vc);
	glv(0);
}


function plzinit() {		

	jQuery.fn.addEvent = jQuery.fn.bind;
	if ( !$('#plzsuche') ) return false;	
	$('#plzsuchego').click(function() {
		plzsuche();
	});
	$('#plzsuche').blur(function() {
		plzsuche();
	});	
	
	
}

//window.addEvent("domready",plzinit);
jQuery(document).ready(function($) {
	//alert(1);
	plzinit()
	
  // Code using $ as usual goes here.
});

