// öffnet ein Fenster
function openNewWindow(URLtoOpen, windowName, windowFeatures) {
	newWindow=window.open(URLtoOpen, windowName, windowFeatures); 
}

// definiert Intro und Extro
var print_intro="<html>\n<head>\n";
print_intro+='<link rel="stylesheet" href="/css/global.css" type="text/css">\n';
print_intro+="<link rel=\"stylesheet\" href=\"/css/channel_"+landingPageId+".css\" type=\"text/css\">\n";
print_intro+='\n</head>\n<body onLoad="window.print();" style="margin:20px;">\n<img src="/pics/layout/cemex_logo_hp_Germany.gif" border="0">\n<br><hr>';

var print_extro="\n<hr>URL dieser Seite:<br>\n"
print_extro+=document.location.href+"<br>\n<br>\n";
print_extro+="ausgedruckt am: "+(new Date()).toLocaleString();
print_extro+="</body>\n</html>";

// druckt den Content-Bereich der Seite wahlweise mit oder ohne Fotos
function printPage(withoutFoto) {
	var printscreen=window.open ("", "printscreen_popup",
							"width=600,height=400,resizable=yes,scrollbars=yes,status=yes");
	var content=document.getElementById("content");
	printscreen.document.write(print_intro);
	var cont=content.innerHTML;
	if(withoutFoto) {
		cont=filterImages(cont);
	}
	printscreen.document.write(cont);
	printscreen.document.write(print_extro);
	printscreen.document.close();
	printscreen.focus();
}

// filtert alle Image-Tags heraus, um eine Druckansicht ohne Bilder zu erhalten.
function filterImages(input) {
	var pos1=-1;
	var securityCounter=0;
	var inputL=input.toLowerCase();
	while((pos1=inputL.indexOf("<img")) != -1 && securityCounter++<1000) {
		var pos2=input.indexOf(">",pos1);
		if(pos2==-1) break; // Fehler im HTML-Code -> Tag kann nicht entfernt werden.
		input=input.substring(0,pos1)+input.substring(pos2+1);
		inputL=input.toLowerCase();
	}
	return input;
}

function showProps(obj) {
 var ausgabe = "<table border=1>";
// obj=document.getElementById("isOK").previousSibling;
 for (var Eigenschaft in obj)
   ausgabe += "<tr><td>" + Eigenschaft + "</td><td>" + obj[Eigenschaft] + "</td></tr>\n";
 document.getElementById("propOutput").innerHTML=ausgabe+"</table>";
} 

/* Überprüfung für Ansprechpartnerformulare ---*/
var reqFields=new Array("NameVorname","StrasseHausnummer","PLZ","Ort","Telefon","E-Mail","Anfrage");
var reqLabels=new Array("Name, Vorname","Straße und Nr.","PLZ","Ort","Telefon","E-Mail","Ihre Anfrage");
function checkForm(f) {
	var inputErrors=0;
	var alertText="";
	var firstEmptyField=null;
	for(var i=0;i<reqFields.length;i++) {
		var field=f.elements[reqFields[i]];
		if(field.value.length==0) {
			alertText+=(inputErrors!=0?", ":"")+"'"+reqLabels[i]+"'";
			field.className="formInputNotAv";
			if(!firstEmptyField)firstEmptyField=field;
			inputErrors++;
		} else {
			field.className="formInput";
		}
	}
	if(inputErrors !=0) {
		alert("Bitte geben Sie "+(inputErrors==1?"im Feld ":"in den Feldern ")+alertText+" Werte ein.");
		firstEmptyField.focus();
	}
	return inputErrors==0;
}