///////////////////////////////////////////////////////////////////////////////////////////
function initSite(){
	with(new bookingFormular()){
		
		//alert(station);
		
		document.getElementsByName("station")[parseInt(station)-1].checked = true;
		document.getElementsByName("fromDate")[0].value	 = fromDate;
		document.getElementsByName("toDate")[0].value	 = toDate;
	} // end with
} // end function initSite
///////////////////////////////////////////////////////////////////////////////////////////
function showStationInfo(EVENT, StationId, Element){

	showElement(document.getElementById(Element));
	stations.prototype.currentStation = StationId;
	stations.prototype.element = Element;
	
	with(getMousePos(EVENT)){
			document.getElementById(Element).style.left = x+3  + "px";
    		document.getElementById(Element).style.top  = y+10 + "px";
	} // end with
	
	if(typeof(new stations().station[StationId]) == "object"){
		return(setStationInfo());
	} // end if
	else{
		new asynPostRequest("mwuebersicht/request/station.info.php", {station:StationId}, getStationInfo);			
	} // end else
	
	return(true);
	
} // end function showStationInfo
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function hideStationInfo(ELEMENT_ID){
	hideElement(document.getElementById(ELEMENT_ID));
} // end function hideInfo
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getStationInfo(JSON){
	
	with(eval(JSON)){
		stations.prototype.station[id] = eval(JSON);
	} // end with
	
	return(setStationInfo());
	
} // end function
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function setStationInfo(){

	var innerHTML = "";
	
	with(new stations().station[new stations().currentStation]){
		
		if(stations.prototype.element == "stationInfo"){
		
			innerHTML+= '<table>';
		
			innerHTML+= 	'<tr>';
			innerHTML+= 		'<td>';
			innerHTML+= 		 	'<b>Unser Partner vor Ort</b>';
			innerHTML+= 		'</td>';
			innerHTML+= 	'</tr>';
		
			innerHTML+= 	'<tr>';
			innerHTML+= 		'<td>';
			innerHTML+= 		 	company;
			innerHTML+= 		'</td>';
			innerHTML+= 	'</tr>';
		
			innerHTML+= 	'<tr>';
			innerHTML+= 		'<td>';
			innerHTML+= 		 	 street + " " + streetNumber + " " + city;
			innerHTML+= 		'</td>';
			innerHTML+= 	'</tr>';
		
			innerHTML+= 	'<tr>';
			innerHTML+= 		'<td>';
			innerHTML+= 		 	phone;
			innerHTML+= 		'</td>';
			innerHTML+= 	'</tr>';
		
			innerHTML+= '</table>';
		}
		
		if(stations.prototype.element == "taxiInfo"){
			var innerHTML = '';
			innerHTML+= 'Kostenloser Taxitransfer zwischen ';
			innerHTML+= 'Mietwagenstation Flughafen und  Mietwagenstation Westerland.<br />'; 
			innerHTML+= 'Einfach Taxi-Ruf unter <b>04651/5050</b> oder <b>5555</b> <br/> oder spontaner ';
			innerHTML+= 'Einstieg in ein mit <b>5050</b> oder <b>5555</b> beklebtes Taxi mit Ziel:<br /> ';
			innerHTML+=  label + '<br />' + street + " " + streetNumber + " " + city;
		} // end if
		
	} // end with	

	
	return(document.getElementById(stations.prototype.element).innerHTML = innerHTML);

} // end function setStationInfo
///////////////////////////////////////////////////////////////////////////////////////////
function setCallendarSettings(CALLBACK){
	
	// Kalender anpassen	
	calendar.prototype.getOnClickStart = function(){
		with(new Date()){
			return(Date.UTC(getFullYear(), getMonth(), getDate()));
		} // end with
	} // end public function onclickStart

	calendar.prototype.getOnClickEnd = function(){
	with(new Date()){
		return(Date.UTC(getFullYear()+1, 11, 31));
		}// end with	
	} // end public function onclickEnd	
		
	// Rckgabe an Ausleihe anpassen
	// Maximale Ausleihe sind 365 Tage, aber nur bis zum 31.12 des nchsten Jahres
	if(CALLBACK == "setToDate"){
		
		calendar.prototype.getOnClickStart = function(){
			with(new bookingFormular()){
				var date = fromDate.split(".");
				return(Date.UTC(date[2], parseInt(date[1])-1, date[0]));
			} // end with
		} // end public function onclickStart
		
		calendar.prototype.getOnClickEnd = function(){
			with(new bookingFormular()){
				var date = fromDate.split(".");
				return(Math.min
					   			(
									Date.UTC(new Date().getFullYear()+1, 11, 31),
									Date.UTC(date[2], parseInt(date[1])-1, parseInt(date[0])+365)
								)
				);
			} // end with
		} // end public function onclickStart	
	} // end if
	
	return(true);
	
} // end function
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function openCalendar(EVENT, CALLBACK, DATE){
	
	// Anzeige justieren 
	var xShift = new Array();
		xShift["setFromDate"]  	=	-200;
		xShift["setToDate"] 	=	-200;
	
	var yShift = new Array();
		yShift["setFromDate"]	=	0;
		yShift["setToDate"] 	=	0;
	
	if(setCallendarSettings(CALLBACK)){
		with(getMousePos(EVENT)){
			// KalenderDiv positionieren
			document.getElementById("calendar").style.left = x + xShift[CALLBACK] + "px";
    		document.getElementById("calendar").style.top  = y + yShift[CALLBACK] + "px";
			// Jahr und Monat fr Kalender ermitteln
			var year  = (DATE.split(".").length == 3) ? DATE.split(".")[2]   : new Date().getFullYear();
			var month = (DATE.split(".").length == 3) ? DATE.split(".")[1]-1 : new Date().getMonth();
			//Kalender aufrufen	
			new calendar(year, month, CALLBACK);
		} // end with getMousePos(EVENT)
	} // end if
} // end function openCalendar
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function setFromDate(DATE){
	
	var fromElement = document.getElementsByName("fromDate")[0];
	var toElement 	= document.getElementsByName("toDate")[0];

	with(DATE){	
		
		bookingFormular.prototype.fromDate 	= new Array(getDate(), getMonth()+1, getFullYear()).join(".");
		bookingFormular.prototype.fromStamp = Date.UTC(getFullYear(), getMonth(), getDate())/1000;
		
		fromElement.value 	= new bookingFormular().fromDate;
		
		with(new bookingFormular()){
			if(fromStamp >= toStamp){
				bookingFormular.prototype.toDate 	= new Array(getDate(), getMonth()+1, getFullYear()).join(".");
				bookingFormular.prototype.toStamp 	= Date.UTC(getFullYear(), getMonth(), getDate())/1000;
				toElement.value 					= fromDate;
			} // end if
		} // end if
	} // end with
	
	document.getElementById("calendar").innerHTML = "";
	
} // end function setFromDate
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function setToDate(DATE){

	var toElement = document.getElementsByName("toDate")[0];
	
	with(DATE){	
		bookingFormular.prototype.toDate 	= new Array(getDate(), getMonth()+1, getFullYear()).join(".");
		bookingFormular.prototype.toStamp 	= Date.UTC(getFullYear(), getMonth(), getDate())/1000;
		toElement.value = new Array(getDate(), getMonth()+1, getFullYear()).join(".");	
	} // end with
	
	document.getElementById("calendar").innerHTML = "";
	
} // end function setToDate
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function popup(url){
	fenster = window.open(url, "", "width=400,height=250,resizable=yes");
	fenster.focus();
 	return false;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
