    function changePicture(number){
        var picture = document.getElementById('FrameImage');
       
            picture.className = "image" + number;
    }

function hdr_ref(object)
{
	if (document.getElementById)
	{
		return document.getElementById(object);
	}
	else if (document.all)
	{
		return eval('document.all.' + object);
	}
	else
	{
		return false;
	}
}

function createXMLHttpRequest()
 {

   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}

   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}

   try { return new XMLHttpRequest(); } catch(e) {}
   alert("XMLHttpRequest not supported");
   return null;
 }
 
function dayClick(day, month, year)
{
 var xhReq = createXMLHttpRequest();
 xhReq.open("GET", "services.php?year="+year+"&month="+month+"&day="+day+"&time="+Math.random(), false);
 xhReq.send(null);
  		var serverResponse = xhReq.responseText;
		 document.getElementById("tag"+day).className = serverResponse;
		 document.getElementById("tag"+day).textContent = day;

 return null;
}

function fieldFocus(field,standart)
{
		if(field.value == standart) field.value = "";
}
 
 var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

function checkDate(name)
{
	var x = document.forms[0].elements;
	var day = parseInt(x[name+"_day"].options[x[name+"_day"].selectedIndex].value);
	var month = parseInt(x[name+"_month"].options[x[name+"_month"].selectedIndex].value);
	var year = parseInt(x[name+"_year"].options[x[name+"_year"].selectedIndex].value);

	if (!day || !month || !year)
		return false;

	if (year/4 == parseInt(year/4))
		monthLength[1] = 29;

	if (day > monthLength[month-1])
		return false;

	monthLength[1] = 28;
}
 
function futureCheck(day, month, year)
{
	var now = new Date();
	now = now.getTime(); //NN3

	var dateToCheck = new Date();
	dateToCheck.setYear(year);
	dateToCheck.setMonth(month-1);
	dateToCheck.setDate(day);
	var checkDate = dateToCheck.getTime();

	if(now <= checkDate)
		return true;
	if(now > checkDate)
		return false;
}
 
function check()
{
var arrival = arrivalCheck();
var departure = departureCheck();
if(arrival && departure)
	callCalendar();

} 
 
function callCalendar()
{
	document.getElementById("QueryResults").style.display = 'inline';
	document.getElementById("QueryResults").innerHTML = '<img src="images/spinner.gif"> Abfrage l&auml;uft...<br>';


	var arDay = document.checkForm.arDay.value;
	var arMonth = document.checkForm.arMonth.value;
	var arYear = document.checkForm.arYear.value;
	
	var deDay = document.checkForm.deDay.value;
	var deMonth = document.checkForm.deMonth.value;
	var deYear = document.checkForm.deYear.value;
	
 var xhReq = createXMLHttpRequest();
 xhReq.open("GET", "services.php?arDay="+arDay+"&arMonth="+arMonth+"&arYear="+arYear+"&deDay="+deDay+"&deMonth="+deMonth+"&deYear="+deYear+"&time="+Math.random(), true);
 xhReq.onreadystatechange = onCallResponse;
 xhReq.send(null);
  		
		function onCallResponse()
	{
		if (xhReq.readyState != 4)  { return; }
			var serverResponse = xhReq.responseText;
			 document.getElementById("QueryResults").style.display = 'inline';
			 document.getElementById("QueryResults").innerHTML = serverResponse;
	}
		 

 return null;
}


 
function arrivalCheck()
{
	var result = true;

	var day = document.checkForm.arDay.value;
	var month = document.checkForm.arMonth.value;
	var year = document.checkForm.arYear.value;
	
		//schaltjahr
	if (year/4 == parseInt(year/4))
		monthLength[1] = 29;
	
	//check month
	if(!month || month > 12 || month < 1)
	{
		document.checkForm.arMonth.className = "error";
		result = false;
	}
	else
		document.checkForm.arMonth.className = "";
		
	//check day
	if(!day || day > monthLength[month-1] || day < 1)
	{
		document.checkForm.arDay.className = "error";
		result = false;
	}
	else
		document.checkForm.arDay.className = "";
	
	//check month
	if(!year || year > 2020 || year < 2005)
	{
		document.checkForm.arYear.className = "error";
		result = false;
	}
	else
		document.checkForm.arYear.className = ""
		
		//Future Check
	if(!futureCheck(day, month, year))
		{
		document.checkForm.arDay.className = "error";
		document.checkForm.arMonth.className = "error";
		document.checkForm.arYear.className = "error";
		result = false;
		}
		
return result;		
}

function departureCheck()
{
	var day = document.checkForm.deDay.value;
	var month = document.checkForm.deMonth.value;
	var year = document.checkForm.deYear.value;

	var result = true;
	
		//schaltjahr
	if (year/4 == parseInt(year/4))
		monthLength[1] = 29;
	
	//check month
	if(!month || month > 12 || month < 1)
	{
		document.checkForm.deMonth.className = "error";
		result = false;
	}
	else
		document.checkForm.deMonth.className = "";
		
	//check day
	if(!day || day > monthLength[month-1] || day < 1)
	{
		document.checkForm.deDay.className = "error";
		result = false;
	}
	else
		document.checkForm.deDay.className = "";
	
	//check month
	if(!year || year > 2020 || year < 2005)
	{
		document.checkForm.deYear.className = "error";
		result = false;
	}
	else
		document.checkForm.deYear.className = ""
		
		//Future Check
	if(!futureCheck(day, month, year))
		{
		document.checkForm.deDay.className = "error";
		document.checkForm.deMonth.className = "error";
		document.checkForm.deYear.className = "error";
		result = false;
		}
		
return result;		
}