﻿function init() {
	node1 = document.getElementById('1');
	node2 = document.getElementById('2');
	node3 = document.getElementById('3');
	href1 = document.getElementById('navi1');
	href2 = document.getElementById('navi2');
	href3 = document.getElementById('navi3');
}

function swapDisplay(id) {
	if (id == '1') {
		node1.style.display = 'block';
		node2.style.display = 'none';
		node3.style.display = 'none';
		href1.style.color = '#ff6600';
		href2.style.color = '';
		href3.style.color = '';
	}
	else if(id == '2') {
		node1.style.display = 'none';
		node2.style.display = 'block';
		node3.style.display = 'none';
		href2.style.color = '#ff6600';
		href1.style.color = '';
		href3.style.color = '';
	}
	else if(id == '3') {
		node1.style.display = 'none';
		node2.style.display = 'none';
		node3.style.display = 'block';
		href3.style.color = '#ff6600';
		href2.style.color = '';
		href1.style.color = '';
	}
}

function swapDisplay2(id) {
	if (id == '1') {
		node1.style.display = 'block';
		node2.style.display = 'none';
		href1.style.color = '#ff6600';
		href2.style.color = '';
	}
	else if(id == '2') {
		node1.style.display = 'none';
		node2.style.display = 'block';
		href2.style.color = '#ff6600';
		href1.style.color = '';
	}
}

function checkAllData(form) {
	out1 = checkDataRechnung(form);
	if (!out1){
		return false;
	}
	out2 = checkDataLieferung(form);
	if (!out2){
		return false;
	}
	return true;
}

function checkDataRechnung(form) {

	if (form.name1.value == '') {
		alert('You must fill in all fields of the billing address!');
		return (false);
	}
	else if (form.vorname1.value == '') {
		alert('You must fill in all fields of the billing address!');
		return (false);
	}
	else if (form.adresse1.value == '') {
		alert('You must fill in all fields of the billing address!');
		return (false);
	}
	else if (form.plz1.value == '') {
		alert('You must fill in all fields of the billing address!');
		return (false);
	}
	else if(form.ort1.value == '') {
		alert('You must fill in all fields of the billing address!');
		return (false);
	}

	div1 = form.mail1.value.split(/@/);
	if ((div1.length != 2) || div1[0] == "" || div1[1] ==  "")
	{
		alert('You have entered an invalid e-mail address.');
		return (false);
	}
	div2 = div1[1].split('.');
	if (div2.length != 2) {
		alert('You have entered an invalid e-mail address.');
		return (false);
	}
	return true;
}


function checkDataLieferung(form) {
	if (form.name2.value == '' && form.vorname2.value == '' && form.adresse2.value == '' && form.plz2.value == '' && form.ort2.value == '') {
		return true;
	}
	else if (form.name2.value != '' && form.vorname2.value != '') {
		return true;
	}
	else{
		alert('Please fill in the name of the person you wish give the gift certificate to.');
		return false;
	}
}

function checkDataAbo(form) {

	if (form.name3.value == '') {
		alert('You must fill in all fields of the billing address!');
		return (false);
	}
	else if (form.vorname3.value == '') {
		alert('You must fill in all fields of the billing address!');
		return (false);
	}
	else if (form.adresse3.value == '') {
		alert('You must fill in all fields of the billing address!');
		return (false);
	}
	else if (form.plz3.value == '') {
		alert('You must fill in all fields of the billing address!');
		return (false);
	}
	else if(form.ort3.value == '') {
		alert('You must fill in all fields of the billing address!');
		return (false);
	}
	else if(form.telefon3.value == '') {
		alert('You must fill in all fields of the billing address!');
		return (false);
	}

	div1 = form.mail3.value.split(/@/);
	if ((div1.length != 2) || div1[0] == "" || div1[1] ==  "")
	{
		alert('You have entered an invalid e-mail address.');
		return (false);
	}
	div2 = div1[1].split('.');
	if (div2.length != 2) {
		alert('You have entered an invalid e-mail address.');
		return (false);
	}
	return true;
}

