// START RAcdn
var version = "1.2";
var divName = "Contiki_RAQ_RAcdn";
var frameName = "Contiki_RAQ_RQ";
var formURL = "https://www.revagency.net/ap5/vendors/Contiki/LeadForm.cfm";
var defaultWidth = 880;
var defaultHeight = 680;
var defaultRefCode = "CHUSA_1004";
var ra_ref = "";
function flowframe(h) {
  document.getElementById(frameName).setAttribute("height", h);
}
var allCookies = document.cookie.split(";");
for (var i = 0; i < allCookies.length; i ++) {
  var onePair = allCookies[i].split("=");
  if (onePair.length == 2) {
    if (onePair[0].replace(/\s/g, "") == "ra_ref") {
      ra_ref = onePair[1];
      break;
    }
  }
}
var hrefsplit = window.location.href.split("?");
var sourceURL = hrefsplit[0];
if (ra_ref == "") {
  if (hrefsplit.length == 2) {
    if (refmatch = hrefsplit[1].match(/\bref=([^&]+)/gi)) {
      for (var i = 0; i < refmatch.length; i++) {
        var refsplit = refmatch[i].split("=");
        if (refsplit.length == 2) {
          if (refsplit[0].toLowerCase() == "ref") {
            ra_ref = refsplit[1];
            break;
          }
        }
      }
    }
  }
}
if (ra_ref == "")
  ra_ref = defaultRefCode;
var stashArgs = {};
stashArgs.print = function() {
  var queryStr = "";
  for (key in this) {
    // everything but the function and departure_list
    if (typeof this[key] != "function" && key != "departure_list")
      queryStr += ("&"+key+"="+encodeURI(this[key]).replace('&','%26'));
  }
  // Now append departure_list, which must be last in the URL
  queryStr += ("&departure_list="+encodeURI(this['departure_list']));
  return queryStr;
}
if (typeof document.forms['RAcdnStash'].departure_ID != "undefined" && document.forms['RAcdnStash'].departure_ID.value != "")
  stashArgs.departure_ID = document.forms['RAcdnStash'].departure_ID.value;
if (typeof document.forms['RAcdnStash'].tour_name != "undefined" && document.forms['RAcdnStash'].tour_name.value != "")
  stashArgs.tour_name = document.forms['RAcdnStash'].tour_name.value;
if (typeof document.forms['RAcdnStash'].tour_price != "undefined" && document.forms['RAcdnStash'].tour_price.value != "")
  stashArgs.tour_price = document.forms['RAcdnStash'].tour_price.value;
if (typeof document.forms['RAcdnStash'].tour_departing != "undefined" && document.forms['RAcdnStash'].tour_departing.value != "")
  stashArgs.tour_departing = document.forms['RAcdnStash'].tour_departing.value;
if (typeof document.forms['RAcdnStash'].tour_start != "undefined" && document.forms['RAcdnStash'].tour_start.value != "")
  stashArgs.tour_start = document.forms['RAcdnStash'].tour_start.value;
if (typeof document.forms['RAcdnStash'].tour_return != "undefined" && document.forms['RAcdnStash'].tour_return.value != "")
  stashArgs.tour_return = document.forms['RAcdnStash'].tour_return.value;
if (typeof document.forms['RAcdnStash'].tour_code != "undefined" && document.forms['RAcdnStash'].tour_code.value != "")
  stashArgs.tour_code = document.forms['RAcdnStash'].tour_code.value;
if (typeof document.forms['RAcdnStash'].tour_url != "undefined" && document.forms['RAcdnStash'].tour_url.value != "")
  stashArgs.tour_url = document.forms['RAcdnStash'].tour_url.value;
if (typeof document.forms['RAcdnStash'].accommodation_type != "undefined" && document.forms['RAcdnStash'].accommodation_type.value != "")
  stashArgs.accommodation_type = document.forms['RAcdnStash'].accommodation_type.value;
if (typeof document.forms['RAcdnStash'].departure_list != "undefined" && document.forms['RAcdnStash'].departure_list.value != "")
  stashArgs.departure_list = document.forms['RAcdnStash'].departure_list.value;
document.getElementById(divName).innerHTML = '<iframe scrolling=\"no\" width=\"'+defaultWidth+'\" height=\"'+defaultHeight+'\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" id=\"'+frameName+'\" name=\"'+frameName+'\" src=\"'+formURL+'?source='+sourceURL+'&ra_ref='+ra_ref+stashArgs.print()+'\"></iframe>';
// END RAcdn
