<!-- //

var browserOK = false;
//standard check for the image object - old browsers return false... easy check.
if (document.images) {
  browserOK = true;
}


var min_size = 800;

// Windows

var new_res_string = "";
var res_addcity = "";
var res_addhotel = "";
var res_addground = "";
var url_href = location.href;
var url_parameters = "";
var cg_CityID = "";
var clear_parameters = false;
var ClearCity = false;
var CityInfo = false;
var html_target = "";





function Get_URLparameters(NewParam) {
  url_split = url_href.split(/\?/);
  if (new_res_string != "") {
    url_parameters = new_res_string;
    new_res_string = "";
  }
  else if (clear_parameters == true) {
    url_parameters = "";
  }
  else {
    url_parameters = url_split[1];
  }
  if ((url_parameters == undefined) || (url_parameters == "")) {
    url_parameters = "";
  }
  else {
    param_split = url_parameters.split(/\&/);
    url_parameters = "";
    var pre = "res_";
    for (var i = 0; i <= param_split.length - 1; i++) {
      //alert(param_split[i].substring(0,pre.length));
      if (param_split[i].substring(0,pre.length) == pre) {
        // Add City

        if ((param_split[i].substring(0,pre.length + 6) == pre + "cities") && (res_addcity != "")) {
          url_parameters = url_parameters + param_split[i] + ", " + res_addcity;
          res_addcity = "";
        }
        // Add Hotel
        else if ((param_split[i].substring(0,pre.length + 8) == pre + "comments") && (res_addhotel != "")) {
          //url_parameters = url_parameters + param_split[i] + "%0dHotel: " + res_addhotel;
          url_parameters = url_parameters + param_split[i] + "%0d" + res_addhotel;
          res_addhotel = "";
        }
        // Add Ground
        else if ((param_split[i].substring(0,pre.length + 8) == pre + "comments") && (res_addground != "")) {
          //url_parameters = url_parameters + param_split[i] + "%0dGround: " + res_addground;
          url_parameters = url_parameters + param_split[i] + "%0d" + res_addground;
          res_addground = "";
        }
        // Other
        else {
          url_parameters = url_parameters + param_split[i];
        }
        
        url_parameters = url_parameters + "&";
      }
      else if (param_split[i].substring(0,3) == "cg_") {
        if (cg_CityID != "") {
          if (!ClearCity) {
            url_parameters = url_parameters + "cg_CityID=" + cg_CityID;
            url_parameters = url_parameters + "&";
          }
          cg_CityID = "";
        }
        else {
          if (!ClearCity) {
            url_parameters = url_parameters + param_split[i];
            url_parameters = url_parameters + "&";
          }
        }
        //url_parameters = url_parameters + "&";
      }
      
    }
  }
  if (cg_CityID != "") {
    if (!ClearCity) {
      url_parameters = url_parameters + "cg_CityID=" + cg_CityID;
      url_parameters = url_parameters + "&";
    }
    cg_CityID = "";
  }
  if (res_addcity != "") {
    url_parameters = url_parameters + "res_cities=" + res_addcity + "&"; 
  }
  if (res_addhotel != "") {
    url_parameters = url_parameters + "res_comments=" + res_addhotel + "&"; 
  }
  if (res_addground != "") {
    url_parameters = url_parameters + "res_comments=" + res_addground + "&"; 
  }
  if (CityInfo != false) {
    url_parameters = url_parameters + "info=" + "true" + "&"; 
  }
  if (url_parameters.substring(url_parameters.length-1,url_parameters.length) == "&") {
    url_parameters = url_parameters.substring(0,url_parameters.length-1);
  }
  
}




function href(url) {
  if (url.substring(url.length-1,url.length) == "?") {
    url = url.substring(0,url.length-1);
  }
  url_split = url.split(/\?/);
  if (url.length < 2) {
    sign = "?";
    Get_URLparameters();
  }
  else {
    Get_URLparameters(url_split[1]);
    param_split = url.split(/\=/);
    //alert(param_split);
    if (param_split.length > 1) {
      sign = "&";
    }
    else {
      sign = "?";
    }    
  }
  if (new_res_string != "") { url_parameters = new_res_string; }
  var url2 = url + sign + url_parameters;
  if ((url2.substring(url2.length-1,url2.length) == "&") || (url2.substring(url2.length-1,url2.length) == "?")) {
    url2 = url2.substring(0,url2.length-1);
  }
  //alert(url + question + amp + url_parameters);
  if (html_target != "") {
    url2 = url2 + "#" + html_target;
  }
  document.location=(url2);
}


