function mergeMail(name, prov, top, subject){
	document.location.href="mailto:" + name +"@"+ prov +"."+ top +"?subject=" + subject;
}

function checkInputs(doc, errmsg, errcolor, validcolor, errbg, validbg)
{
	var inputs = $$('.required');

	//defaults
	var focused = false;

	if(errmsg == undefined) errmsg = '&nbsp;'; // set emtpy error message
	if(errcolor == undefined) errcolor = 'red'; // set error color
	if(errbg == undefined) errbg = '#EAEAEA'; // set error background
	if(validcolor == undefined) validcolor = '#b4babc'; // set valid color
	if(validbg == undefined) validbg = '#ffffff'; // set valid background color

	var iserror = 0;
	var gerror = 0;


	for (var index = 0; index < inputs.length; ++index) {

		var item = inputs[index];
		var inputValue = item.value;
		var titleValue = item.getAttribute('title');
		iserror = 0;



		// extra code for sepcial fields
		if(titleValue == 'agb') {
		 //alert(item.checked);
		}
		// reset colors
		item.setStyle({ backgroundColor: validbg, borderColor: validcolor });


		if(titleValue == 'email' || titleValue == 'email_friend') {

			if (inputValue == '' || inputValue.length < 6 || (inputValue.indexOf("@") < 1)  || (inputValue.indexOf(".") < 1) ) {
				iserror = 1;
				gerror += 1;
			}
		}

		else if(titleValue == 'terms_checkbox') {
			if ($('terms_checkbox').checked == false ) {
				iserror = 1;
				gerror += 1;
			}
		}

		else if(titleValue == 'age') {

			if(inputValue == '') {
				iserror = 1;
				gerror += 1;
			}

			if(2009 - (inputValue.slice(inputValue.length-4, inputValue.length)) <= 6){
				alert("Eine Teilnahme unter 6 Jahre ist nicht möglich. / L‘âge minimum de participation est de 6 ans.");
				iserror = 1;
				gerror += 1;
			}

		}

		else if(titleValue == 'zip') {
			if (inputValue == '' || inputValue.length < 4 || inputValue.length > 4 ) {
				iserror = 1;
				gerror += 1;
			}
		}
		else if(titleValue == 'password') {
			if (inputValue != $F('password_repeat') || inputValue == '') {
				iserror = 1;
				gerror += 1;
			}
		}
		else if(titleValue == 'age') {

			if (inputValue == '' || inputValue.length < 9 || (inputValue.indexOf(".") < 1) ) {
				iserror = 1;
				gerror += 1;
			}
		}
		else if(titleValue == 'agb') {

			if($('agbtitle')) { $('agbtitle').setStyle({ color:'#333333' }); }
			if (item.checked == false) {

				$('agb_error').setStyle({ color:errcolor });
				iserror = 1;
				gerror += 1;
			}
		}
		else if(titleValue != '' && inputValue == '') {
			iserror = 1;
			gerror += 1;
		}

		if(iserror==1){
			item.setStyle({ backgroundColor:errbg, borderColor: errcolor });
			Effect.Pulsate(item,{duration:1, pulses: 2});

			if(!focused) item.focus();
			focused = true;
		}
	}

	if(gerror > 0){
		if($('errormsg')) {
			$('errormsg').innerHTML = errmsg;
		}
	}

	if (gerror == 0)
		$(doc).submit();
}



function checkAllInputs(doc, mcss, errmsg, errcolor, validcolor, errbg, validbg)
{
	var inputs = $$(mcss);

	//defaults
	var focused = false;

	if(errmsg == undefined) errmsg = '&nbsp;'; // set emtpy error message
	if(errcolor == undefined) errcolor = '#ff9933'; // set error color
	if(errbg == undefined) errbg = '#fff2e5'; // set error background
	if(validcolor == undefined) validcolor = '#b4babc'; // set valid color
	if(validbg == undefined) validbg = '#ffffff'; // set valid background color

	var iserror = 0;
	var gerror = 0;

	for (var index = 0; index < inputs.length; ++index) {

		var item = inputs[index];
		var inputValue = item.value;
		var titleValue = item.getAttribute('title');
		iserror = 0;

		// extra code for sepcial fields
		if(titleValue == 'agb') {
			//alert(item.checked);
		}
		// reset colors
		item.setStyle({ backgroundColor: validbg, borderColor: validcolor });

		if ($(doc).id == 'user_edit') {
			if ($('password').value != $('password_repeat').value)  {
				$('password').setStyle({ backgroundColor:errbg });
				$('password_repeat').setStyle({ backgroundColor:errbg });
				Effect.Pulsate($('password'),{duration:1, pulses: 2});
				Effect.Pulsate($('password_repeat'),{duration:1, pulses: 2});
			}
		}

		if(titleValue == 'email' || titleValue == 'shipping_email') {

			if (inputValue == '' || inputValue.length < 6 || (inputValue.indexOf("@") < 1)  || (inputValue.indexOf(".") < 1) ) {
				iserror = 1;
				gerror += 1;
			}
		}
		else if(titleValue == 'zip' || titleValue == 'shipping_zip' ) {
			if (inputValue == '' || inputValue.length < 4 || inputValue.length > 4 ) {
				iserror = 1;
				gerror += 1;
			}
		}
		else if(titleValue == 'agb') {

			if($('agbtitle')) { $('agbtitle').setStyle({ color:'#333333' }); }
			if (item.checked == false) {

				$('agb_error').setStyle({ color:errcolor });
				iserror = 1;
				gerror += 1;
			}
		}
		else if(titleValue == 'terms_conditions') {
			if(!item.checked) {
				iserror = 1;
				gerror += 1;
			}
		}
		else if(titleValue != '' && inputValue == '') {
			iserror = 1;
			gerror += 1;
		}

		if(iserror==1){
			item.setStyle({ backgroundColor:errbg });
			Effect.Pulsate(item,{duration:1, pulses: 2});

			if(!focused) item.focus();
			focused = true;
		}
	}

	if(gerror > 0){
		if($('errormsg')) {
			$('errormsg').innerHTML = errmsg;
		}
	}

	if (gerror == 0)
		$(doc).submit();
}

function urlSubmit(url, message)
{
	var agree=confirm(message);
	if (agree)
		window.location.href=url;
}
