/*
	copyright @ christian metzger
*/

/*
	This function ist for generating e-mail adress
	It's the better way because spider can't read those
	generated e-mail adresses

*/
	function generateEmail(first)
	{
		var domain="karatemgh.de";
		document.write('<a href=\"mailto:' + first +'@' + domain + '\">');
		document.write(name + '@' + domain + '</a>');
	}

	
/*
	Checks if input fiels are empty

*/
function isEmpty(field,ErrorMessage)
{
	if(field.value=="")
	{
		alert(ErrorMessage);
		field.focus();
		return true;
	}
	return false;
}

/*
	checks if radio buttons are selected
*/

function checkButton(field,ErrorMessage)
{
	if ((field[0].checked==false)&&(field[1].checked==false))
	{
		alert(ErrorMessage);
		return true;
	}
	return false;
}

/*
	check if maybe a correct email adress is given
*/

function checkEmail(field,ErrorMessage )
{
	var email = field.value.lastIndexOf("@");
	if (email==-1)
	{
		alert(ErrorMessage);
		field.focus();
		return false;
	}
	return true;
}


function checkSelectList(field, formular, action)
{
	if (field.value =="%")
    {
    	alert ("Bitte wählen Sie einen Event aus!");
        field.focus();
        return false;
	}
	formular.method = "POST";
    action = action.value;
    formular.submit();
    return true;
}

function ask()
{
	result=confirm("Wollen Sie das wirklich tun?\n Denken Sie lieber noch einmal darüber nach!!");
	return result;
}

function checkLogin(firstname, surname, password)
{

	if(isEmpty(firstname.value,"Bitte geben Sie Ihren Vornamen an"))
	{
		firstname.focus();
		return false;
	}
	if(isEmpty(surname.value,"Bitte geben Sie Ihren Nachnamen an"))
	{
		surname.focus();
		return false;
	}

	if(isEmpty(password, "Bitte geben Sie Ihr Passwort ein"))
	{
		password.focus();
		return false;
	}
	return true;
}

function openWindow(theURL,winName,features) 
{ 
  window.open(theURL,winName,features);
}

function adjust_popup()
{
	var w, h, fixedW, fixedH, diffW, diffH;
	
	if (document.all) {
		fixedW = document.body.clientWidth;
		fixedH = document.body.clientHeight;
		window.resizeTo(fixedW, fixedH);
		diffW = fixedW - document.body.clientWidth;
		diffH = fixedH - document.body.clientHeight;
	} else {
		fixedW = window.innerWidth;
		fixedH = window.innerHeight;
		window.resizeTo(fixedW, fixedH);
		diffW = fixedW - window.innerWidth;
		diffH = fixedH - window.innerHeight;
	}
	w = fixedW + diffW;
	h = fixedH + diffH;
	if (h >= screen.availHeight) w += 16;
	if (w >= screen.availWidth)  h += 16;
	w = Math.min(w,screen.availWidth);
	h = Math.min(h,screen.availHeight);
	window.resizeTo(w,h);
	window.moveTo((screen.availWidth-w)/2, (screen.availHeight-h)/2);
}

function newPopUp(url)
{
	desktop = window.open(url, title, "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=600,height=500,resizable=yes");
	
}

function checkReciever(email1, email2)
{
	var NO_RECIEVER="Keinen Empfänger angegeben";
	var NO_SENDER="Keinen Absender angegeben";
	if(!checkEmail(email1,NO_RECIEVER)) return false;
	if(!checkEmail(email2,NO_SENDER)) return false;
	return true;
}