//windows



function openWindow(url, frame, param) {
  window.open(url, frame, param);
}


function openWindowCentered(url, frame, param) {
  Left = (screen.width / 2) - 200
  Top = (screen.height / 2) - 215
  window.open(url, frame, param + ",left=" + Left + ",top=" + Top);
}


function TravelGuard() {
	window.open("http://www.travelguard.com/agentlink.asp?ta_arc=10516833&pcode=TGE&agencyemail=dan@discoverbraziltours.com","TravelGuard","height=660, width=850, address=yes, resizezble=yes, scrollbars=yes, toolbar=1");
	}
	
function ViewTrip() {
	window.open("http://www.viewtrip.com/ViewTrip.asp","ViewTrip","resizeable=yes, scrollbars=yes, address=yes,toolbar=1");
	}		







// Images

function setImg(obj, img) {
  document.images[obj].src = img;
}


function setBg(obj, img) {
  obj.background = img;
  }


function setThemeImages() {
  setBg(title_bg, imgDir + "/title_" + title + ".jpg");
  setBg(menu_a_bg, imgPath + "/menu_a_bg.gif");
  setImg(menu_a_b, imgPath + "/menu_a_b.gif");
  setBg(menu_b_bg1, imgPath + "/menu_b_bg.gif");
  setBg(menu_b_bg2, imgPath + "/menu_b_bg.gif");
}



function clearReservations() {
  clear_parameters = true;
}




function Submit_Hotels() {

  cg_CityID = document.SearchHotels.CityID.value;

  if (document.SearchHotels.CityID.value != "") {
    param_CityID = ("&CityID=" + document.SearchHotels.CityID.value);
  } else {
  param_CityID = "";
  alert("Please select a city from the list.");
  return;
  }

  if (document.SearchHotels.Prioritize.value == 1) {
    param_Prioritize = ("&Recommended=1");
  } else { param_Prioritize = ""; }
  
  param_form = ("&form_cityid=" + document.SearchHotels.CityID.value + "&form_prioritize=" + document.SearchHotels.Prioritize.checked);
  parameters = (param_CityID + param_Prioritize + param_form)
  search_url = ("/cgi-local/hotels.pl?" + parameters);
  
  href(search_url);

 }





var cities = [
              ["ABA","Abadi&#226;nia"],
              ["AMA","Amazon Jungle Lodges & Cruises"],
              ["ANG","Angra dos Reis"],
              ["AQU","Aquiraz, Cear&aacute;"],
              ["AJU","Aracaj&uacute;"],
              ["ARR","Arraial d&#39;Ajuda"],
              ["BEB","Beberibe, Ceara"],
              ["BEL","Bel&eacute;m"],
              ["BHZ","Belo Horizonte"],
              ["BEN","Bento Gon&ccedil;alves, RS"],
              ["BLU","Blumenau"],
              ["BON","Bonito"],
              ["BSB","Bras&iacute;lia"],    
              ["BUZ","B&uacute;zios"],
			  ["AGO","Cabo de Santo Agostinho"],
              ["CGR","Campo Grande"],
              ["CPQ","Campinas"],
              ["CAM","Campos do Jord&#227;o"],
              ["CAN","Canela"],
              ["CAQ","Canoa Quebrada"],
              ["CAX","Caxias do Sul, RS"],
              ["SAU","Costa do Sau&iacute;pe"],
              ["CGB","Cuiab&aacute;"],
              ["CUM","Cumbuco, Cear&aacute;"],
              ["CWB","Curitiba"],
              ["FEN","Fernando de Noronha"],
              ["FLN","Florian&oacute;polis"],
              ["FOR","Fortaleza"],
              ["IGU","Foz do Igua&ccedil;&uacute;"], 
              ["IGR","Puerto Iguaz&uacute;, Argentina"], 
		      ["GEN","Genipabu"],
		      ["GYN","Goi&#226;nia"],
	    	  ["GRA","Gramado, RS"],
	    	  ["GRU","Guarulhos, SP"],
              ["GUA","Guaruj&aacute;, SP"],
              ["ILH","Ilhabela, SP"],
              ["IOS","Ilh&eacute;us"],
              ["ITC","Itacar&eacute;, Bahia"],
              ["ITA","Itaparica, Bahia"],
              ["JER","Jericoacoara"],
              ["JPA","Jo&#227;o Pessoa"],
              ["MCZ","Macei&oacute;"],
              ["MAO","Manaus"],
              ["MAR","Maragogi, Alagoas"],
              ["MSP","Morro de S&#227;o Paulo, Bahia"],
              ["NAT","Natal"],
              ["OLI","Olinda"],
              ["OUR","Ouro Preto"],
              ["PAN","Pantanal Lodges (norte)"],
              ["PNS","Pantanal Lodges (sul)"],
              ["PAR","Parati"],
              ["PET","Petr&oacute;polis, RJ"],
              ["BPS","Porto Seguro"],
              ["POA","Porto Alegre"],
              ["PTG","Porto de Galinhas"],
              ["PDF","Praia do Forte"],
              ["PIP","Praia da Pipa"],
              ["RAO","Riber&#227;o Preto, SP"],
              ["REC","Recife"],
              ["RIO","Rio de Janeiro"],
              ["QUE","Rio Quente, Caldas Novas"],
              ["STM","Santar&eacute;m"],
              ["SAN","Santos, SP"],
              ["SJR","S&#227;o Jo&#227;o del Rei"],
              ["SLZ","S&#227;o Lu&iacute;s"],
              ["SAO","S&#227;o Paulo"],
              ["SSB","S&#227;o Sebasti&#227;o, SP"],
              ["SSA","Salvador da Bahia","Salvador"],
              ["TER","Teres&oacute;polis, RJ"],
              ["TIB","Tibau do Sul"],
              ["TIR","Tiradentes"],
              ["TRA","Transcoso, Bahia"],
              ["BRC","Bariloche, Argentina","Bariloche"],
              ["BUE","Buenos Aires, Argentina","Buenos Aires"] // NO COMMA
              ];


