//--------------------------------------------------------------------------------------------------------------------
function subFrm() {
 document.main.action = "https://select.worldpay.com/wcc/purchase";
 document.main.target = "pFrame";
 document.main.submit();
 document.main.action = "order_vouchers.asp";
 document.main.target = "uFrame";
 document.main.submit();
 document.getElementById("divFrm").className = "vhidden";
 document.getElementById("divPay").className = "vdisplay";
 return true;
}
//--------------------------------------------------------------------------------------------------------------------
function changeEl(){
 var el = null;
 el = document.getElementById("l1");
 el.innerHTML = '<a href="http://www.cubana.co.uk/" title="Cubana Bar &amp; Restaurant">Cubana Bar &amp; Restaurant</a>';
 el = document.getElementById("l2");
 el.innerHTML = '<a href="http://www.cubanacan.cu/index.php?option=com_content&task=view&id=81&Itemid=86&lang=en" title="Cubanacan Group">Cubanacan Group</a>';
 el = document.getElementById("l3");
 el.innerHTML = '<a href="http://www.cocotours.com" title="Coco Tours">Coco Tours</a>';
 el = document.getElementById("l4");
 el.innerHTML = '<a href="http://www.excelinegypt.travel" title="Excel in Egypt with Excel Travel">Excel in Egypt with Excel Travel</a>';
 el = document.getElementById("l5");
 el.innerHTML = '<a href="http://www.lightandland.co.uk" title="Light and Land">Light and Land</a>';
 el = document.getElementById("l6");
 el.innerHTML = '<a href="http://www.paradiso.cu" title="Paradiso Turismo Cultural">Paradiso Turismo Cultural</a>';
}
//--------------------------------------------------------------------------------------------------------------------
function changeSort(ctrl) {
 document.getElementById('orderTop').value = ctrl.value;
 document.getElementById('orderBot').value = ctrl.value;
 document.main.submit();
}
//--------------------------------------------------------------------------------------------------------------------
function submitNotNull(sVal) {
 if (sVal.value!='0') {
  document.main.submit();
 }
}
//--------------------------------------------------------------------------------------------------------------------
function calcVouchers() {
 var vtot = 0;
 vtot += 25 * document.getElementById('25').value;
 vtot += 50 * document.getElementById('50').value;
 vtot += 75 * document.getElementById('75').value;
 vtot += 100 * document.getElementById('100').value;
 document.getElementById('rate').value = vtot;
 document.getElementById('vtot').innerHTML = '<b>&pound;' + vtot + '</b>';
}
//--------------------------------------------------------------------------------------------------------------------
var isOpen=null;
function popD(target,titulo,ancho,alto) {
 var lefPos = 0;
 var topPos = 0;
 if (screen) {
  lefPos = (screen.width / 2) - ancho;
  topPos = (screen.height / 2) - alto;
 }
 target='calendar.asp?fecha=' + eval(target + '.value') + '&formcontrol=' + target.substr(9,target.length)
 if (isOpen!=null){
  if (isOpen.closed) {
   isOpen=window.open(target,titulo,'width='+ancho+',height='+alto+',left='+lefPos+',top='+topPos);
  } else {
   isOpen.focus();
  }
 } else {
  isOpen=window.open(target,titulo,'width='+ancho+',height='+alto+',left='+lefPos+',top='+topPos);
 }
}
//--------------------------------------------------------------------------------------------------------------------
function popW(target,titulo,detalles) {
    if (isOpen!=null){
       if (isOpen.closed){isOpen=window.open(target,titulo,detalles);}
       else{isOpen.focus();}
    }
    else{isOpen=window.open(target,titulo,detalles);}
}
//--------------------------------------------------------------------------------------------------------------------
function popWD(target,titulo,detalles,alto,ancho) {
	 var lefPos = 0;
	 var topPos = 0;
	 if (screen) {
	  lefPos = (screen.width / 2) - ancho;
	  topPos = (screen.height / 2) - alto;
	 }
     if (isOpen!=null){
       if (isOpen.closed){
		   isOpen=window.open(target,titulo,'width='+ancho+',height='+alto+',left='+lefPos+',top='+topPos+',menubar=false,scrollbars=false,toolbar=false,titlebar=false');
	   }
       else{isOpen.focus();}
     }
     else{
		 isOpen=window.open(target,titulo,'width='+ancho+',height='+alto+',left='+lefPos+',top='+topPos+',menubar=false,scrollbars=false,toolbar=false,titlebar=false');
	 }
}
//--------------------------------------------------------------------------------------------------------------------
function cleanThis(ctrl) {
 ctrl.value = '';
}
//--------------------------------------------------------------------------------------------------------------------
function showDiv(cnt,div) {
 document.getElementById("d_ovr").className = "hid";
 document.getElementById("d_hot").className = "hid";
 document.getElementById("d_exc").className = "hid";
 if (document.getElementById("a_ovr") != null) {
  document.getElementById("a_ovr").className = "nav_link";
 }
 if (document.getElementById("a_hot") != null) {
  document.getElementById("a_hot").className = "nav_link";
 }
 if (document.getElementById("a_exc") != null) {
  document.getElementById("a_exc").className = "nav_link";
 }
 document.getElementById(div).className = "box";
 cnt.className = "nav_curr";
}
//--------------------------------------------------------------------------------------------------------------------
function showTab(actab) {
 if (document.getElementById('hot') != null) {document.getElementById('hot').className = 'hid';}
 if (document.getElementById('exc') != null) {document.getElementById('exc').className = 'hid';}
 if (document.getElementById(actab) != null) {document.getElementById(actab).className = 'res_hot';}
 if (document.getElementById('tab_hot') != null) {document.getElementById('tab_hot').className = 'res_nsl';}
 if (document.getElementById('tab_exc') != null) {document.getElementById('tab_exc').className = 'res_nsl';}
 if (document.getElementById('tab_' + actab) != null) {document.getElementById('tab_' + actab).className = 'res_sel';}
}
//--------------------------------------------------------------------------------------------------------------------
function addHidden(div){
 if (div == 'd_intr') {
  document.getElementById('d_intr').className = "cn_wrap_hid";
  document.getElementById('d_info').className = "cn_wrap";
  document.getElementById('intr').className = "lnk_tab";
  document.getElementById('info').className = "lnk_tab_sel";
 } else {
  document.getElementById('d_intr').className = "cn_wrap";
  document.getElementById('d_info').className = "cn_wrap_hid";
  document.getElementById('intr').className = "lnk_tab_sel";
  document.getElementById('info').className = "lnk_tab";
 }
}
//--------------------------------------------------------------------------------------------------------------------
function showMore(actn) {
 if (actn=='show') {
  document.getElementById('inf_clv').className = "info_hid";
  document.getElementById('inf_clh').className = "info_vis";
  document.getElementById('inf_hid').className = "info_vis";
 }else{
  document.getElementById('inf_clv').className = "info_vis";
  document.getElementById('inf_clh').className = "info_hid";
  document.getElementById('inf_hid').className = "info_hid";
 }
}
//--------------------------------------------------------------------------------------------------------------------
function showTMdivs(num){
 document.getElementById("cat1_holidays").className = "tmhid";
 document.getElementById("cat2_holidays").className = "tmhid";
 document.getElementById("cat3_holidays").className = "tmhid";
 document.getElementById("cat1_head").className = "tmade";
 document.getElementById("cat2_head").className = "tmade";
 document.getElementById("cat3_head").className = "tmade";
 if (document.getElementById("cat" + num + "_holidays") != null) {
  document.getElementById("cat" + num + "_holidays").className = "tmblk";
 }
 if (document.getElementById("cat" + num + "_head") != null) {
  document.getElementById("cat" + num + "_head").className = "tmsel";
 }
}
//--------------------------------------------------------------------------------------------------------------------
function swapImage(img){
 document.getElementById("tar_p").src = img; 
}
//--------------------------------------------------------------------------------------------------------------------
function swapClass(ctl){
 var isFirstTime = document.getElementById("hidMap");
 document.getElementById("tab_p").className = "gnos";
 document.getElementById("tab_v").className = "gnos";
 document.getElementById("tab_i").className = "gnos";
 document.getElementById("tab_m").className = "gnos";
 document.getElementById("tab_" + ctl).className = "gsel";
 document.getElementById("tar_p").className = "hidetag";
 document.getElementById("tar_v").className = "hidetag";
 document.getElementById("tar_i").className = "hidetag";
 document.getElementById("tar_m").className = "hidetag";
 document.getElementById("tar_" + ctl).className = "showtag";
 document.getElementById("nav_p").className = "hidetag";
 document.getElementById("nav_v").className = "hidetag";
 document.getElementById("nav_i").className = "hidetag";
 document.getElementById("nav_m").className = "hidetag";
 document.getElementById("nav_" + ctl).className = "showtag";
 if (ctl == 'm' && isFirstTime.value == '0') {
  drawMap();
  isFirstTime.value = '1';
 }
}
//--------------------------------------------------------------------------------------------------------------------
function swapMovie(movn){
 var ytub = window.document.ytub;
 ytub.src = 'http://www.youtube.com/v/' + movn;
 ytub.movie = 'http://www.youtube.com/v/' + movn;
}
//--------------------------------------------------------------------------------------------------------------------
function handleResponse(xhr) {
 var res = xhr.responseXML;
 var selElems = res.getElementsByTagName("selFields");
 var sel = $("menuResort");
 sel.options.length = 0;
 var optElems = selElems[0].getElementsByTagName("optField");
 for (var j=0; j<optElems.length; j++) {
   sel.options[j] = new Option(unescape(optElems[j].getAttribute("name")).replace(/\+/g, ' '), optElems[j].getAttribute("value"), false, false);
 }
 new Element.hide("imgIndicator");
 new Form.enable("search-form");
}
//--------------------------------------------------------------------------------------------------------------------
function reportError(xhr) {
  alert("Error getting resorts");
  new Form.enable("search-form");
}
//--------------------------------------------------------------------------------------------------------------------
function getResorts(deid) {
  var pars = "id="+deid;
  new Element.show("imgIndicator");
  new Form.disable("search-form");
  var myAjax = new Ajax.Request('ajax.asp', {method: 'get', parameters: pars, onSuccess: handleResponse, onFailure:reportError});
}
//--------------------------------------------------------------------------------------------------------------------
function addFlex() {
  $("flex").value = parseInt($F("flex")) + 1;
}
//--------------------------------------------------------------------------------------------------------------------
function decFlex() {
  if (parseInt($F("flex"))!=0) {
    $("flex").value = parseInt($F("flex")) - 1;
  }
}
//---------------------------------------------------------------------------------------------------------------------
function reportError(request) {
  Element.toggle('img_wait');
  alert("Error while saving your data, please wait some seconds and try again");
  Form.enable('main');
}
//---------------------------------------------------------------------------------------------------------------------
function enableForm() {
  Element.toggle('img_wait');
  Form.enable('main');
  //document.getElementById("divFrm").className = "vhidden";
  //document.getElementById("divPay").className = "vdisplay";
}
//---------------------------------------------------------------------------------------------------------------------
function check_and_post() { 
  var d = new Date();
  var params = Form.serialize('main')+'&cache='+d.getTime();
  Element.toggle('img_wait');
  Element.hide('post_msg');
  Form.disable('main');
  var req = new Ajax.Updater({success: 'post_msg'},'check_and_add_customer.asp',{method: 'post', parameters: params,evalScripts: true,onFailure: reportError,onSuccess: enableForm});
}
//---------------------------------------------------------------------------------------------------------------------
var option2_fields = ['code2', 'coid2', 'city2', 'addr2'];
var option2_tr_fields = ['tr-code2', 'tr-coid2', 'tr-city2', 'tr-addr2'];
var option3_fields = ['tiid2', 'name2', 'surn2', 'phone2', 'mail2', 'mail3'];
var option3_tr_fields = ['tr-tiid2', 'tr-name2', 'tr-surn2', 'tr-phone2', 'tr-mail2', 'tr-mail3'];

