var xmlHttp

function showResult(str)
{


xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

var url="livesearch.php"
url=url+"?q="+str
url=url+"&menu=6"
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 document.getElementById("livesearch").
 innerHTML=xmlHttp.responseText;

 }
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function MM_openBrWindow(theURL,winName,features)
 {
  window.open(theURL,winName,features);
}

var day, month, year, day_week, flag = true;
function test_input_data(day, month, year) {

	switch(day) {
		case 29 : // tests for leap years
		  if(month == 2) { // only applies to February
		    if(((year / 4) - Math.floor(year / 4)) == 0) { // year divisible by 4
		      if(((year / 100) - Math.floor(year / 100)) == 0) { // year div by 100
			if(((year / 400) - Math.floor(year / 400)) == 0) { // year div by 400
			  break;
			} // year div by 400 so is a leap year
			else {
			  alert('Es ist ein Schaltjahr! Deshalb 29 Tage!');
			  flag = false;
			  return flag;
			} // year div by 4 and 100 but not 400 so can't be a leap year
		       }
		       else { // year div by 4 but not by 100 so is a leap year
			 break;
		       }
		    }
		    else { // year not div by 4 so can't be a leap year
		      alert('Es ist kein Schaltjahr! Deshalb 28 Tage!');
		      flag = false;
		      return flag;
		    }
		  }
		  else { // not February
	 	    break;
		  }

		case 30 :
		  if(month == 2) {
		    days_in_a_month();
		    flag = false;
		    return flag;
		  }
		  else {
		    break;
		  }

		case 31 :
		  if((month == 2)||(month == 4)||(month == 6)||(month == 9)||(month == 11)) {
		    days_in_a_month();
		    flag = false;
		    return flag;
		  }
		   else {
		    break;
		  }
	}
}

function days_in_a_month() {
	var m1 = "April, June, September, and November have 30 days.\n";
	var m2 = "All the rest have 31, except February, which has\n";
	var m3 = "28 days (29 in each leap year)";

	alert(m1 + m2 + m3);
	return;
}

function day_of_the_week(day, month, year) {
	var m, y, c, dd; 	// parameters used in the calculations

	var month_array = new Array(1, 4, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5);
	m = month_array[month-1];

	if((month == 1)||(month == 2)) {
		year = year - 1;
	}

	y = (5 * (Math.floor((year % 100) / 4)) + year % 4)%7;
	c = (5 * ((Math.floor(year / 100)) % 4))%7;
	dd = (m + day + c + y)%7;

	var day_array = new Array("Samstag", "Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag");
	day_week = day_array[dd];

	return day_week;
}

function day_of_week(year, month, day, day_name) {
	year = year*1;
	month = month*1;
	day = day*1;

	test_input_data(day, month, year);
	if(flag == false) {
	  flag = true;
	  return;
	}
	else {
		day_of_the_week(day, month, year);
	}

	document.form[day_name].value = day_week;

}

function Pruefen()
{
	if (document.form.von.value=="")
	 {
		alert('Bitte die Beginnzeit eingeben!');
	 	document.form.von.focus();
     	return false;
    }
   	if(document.form.von.value.indexOf(':') == -1)
    	{
     		alert("Keine gültige Uhrzeit!");
 			document.form.von.focus();
     		return false;
    	}
		if (document.form.ortszusatz.value=="")
	 	{
			alert('Bitte den Ortszusatz eingeben!');
	 		document.form.ortszusatz.focus();
     		return false;
    	}
		if (document.form.ort.value=="")
		{
			alert('Bitte den Ort eingeben!');
	 		document.form.ort.focus();
     		return false;
    	}
}

function Pruefen1()
{
	if (document.form.veranstaltung.value=="")
	 {
		alert('Bitte geben Sie den Veranstaltungsnamen ein!');
	 	document.form.veranstaltung.focus();
     	return false;
    }
	if (document.form.von.value=="")
	 {
		alert('Bitte die Beginnzeit eingeben!');
	 	document.form.von.focus();
     	return false;
    }
   	if(document.form.von.value.indexOf(':') == -1)
    	{
     		alert("Keine gültige Uhrzeit!");
 			document.form.von.focus();
     		return false;
    	}
		if (document.form.ortszusatz.value=="")
	 	{
			alert('Bitte den Ortszusatz eingeben!');
	 		document.form.ortszusatz.focus();
     		return false;
    	}
		if (document.form.ort.value=="")
		{
			alert('Bitte den Ort eingeben!');
	 		document.form.ort.focus();
     		return false;
    	}
}

function ortsel()
{
	document.forms["form"].elements["action"].value = "ortsel";
	document.form.submit();
}

function cntrysel()
{
	document.forms["form"].elements["action"].value = "cntrysel";
	document.form.submit();
}

function email()
{
	document.forms["form"].elements["action"].value = "cntrysel";
	document.form.submit();
}



function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}


