var showVideoTourWindow;

function onCountryChange(field) {
  var country = field.options[field.selectedIndex].text;
  document.getElementById('STATE').disabled = !('United States' == country);
//  document.getElementById('ZIPCODE').disabled = !('United States' == country) && !('Canada' == country);
}

var uid = (function() {
  var id = 0;
  return function() {
    if(arguments[0] === 0) {
      id = 0;
    }
    return id++;
  };
})();

function cloneElement(id) {
  var new_div = Element.clone($(id), true);
  var new_id = uid();
  new_div.id = 'div_' + new_id;
  var children = new_div.select('*[id]');
  for (var i = 0; i < children.length; i++) {
    var old_id = children[i].getAttribute('id');
    if (old_id.length > 0) {
      children[i].setAttribute('id', old_id + new_id);
    }
  }
  document.body.appendChild(new_div);
  return new_id;
}

function showVideoTour(code) {
  var container = $('video_tour_frame');
  container.innerHTML = code;
  var embed = container.select('object');
  if (embed.length == 0) {
    container.select('iframe');
  }
  if (embed.length > 0) {
    $('video_tour_div').style.width = (embed[0].width - 18) + 'px';
    container.style.width = embed[0].width + 'px';
    container.style.height = embed[0].height + 'px';
    showVideoTourWindow = new Popup.Window($('video_tour_div'));
    showVideoTourWindow.show();
  }
}
