var m_iCurrentMonth = 0
var m_iCurrentYear = 0
m_iCurrentYear = (m_iCurrentYear+1900);


function getFullYear(date) {
  var y = date.getYear();
  if(y<1000) y+=1900;
  return y;
}
 
var dateset = false;
 
function setDropoffDate() {
 
    //alert("Inside setDropoffDate function...");
    
    var selectedMonthYear = document.forms['RES_FORM'].PICKUP_MONTH;
    var selectedDay = document.forms['RES_FORM'].PICKUP_DAY;
    var setMonthYear = document.forms['RES_FORM'].RETURN_MONTH;
    var setDay = document.forms['RES_FORM'].RETURN_DAY;
    
    var puMonth = selectedMonthYear.options[selectedMonthYear.selectedIndex].value;
    var puYear;
    if(puMonth >= m_iCurrentMonth)
     puYear = m_iCurrentYear;
    else
     puYear = m_iCurrentYear + 1;
    
    var puDay = selectedDay.options[selectedDay.selectedIndex].value;
    
    var puDate = new Date(puYear,(parseInt(puMonth,10)), parseInt(puDay,10));
    var doDate = new Date(puYear,(parseInt(puMonth,10)), (parseInt(puDay,10) + 1));
    
    for(var i = 0; i < selectedMonthYear.options.length; i++) {
            var month = selectedMonthYear.options[i].value
            var year;
     if(month > m_iCurrentMonth)
  year = m_iCurrentYear;
     else
  year = m_iCurrentYear + 1;
            if((parseInt(month,10) == puDate.getMonth()) &&  (parseInt(year,10) == getFullYear(puDate))) {
                //selectedMonthYear.options[i].selected = 1;
            }
    }   
 
    for(var i=0;i<selectedDay.options.length;i++) {
        var day = selectedDay.options[i].value;
        if(parseInt(day,10) == puDate.getDate()) {
            //selectedDay.options[i].selected=1;
        }
    }   
 
    if(dateset==false) {
        for(i=0;i<setMonthYear.options.length;i++) {
            var month = setMonthYear.options[i].value;
            var year;
            if(month >= m_iCurrentMonth)
  year = m_iCurrentYear;
     else
  year = m_iCurrentYear + 1;
            if((parseInt(month,10) == doDate.getMonth())) {
                //setMonthYear.options[i].selected=1;
            }
        }   
 
        for(i=0;i<setDay.options.length;i++) {
            var day = setDay.options[i].value;
            if(parseInt(day,10) == doDate.getDate()) {
                //setDay.options[i].selected=1;
            }
        }
    }
}
 
// Stop hiding from old browsers -->
 
function setRapidDropoffDate() {
 
    //alert("Inside setRapidDropoffDate function...");
    
    var selectedMonthYear = document.forms['REQUEST_A_RATE'].PICKUP_MONTH;
    var selectedDay = document.forms['REQUEST_A_RATE'].PICKUP_DAY;
    var setMonthYear = document.forms['REQUEST_A_RATE'].RETURN_MONTH;
    var setDay = document.forms['REQUEST_A_RATE'].RETURN_DAY;
    
    var puMonth = selectedMonthYear.options[selectedMonthYear.selectedIndex].value;
    var puYear;
    if(puMonth >= m_iCurrentMonth)
     puYear = m_iCurrentYear;
    else
     puYear = m_iCurrentYear + 1;
    
    var puDay = selectedDay.options[selectedDay.selectedIndex].value;
    
    var puDate = new Date(puYear,(parseInt(puMonth,10)), parseInt(puDay,10));
    var doDate = new Date(puYear,(parseInt(puMonth,10)), (parseInt(puDay,10) + 1));
    
    for(var i = 0; i < selectedMonthYear.options.length; i++) {
            var month = selectedMonthYear.options[i].value
            var year;
     if(month > m_iCurrentMonth)
  year = m_iCurrentYear;
     else
  year = m_iCurrentYear + 1;
            if((parseInt(month,10) == puDate.getMonth()) &&  (parseInt(year,10) == getFullYear(puDate))) {
                selectedMonthYear.options[i].selected = 1;
            }
    }   
 
    for(var i=0;i<selectedDay.options.length;i++) {
        var day = selectedDay.options[i].value;
        if(parseInt(day,10) == puDate.getDate()) {
            selectedDay.options[i].selected=1;
        }
    }   
 
    if(dateset==false) {
        for(i=0;i<setMonthYear.options.length;i++) {
            var month = setMonthYear.options[i].value;
            var year;
            if(month >= m_iCurrentMonth)
  year = m_iCurrentYear;
     else
  year = m_iCurrentYear + 1;
            if((parseInt(month,10) == doDate.getMonth())) {
                setMonthYear.options[i].selected=1;
            }
        }   
 
        for(i=0;i<setDay.options.length;i++) {
            var day = setDay.options[i].value;
            if(parseInt(day,10) == doDate.getDate()) {
                setDay.options[i].selected=1;
            }
        }
    }
}
 

