//--------------------------------------------------------------- Variables -
var popupPrintWindow = null
var popup = null;
var width = null;
var height = null;
var newWidth = null;
var newHeight = null;
var positionX = null;
var positionY = null;
var sprache = null;
var name = null;
var vorname = null;
var postleitzahl = null;
var email = null;
var keineEmail = null;
var emailLeer = null;

//--------------------------------------------------------------- printPage -

function printPage(url,width,height) {
// ***************************************************************************
// * Method.....: printPage()
// * Description: Print Preview of HTML page in external window
// ***************************************************************************

	showPrintPage(url,width,height);
	setTimeout("popupPrintWindow.print()",1000);
}

//----------------------------------------------------------- showPrintPage -

function showPrintPage(url,width,height) {
// ***************************************************************************
// * Method.....: showPrintPage()
// * Description: Show HTML page in external window
// ***************************************************************************

	if (popupPrintWindow != null) {
    	popupPrintWindow.close();
		popupPrintWindow = null;
	}
	popupPrintWindow = window.open("","popupPrintWindow","dependent=yes,directories=no,hotkeys=no,location=no,menubar=no,status=no,toolbar=no,width=" + width + ",height=" + height + ",scrollbars=yes,resizable=yes");
	popupPrintWindow.moveTo(100,100);
	popupPrintWindow.document.location = url;
	popupPrintWindow.focus();
};

//--------------------------------------------------------------- showPopup -

function showPopup(file,width,height) {
// ***************************************************************************
// * Method.....: showPopup()
// * Description: Show POPUP page in external window
// ***************************************************************************

	newWidth = width + 60;
	newHeight = height + 60;
	positionX = ((screen.availWidth / 2) - newWidth / 2);
	positionY = ((screen.availHeight / 2) - newHeight / 2);
	
	popup = window.open(file,"showPopup","dependent=yes,directories=no,hotkeys=no,location=no,menubar=no,status=no,toolbar=no,width=" + newWidth + ",height=" + newHeight + ",left=" + positionX + ",top=" + positionY + ",scrollbars=yes,resizable=yes");
	//popup = window.open("/fileadmin/TLS/scripte/popup.php","showPopup","width=" + newWidth + ",height=" + newHeight + ",left=" + positionX + ",top=" + positionY);
	popup.focus();
};

//--------------------------------------------------------------- checkForm -

function chkForm(sprache) {
// ***************************************************************************
// * Method.....: checkForm()
// * Description: Check input data from contact form
// ***************************************************************************

switch(sprache) {
	case 1:
		name = "Please enter your last name!";
		vorname = "Please enter your first name!";
		//postleitzahl = "EN-Eine Postleitzahl muss aus 5 Stellen bestehen!";
		emailLeer = "Please enter your e-mail address!";
		keineEmail = "No valid e-mail address!";
		break;
	case 2:
		name = "FR-Bitte Ihren Namen eingeben!";
		vorname = "FR-Bitte Ihren Vornamen eingeben!";
		//postleitzahl = "FR-Eine Postleitzahl muss aus 5 Stellen bestehen!";
		emailLeer = "FR-Bitte Ihre E-Mail Adresse eingeben!";
		keineEmail = "FR-Keine E-Mail Adresse!";
		break;
	default:
		name = "Bitte Ihren Namen eingeben!";
		vorname = "Bitte Ihren Vornamen eingeben!";
		//postleitzahl = "Eine Postleitzahl muss aus 5 Stellen bestehen!";
		emailLeer = "Bitte Ihre E-Mail Adresse eingeben!";
		keineEmail = "Keine gültige E-Mail Adresse!";
		break;
}

	if(document.tls_kontaktformular.name.value == "") {
		alert(name);
		document.tls_kontaktformular.name.focus();
		return false;
	}
	
	if(document.tls_kontaktformular.vorname.value == "") {
		alert(vorname);
		document.tls_kontaktformular.vorname.focus();
		return false;
	}
	
	/*if(document.tls_kontaktformular.postleitzahl.value.length != 5) {
		alert(postleitzahl);
		document.tls_kontaktformular.postleitzahl.focus();
		return false;
	}*/
	
	if(document.tls_kontaktformular.email.value == "") {
		alert(emailLeer);
		document.tls_kontaktformular.email.focus();
		return false;
	}
	
	if(document.tls_kontaktformular.email.value.indexOf("@") == -1){
		alert(keineEmail);
		document.tls_kontaktformular.email.focus();
		return false;
	}
	
	return true;
};

