function limitMonth(dropDownList) {               
        var scheduleEndMonth = 10;              // Wert �ndern, wenn neuer Flugplan kommt 
        var scheduleEndYear = 2006;     // Wert �ndern, wenn neuer Flugplan kommt 
        
        var currentDate = new Date(); 
        var currentMonth = currentDate.getMonth(); 
        var currentYear = 1900 + (currentDate.getYear()); 
        
        if (currentYear < scheduleEndYear) { 
                scheduleEndMonth = scheduleEndMonth+(12*(scheduleEndYear - currentYear)); 
        } 
        
        limit = scheduleEndMonth - currentMonth;                        
        
        if (dropDownList) { 
                if (limit < dropDownList.options.length) { 
                        numDeleteItems = dropDownList.options.length - limit; 
                        for (i=0; i < numDeleteItems; i++) { 
                                dropDownList.remove(dropDownList.options.length-1); 
                        } 
                } 
        } 
}

function limitDateRange(selectorId, endMonYear){
	var selectorElem = document.getElementById(selectorId);
	for(var i = 0; i < selectorElem.options.length; i++){
		if(selectorElem.options[i].value > endMonYear){
			break;
		}
	}
	if (selectorElem.options.length != i){
		selectorElem.options.length = i;
	}
}

function changeReturnDate(elementId) {
       var prefix="";
       if(elementId=="ControlGroupSearchView_AvailabilitySearchInputSearchView_DropDownListMarketMonth1" || elementId=="ControlGroupSearchView_AvailabilitySearchInputSearchView_DropDownListMarketDay1") {
	       prefix="ControlGroupSearchView_";
       } else if(elementId=="AvailabilitySearchInputSearchView_DropDownListMarketMonth1" || elementId=="AvailabilitySearchInputSearchView_DropDownListMarketDay1") {
           prefix="";
       } else return;
	   captureDates(prefix); 
	   if ( rDay != 0 ) { 
           if ( ( rMonth < oMonth && rYear == oYear ) || rYear < oYear ) { 
               document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketMonth2").options.selectedIndex = document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketMonth1").options.selectedIndex;
			   document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketDay2").options.selectedIndex = document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketDay1").options.selectedIndex;
           } else if ( rDay < oDay && rMonth == oMonth && rYear == oYear ) { 
               document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketDay2").options.selectedIndex = document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketDay1").options.selectedIndex;
           }
       } 
}

function captureDates(prefix) {
 oDay    = document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketDay1").options[document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketDay1").selectedIndex].value;
 oMonth  = document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketMonth1").options[document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketMonth1").selectedIndex].value.substring(5,7);
 oYear   = document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketMonth1").options[document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketMonth1").selectedIndex].value.substring(0,4);
 rDay    = document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketDay2").options[document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketDay2").selectedIndex].value;
 rMonth  = document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketMonth2").options[document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketMonth2").selectedIndex].value.substring(5,7);
 rYear   = document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketMonth2").options[document.getElementById(prefix+"AvailabilitySearchInputSearchView_DropDownListMarketMonth2").selectedIndex].value.substring(0,4);
} 

function changeReturnDateCompact(elementId) {	  
       if(elementId=="AvailabilityCompactSearchInputViewType_DropDownListMarketMonth1" || elementId=="AvailabilityCompactSearchInputViewType_DropDownListMarketDay1") { 
               captureDatesCompact(); 
               if ( rDay != 0 ) { 
                       if ( ( rMonth < oMonth && rYear == oYear ) || rYear < oYear ) { 
                               document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketMonth2").options.selectedIndex = document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketMonth1").options.selectedIndex;
               document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketDay2").options.selectedIndex = document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketDay1").options.selectedIndex;
                       } 
                       else if ( rDay < oDay && rMonth == oMonth && rYear == oYear ) { 
                               document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketDay2").options.selectedIndex = document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketDay1").options.selectedIndex;
                       }
               } 
        } 
}

function captureDatesCompact() {
 oDay    = document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketDay1").options[document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketDay1").selectedIndex].value;
 oMonth  = document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketMonth1").options[document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketMonth1").selectedIndex].value.substring(5,7);
 oYear   = document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketMonth1").options[document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketMonth1").selectedIndex].value.substring(0,4);
 rDay    = document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketDay2").options[document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketDay2").selectedIndex].value;
 rMonth  = document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketMonth2").options[document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketMonth2").selectedIndex].value.substring(5,7);
 rYear   = document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketMonth2").options[document.getElementById("AvailabilityCompactSearchInputViewType_DropDownListMarketMonth2").selectedIndex].value.substring(0,4);
} 

