function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
//window.onload = externalLinks;
 


/*for the search pods */
function generateInfantRoomAllocation(){
    var searchForm = document.forms['tripPackageHotelFlightSearchForm'];
    if (searchForm == null){
        searchForm = document.forms['ComtecForm'];
    }
    var inputName = 'roomAllocations[0].adultQuantity';
    var infantRoomAllocation = 'roomAllocations[0].infantQuantity';
    var totalTravellers=parseInt(searchForm[inputName].value);
    generateOption(searchForm[infantRoomAllocation], parseInt(searchForm[inputName].value));
}

function generateOption(elem, num){
    var prevSelectedVal = elem.value;

    elem.length = 0;
    for (var i=0; i<=num; i++){
        var option = document.createElement('option');
        option.value = i;
        option.innerHTML = i;
        if (i==prevSelectedVal){
            option.selected = "true";
        }
        elem.appendChild(option);
        if (prevSelectedVal < elem.length){
            elem.selectedIndex = prevSelectedVal;
        } else {
            elem.selectedIndex = elem.length - 1;
        }
    }
}
 

function copyDestinationName() {
    var destinationList = document.getElementById('destination');
    var destElement = document.getElementById('destinationInput');
    var toCopy = destinationList.options[destinationList.selectedIndex];
    destElement.value = toCopy.innerHTML;
}
 
/*Info popup for children in flights MPS on HP */
function childrenWin() {
        var newWin 
        newWin = window.open("http://opodode.custhelp.com/cgi-bin/opodode.cfg/php/enduser/popup_adp.php?p_faqid=1164","tandc","width=788,height=600,scrollbars=yes,left=20,top=10");
        newWin.focus();
    }