function setReturnDropoffDate() {
   
    //alert("Inside setReturnDropoffDate function...");
        
        var selectedMonthYear = document.forms['RES_FORM'].RETURN_MONTH;
    var selectedDay = document.forms['RES_FORM'].RETURN_DAY;
            
        var puMonth = selectedMonthYear.options[selectedMonthYear.selectedIndex].value;
        var puYear;
        if(puMonth >= m_iCurrentMonth)
         puYear = m_iCurrentYear;
        else
         puYear = m_iCurrentYear + 1;
        
        var puDay = selectedDay.options[selectedDay.selectedIndex].value;
        
        var puDate = new Date(puYear,(parseInt(puMonth,10)), parseInt(puDay,10));
        var doDate = new Date(puYear,(parseInt(puMonth,10)), (parseInt(puDay,10) + 1));
        
        for(var i = 0; i < selectedMonthYear.options.length; i++) {
                var month = selectedMonthYear.options[i].value
                var year;
         if(month > m_iCurrentMonth)
      year = m_iCurrentYear;
         else
      year = m_iCurrentYear + 1;
                if((parseInt(month,10) == puDate.getMonth()) &&  (parseInt(year,10) == getFullYear(puDate))) {
                    selectedMonthYear.options[i].selected = 1;
                }
        }   
     
        for(var i=0;i<selectedDay.options.length;i++) {
            var day = selectedDay.options[i].value;
            if(parseInt(day,10) == puDate.getDate()) {
                selectedDay.options[i].selected=1;
            }
        }   
    
}    
 

function setRapidReturnDropoffDate() {
 
    //alert("Inside setRapidReturnDropoffDate function...");
    
    var selectedMonthYear = document.forms['REQUEST_A_RATE'].RETURN_MONTH;
    var selectedDay = document.forms['REQUEST_A_RATE'].RETURN_DAY;
        
    var puMonth = selectedMonthYear.options[selectedMonthYear.selectedIndex].value;
    var puYear;
    if(puMonth >= m_iCurrentMonth)
     puYear = m_iCurrentYear;
    else
     puYear = m_iCurrentYear + 1;
    
    var puDay = selectedDay.options[selectedDay.selectedIndex].value;
    
    var puDate = new Date(puYear,(parseInt(puMonth,10)), parseInt(puDay,10));
    var doDate = new Date(puYear,(parseInt(puMonth,10)), (parseInt(puDay,10) + 1));
    
    for(var i = 0; i < selectedMonthYear.options.length; i++) {
            var month = selectedMonthYear.options[i].value
            var year;
     if(month > m_iCurrentMonth)
  year = m_iCurrentYear;
     else
  year = m_iCurrentYear + 1;
            if((parseInt(month,10) == puDate.getMonth()) &&  (parseInt(year,10) == getFullYear(puDate))) {
                selectedMonthYear.options[i].selected = 1;
            }
    }   
 
    for(var i=0;i<selectedDay.options.length;i++) {
        var day = selectedDay.options[i].value;
        if(parseInt(day,10) == puDate.getDate()) {
            selectedDay.options[i].selected=1;
        }
    }   
}


 
function setTempReturnDropoffDate() {
 
    //alert("Inside setDropoffDate function...");
    
    var selectedMonthYear = document.forms['RES_FORM'].RETURN_MONTH;
    var selectedDay = document.forms['RES_FORM'].RETURN_DAY;
   
    var setMonthYear = document.forms['RES_FORM'].PICKUP_MONTH;
    var setDay = document.forms['RES_FORM'].PICKUP_DAY;
        
    var puMonth = selectedMonthYear.options[selectedMonthYear.selectedIndex].value;
    var doMonth = setMonthYear.options[setMonthYear.selectedIndex].value;
    var puYear;
    
    if(puMonth >= m_iCurrentMonth)
     puYear = m_iCurrentYear;
    else
     puYear = m_iCurrentYear + 1;
    
    var puDay = selectedDay.options[selectedDay.selectedIndex].value;
    var doDay = setDay.options[setDay.selectedIndex].value;
    
    var puDate = new Date(puYear,(parseInt(puMonth,10)), parseInt(puDay,10));
    var doDate = new Date(puYear,(parseInt(doMonth,10)), (parseInt(doDay,10) + 1));
   
    for(var i = 0; i < selectedMonthYear.options.length; i++) 
    {
            var month = selectedMonthYear.options[i].value
            var year;
            if((parseInt(month,10)) == (doDate.getMonth())) {
               selectedMonthYear.options[i].selected=1;
            }
    }   
 
    for(var i=0;i<selectedDay.options.length;i++) {
        var day = selectedDay.options[i].value;
        if(parseInt(day,10) == doDate.getDate()) {
            selectedDay.options[i].selected=1;
        }
    }   
}    



