function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

var popLA = null;

function SubmitFormLA ()
{
	if (popLA)
	{
		document.formLA.submit();
		popLA.focus();
		return (true);
	}
	else	{ return (false); };
}

function winLA_open (urlLA)
{
	window.name = 'parentLA';
	if (!urlLA) { urlLA = 'about:blank'; };
	popLA = window.open(urlLA, 'winLA', 'top=40,left=20,screenY=40,screenX=20,location=no,menubar=no,scrollbar=no,toolbar=no,status=no,resize=no,width=600,height=240');
	popLA.focus();
}

function winLA_close()
{
	var popup = parent.window.open('about:blank', 'winLA', 'top=0,left=0,screenY=0,screenX=0,location=no,menubar=no,scrollbar=no,toolbar=no,status=no,resize=no,width=1,height=1');
	popup.close();
}

function popup(mylink, windowname)
{
	var breite=500;
	var hoehe=600;
	var	x=20;
	var y=60;
	var href;

	if (!window.focus) return true;

	if (typeof(mylink) == 'string') href = mylink;
	else														href = mylink.href;

	fenster_empf = window.open(href, windowname, 'top=' + y + ',left=' + x + ',screenY=' + y + ',screenX=' + x + ',location=no,menubar=no,scrollbar=no,toolbar=no,status=no,resize=no,width=' + breite + ',height=' + hoehe);

	return false;
}

						function homepageSearchSetText()
						{
							if (getCookie('mhRecognitionUsertype') != 1)
							{
								if (homepageSearchInputfield.value == '')
								{
									homepageSearchInputfield.value = searchTextDefault;
									homepageSearchInputfield.className = 'homepageSearchInputfieldBlur';
								}
							}
						}

						function homepageSearchUnsetText()
						{
							if (getCookie('mhRecognitionUsertype') != 1)
							{
								if (homepageSearchInputfield.value == searchTextDefault)
								{
									homepageSearchInputfield.value = '';
									homepageSearchInputfield.className = 'homepageSearchInputfieldNormal';
								}
							}
						}

						function clearDefaultText()
						{
							if (homepageSearchInputfield.value == searchTextDefault)
							{
								homepageSearchInputfield.value = '';
								homepageSearchInputfield.className = 'homepageSearchInputfieldNormal';
							}
						}

	function EMail(s)
	{
  	var res = false;
    res = (s.search('@') >= 1 &&
           s.lastIndexOf('.') > s.search('@') &&
           s.lastIndexOf('.') >= s.length-5)
  	return(res);
	}

	function alertError (e_no)
	{
		errorPopup=window.open('about:blank', 'Fehler', 'top=100,left=400,screenY=100,screenX=400,width=430,height=250,resizable=no,location=no,scrollbars=no');

		var e_txt = '<html><head><title>Fehlermeldung</title><link rel="stylesheet" href="';
		e_txt = e_txt + docs_rel + '/images/default-rt.css" type="text/css"></head><body bgcolor="#F0F6F8"><p>&nbsp;</p><table align="center" border="0" width="90%"><tr><td valign="top"><p style="color: red;"><b>';

		if (e_no == 8)
		{
			if (document.formA.email.value != '') e_txt = e_txt + '&lt;' + document.formA.email.value + '&gt; ist keine g&uuml;ltige E-Mail-Adresse!</b></p><p><b>';
			e_txt = e_txt + 'Bitte geben Sie eine g&uuml;ltige E-Mail-Adresse ein!';
		}
		else if (e_no == 9) e_txt = e_txt + 'Bitte w&auml;hlen Sie eine passende Kategorie!';
		else if (e_no == 10) e_txt = e_txt + 'Bitte geben Sie einen aussagekr&auml;ftigen Auftragsnamen an!';
		else if (e_no == 11) e_txt = e_txt + 'Bitte w&auml;hlen Sie eine passende Kategorie und einen aussagekr&auml;ftigen Auftragsnamen!';

		e_txt = e_txt + '</b></p></td></tr></table><p>&nbsp;</p></body></html>';

		errorPopup.document.writeln(e_txt);
		errorPopup.focus();
		errorPopup.setTimeout("stop()", 2500);
	}

	function CheckFormA ()
	{
		 var res = EMail(document.formA.email.value);
		 if (res == false) { alertError (8); };
		 return (res);
	};

	function SubmitFormA ()
	{
		var res = CheckFormA ();
		if (res == true) { document.formA.submit(); };
		return (res);
	};

	function CheckFormB ()
	{
		var res1 = (document.formB.elements["prefillStep1[title]"].value.length < 5) ? false : true;
		var res2 = (document.formB.elements["prefillStep1[category1]"].value < 0) ? false : true;
		if (res1 == false && res2 == false) { alertError (11); }
		else if (res1 == false) { alertError (10); }
		else if (res2 == false) { alertError (9); };
		return(res1 && res2);
	};

	function SubmitFormB ()
	{
		 var res = CheckFormB ();
		 if (res == true) { document.formB.submit(); };
		 return (res);
	};