
// Version       : 1.0
// Last modified : (AL) 09.03.2005
// Author        : dCTRL GmbH - Zurich/Switzerland
// Copyright     : Copyright © 2000-2004 dCTRL - Switzerland. All Rights Reserved.
// Note          : All content from this site may not be reproduced without prior written permission.
//                 All characters, titles and plublication names on this site are the intellectual property 
//                 of their respective owners/creators.
// Contact       : dCTRL - INTERACTIVE MEDIA & MOTION GRAPHICS GMBH
//                 Konradstrasse 17, CH-8005 Zurich, Switzerland
//                 Tel. 01-271 9828, Fax. 01-271 9829, info[at]dctrl[dot]com, www.dctrl.com



// ------------------- PopUp Window oeffnen ---------------------------------------------
// OEFFNET DAS POPUP FENSTER MIT DER MICROSITE
focusflg = true;

function oeffnefenster(url) {
	var win 			= null;
	var x 				= 600;
	var y 				= 400;
	var centerwidth		= (screen.width/2)-(x/2);
	var centerheight	= (screen.height/2)-(y/2);
	var scrollbarstext 	= 'scrollbars = no,';
	var resizabletext 	= 'resizable = no,';
	var statustext 		= 'status = no,';
	var locationtext 	= 'location = no,';
	var toolbartext 	= 'toolbar = no,';
	var features 		= '';
	features = scrollbarstext+resizabletext+statustext;
	features = features + locationtext+toolbartext;
	features = features + 'width = '+x+',height = '+y;
	features = features + ',top = ' + centerheight;
	features = features + ',left = ' + centerwidth;
	win = window.open(url, name, features);
	win.focus();
	movefenster();
}

// ------------------- Opener Resize ---------------------------------------------
// NACH DEM OEFFNEN DES POPUP WIRD DAS PARENT WINDOW FULLSCREEN
function movefenster() {
	self.moveTo(0,0);
	resizeTo(screen.availWidth,screen.availHeight);
	if (document.layers||document.getElementById) {
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
			top.window.outerHeight = screen.availHeight;
			top.window.outerWidth = screen.availWidth;
		}
	}
	redirectparent();
}

// ------------------- Opener Redirect ---------------------------------------------
// NACH DEM OEFFNEN DES POPUP LADE LEERE SEITE IN DAS PARENT WINDOW
function redirectparent() {
	window.location="end.htm";
}

// ------------------- Opener Go Back ---------------------------------------------
// WIRD DAS POPUP GESCHLOSSEN, LADE IN DAS PARENT WINDOW EINE NEUE ODER DIE ALTE SEITE
function gopage() {
	//window.location="opener.htm";
	if(focusflg){
		location.replace("opener.htm");
	}
}

function setfocus(){
		onfocus = gopage;
		focusflg = true;
}

function offfocus(){
		focusflg = false;
}

/* ---- PRINT CSS LADEN ---------------------------------------------- */
var urlstring = location.href;
//alert(urlstring);
var qrystring = urlstring.substring(urlstring.indexOf("=") + 1, urlstring.length);
//alert(qrystring);
if (qrystring == "true") {
document.write("<link rel='stylesheet' href='../../assets/css/print.css' type='text/css' />");
}

/* ---- PRINT DOCUMENT ---------------------------------------------- */
function printThisPage(){
print(document);
}

/* ---- OPEN PRINT WINDOW ------------------------------------------- */
function OpenPrint () {
var c = window.location.href;
var b = "?print_view=true"
window.open(c+b,'window','width=560,height=550,scrollbars=yes,menubar=yes,status=yes');
}

/* ---- SEND TO A FRIEND --------------------------------------------- */
function OpenMail (c) {
window.open(c,'window','width=300,height=480,scrollbars=no,status=yes');
}


