// Formularfelder ueberpruefen
function chkMail() {
	var chkOK = true;
	var chkMail = true;
	var chkEmpty = true;
	var msg = "";

	$$(".chkEmpty").each( function(item){
		if($F(item)=="") {
			chkOK = false;
			chkEmpty = false;
			item.setStyle({backgroundColor: '#FF9999'});
		} else {
			item.setStyle({backgroundColor: '#FFFFFF'});
		}
	} );

	$$(".chkEmail").each( function(item){
                var reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+'(\\@)([a-zA-Z0-9\\-\\.]+)'+'(\\.)([a-zA-Z]{2,4})$');
                
		if(!reg.test($F(item)))	{
		//if($F(item)=="") {
			chkOK = false;
			chkMail = false;
			item.setStyle({backgroundColor: '#FF9999'});
		} else {
			item.setStyle({backgroundColor: '#FFFFFF'});
		}
	} );

	if(!chkEmpty) msg += ixTransFormJsEmpty +"\n";
	if(!chkMail) msg += ixTransFormJsEmail +"\n";
	if(msg!="") alert(msg);
	return chkOK;
}

function mouseRollOver()
{
	$$('.rollOver').each(function (i)
	{
		i.observe('mouseover', function (e)
		{
			index = i.src.lastIndexOf('.');
			if (index > -1) {i.src = i.src.substring(0, index)+'.mo'+i.src.substring(index);}
		})

		i.observe('mouseout', function (e)
		{
			i.src = i.src.replace('.mo.', '.');
		})
	});
}

//**************************
//*** SPAMSCHUTZ ***  
//**************************


// UnCryptMailto() entschluesselt die Mail-Adresse, zu zuvor mit
// der PHP-Funktion encryptEmail() verschlÃƒÂ¼sselt wurde
// Anwendung:
/*
<?php $link="javascript:linkTo_UnCryptMailto('".encryptEmail("john@doe.de")."');"; ?>
<a href="<?php echo $link ?>">E-Mail an John Doe schreiben</a>
*/
 
// JS function for uncrypting spam-protected emails:
function UnCryptMailto(s) {	//
	var n=0;
	var r="";
	for(var i=0; i < s.length; i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(1));
	}
	return r;
}

  // JS function for uncrypting spam-protected emails:
function linkTo_UnCryptMailto(s)	{	//
	location.href="mailto:"+UnCryptMailto(s);
}

/* PRINTVERSION */


function strReplace(strsearch, strreplace, haystack)
{
	// Autor : Thomas B?chler
	// Erstellt : 13.04.2004
	// Beschreibung : Ersetzt alle strsearch innerhalb haystack durch strreplace

	if ((haystack == null) || (strsearch == null))
	{
		return null;
	}
   	
   	if ((haystack.length == 0) || (strsearch.length == 0))
   	{
   		return haystack;
   	}

    if ((strreplace == null) || (strreplace.length == 0))
    { 
    	strreplace = "";
    }

    var len_strsearch = strsearch.length;
    var len_strreplace = strreplace.length;
    var Pos = haystack.indexOf(strsearch, 0);

    while (Pos >= 0)
    {
    	haystack = haystack.substring(0, Pos) + strreplace + haystack.substring(Pos + len_strsearch);
    	Pos = haystack.indexOf(strsearch, Pos + len_strreplace);
    }
    
    return haystack;
}


function showPrintVersion(idName)
{
	var textzelle = document.getElementById(idName);
	var text = textzelle.innerHTML;
	
	while (text.indexOf("href=\"") != -1)
	{
		var part0 = text.substr(text.indexOf("href=\"")+6,text.length);
		var part1 = part0.substr(0,part0.indexOf("\""));	
		
		part1 = "href=\""+part1+"\"";
		var newLnk = "";
		text = strReplace(part1, newLnk, text);
	}
		
	
		
	if(text.length > 0)
	{
		text = strReplace("&lt;&lt; zurück", "", text);
		
		neues_fenster = window.open('', "Window", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=700,height=550,screenX=10,screenY=10,top=10,left=10");
		neues_fenster.document.open();
		
		var content ="<div id='button'><a href='javascript:self.print();'>"+item["print-window"]+"</a> <a href='javascript:self.close();'>"+item["close-window"]+"</a></div>";

			content="<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>";
			content=content+"<html>";
				content=content+"<head>";
					content=content+"<meta http-equiv='content-type' content=content+'text/html;charset=utf-8'>";
					content=content+"<meta name='generator' content=content+'Adobe GoLive'>";
					content=content+"<title>Printversion</title>";
					content=content+"<link href='css/printversion.css' type='text/css' rel='stylesheet' media='all'>";
				content=content+"</head>";
	
				content=content+"<body bgcolor='#ffffff'>";
					content=content+"<div id='content'>";
					content=content+"<div id='menu'><div class='logo'><img id='logo' src='images/ebene2/printlogo.jpg' alt='' border='0'></div><div class='menuImg'></div><div class='clear'></div></div><br><br>";
						content=content+"<div id='button'><a href='javascript:self.print();'>"+item["print-window"]+"</a> <a href='javascript:self.close();'>"+item["close-window"]+"</a></div>";
						content=content+"<div id='dynamicContent'>"+text+"</div>";
						content=content+"<div id='clear'></div>";
						content=content+"<p><b>"+item["cus-company"]+"</b><br>"+item["cus-street"]+"<br>";
						content=content+""+item["cus-zip"]+" "+item["cus-city"]+"</p>";
						content=content+"<div class='phone'>"+item["phone"]+"</div><div class='number'>"+item["cus-phone"]+"</div>";
						content=content+"<div class='phone'>"+item["fax"]+"</div><div class='number'>"+item["cus-fax"]+"</div>";
						content=content+"<div class='phone'>E-Mail</div><div class='number'>"+item["cus-mail"]+"</div>";
					content=content+"</div>";
				content=content+"</body>";
			content=content+"</html>";

		with(neues_fenster.document)
		{
			writeln(content);
		}

		neues_fenster.document.close();
		neues_fenster.focus();
	}
}

/* FADEER FUER HOME-HEADER-GRAFIKEN */

function fadeImg() {
	pfad = "/userImages/global/homeImages/";
	$('homeImage1').fade({afterFinish: function()
{
	$('homeImage1').src=pfad+bildArray[counter++];
	if(counter == bildArray.length){ counter = 0; }
	$('homeImage1').appear(); return;}
}); 	
	

}

function mouseOverMenu()
{
	$$('.menue').each(function (i)
	{		
		i.observe('mouseover', function (e)
		{
			/*if (i.down('.rollOver'))
			{
				index = i.down('.rollOver').src.lastIndexOf('.');
				if (index > -1) {i.down('.rollOver').src = i.down('.rollOver').src.substring(0, index)+'.mo'+i.down('.rollOver').src.substring(index);}
			}*/
		if($('expand'+i.id) != null){
			$('expand'+i.id).style.display = 'block';
		}

		});

		i.observe('mouseout', function (e)
		{
			/*if (i.down('.rollOver')) {i.down('.rollOver').src = i.down('.rollOver').src.replace('.mo.', '.');}*/
		if($('expand'+i.id) != null){
			$('expand'+i.id).style.display = 'none';
		}
		});
	});
}



