function pickup_calendar(Language_ID) {		
	w=230;
	h=180;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    settings ='height='+h+',width='+w+',top='+TopPosition+', left='+LeftPosition+',scrollbars=no,toolbar=no,status=,resizable=no'
	day = document.forms[0].drpPickup_Day.value;
	month = document.forms[0].drpPickup_Month.value;
	nday = 'document.forms[0].drpPickup_Day'
	nmonth = 'document.forms[0].drpPickup_Month'
	calendar_Window=window.open('kalendar.aspx?formname='+nday+'&formname2='+nmonth+'&day='+day+'&month='+month+'&Language_ID='+				Language_ID,'calendar_Window',settings);
	calendar_Window.focus();
	}
	
function return_calendar(Language_ID) {
	w=230;
	h=180;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    settings ='height='+h+',width='+w+',top='+TopPosition+', left='+LeftPosition+',scrollbars=no,toolbar=no,status=,resizable=no'
	day = document.forms[0].drpDropoff_Day.value;
	month = document.forms[0].drpDropoff_Month.value;
	nday = 'document.forms[0].drpDropoff_Day'
	nmonth = 'document.forms[0].drpDropoff_Month'
	calendar_Window=window.open('kalendar.aspx?formname='+nday+'&formname2='+nmonth+'&day='+day+'&month='+month+'&Language_ID='+Language_ID,'calendar_Window',settings);
	calendar_Window.focus();
	}




function changeTime () {
	for(i=0;i<document.getElementById('drpPickup_Time').length;++i)
	if(document.getElementById('drpPickup_Time').options[i].selected == true)
	document.getElementById('drpDropoff_Time').options[i].selected = true;
}

function changeDropoffCity() {
	for(i=0;i<document.getElementById('drpPickup_City').length;++i)
	if(document.getElementById('drpPickup_City').options[i].selected == true)
	document.getElementById('drpDropoff_City').options[i].selected = true;
}

function changeDropoffAirport() {
	for(i=0;i<document.getElementById('drpPickup_Airport').length;++i)
	if(document.getElementById('drpPickup_Airport').options[i].selected == true)
	document.getElementById('drpDropoff_Airport').options[i].selected = true;
}
function ChangePickup(id,c_dropoff_also) {

    //alert(id);

    var PCITY = document.getElementById('rowPickup_City');
    var DCITY = document.getElementById('rowDropOff_City');
    var PAIR = document.getElementById('rowPickUpAirport');
    var DAIR = document.getElementById('rowDropoffAirport');
    var radDropAir = document.getElementById('radDropOffType_0');
    var radDropCity = document.getElementById('radDropOffType_1');
    
    //alert(radDropAir);
    
    if(c_dropoff_also == true) {
        if(id == 1) { //city
            PCITY.style.display = "";
            DCITY.style.display = "";
            PAIR.style.display = "none";
            DAIR.style.display = "none";
            radDropAir.checked = false;
            radDropCity.checked = true;
        }
        if(id == 2) { //airport
            PCITY.style.display = "none";
            DCITY.style.display = "none";
            PAIR.style.display = "";
            DAIR.style.display = "";    
            radDropAir.checked = true;
            radDropCity.checked = false;            
        }    
    }
    if(c_dropoff_also == false) {
        if(id == 1) { //city
            DCITY.style.display = "";
            DAIR.style.display = "none";
        }
        if(id == 2) { //airport
            DCITY.style.display = "none";
            DAIR.style.display = "";    
        }    
    }
}

function change_dropoff_date(id,value) {
    //alert(value);
    if(value.length != 10) {
        alert("Falsches Datumsformat. dd.mm.jjjj");
        return false;
    }
    var Day = value.substr(0,2);
    var Month = value.substr(3,2);
    var Year = value.substr(6,4);
    
    var myDate = new Date();
    myLastYear = (eval(myDate.getFullYear()) + 2);
    
    if(Day < 1 || Day > 31) {
        alert("Falsches Datum!");
        return false;
    }
    if(Month < 1 || Month > 12) {
        alert("Falsches Datum!");
        return false; 
    }
    if(Year < myDate.getFullYear() || Year > myLastYear) {
        alert("Falsches Datum!");
        return false;
    }
    
    var PickUp = new Date();
    var DropOff = new Date();
    var DDay,DMonth,DYear;
    var PLimit = new Date();
    var DropField = document.getElementById('txtDropOffDate');

    PickUp.setTime(Date.parse(Month + '/' + Day + '/' + Year));
    DropOff = PickUp;

    DropOff.setDate(DropOff.getDate() + 7);
    DDay = DropOff.getDate();
    if(DDay < 10) { DDay = '0' + DDay }
    DMonth = DropOff.getMonth() + 1;
    if(DMonth < 10) { DMonth = '0' + DMonth }
    DYear = DropOff.getFullYear();

    DropField.value = DDay + '.' + DMonth + '.' + DYear;

}