// ------------------- Kontrolle Newsletterform ---------------------------------------------
function subscribeNews(myobject) {
    if (myobject.FromName.value == ""){
		alert("Bitte tragen Sie Ihren Namen ein!");
		(myobject.FromName).focus();
        return false;
    }
	if (myobject.FromEmail.value == ""){
		alert("Bitte tragen Sie Ihre Emailadresse ein!");
		(myobject.FromEmail).focus();
        return false;
    }
	if (myobject.FromEmail.value.indexOf('@') == -1){
		alert("Ihre Emailadresse ist unvollstaendig!");
		(myobject.FromEmail).focus();
        return false;
    }
	else {
        alert("Vielen Dank fuer Ihr Interesse am Newsletter!\nDieser wird Ihnen ab der naechsten Ausgabe zugeschickt!\n\nSt.Moritz Matchrace");
		myobject.abo.value = "Subscribe"
		myobject.FormDate.value = day + "." + month + "." + year + " - " + hour + ":" + minute;
        return true;
    }
}
function unsubscribeNews(myobject) {
    if (myobject.FromName.value == ""){
		alert("Bitte tragen Sie Ihren Namen ein!");
		(myobject.FromName).focus();
        return false;
    }
	if (myobject.FromEmail.value == ""){
		alert("Bitte tragen Sie Ihre Emailadresse ein!");
		(myobject.FromEmail).focus();
        return false;
    }
	if (myobject.FromEmail.value.indexOf('@') == -1){
		alert("Ihre Emailadresse ist unvollstaendig!");
		(myobject.FromEmail).focus();
        return false;
    }
	else {
        alert("Vielen Dank fuer Ihr Interesse am Newsletter!\nIhre Adresse wird aus dem Verteiler geloescht!\n\nSt.Moritz Matchrace");
		myobject.abo.value = "Unsubscribe"
		myobject.FormDate.value = day + "." + month + "." + year + " - " + hour + ":" + minute;
        return true;
    }
}

/* ---- FORM VALIDATION  --------------------------------------------- */
function validation(objet) {
	with (objet) {
		return true;
	}
}

function SendForm(objet) {
	with (objet) {
		if (validation(objet)==true) {
			submit();
		}
	}
}

/* ---- FORM VALIDATION PUBLICATION ORDER  -------------------------- */
function checkContact() { 
	emptyfields = "";
	if (document.formContact.toName.value == "") { 
		emptyfields += "\n - Kein Name"; 
	}
	if (document.formContact.toSurname.value == "") { 
		emptyfields += "\n - Kein Vorname"; 
	}
	if (document.formContact.toStreet.value == "") { 
		emptyfields += "\n - Keine Strasse"; 
	}
	if (document.formContact.toCity.value == "") { 
		emptyfields += "\n - Kein Ort"; 
	}
	if (document.formContact.toCountry.value == "") { 
		emptyfields += "\n - Kein Land"; 
	}
	if(document.formContact.toEmail.value == "") { 
		emptyfields += "\n - Keine eMail"; 
	}
	
	if (document.formContact.toEmail.value!="") {
		if (document.formContact.toEmail.value.indexOf("@")==-1 ||
			document.formContact.toEmail.value.indexOf(".")==-1 || 
			document.formContact.toEmail.value.indexOf(" ")!=-1 || 
			document.formContact.toEmail.value.length<6) {
			emptyfields += "\n - Falsche eMail";
		}
	}
	if (document.formContact.toPhone.value == "") { 
		emptyfields += "\n - Kein Phone"; 
	}
	if (document.formContact.toMessage.value == "") { 
		emptyfields += "\n - Keine Message"; 
	}
	
	if (emptyfields!= "") { 
		emptyfields = "Das Kontaktformular weist folgende Fehler auf:\n" + 
		emptyfields + "\n\nBitte korrigieren und erneut senden!"; 
		alert(emptyfields); 
		return false; 
	} 
	else return true; 
} 



/* ---- FORM VALIDATION MAIL ARTIKEL  -------------------------- */
function checkFields() { 
	emptyfields = "";
	
	if (document.myform.toName.value == "") { 
		emptyfields += "\n - Kein Empfaenger Name"; 
	} 
	if(document.myform.toMail.value == "") { 
		emptyfields += "\n - Keine Empfaenger eMail"; 
	}
	
	if (document.myform.toMail.value!="") {
		if (document.myform.toMail.value.indexOf("@")==-1 ||
			document.myform.toMail.value.indexOf(".")==-1 || 
			document.myform.toMail.value.indexOf(" ")!=-1 || 
			document.myform.toMail.value.length<6) {
			emptyfields += "\n - Falsche Empfaenger eMail";
		}
	}
	
	if (document.myform.fromName.value == "") { 
		emptyfields += "\n - Kein Absender Name"; 
	}
	if (document.myform.fromMail.value == "") { 
		emptyfields += "\n - Keine Absender eMail"; 
	}
	if (document.myform.fromMail.value!="") {
		if (document.myform.fromMail.value.indexOf("@")==-1 ||
			document.myform.fromMail.value.indexOf(".")==-1 || 
			document.myform.fromMail.value.indexOf(" ")!=-1 || 
			document.myform.fromMail.value.length<6) {
			emptyfields += "\n - Falsche Absender eMail";
		}
	}
	
	if (emptyfields!= "") { 
		emptyfields = "Das Formular weist folgende Fehler auf:\n" + 
		emptyfields + "\n\nBitte korrigieren und erneut senden!"; 
		alert(emptyfields); 
		return false; 
	} 
	else return true; 
} 
