/* JavaScript by Armin Priesner, Webdesignen.at */

// Backbuttons
var backbtn_out = new Image();
backbtn_out.src = "../img/back-button-1.gif";
var backbtn_over = new Image();
backbtn_over.src = "../img/back-button-2.gif";

function fnSwapButtons(id, btn) {
	if(window.document.images[id]) {
		window.document.images[id].src = btn.src;
	}
}

function fnImprint() {
	if (document.URL.indexOf("/de/") > 0)
		relPfad = "impressum.php";
	if (document.URL.indexOf("/en/") > 0)
		relPfad = "imprint.php";
	if (document.URL.indexOf("/de/") < 0 && document.URL.indexOf("/en/") < 0)
		relPfad = "de/impressum.php";
	
	var screenWidth = screen.width;
	var screenHeight = screen.height;
	
	var popupHeight = 500;
	var popupWidth = 400;
	
	// X und Y Koordinaten
	var posX = screenWidth / 2 - popupWidth / 2;
	var posY = screenHeight / 2 - popupHeight / 2;
	
	var win = window.open(relPfad, "", "width=" + popupWidth + "px,height=" + popupHeight + "px,left=" + posX + "px,top=" + posY + "px,scrollbars=no");
	win.focus();
}

function fnContact(arg1) {
	var screenWidth = screen.width;
	var screenHeight = screen.height;
	
	var popupHeight = 269;
	var popupWidth = 409;
	
	// X und Y Koordinaten
	var posX = screenWidth / 2 - popupWidth / 2;
	var posY = screenHeight / 2 - popupHeight / 2;
	
	var win = window.open(arg1, "", "width=" + popupWidth + "px,height=" + popupHeight + "px,left=" + posX + "px,top=" + posY + "px,scrollbars=no");
	win.focus();
}

function fnContactTeam(arg1) {
	var screenWidth = screen.width;
	var screenHeight = screen.height;
	
	var popupHeight = 560;
	var popupWidth = 300;
	
	// X und Y Koordinaten
	var posX = screenWidth / 2 - popupWidth / 2;
	var posY = screenHeight / 2 - popupHeight / 2;
	
	var win = window.open(arg1, "", "width=" + popupWidth + "px,height=" + popupHeight + "px,left=" + posX + "px,top=" + posY + "px,scrollbars=no");
	win.focus();
}

function fnImgPopups(arg1, arg2, arg3) {
	var screenWidth = screen.width;
	var screenHeight = screen.height;
	
	var popupHeight = arg3;
	var popupWidth = arg2;
	
	// X und Y Koordinaten
	var posX = screenWidth / 2 - popupWidth / 2;
	var posY = screenHeight / 2 - popupHeight / 2;
	
	var html = '<html><head><title>.::: mkctotalmedia :::.</title></head><body style="margin:0px;"><img src="' + arg1 + '" alt="" border="0" /></body></html>';
	
	var win = window.open("", "", "width=" + popupWidth + "px,height=" + popupHeight + "px,left=" + posX + "px,top=" + posY + "px,scrollbars=no");
	win.document.write(html);
	win.focus();
}

var myImgPosition = 1;
var imgLoading = new Image();
imgLoading.src = "../img/production_design_galerie/default_logo.gif";
function fnGalerie(arg1, arg2) {
	var pfad = arg1;
	var bildnr = arg2;
	
	
	function myImgOnLoadHandler() {
		document.images['galerie'].src = img.src;
		myImgPosition = bildnr;
	}
	
	function myImgOnErrorHandler() {
		alert("Das angeforderte Bild konnte nicht geladen werden!\nThe requested image could not be loaded.");
	}
	
	function myImgCompleteHandler() {
		document.images['galerie'].src = imgLoading.src;
	}
	
	var img = new Image();
	img.onload = myImgOnLoadHandler;
	img.onerror = myImgOnErrorHandler;
	
	// Preloader: Unterscheidung IE und Mozilla, Opera
	if(navigator.userAgent.indexOf('MSIE') > -1) {
		var bool = true; // MS IE
	}
	else {
		var bool = false; // Mozilla, Opera
	}
	do {
		myImgCompleteHandler();
	}
	while(img.complete == bool);
	
	img.src = pfad + bildnr + ".jpg";
}

function fnGalerieButton(arg1, arg2) {
	// weiter oder zurück
	if(arg2 == "+") {
		if(myImgPosition + 1 < 13) {
			myImgPosition++;
		}
		else {
			myImgPosition = 1;
		}
	}
	else {
		if(myImgPosition - 1 > 0) {
			myImgPosition--;
		}
		else {
			myImgPosition = 12;
		}
	}
	
	fnGalerie(arg1, myImgPosition);
}


function startLogin() {
	document.getElementById('flvplayerframe').style.display = 'none';
	document.getElementById('flvplayerdisclaimer').style.display = 'none';
	
	document.getElementById('boxShowreelBackground').style.backgroundImage = 'url(../img/showreel_empty_bg.jpg)';
	
	document.getElementById('registerform').style.display = 'none';
	document.getElementById('loginform').style.display = 'inline';
}


function startRegister() {
	document.getElementById('flvplayerframe').style.display = 'none';
	document.getElementById('flvplayerdisclaimer').style.display = 'none';
	
	document.getElementById('boxShowreelBackground').style.backgroundImage = 'url(../img/showreel_empty_bg.jpg)';
	
	document.getElementById('loginform').style.display = 'none';
	document.getElementById('registerform').style.display = 'inline';
}


function setKunde() {
	
	var f = document.registerform;
	var txt = '';
	var bol = true;
	
	if(f.reg_name.value == '') {
		txt += 'name fehlt\n';
		bol = false;
	}
	
	if(f.reg_firma.value == '') {
		txt += 'firmenname fehlt\n';
		bol = false;
	}
	
	if(f.reg_land.value == '') {
		txt += 'land fehlt\n';
		bol = false;
	}
	
	if(f.reg_email.value.indexOf('@') < 1 || f.reg_email.value.length < 6) {
		txt += 'e-mail fehlt\n';
		bol = false;
	}
	
	if(txt != '') alert(txt);
	
	return bol;
}


function setKundeEn() {
	
	var f = document.registerform;
	var txt = '';
	var bol = true;
	
	if(f.reg_name.value == '') {
		txt += 'name is missing\n';
		bol = false;
	}
	
	if(f.reg_firma.value == '') {
		txt += 'company name is missing\n';
		bol = false;
	}
	
	if(f.reg_land.value == '') {
		txt += 'land is missing\n';
		bol = false;
	}
	
	if(f.reg_email.value.indexOf('@') < 1 || f.reg_email.value.length < 6) {
		txt += 'e-mail is missing\n';
		bol = false;
	}
	
	if(txt != '') alert(txt);
	
	return bol;
}