//Function to load return section
function showhidedivnew(field, isOnload){
    var jType = document.getElementById("journeyType").value;
    var applState = document.forms[0].appState.value;

    if(jType == 'openReturn'){
        document.getElementById("rtnDepArrDiv").style.display = "none";
        document.getElementById("rtnDateDIV").style.display = "none";
        document.getElementById("rtnCalendarDIV").style.display = "none";
        document.getElementById("rtnTimeDiv").style.display = "none";
        document.getElementById("rtnDateTxtDiv").style.display = "none";
        document.getElementById("rtnDateSpacer").style.display = 'none';
        document.getElementById("rtnTimeTxtDiv").style.display = "none";
        document.getElementById("rtnTimeSpacer").style.display = 'none';
        //document.getElementById("DIV2").style.display= '';
        document.forms[0].rtnTo.disabled = true;
        document.forms[0].rtnFrom.disabled = true;

/*
        // Check to see if the  field is a select object
        if(document.forms[0].outFrom.type == "select-one"){
            if(document.forms[0].rtnTo.type == "select-one"){
                document.forms[0].rtnTo.value = document.forms[0].outFrom.value;
            }
            else {
                document.forms[0].rtnTo.value = document.forms[0].outFrom.options[document.forms[0].outFrom.selectedIndex].text;
            }
        }
        else {
            document.forms[0].rtnTo.value = document.forms[0].outFrom.value;
        }

        // Check to see if the  field is a select object
        if(document.forms[0].outTo.type == "select-one"){
            if(document.forms[0].rtnFrom.type == "select-one"){
                document.forms[0].rtnFrom.value = document.forms[0].outTo.value;
            }
            else {
                document.forms[0].rtnFrom.value = document.forms[0].outTo.options[document.forms[0].outTo.selectedIndex].text;
            }
        }
        else {
            document.forms[0].rtnFrom.value = document.forms[0].outTo.value;
        }
*/

        if(applState == "1" || applState == "2" || applState == "4"){
            document.forms[0].appState.value = "3";
        }
        else {
            document.forms[0].appState.value = "7";
        }
    }
    else if(jType == 'return'){
        //document.getElementById("DIV2").style.display= '';
        document.getElementById("rtnDepArrDiv").style.display = '';
        document.getElementById("rtnDateDIV").style.display = '';
        document.getElementById("rtnCalendarDIV").style.display = '';
        document.getElementById("rtnTimeDiv").style.display = '';
        document.getElementById("rtnDateTxtDiv").style.display = '';
        document.getElementById("rtnDateSpacer").style.display = '';
        document.getElementById("rtnTimeTxtDiv").style.display = '';
        document.getElementById("rtnTimeSpacer").style.display = '';
        document.forms[0].rtnTo.disabled = true;
        document.forms[0].rtnFrom.disabled = true;
        // Check to see if the  field is a select object

        if(document.forms[0].rtnTime.value == ''){
            setReturnTime();
        }

/*
        if(document.forms[0].outFrom.type == "select-one"){
            if(document.forms[0].rtnTo.type == "select-one"){
                document.forms[0].rtnTo.value = document.forms[0].outFrom.value;
            }
            else {
                document.forms[0].rtnTo.value = document.forms[0].outFrom.options[document.forms[0].outFrom.selectedIndex].text;
            }
        }
        else {
            document.forms[0].rtnTo.value = document.forms[0].outFrom.value;
        }

        // Check to see if the  field is a select object
        if(document.forms[0].outTo.type == "select-one"){
            if(document.forms[0].rtnFrom.type == "select-one"){
                document.forms[0].rtnFrom.value = document.forms[0].outTo.value;
            }
            else {
                document.forms[0].rtnFrom.value = document.forms[0].outTo.options[document.forms[0].outTo.selectedIndex].text;
            }
        }
        else {
            document.forms[0].rtnFrom.value = document.forms[0].outTo.value;
        }
*/

        if(!isOnload){
        //ie. only set this value when showing div1 for first time, otherwise use stored value
            if(document.forms[0].outDepArr[0].checked == true){
                document.forms[0].rtnDepArr[0].checked = true;
                document.forms[0].rtnDepArr[1].checked = false;
            }
            else {
                document.forms[0].rtnDepArr[0].checked = false;
                document.forms[0].rtnDepArr[1].checked = true;
            }
        }

        if(document.getElementById("rtnDate").value == ''){
            document.getElementById("rtnDate").value = document.all.outDate.value;
        }

        if(applState == "1" || applState == "3" || applState == "4"){
            document.forms[0].appState.value = "2";
        }
        else {
            document.forms[0].appState.value = "6";
        }
    }
    else if(jType == 'openJaw'){
        document.forms[0].rtnFrom.disabled = true;
        //document.getElementById("DIV2").style.display= '';
        document.getElementById("rtnDepArrDiv").style.display = '';
        document.getElementById("rtnDateDIV").style.display = '';
        document.getElementById("rtnCalendarDIV").style.display = '';
        document.getElementById("rtnTimeDiv").style.display = '';
        document.getElementById("rtnDateTxtDiv").style.display = '';
        document.getElementById("rtnDateTxtspacer").style.display = '';
        document.getElementById("rtnTimeTxtDiv").style.display = '';
        document.getElementById("rtnTimeTxtspacer").style.display = '';
        document.forms[0].rtnTo.disabled = false;
        if(document.forms[0].rtnTo.type != "select-one"){
            document.forms[0].rtnTo.value = '';
        }

/*
        // Check to see if the field is a select object
        if(document.forms[0].outTo.type == "select-one"){
            if(document.forms[0].rtnFrom.type == "select-one"){
                document.forms[0].rtnFrom.value = document.forms[0].outTo.value;
            }
            else {
                document.forms[0].rtnFrom.value = document.forms[0].outTo.options[document.forms[0].outTo.selectedIndex].text;
            }
        }
        else {
            document.forms[0].rtnFrom.value = document.forms[0].outTo.value;
        }
*/

        if(document.forms[0].outDepArr[0].checked == true){
            document.forms[0].rtnDepArr[0].checked = true;
            document.forms[0].rtnDepArr[1].checked = false;
        }
        else {
            document.forms[0].rtnDepArr[0].checked = false;
            document.forms[0].rtnDepArr[1].checked = true;
        }

        if(document.getElementById("rtnDate").value == ''){
            document.getElementById("rtnDate").value = document.all.outDate.value;
        }

        if(applState == "1" || applState == "2" || applState == "3"){
            document.forms[0].appState.value = "4";
        }
        else {
            document.forms[0].appState.value = "8";
        }
    }
    else {
        //document.getElementById("DIV2").style.display= "none";
		document.getElementById("rtnDateDIV").style.display = "none";
		document.getElementById("rtnCalendarDIV").style.display = "none";
		document.getElementById("rtnTimeDiv").style.display = "none";
		document.getElementById("rtnDateTxtDiv").style.display = "none";
		document.getElementById("rtnDateSpacer").style.display = 'none';
		document.getElementById("rtnTimeTxtDiv").style.display = "none";
		document.getElementById("rtnTimeSpacer").style.display = 'none';

        if(applState == "2" || applState == "3" || applState == "4"){
            document.forms[0].appState.value = "1";
        }
        else {
            document.forms[0].appState.value = "5";
        }
    }

    copy_From_To();
    copy_To_From();
}