function selectSendType(option) {
  switch(option) {
    case 1:
	  for (i=0; i<option2_tr_fields.length; i++) {Element.hide(option2_tr_fields[i]);}
	  for (i=0; i<option3_tr_fields.length; i++) {Element.hide(option3_tr_fields[i]);}  
	  for (i=0; i<option2_fields.length; i++) {$(option2_fields[i]).disabled=true;}
	  for (i=0; i<option3_fields.length; i++) {$(option3_fields[i]).disabled=true;}
	  break;
	case 3:
	  for (i=0; i<option2_fields.length; i++) {$(option2_fields[i]).disabled=false;}
	  for (i=0; i<option3_fields.length; i++) {$(option3_fields[i]).disabled=false;} 
	  for (i=0; i<option3_tr_fields.length; i++) {Element.show(option3_tr_fields[i]);}
	  for (i=0; i<option2_tr_fields.length; i++) {Element.show(option2_tr_fields[i]);}
	  break;
	case 2:
	  for (i=0; i<option2_fields.length; i++) {$(option2_fields[i]).disabled=false;}
	  for (i=0; i<option3_fields.length; i++) {$(option3_fields[i]).disabled=true;}
	  for (i=0; i<option2_tr_fields.length; i++) {Element.show(option2_tr_fields[i]);}
	  for (i=0; i<option3_tr_fields.length; i++) {Element.hide(option3_tr_fields[i]);}
	  break;
  }
}
//--------------------------------------------------------------------------------------------------------------------
function showElmTab(cnt,div) {
 document.getElementById("ch_popr_dls").style.display = "none";
 document.getElementById("ch_recd_dls").style.display = "none";
 document.getElementById(div).style.display = "block";
 document.getElementById("ch_popr_tab").className = "";
 document.getElementById("ch_recd_tab").className = "";
 cnt.className = "ch_actv_tab";
}
//--------------------------------------------------------------------------------------------------------------------