function changeDate () {
	
	datum_jetzt = new Date();
	vorbuchfrist = new Date();
	abholdatum = new Date();
	abgabedatum = new Date();
	testDate = new Date();
	

	// Vorbuchfrist wird definiert
    vorbuchfrist = datum_jetzt.setDate(datum_jetzt.getDate()); 
	// alert (vorbuchfrist);
	
	// aktuell ausgewähltes Anmietdatum wird ausgelesen
    abholdatum_tag = document.forms[0].drpPickup_Day.value;
	abholdatum_monat = document.forms[0].drpPickup_Month.value.substring(0,2);
	abholdatum_jahr = document.forms[0].drpPickup_Month.value.substring(3,7);
	abholdatum.setTime(Date.parse(abholdatum_monat + '/' + abholdatum_tag + '/' + abholdatum_jahr));
	// alert (abholdatum);
	
	if (vorbuchfrist > abholdatum)  // überprüft ob die Vorbuchfrist eingehalten ist
	    {
		bookingTime ();
		anmietung_tag = testDate.getDate();
		document.forms[0].drpPickup_Day.options[anmietung_tag].selected = true
		}
	else // Abgabedatum wird ausgewählt
		{
		abgabedatum = abholdatum;
		abgabedatum.setDate(abgabedatum.getDate() +7); 
		//alert (abgabedatum)
		abgabedatum_tag = abgabedatum.getDate();
		abgabedatum_monat = abgabedatum.getMonth() + 1;
		if (abgabedatum_monat < 10) abgabedatum_monat = '0' + abgabedatum_monat
		abgabedatum_jahr = abgabedatum.getFullYear();
		document.forms[0].drpDropoff_Day.options[abgabedatum_tag].selected = true
		// alert(abgabedatum_monat + '.' + abgabedatum_jahr)
		
		for(i=0;i<document.forms[0].drpDropoff_Month.length;++i)
		if(document.forms[0].drpDropoff_Month.options[i].value == abgabedatum_monat + '.' + abgabedatum_jahr)
		document.forms[0].drpDropoff_Month.options[i].selected = true;
		}
}

function changeDate2 () {
	
	datum_jetzt = new Date();
	vorbuchfrist = new Date();
	abholdatum = new Date();
	abgabedatum = new Date();
	testDate = new Date();
	

	// Vorbuchfrist wird definiert
    vorbuchfrist = datum_jetzt.setDate(datum_jetzt.getDate()); 
	// alert (vorbuchfrist);
	
	// aktuell ausgewähltes Anmietdatum wird ausgelesen
    abholdatum_tag = document.forms[0].drpPickup_Day.value;
	abholdatum_monat = document.forms[0].drpPickup_Month.value.substring(0,2);
	abholdatum_jahr = document.forms[0].drpPickup_Month.value.substring(3,7);
	abholdatum.setTime(Date.parse(abholdatum_monat + '/' + abholdatum_tag + '/' + abholdatum_jahr));
	// alert (abholdatum);
	
		abgabedatum = abholdatum;
		abgabedatum.setDate(abgabedatum.getDate() +7); 
		//alert (abgabedatum)
		abgabedatum_tag = abgabedatum.getDate();
		abgabedatum_monat = abgabedatum.getMonth() + 1;
		if (abgabedatum_monat < 10) abgabedatum_monat = '0' + abgabedatum_monat
		abgabedatum_jahr = abgabedatum.getFullYear();
		document.forms[0].drpDropoff_Day.options[abgabedatum_tag - 1].selected = true
		// alert(abgabedatum_monat + '.' + abgabedatum_jahr)
		
		for(i=0;i<document.forms[0].drpDropoff_Month.length;++i)
		if(document.forms[0].drpDropoff_Month.options[i].value == abgabedatum_monat + '.' + abgabedatum_jahr)
		document.forms[0].drpDropoff_Month.options[i].selected = true;
}

function changeTime () {
	for(i=0;i<document.forms[0].drpPickup_Time.length;++i)
	if(document.forms[0].drpPickup_Time.options[i].selected == true)
	document.forms[0].drpDropoff_Time.options[i].selected = true;
}