// JavaScript Document
        function flightToggle(id) {
            if (document.getElementById(id).style.display == "block") {
                document.getElementById(id).style.display = "none";
            }
            else {
                document.getElementById(id).style.display = "block";
            }
        }


        function checkStuff() {
            
            var ins1 = document.getElementById('dnn_require_flights');

            if (ins1.getAttribute('type') == 'checkbox') {
                if (ins1.checked == true) {
                    document.getElementById('flightPop').style.display = "block";
                }
            }

            var ins2 = document.getElementById('dnn_car_rental');

            if (ins2.getAttribute('type') == 'checkbox') {
                if (ins2.checked == true) {
                    document.getElementById('carPop').style.display = "block";
                }
            }
        }
        

        function AddPassenger() {

            var div = document.getElementById("passengers");
            var numPass = div.getElementsByTagName("table").length;

            var passNum = numPass + 1;

            if (numPass < 20) {

                var newTable = document.createElement("table");
                var newTbody = document.createElement("tbody");
                var newRowA = document.createElement("tr");
                var newRowB = document.createElement("tr");
                var newCellA = document.createElement("td");
                var newCellB = document.createElement("td");
                var newCellC = document.createElement("td");
                var newCellD = document.createElement("td");
                var newCellE = document.createElement("td");
                var newCellF = document.createElement("td");
                var newCellG = document.createElement("td");
                var newCellH = document.createElement("td");
                var newCellI = document.createElement("td");
                var newSpanTitle = document.createElement("span");
                var newSpanFirstName = document.createElement("span");
                var newSpanLastName = document.createElement("span");
                var newSpanAdult = document.createElement("span");
                var newSpanChild = document.createElement("span");
                var newSpanChildAge = document.createElement("span");
                var newFirstNameCell = document.createElement("td");

                newSpanTitle.className = "EnquiryText";
                newSpanFirstName.className = "EnquiryText";
                newSpanLastName.className = "EnquiryText";
                newSpanAdult.className = "EnquiryText";
                newSpanChild.className = "EnquiryText";
                newSpanChildAge.className = "EnquiryText";

                newSpanTitle.setAttribute("class", "EnquiryText");
                newSpanFirstName.setAttribute("class", "EnquiryText");
                newSpanLastName.setAttribute("class", "EnquiryText");
                newSpanAdult.setAttribute("class", "EnquiryText");
                newSpanChild.setAttribute("class", "EnquiryText");
                newSpanChildAge.setAttribute("class", "EnquiryText");

                var newCellBInner = document.createElement("select");

                newCellBInner.setAttribute("id", "title_pass" + passNum);
                newCellBInner.setAttribute("name", "title_pass" + passNum);
                newCellBInner.setAttribute("class", "EnquiryText");

                newCellBInner.options[0] = new Option("Mr", "Mr");
                newCellBInner.options[1] = new Option("Mrs", "Mrs");
                newCellBInner.options[2] = new Option("Ms", "Ms");
                newCellBInner.options[3] = new Option("Miss", "Miss");
                newCellBInner.options[4] = new Option("Dr", "Dr");
                newCellBInner.options[5] = new Option("Rev", "Rev");
                newCellBInner.options[6] = new Option("Prof", "Prof");

                var newCellDInner = document.createElement("input");

                newCellDInner.setAttribute("id", "first_name_pass" + passNum);
                newCellDInner.setAttribute("name", "first_name_pass" + passNum);
                newCellDInner.setAttribute("class", "EnquiryText");
                newCellDInner.setAttribute("type", "text");
                newCellDInner.className = "tbox";

                var newCellFInner = document.createElement("input");

                newCellFInner.setAttribute("id", "last_name_pass" + passNum);
                newCellFInner.setAttribute("name", "last_name_pass" + passNum);
                newCellFInner.setAttribute("type", "text");
                newCellFInner.setAttribute("class", "EnquiryText");
                newCellFInner.className = "tbox";

                var newCellGInner1Lab;

                newCellGInner1Lab = document.createElement("label");
                
                newCellGInner1Lab.setAttribute("for", ("type_adult_pass" + passNum));
                newCellGInner1Lab.appendChild(document.createTextNode("Adult"));
                newCellGInner1Lab.setAttribute("class", "EnquiryText");

                var newCellGInner2Lab;

                newCellGInner2Lab = document.createElement("label");

                newCellGInner2Lab.setAttribute("for", ("type_child_pass" + passNum));
                newCellGInner2Lab.appendChild(document.createTextNode("Child"));

                newCellG.setAttribute("colspan", "2");
                newCellG.setAttribute("colspan", "3");

                var newCellGInner1;
                var newCellGInner2;                

                   // Try the IE way; this fails on standards-compliant browsers
                   try {
                       newCellGInner1 = document.createElement("<input type='radio' id='type_adult_pass" + passNum + "'name='type_pass" + passNum + "' value='Adult' checked />");
                       newCellGInner2 = document.createElement("<input type='radio' id='type_child_pass" + passNum + "'name='type_pass" + passNum + "' value='Child' />");
                       
                       } catch (e) {
                       }
                       if (!newCellGInner1 || !newCellGInner2) {
                          // Non-IE browser; use canonical method to create named element
                          
                          newCellGInner1 = document.createElement("input");
                          newCellGInner1.id = ("type_adult_pass" + passNum);
                          newCellGInner1.name = ("type_pass" + passNum);
                          newCellGInner1.value = "Adult";
                          newCellGInner1.type = "radio";
                          newCellGInner1.setAttribute('checked', 'true');

                          newCellGInner2 = document.createElement("input");
                          newCellGInner2.id = ("type_child_pass" + passNum);
                          newCellGInner2.name = ("type_pass" + passNum);
                          newCellGInner2.value = "Child";
                          newCellGInner2.type = "radio";
                       }

                var newCellIInner = document.createElement("select");

                newCellIInner.setAttribute("id", "child_age_pass" + passNum);
                newCellIInner.setAttribute("name", "child_age_pass" + passNum);

                newCellIInner.options[0] = new Option("1", "1");
                newCellIInner.options[1] = new Option("2", "2");
                newCellIInner.options[2] = new Option("3", "3");
                newCellIInner.options[3] = new Option("4", "4");
                newCellIInner.options[4] = new Option("5", "5");
                newCellIInner.options[5] = new Option("6", "6");
                newCellIInner.options[6] = new Option("7", "7");
                newCellIInner.options[7] = new Option("8", "8");
                newCellIInner.options[8] = new Option("9", "9");
                newCellIInner.options[9] = new Option("10", "10");
                newCellIInner.options[10] = new Option("11", "11");
                newCellIInner.options[11] = new Option("12", "12");
                newCellIInner.options[12] = new Option("13", "13");
                newCellIInner.options[13] = new Option("14", "14");
                newCellIInner.options[14] = new Option("15", "15");
                newCellIInner.options[15] = new Option("16", "16");
                newCellIInner.options[16] = new Option("17", "17");
                newCellIInner.options[17] = new Option("18", "18");


                newRowA.appendChild(newCellA);
                newRowA.appendChild(newCellB);
                newRowA.appendChild(newCellC);
                newRowA.appendChild(newCellD);
                newRowA.appendChild(newCellE);
                newRowA.appendChild(newCellF);

                newRowB.appendChild(newCellG);
                newRowB.appendChild(newCellH);
                newRowB.appendChild(newCellI);

                newRowA.className = "enqAlign";
                newRowB.className = "enqAlign";
                newCellA.appendChild(newSpanTitle);
                newSpanTitle.appendChild(document.createTextNode("Title"));

                //newCellA.appendChild(document.createTextNode("Title"));
                newCellA.className = "aright fC";

                newCellB.appendChild(newCellBInner);
                
                newCellB.className = "aleft";
                newCellB.width = 61;
                newCellC.appendChild(newSpanFirstName);
                newSpanFirstName.appendChild(document.createTextNode("First Name"));

                //newCellC.appendChild(document.createTextNode("First Name"));

                newCellC.className = "aright";
                newCellC.width = 67;

                newCellD.appendChild(newCellDInner);
                
                newCellD.className = "aleft";
                newCellD.width = 223;

                newCellE.appendChild(newSpanLastName);
                newSpanLastName.appendChild(document.createTextNode("Last Name"));

                //newCellE.appendChild(document.createTextNode("Last Name"));

                newCellE.className = "aright";
                newCellE.width = 67;

                newCellF.appendChild(newCellFInner);
                
                newCellF.className = "aleft";
                newCellF.width = 223;

                newCellG.appendChild(newCellGInner1);
                newCellG.appendChild(newSpanChild);
                newSpanChild.appendChild(newCellGInner1Lab);
                //newCellG.appendChild(newCellGInner1Lab);
                newCellG.appendChild(newCellGInner2);
                newCellG.appendChild(newSpanAdult);
                newSpanAdult.appendChild(newCellGInner2Lab);
                //newCellG.appendChild(newCellGInner2Lab);
                    
                newCellG.className = "aright";
                newCellG.colSpan = 2;
                newCellG.width = 117;

                newCellH.appendChild(newSpanChildAge);
                newSpanChildAge.appendChild(document.createTextNode("Child Age"));

                //newCellH.appendChild(document.createTextNode("Child Age"));

                newCellH.className = "aright";

                newCellI.appendChild(newCellIInner);
                
                newCellI.colSpan = 3;
                newCellI.className = "aleft";

                newTbody.appendChild(newRowA);
                newTbody.appendChild(newRowB);

                newTable.appendChild(newTbody);

                div.appendChild(newTable);

                newTable.className = "passys";
                
                /*newTable.style.backgroundColor = "#f2f3f4";
                
                newTable.style.display = "block";
                newTable.style.fontFamily = "Arial, Helvetica, sans-serif";
                newTable.style.hasLayout = "-1";
                newTable.style.verticalAlign = "middle";
                newTable.style.width = "730px";
                newTable.style.marginBottom = "2px";
                newTable.style.clear = "both";*/
             
            }

        }

        function RemovePassenger() {
            var div = document.getElementById("passengers");
            var numTables = div.getElementsByTagName("table").length;

            if (numTables > 1) {
                div.removeChild(div.lastChild);
            }
        }


        function checkDate(sender, args) {
            if (sender._selectedDate < new Date()) {
                alert("You cannot select a day earlier than today!");
                sender._selectedDate = new Date();
                // set the date back to the current date
                sender._textbox.set_Value(sender._selectedDate.format(sender._format))
            }
        }