function Cities_Select() {
  for (var i = 0; i <= cities.length-1; i++) {
    document.write("<OPTION VALUE=\"" + cities[i][0] + "\">" + cities[i][1]);
  }
}


function formcityselect_href(fcs_CityID) {
  cg_CityID=fcs_CityID;
  href('/cgi-local/cityguide.pl');
  return true;
}

function formTransfercityselect_href(fcs_CityID) {
  cg_CityID=fcs_CityID;
  href('/cgi-local/groundservices.pl');
  return true;
}



function openCityPicture(url)  


{
  mywindow = window.open(url, "winCityPhoto", "address=no,status=no,scrollbars=no,resize=no,toolbar=no,menubar=no,width=auto,height=auto,top=150,left=150");
if (window.focus) {mywindow.focus()} 
  
}








var TableNum;




function highliteHotel(s,i) {
  if (browserOK){document.images[s].src=ImgHotelArray[i].src;}
  }


function priceHighlite(tableName) {
  TableNum = 1;
  if (document.all[tableName + '_1'].className == "hotelCell$styleClass; pricingTD2") {
    //this.className='hotelCell$styleClass; pricingTD1';
    	for (TableNum = 1; TableNum <= 6; TableNum++) {
      	document.all[tableName + '_' + TableNum].className = "hotelCell$styleClass; pricingTD1";
      	}
    }
    
    else {
    //this.className='hotelCell$styleClass; pricingTD2';
    for (TableNum = 1; TableNum <= 6; TableNum++) {
      document.all[tableName + '_' + TableNum].className = "hotelCell$styleClass; pricingTD2";
      }
    }
  }



function showHotel(id) {
HotelID = document.getElementById(id);
	if (HotelID.style.display == "none") {
	HotelID.style.display = "";} 
	else {
		HotelID.style.display = "none";}}




function validateForm(form) { //This is the name of the function

if (form.res_user_name.value == "") { //This checks to make sure the field is not empty
   alert("Please fill-in buyer's name."); //Informs user of empty field
   form.res_user_name.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }
   
   if (form.res_user_email.value == "") { //This checks to make sure the field is not empty
   alert("Please fill-in email address."); //Informs user of empty field
   form.res_user_email.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }
   
      if (form.res_user_telephone.value == "") { //This checks to make sure the field is not empty
   alert("Please fill-in telephone."); //Informs user of empty field
   form.res_user_telephone.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }
   
// you may copy the above 5 lines for each form field you wish to validate
// Replace the text "FIELD1" with the name you wish to call the field
}





















// -->