function update_return_date(){
    if(document.quoteForm.return_day.selectedIndex <  document.quoteForm.start_day.selectedIndex && document.quoteForm.start_month.selectedIndex == document.quoteForm.return_month.selectedIndex){
        document.quoteForm.return_day.selectedIndex = document.quoteForm.start_day.selectedIndex;
    }
if(document.quoteForm.return_month.selectedIndex <  document.quoteForm.start_month.selectedIndex ){
        document.quoteForm.return_day.selectedIndex = document.quoteForm.start_day.selectedIndex;
        document.quoteForm.return_month.selectedIndex = document.quoteForm.start_month.selectedIndex;
    }
}

function confirm_cancel(){
	return confirm("Proceed with cancellation? (Y/N)");	
	
}

function reset_times(){
    for(x=0;x<48;x++){
        if(x % 2 == 1){
            append_time = "30";
        }else{
            append_time = "00";
        }
        am = "am";
        if(x==0 || x==1){
            time =12;
        }else{
            time = Math.floor(x/2);
        }
        if(x==24 || x==25){
            am="pm";
        }
        if(x>25){
            time = time -12;
            am = "pm";
        }
        document.quoteForm.start_time.options[x].disabled = false;
        document.quoteForm.start_time.options[x].value = Math.floor(x/2) + ":"+ append_time;
        document.quoteForm.start_time.options[x].text = (time) + ":"+ append_time+am;

        document.quoteForm.return_time.options[x].disabled = false;
        document.quoteForm.return_time.options[x].text = (time) + ":"+ append_time+am;
        document.quoteForm.return_time.options[x].value = Math.floor(x/2) + ":"+append_time;

    }
}
function update_times(location){
    reset_times();
    always_open = false;
    switch(location.value){
        case 'christchurch':
            open_time = 7*2;
            close_time = 21*2;
        break
        
        default:
            always_open = true;
            
        break;
    }
    if(always_open == false){
        for(x=0;x<48;x++){
            if((open_time < close_time  && (x<open_time || x > close_time)) || (open_time > close_time  && x> close_time && x < open_time) ){
                document.quoteForm.start_time.options[x].text = "CLOSED";
                document.quoteForm.start_time.options[x].disabled = true;
                document.quoteForm.return_time.options[x].text = "CLOSED";
                document.quoteForm.return_time.options[x].disabled = true;
                if(x % 2 == 1){
                    append_time = "30";
                }else{
                    append_time = "00";
                }
                document.quoteForm.start_time.options[x].value = (open_time/2) + append_time;
                document.quoteForm.return_time.options[x].value = (close_time/2) + append_time;
               
            }
        }
    }
}




