// scroller
var count=100;
var span;
window.onload=main;
function main()
{  
	//alert(document.getElementById('scrollerText').childNodes.length);
	if (document.getElementById('scrollerText'))
	{
		x = document.getElementById('scrollerText').childNodes.length;
		y=0;
		for(i=0; i<x; i++)
		{
			b = document.getElementById('scrollerText').childNodes[i].nodeValue;		
			if (b != null)
			{
				y += b.length;
			}
		}
		document.getElementById('scrollerText').style.height=y+100+'px';
		moveSpan(0);
	}
}
function moveSpan(scrollen)
{
	var y;
	if (!y)
	{
		x = document.getElementById('scrollerText').childNodes.length;
		y=0;
		for(i=0; i<x; i++)
		{
			b = document.getElementById('scrollerText').childNodes[i].nodeValue;
			if (b != null)
			{
				y += b.length;
			}
		}
	}
	
	span=document.getElementById('scrollerText');
	
	if(count>-y-100)
	{
		span.style.top=count+'px';
		count--;
	}
	else
	{
		count=100;
	}
	if (scrollen==0)
	{
		scrollTime = setTimeout("moveSpan(0)",50);
	}
	else
	{
		clearTimeout(scrollTime);
	}
}

// validiere such-Formular

function suchformCheck()
{
	if (document.suchform.text.value == ' Stichwort')
	{
		document.suchform.text.value = '';
	}
	return true;
}

// routenplaner Eingabe Check
function mapCheck()
{
	var plzValue = document.route.szip.value;
	if (document.route.sstreet.value == "Strasse") 
	{
		document.route.sstreet.value = '';
	}
	if (document.route.scity.value == "-Ort-") 
	{
		document.route.scity.value = "";
	}
	if (document.route.szip.value == "" || document.route.szip.value == "PLZ" || isNaN(document.route.szip.value) == true) 
	{
		alert ("Bitte geben Sie eine Start PLZ ein.");
		document.route.szip.value == "";
		document.route.szip.focus();
		return false;
	}
	
	else 
	{
		var plz = document.route.szip.value.length;
		if (document.route.szip.value != "" && plz < 5)
		{
			var eingabe = confirm('Die Eingabe einer nicht vollständigen PLZ kann zu unerwarteten Ergebnissen führen.\n\nTrotzdem fortfahren?');
			if (eingabe == true)
			{
				document.route.szip.value = plzValue;
				return true;
			}
			else
			{
				return false;
			}
		}
		return true;
	}
}
// E-Mail checker
function check_mail(formular, emailfeld, mailfeld)
{
	var inputs = mailfeld.split("###");
	var emails = emailfeld.split("###");
	var fehler;
	var re = new RegExp ("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4}$");
	var laenge = inputs.length;
	for (n=0; n<laenge; n++)
	{
		fehler = inputs[n].split(";;;");
		if (document[formular][fehler[0]].value == "")
		{
		   alert(fehler[1]);
		   return false;		   
		}
	}
	laenge = emails.length;
	for (n=0; n<laenge; n++)
	{
		if (re.test(document[formular][emails[n]].value) == false)
		{
		   alert('Bitte geben Sie eine gültige E-mail Adresse\nin der Form IhrName@IhreDomain.de ein.')
		   document[formular][emails[n]].value = "";
		   document[formular][emails[n]].focus();
		   return false;
		}
	}
	return true;
}
// Ausschreibung
function angebotscheck()
{
	if(document.anfrage.fullname.value == "")
	{
		alert("Bitte geben Sie Ihren Namen oder Firma ein!");
		document.anfrage.fullname.focus();
		return false;
	}
	if(document.anfrage.email.value == "")
	{
		alert("Bitte geben Sie zur Kontaktaufnahme Ihre vollständige Adresse und E-Mail-Adresse an!");
		document.anfrage.email.focus();
		return false;
	}
	if(document.anfrage.strasse.value == "")
	{
		alert("Bitte geben Sie zur Kontaktaufnahme Ihre vollständige Adresse und E-Mail-Adresse an!");
		document.anfrage.strasse.focus();
		return false;
	}
	if(document.anfrage.plz.value == "")
	{
		alert("Bitte geben Sie zur Kontaktaufnahme Ihre vollständige Adresse und E-Mail-Adresse an!");
		document.anfrage.plz.focus();
		return false;
	}
	if(document.anfrage.ort.value == "")
	{
		alert("Bitte geben Sie zur Kontaktaufnahme Ihre vollständige Adresse und E-Mail-Adresse an!");
		document.anfrage.ort.focus();
		return false;
	}
	if(document.getElementsByName("branche")[0].style.display =="")
	{
		if(document.anfrage.branche.value == "nichts")
		{
			alert("Bitte geben Sie eine Branche an!");
			document.anfrage.branche.focus();
			return false;
		}
	}
	if(document.anfrage.bau_plz.value == "")
	{
		alert("Bitte geben Sie die PLZ des Ortes an, in dem der Auftrag ausgeführt werden soll!");
		document.anfrage.bau_plz.focus();
		return false;
	}
	if(document.anfrage.nachricht.value == "")
	{
		alert("Bitte geben Sie eine kurze Beschreibung Ihres Angebots an!");
		document.anfrage.nachricht.focus();
		return false;
	}
}
// tooltip >
wmtt = null;

document.onmousemove = updateWMTT;

function updateWMTT(e) {
	x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
	if (wmtt != null) {
		wmtt.style.left = (x + 20) + "px";
		if (navigator.appVersion.indexOf('MSIE 6.0') > -1)
		{
			wmtt.style.top 	= (y + 60) + "px";
		}
		else
		{
			wmtt.style.top 	= (y + 20) + "px";
		}
	}
}

function showWMTT(id) {
	wmtt = document.getElementById(id);
	wmtt.style.display = "block";
}

function hideWMTT() {
	wmtt.style.display = "none";
}


function winOpen(id, width, height)
{
		 width=width+40;
		 height=height+40;
		 window.open('referenzen.php?id=' + id + '', '', 'width='+ width +',height='+ height +',scrollbars=yes');
}