function setTempRapidReturnDropoffDate() {
 
    //alert("Inside setTempRapidReturnDropoffDate function...");
    
    var selectedMonthYear = document.forms['REQUEST_A_RATE'].RETURN_MONTH;
    var selectedDay = document.forms['REQUEST_A_RATE'].RETURN_DAY;
   
    var setMonthYear = document.forms['REQUEST_A_RATE'].PICKUP_MONTH;
    var setDay = document.forms['REQUEST_A_RATE'].PICKUP_DAY;
        
    var puMonth = selectedMonthYear.options[selectedMonthYear.selectedIndex].value;
    var doMonth = setMonthYear.options[setMonthYear.selectedIndex].value;
    var puYear;
    
    if(puMonth >= m_iCurrentMonth)
     puYear = m_iCurrentYear;
    else
     puYear = m_iCurrentYear + 1;
    
    var puDay = selectedDay.options[selectedDay.selectedIndex].value;
    var doDay = setDay.options[setDay.selectedIndex].value;
    
    var puDate = new Date(puYear,(parseInt(puMonth,10)), parseInt(puDay,10));
    var doDate = new Date(puYear,(parseInt(doMonth,10)), (parseInt(doDay,10) + 1));
   
    for(var i = 0; i < selectedMonthYear.options.length; i++) 
    {
            var month = selectedMonthYear.options[i].value
            var year;
            if((parseInt(month,10)) == (doDate.getMonth())) {
               selectedMonthYear.options[i].selected=1;
            }
    }   
 
    for(var i=0;i<selectedDay.options.length;i++) {
        var day = selectedDay.options[i].value;
        if(parseInt(day,10) == doDate.getDate()) {
            selectedDay.options[i].selected=1;
        }
    }   
}


function popupCalendar(sF,sDEl,sMEl,sLang,sCntry) {
	var oForm = document.forms[sF];
	var oObj = oForm.elements[sMEl];
	var strCalendarURL = "calendar";
	
    oMonths=new Array("01","02","03","04","05","06","07","08","09","10","11","12");

    oDate=new Date();
    this_month=parseInt(oDate.getMonth()) + 1;
    this_year=oDate.getYear();

            
    if (this_year < 1900) this_year=1900+this_year;

    testMnth= parseInt(oObj.selectedIndex)+1;

    if (this_month > testMnth) { this_year=parseInt(this_year)+1; }

    strCalendarURL+="?" + oMonths[oObj.selectedIndex] + this_year;
    strCalendarURL+="&" + sF;
    strCalendarURL+="&" + sDEl;
    strCalendarURL+="&" + sMEl;
    strCalendarURL+="&" + sLang;
    strCalendarURL+="&" + sCntry;
    
    XP=260; YP=220;
	l = (screen.availWidth-10 - XP) / 2 + 200;
	t = (screen.availHeight-20 - YP) / 2;
    //var strOptions = 'screenX='+ XP + ',screenY=' + YP + ',left=' + l + ',top=' + t;
    //calendarWindow = window.open(strCalendarURL,'calendar','resizable=yes,scrollbars=no,toolbar=no,menubar=no,height=160,width=180,' + strOptions);
    var strOptions = 'width='+ XP + ',height=' + YP + ',left=' + l + ',top=' + t;
    calendarWindow = window.open(strCalendarURL,'calendar','resizable=yes,scrollbars=no,toolbar=no,menubar=no,' + strOptions);
    calendarWindow.focus();
    
    return false;

}

/*function resizedPopUp(objPage, objSize)
{
    window.open(objPage, 'Info', 'resizable=yes,scrollbars=no,toolbar=no,menubar=no,' + objSize);
}*/
