
function getTemplate(template_name, texts)
{
var template
if (template_name == "sfb_table_horizontal") 
	template = ["<div id=\"tiplayer\"  style=\"visibility:hidden;position:absolute;z-index:1000;top:-100;\"></div> ", 
"<form action=\"\" method=\"get\" name=\"frm_sfb_search_box\" id=\"frm_sfb_search_box\">", 
"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" id=\"tbl_sfb_search_box\" >", 
"<tr id=\"tr_top\"><td id=\"td_top\" colspan=\"2\" ><h2>##txt_box_title##</h2></td></tr>", 
"<tr id=\"tr_group\"> ", 
"<td id=\"sfb_button_flight\" class=\"radio\"> <input name=\"sfb_rg_product_type\" id=\"sfb_rg_flight\" type=\"radio\" value=\"flight\" checked /> ##flights_inter##&nbsp;&nbsp;</td>", 
"<td id=\"sfb_button_domestic_flight\" class=\"radio\"> <input name=\"sfb_rg_product_type\"", 
"id=\"sfb_rg_domestic_flight\" type=\"radio\" value=\"domestic_flight\" />", 
"##flights_domes##&nbsp;&nbsp;</td>", 
"</tr>", 
"<tr >", 
"<td id=\"sfb_cell_out\" colspan=\"2\" valign=\"top\" >", 
"<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">", 
"<tr>", 
"<td width=\"35%\" align=\"right\">##depart##</td>", 
"<td width=\"65%\" align=\"left\"><select name=\"cbx_flg_departure_city\" id=\"cbx_flg_departure_city\" class=\"route\"></select>&nbsp;<input id=\"txt_flg_departure_city_title\" value=\"\" name=\"txt_flg_departure_city_title\" class=\"code\"></td>", 
"</tr>", 
"<tr>", 
"<td align=\"right\">##arrival##</td>", 
"<td align=\"left\"><select name=\"cbx_flg_arrival_city\"  id=\"cbx_flg_arrival_city\" class=\"route\"></select>&nbsp;<input id=\"txt_flg_arrival_city_title\" value=\"\" name=\"txt_flg_arrival_city_title\" class=\"code\"></td>", 
"</tr>", 
"<tr>", 
"<td align=\"right\">##flg_type## </td>", 
"<td align=\"left\"><label name=\"lb_flg_round\" id=\"lb_flg_round\" style=\"cursor:pointer\"><input name=\"rg_flg_type\" type=\"radio\" id=\"rg_flg_type\" value=\"R\" checked> ##flg_type_round##</label>", 
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", 
"<label name=\"lb_flg_one\" id=\"lb_flg_one\" style=\"cursor:pointer\"><input type=\"radio\" id=\"rg_flg_type\" name=\"rg_flg_type\" value=\"O\"> ##flg_type_one##</label></td>", 
"</tr>", 
"<tr>", 
"<td align=\"right\">##dep_date##</td>", 
"<td align=\"left\"><input id=\"txt_flg_departure_date\" class=\"time\" value=\"\" name=\"txt_flg_departure_date\" readonly=\"1\">", 
" <img id=\"img_flg_departure_date\" title=\"##msg_date##\"/>", 
" <i>##date##</i> ", 
"<input id=\"departureDate\" value=\"\" name=\"departureDate\" type=\"hidden\"><input id=\"departureMonth\" value=\"\" name=\"departureMonth\" type=\"hidden\"><input id=\"departureYear\" value=\"\" name=\"departureYear\" type=\"hidden\"></td> ", 
"</tr>", 
"<tr id=\"sfb_tr_flg_return_date\"> ", 
"<td align=\"right\">##ret_date##</td> ", 
"<td align=\"left\"><input id=\"txt_flg_return_date\" class=\"time\" value=\"\" name=\"txt_flg_return_date\" readonly=\"1\"> ", 
" <img id=\"img_flg_return_date\" title=\"##msg_date##\"  /> ", 
" <i>##date##</i> ", 
"<input id=\"returnDate\" value=\"\" name=\"returnDate\" type=\"hidden\"><input id=\"returnMonth\"", 
" value=\"\" name=\"returnMonth\" type=\"hidden\"><input id=\"returnYear\" value=\"\" name=\"returnYear\" type=\"hidden\"></td> ", 
"</tr> ", 
"<tr id=\"sfb_tr_class\"> ", 
"<td align=\"right\">##class##</td> ", 
"<td align=\"left\"><select name=\"cbx_flg_class\"  id=\"cbx_flg_class\"> ", 
"<option value=\"\">##any##</option><option value=\"E\">##economy##</option><option value=\"B\">##business##</option><option value=\"F\">##first##</option></select></td> ", 
"</tr> ", 
"<tr> ", 
"<td align=\"center\" colspan=\"2\">##adults##&nbsp; ",
"<select name=\"cbx_flg_number_of_adults\" id=\"cbx_flg_number_of_adults\"> ",
"<option value=\"1\">1</option><option value=\"2\">2</option><option value=\"3\">3</option><option value=\"4\">4</option><option value=\"5\">5</option><option value=\"6\">6</option></select> ",
"<a class=\"help\" onMouseOver=\"showhint(\'##help_adults##\', this, event, \'150px\')\">[?]</a> ",
"&nbsp;##children##&nbsp; ",
"<select name=\"cbx_flg_number_of_children\"  id=\"cbx_flg_number_of_children\"> ",
"<option value=\"0\">0</option><option value=\"1\">1</option><option value=\"2\">2</option><option value=\"3\">3</option></select> ",
"<a class=\"help\" onMouseOver=\"showhint(\'##help_children##\', this, event, \'150px\')\">[?]</a> ",
"&nbsp;<label >##infants##</label><select name=\"cbx_flg_number_of_infants\"  id=\"cbx_flg_number_of_infants\"> ",
"<option value=\"0\">0</option><option value=\"1\">1</option><option value=\"2\">2</option><option value=\"3\">3</option></select> ",
"<a class=\"help\" onMouseOver=\"showhint(\'##help_infants##\', this, event, \'250px\')\">[?]</a></td> ",
"</tr> ",
"<tr id=\"sfb_tr_curr\"><td align=\"right\">##curr##</td><td align=\"left\"><select name=\"cbxCurr\" id=\"cbxCurr\"></select></td></tr> ",
"<tr id=\"tr_ct\" style=\"display:none\"><td id=\"td_ctt\" align=\"right\">##txt_client_type##</td> ",
"<td id=\"td_ct\" align=\"left\"> <select name=\"ClientType\" id=\"ClientType\"></select></td></tr> ",
"<tr id=\"tr_ac\" style=\"display:none\"><td id=\"td_act\" align=\"right\">##txt_a_code##</td> ",
"<td id=\"td_ac\" align=\"left\"> <input name=\"AccessCode\" id=\"AccessCode\" type=\"text\" value=\"\"> <a id=\"ta_link\" style=\"display:none\" href=\"#\">##txt_ta_link##</a></td></tr> ",
"<tr id=\"tr_bottom\"> ",
"<td></td> ",
"<td align=\"left\"><input name=\"btn_search_flight\" id=\"btn_search_flight\" type=\"button\" class=\"button\" value=\"##button_label##\"></td> ",
"</tr> ",
"</table> ",
"</td></tr></table> ",
"</form><div style=\"visibility:hidden;display:none;\"><form action=\"\" method=\"get\" id=\"frm_sfb_search_box_info\" name=\"frm_sfb_search_box_info\" style=\"visibility:none\" ></form></div>"];

else if (template_name == "sfb_table_vertical") 
	template = ["<div id=\"tiplayer\" style=\"visibility:hidden;position:absolute;z-index:1000;top:-100;\"></div> ",
"<form action=\"\" method=\"get\" name=\"frm_sfb_search_box\" id=\"frm_sfb_search_box\"> ",
"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" id=\"tbl_sfb_search_box\"  > ",
"<tr id=\"tr_top\"><td id=\"td_top\" colspan=\"4\" ><h2>##txt_box_title##</h2></td></tr> ",
"<tr id=\"tr_group\"> ",
"<td id=\"sfb_button_flight\" class=\"radio\"> <input name=\"sfb_rg_product_type\" id=\"sfb_rg_flight\" type=\"radio\" value=\"flight\" checked /></td> ",
"<td class=\"label_radio\">##flights_inter##</td> ",
"<td id=\"sfb_button_domestic_flight\" class=\"radio\"> <input name=\"sfb_rg_product_type\" id=\"sfb_rg_domestic_flight\" type=\"radio\" value=\"domestic_flight\" /></td> ",
"<td class=\"label_radio\">##flights_domes##</td> ",
"</tr> ",
"<tr > ",
"<td id=\"sfb_cell_out\" colspan=\"4\" valign=\"top\" > ",
"<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> ",
"<tr> ",
"<td width=\"40%\" align=\"right\" id=\"departure_city\">##depart##&nbsp;</td> ",
"<td width=\"60%\" align=\"left\"><select name=\"cbx_flg_departure_city\" id=\"cbx_flg_departure_city\" class=\"route\"></select>&nbsp;<input id=\"txt_flg_departure_city_title\" value=\"\" name=\"txt_flg_departure_city_title\" class=\"code\"></td> ",
"</tr> ",
"<tr> ",
"<td align=\"right\">##arrival##&nbsp;</td> ",
"<td align=\"left\"><select name=\"cbx_flg_arrival_city\"  id=\"cbx_flg_arrival_city\" class=\"route\"></select>&nbsp;<input id=\"txt_flg_arrival_city_title\" value=\"\" name=\"txt_flg_arrival_city_title\" class=\"code\"></td> ",
"</tr> ",
"<tr> ",
"<td align=\"center\" colspan=\"2\" valign=\"absmiddle\">##flg_type## &nbsp;<label name=\"lb_flg_round\" id=\"lb_flg_round\" style=\"cursor:pointer\"><input name=\"rg_flg_type\" type=\"radio\" id=\"rg_flg_type\" value=\"R\" checked> ##flg_type_round##</label> ",
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ",
"<label name=\"lb_flg_one\" id=\"lb_flg_one\" style=\"cursor:pointer\"><input type=\"radio\" id=\"rg_flg_type\" name=\"rg_flg_type\" value=\"O\"> ##flg_type_one##</label></td> ",
"</tr> ",
"<tr> ",
"<td align=\"right\">##dep_date##&nbsp;</td> ",
"<td align=\"left\"><input id=\"txt_flg_departure_date\" class=\"time\" value=\"\" name=\"txt_flg_departure_date\" readonly=\"1\"> ",
"<img id=\"img_flg_departure_date\" title=\"##msg_date##\"/> ",
"<i>##date##</i> ",
"<input id=\"departureDate\" value=\"\" name=\"departureDate\" type=\"hidden\"><input id=\"departureMonth\" value=\"\" name=\"departureMonth\" type=\"hidden\"><input id=\"departureYear\" value=\"\" name=\"departureYear\" type=\"hidden\"></td> ",
"</tr> ",
"<tr id=\"sfb_tr_flg_return_date\"> ",
"<td align=\"right\">##ret_date##&nbsp;</td> ",
"<td align=\"left\"><input id=\"txt_flg_return_date\" class=\"time\" value=\"\" name=\"txt_flg_return_date\" readonly=\"1\"> ",
"<img id=\"img_flg_return_date\" title=\"##msg_date##\"  /> ",
"<i>##date##</i> ",
"<input id=\"returnDate\" value=\"\" name=\"returnDate\" type=\"hidden\"><input id=\"returnMonth\" value=\"\" name=\"returnMonth\" type=\"hidden\"><input id=\"returnYear\" value=\"\" name=\"returnYear\" type=\"hidden\"></td> ",
"</tr> ",
"<tr id=\"sfb_tr_class\"> ",
"<td align=\"right\">##class##&nbsp;</td> ",
"<td align=\"left\"><select name=\"cbx_flg_class\"  id=\"cbx_flg_class\"> ",
"<option value=\"\">##any##</option><option value=\"E\">##economy##</option><option value=\"B\">##business##</option><option value=\"F\">##first##</option></select></td> ",
"</tr> ",
"<tr> ",
"<td align=\"center\" colspan=\"4\"> ",
"<table width=\"100%\" border=\"0\"> ",
"<tr> ",
"<td class=\"passengers\" width=\"15%\" aling=\"center\">&nbsp;</td> ",
"<td class=\"passengers\" width=\"25%\" aling=\"center\">##adults##</td> ",
"<td class=\"passengers\" width=\"25%\" aling=\"center\">##children##</td> ",
"<td class=\"passengers\" width=\"35%\" aling=\"center\">##infants##</td> ",
"</tr> ",
"<tr> ",
"<td width=\"15%\" aling=\"center\">&nbsp;</td> ",
"<td width=\"25%\" aling=\"center\"> ",
"<select name=\"cbx_flg_number_of_adults\" id=\"cbx_flg_number_of_adults\"> ",
"<option value=\"1\">1</option><option value=\"2\">2</option><option value=\"3\">3</option><option value=\"4\">4</option><option value=\"5\">5</option><option value=\"6\">6</option></select> ",
"<a class=\"help\" onMouseOver=\"showhint(\'##help_adults##\', this, event, \'150px\')\">[?]</a> ",
"</td> ",
"<td width=\"25%\" aling=\"center\"> ",
"<select name=\"cbx_flg_number_of_children\"  id=\"cbx_flg_number_of_children\"> ",
"<option value=\"0\">0</option><option value=\"1\">1</option><option value=\"2\">2</option><option value=\"3\">3</option></select> ",
"<a class=\"help\"  onMouseOver=\"showhint(\'##help_children##\', this, event, \'150px\')\">[?]</a> ",
"</td> ",
"<td width=\"35%\" aling=\"center\"> ",
"<select name=\"cbx_flg_number_of_infants\"  id=\"cbx_flg_number_of_infants\"> ",
"<option value=\"0\">0</option><option value=\"1\">1</option><option value=\"2\">2</option><option value=\"3\">3</option></select> ",
"<a class=\"help\" onMouseOver=\"showhint(\'##help_infants##\', this, event, \'250px\')\">[?]</a></td> ",
"</td> ",
"</tr> ",
"</table> ",
"</td> ",
"</tr> ",
"<tr id=\"sfb_tr_curr\"><td align=\"right\">##curr##&nbsp;</td><td align=\"left\"><select name=\"cbxCurr\" id=\"cbxCurr\"></select></td></tr> ",
"<tr id=\"tr_ct\" style=\"display:none\"><td id=\"td_ctt\" align=\"right\">##txt_client_type##</td> ",
"<td id=\"td_ct\" align=\"left\"> <select name=\"ClientType\" id=\"ClientType\"></select></td></tr> ",
"<tr id=\"tr_ac\" style=\"display:none\"><td id=\"td_act\" align=\"right\">##txt_a_code##</td> ",
"<td id=\"td_ac\" align=\"left\"> <input name=\"AccessCode\" id=\"AccessCode\" type=\"text\" value=\"\"> <a id=\"ta_link\" style=\"display:none\" href=\"#\">##txt_ta_link##</a></td></tr> ",
"<tr id=\"tr_bottom\"> ",
"<td></td> ",
"<td><input name=\"btn_search_flight\" id=\"btn_search_flight\" type=\"button\" class=\"button\" value=\"##button_label##\"></td> ",
"</tr> ",
"</table> ",
"</td></tr></table> ",
"</form><div style=\"visibility:hidden;display:none;\"><form action=\"\" method=\"get\" id=\"frm_sfb_search_box_info\" name=\"frm_sfb_search_box_info\" style=\"visibility:none\" ></form></div>"];
	var templateText = template.join("");
	for (var i = 0; i < texts.length; i++) 
		while (templateText.indexOf(texts[i][0]) != -1)
			templateText = templateText.replace(texts[i][0], texts[i][1]);
	return (templateText);
}	

var ctn_languages = new Array("en", "fr", "de", "es", "it", "nl");
var ctn_currencies_default = new Array("AUD", "CAD","EUR","GBP","JPY", "USD");
var ctn_countries = new Array("CUB", "DOM");

if (typeof commercial_client_code == 'undefined') {commercial_client_code = "";}
if (typeof point_of_sale == 'undefined') {point_of_sale = "";}
if (typeof commercial_client_type == 'undefined') {commercial_client_type = "";}
if (typeof ctn_affiliate_id == 'undefined') {ctn_affiliate_id = "";}
if (typeof reseller_id == 'undefined') {reseller_id = "";}

if (typeof ctn_box_mode== 'undefined' ) {ctn_box_mode= "book-ol";}
if (typeof ctn_title== 'undefined' ) {ctn_title= "";}
if (typeof ctn_color_dark== 'undefined' )  ctn_color_dark= "#000000"; 
if (typeof ctn_color_medium== 'undefined' )  ctn_color_medium= "#097864";
if (typeof ctn_color_clear== 'undefined' )  ctn_color_clear= "#ffffff";
if (typeof ctn_currencies == 'undefined') {ctn_currencies = ctn_currencies_default;} 
if (typeof ctn_add_currencies != 'undefined') {ctn_currencies = ctn_currencies.concat(ctn_add_currencies);}
if (typeof ctn_currency== 'undefined' ) ctn_currency= "EUR";
if (typeof ctn_language== 'undefined' ) ctn_language= "en";
if (typeof ctn_release_time == 'undefined') {ctn_release_time = 5;}
if (typeof ctn_min_booking_time == 'undefined') {ctn_min_booking_time = 1;}
if (typeof ctn_site_name== 'undefined' ) { ctn_site_name= "";}
if (typeof ctn_site_from== 'undefined' ) ctn_site_from= "http://www.fast-manager.com";
if (typeof ctn_template== 'undefined' ) ctn_template= "sfb_table_horizontal";
if (typeof ctn_use_external_css== 'undefined' ) ctn_use_external_css= "0";
if (typeof ctn_width== 'undefined' ) ctn_width= "100%"; 
if (typeof ctn_refering_url== 'undefined' ) ctn_refering_url= ""; 

if (typeof ctn_country == 'undefined') {ctn_country = "CUB";}
if (typeof ctn_departure_city == 'undefined') {ctn_departure_city = "";}
if (typeof ctn_arrival_city == 'undefined') {ctn_arrival_city = "";}
if (typeof ctn_show_city_code == 'undefined') {ctn_show_city_code = "0";}
if (typeof ctn_group_id == 'undefined') {ctn_group_id = 'International';}
if (typeof ctn_airline == 'undefined') {ctn_airline = "";}

if (typeof ctn_trade_mark == 'undefined') {ctn_trade_mark = "CUBA TRAVEL NETWORK";}

if (typeof ctn_show_group== 'undefined' )  {ctn_show_group= "1";}; 
if (typeof ctn_show_class== 'undefined' )  {ctn_show_class= "1";}; 
if (typeof ctn_show_title== 'undefined' )  {ctn_show_title= "0";}; 
if (typeof ctn_show_currency == 'undefined') {ctn_show_currency = "1";}
if (typeof ctn_show_commercial_client_type == 'undefined') {ctn_show_commercial_client_type = "0";}

if (typeof ctn_contact_us_ta_link== 'undefined') {ctn_contact_us_ta_link = "";}

//BCC Area
if ((typeof currencyCode != 'undefined') && (ctn_currency == "USD")) {ctn_currency = currencyCode;}
if ((typeof show_currency != 'undefined') && (ctn_show_currency == "1")) {ctn_show_currency = show_currency;}
if ((typeof show_currencies != 'undefined') && (ctn_show_currency == "1")) {if (show_currencies == true) ctn_show_currency = "1";}
//var showOfficeID = 0 //param eliminado 

var ctn_test_sever = "http://site4.fast-manager.com"
if (ctn_test_sever.toLowerCase() == ctn_site_from.toLowerCase()) {ctn_box_mode= "test";}

//la url de reserva se forma 
var book_url = "http://secure." + ctn_trade_mark.split(" ").join("").toLowerCase() + ".com/get_availability.aspx";
//var test_url = "http://site12.fast-manager.com/bookings/get_availability.aspx";

//se busca si el idioma definido está dentro del areglo, si no se establece EN
for(var i = 0; i < ctn_languages.length; i ++) if(ctn_language == ctn_languages[i]) break;
ctn_language = (i < ctn_languages.length) ? ctn_languages[i] : "en";

//se busca si el pais definida está dentro del arreglo, si no se establece CUB
ctn_country = ctn_country.toUpperCase();
for(var i = 0; i < ctn_countries.length; i ++) if(ctn_country == ctn_countries[i]) break;
ctn_country = (i < ctn_countries.length) ? ctn_countries[i] : "CUB";

var ctn_exclusion_currency = "";
var ctn_default_currency = "USD";

if (ctn_country == "CUB") {
	ctn_exclusion_currency = "USD";
	ctn_default_currency = "EUR";
}

for(var i = 0; i < ctn_currencies.length; i ++) if((ctn_currency == ctn_currencies[i]) && (ctn_currency != ctn_exclusion_currency)) break;
ctn_currency = (i < ctn_currencies.length) ? ctn_currencies[i] : ctn_default_currency;

document.writeln('<link href="' + ctn_site_from + '\/comun\/styles\/helphint.css" rel="stylesheet" type="text\/css">\r\n');
if (ctn_use_external_css == "0") {
	document.writeln('<link href="' + ctn_site_from + '\/comun\/styles\/sbf_search_box.css" rel="stylesheet" type="text\/css">\r\n');
	document.writeln('<link href="' + ctn_site_from + '\/comun\/calendar\/cars/calendar.css" rel="stylesheet" type="text\/css">\r\n');
}
sfb_load_script(ctn_site_from + "\/comun\/calendar\/calendar.js");
sfb_load_script(ctn_site_from + "\/comun\/calendar\/calendar-"+ ctn_language +".js");
sfb_load_script(ctn_site_from + "\/comun\/calendar\/calendar-setup.js");
sfb_load_script(ctn_site_from + "\/comun\/scripts\/date_en.js");
sfb_load_script(ctn_site_from + "\/comun\/scripts\/main15.js");
sfb_load_script(ctn_site_from + "\/comun\/scripts\/helphint.js");

var rnd_p = Math.random();
if (ctn_airline == "" ) 
	sfb_load_script(ctn_site_from + "\/comun\/data\/searchbox_flg\/sfb_jsdata_" + ctn_country + "_" + ctn_language + ".js?p=" + rnd_p);
else if (ctn_airline == 'aerocaribbean' || ctn_airline == 'aerodomca')
	sfb_load_script(ctn_site_from + "\/comun\/data\/searchbox_flg\/sfb_jsdata_" + ctn_airline + "_" + ctn_language + ".js?p=" + rnd_p);
else
	sfb_load_script(ctn_site_from + "\/comun\/scripts\/sfb_get.js.asp?language_id=" + ctn_language + "&country_id=" + ctn_country + "&ctn_airline=" + ctn_airline);


//	Valor inicial para las fechas de salida y arribo
var sfb_flg_curDate = new Date(); 
var sfb_min_flg_departure_date 	= new Date(sfb_flg_curDate.valueOf() + (ctn_release_time)*24*60*60*1000);
var sfb_min_flg_return_date		= new Date(sfb_flg_curDate.valueOf() + (ctn_release_time + ctn_min_booking_time)*24*60*60*1000);

var TipId="tiplayer"; // should be the same as <div> tag's id
function sfb_help(t,m){
  var Text=[t,m];
  var Style=["#FFFFFF","#005EA6","","","Verdana, Arial, Helvetica, sans-serif",,"black","#E2F2FE","","","Verdana, Arial, Helvetica, sans-serif",,,,2,"#005EA6",2,24,0.5,0,2,"gray",,0,20,20];
  stm(Text,Style);  
}

function sfb_paintform_innerElement(elementId){
	document.getElementById(elementId).innerHTML = getTemplate(ctn_template,_ft);
	sfb_initializeSearchBox();
	setBox();
}

function sfb_load_script(src_script) {
	var scripts_loaded;
	var found = false;
	scripts_loaded = document.getElementsByTagName("script");
	for (var i= 0; i < scripts_loaded.length && !found ; i++) {
		if (scripts_loaded[i].src.slice(scripts_loaded[i].src.lastIndexOf("/")) == src_script.slice(src_script.lastIndexOf("/"))) {
			found = true;
		}
	}
	if (!found){ document.writeln('<script type="text\/javascript" src="' + src_script + '"><\/script>\r\n');}
}

function sfb_populateSelect(selectId, x, v, f, d)
{
	document.getElementById(selectId).innerHTML = "";
	for (i=0;i<x.length;i++)
		for (j=0;j<x[i][2].length;j++)
			if ((x[i][2][j] == f ) || (f == "") || (x[i][0] == d )) {
				var optionElement = document.createElement('OPTION');
				optionElement.setAttribute('value', x[i][0]);
				if ((x[i][1] == v ) || (x[i][0] == d )) optionElement.setAttribute('selected', 'true');
				optionElement.innerHTML = x[i][1];
				document.getElementById(selectId).appendChild(optionElement);
				j = x[i][2].length;
			}
}

function sort_array(x, l){
	for (var i=0; i < x.length; i++)
		for (var j=i+1; j < x.length; j++)
			if ((x[i][l][3] > x[j][l][3]) || ((x[i][l][3] == x[j][l][3]) && (x[i][l][2] > x[j][l][2])))
				{var tmp = x[j]; x[j] = x[i];  x[i] = tmp;}
	return (x);
}

function find_array(x, l){
	var found = false;
	for (var i=0; i < x.length && !found; i++) if (x[i].value == l) found = true;
	return (found);
}

function sfb_populate_DepartureSelect(selectId, x, y, d){
	document.getElementById(selectId).innerHTML = "";
	
	// Poniendo Select a destination como primer item del select
	var optionElementSelect = document.createElement('OPTION');
	optionElementSelect.setAttribute('value', '');
	if (d == '') optionElementSelect.setAttribute('selected', 'true');
	optionElementSelect.innerHTML = option_select;
	document.getElementById(selectId).appendChild(optionElementSelect);		
	
	var prevValue = String("");
	x = sort_array(x, 0);
	for (i=0; i < x.length; i++)
		if ((x[i][2][0] == y) && (!find_array(document.getElementById(selectId).options, x[i][0][0]))){
			if (prevValue != x[i][0][3]) {
				prevValue = x[i][0][3];
				var optionGroup = document.createElement('OPTGROUP');
				optionGroup.setAttribute('label', x[i][0][3]);
				document.getElementById(selectId).appendChild(optionGroup);							
			}
			var optionElement = document.createElement('OPTION');
			optionElement.setAttribute('value', x[i][0][0]);
			var theData = document.createTextNode(x[i][0][2]);
			if ((x[i][0][0] == d) || (x[i][0][1] == d)) optionElement.setAttribute('selected', 'true');
			optionElement.appendChild(theData);
			optionGroup.appendChild(optionElement);
		}
}

function sfb_populate_ArrivalSelect(selectId, x, y, d, o){
	document.getElementById(selectId).innerHTML = "";
	
	var optionElementSelect = document.createElement('OPTION');
	optionElementSelect.setAttribute('value', '');
	var theDataSelect = document.createTextNode(option_select);
	if (d == '') optionElementSelect.setAttribute('selected', 'true');
	optionElementSelect.appendChild(theDataSelect);
	document.getElementById(selectId).appendChild(optionElementSelect);			
	
	var prevValue = String("");
	x = sort_array(x, 1);
	for (i=0; i < x.length; i++)
		if ((x[i][2][0] == y) && (x[i][0][0] == o) && (!find_array(document.getElementById(selectId).options, x[i][1][0]))) {
			if (prevValue != x[i][1][3]) {
				prevValue = x[i][1][3];
				var optionGroup = document.createElement('OPTGROUP');
				optionGroup.setAttribute('label', x[i][1][3]);
				document.getElementById(selectId).appendChild(optionGroup);
			}
			var optionElement = document.createElement('OPTION');
			optionElement.setAttribute('value', x[i][1][0]);
			var theData = document.createTextNode( x[i][1][2]);
			if ((x[i][1][0] == d) || (x[i][1][1] == d)) optionElement.setAttribute('selected', 'true');
			optionElement.appendChild(theData);
			optionGroup.appendChild(optionElement);
		}
}


//	Funcion para alternar entre vuelos hacia y desde Cuba y domesticos
function sfb_show_product_type(product_type)
{
    
	if ((product_type=='flight') && (pt_flights > 0)){
	    ctn_group_id = 'International';
		sfb_populate_DepartureSelect('cbx_flg_departure_city', _r, ctn_group_id, ctn_departure_city)
		sfb_populate_ArrivalSelect('cbx_flg_arrival_city', _r, ctn_group_id, ctn_arrival_city, document.frm_sfb_search_box.cbx_flg_departure_city.value);
		if (ctn_use_external_css == "0") {
			document.getElementById("sfb_button_flight").style.backgroundColor  = ctn_color_dark;
			document.getElementById("sfb_button_flight").style.border  = "1px solid " + ctn_color_dark;
			document.getElementById("sfb_button_domestic_flight").style.backgroundColor  = ctn_color_medium;
			document.getElementById("sfb_button_domestic_flight").style.border  = "1px solid " + ctn_color_medium;
		}
		document.getElementById('sfb_rg_flight').checked = true;
	}
	if ((product_type=='domestic_flight') && (pt_dflights > 0)){
		ctn_group_id = 'Domestic';
		sfb_populate_DepartureSelect('cbx_flg_departure_city', _r, ctn_group_id, ctn_departure_city)
		sfb_populate_ArrivalSelect('cbx_flg_arrival_city', _r, ctn_group_id, ctn_arrival_city, document.frm_sfb_search_box.cbx_flg_departure_city.value);
		if (ctn_use_external_css == "0") {
			document.getElementById("sfb_button_flight").style.backgroundColor  = ctn_color_medium;
			document.getElementById("sfb_button_flight").style.border  = "1px solid " + ctn_color_medium;
			document.getElementById("sfb_button_domestic_flight").style.backgroundColor  = ctn_color_dark;
			document.getElementById("sfb_button_domestic_flight").style.border  = "1px solid " + ctn_color_dark;
		}
		document.getElementById('sfb_rg_domestic_flight').checked = true;
	}
}

function sfb_flg_departure_date_status(date) { 
	return (date.getTime() < new Date(sfb_min_flg_departure_date.valueOf() - 24*60*60*1000).getTime());
}

function sfb_flg_arrival_date_status(date) { 
	return (date.getTime() < new Date(sfb_min_flg_return_date.valueOf() - 24*60*60*1000).getTime());
}

function sfb_synchronize_flg_calendars(cal) {
	var f = document.getElementById("frm_sfb_search_box");
	if ((getDateFromFormat(f.txt_flg_return_date.value,'d/M/y') - getDateFromFormat(f.txt_flg_departure_date.value,'d/M/y')) < ctn_min_booking_time *24*60*60*1000) {
		var toUpdateField = f.txt_flg_departure_date;
		if (toUpdateField == cal.params.inputField) {
			tempDate = new Date(cal.date.getTime() + ctn_min_booking_time *24*60*60*1000);
			var complete_return = tempDate.getDate() + "/";
			if (tempDate.getDate()<10) 
			   complete_return = "0" + complete_return;
			if ((tempDate.getMonth() + 1)<10)
			    complete_return  = complete_return + "0"  + (tempDate.getMonth() + 1) + "/";
			else
			    complete_return  = complete_return + (tempDate.getMonth() + 1) + "/";
			complete_return  = complete_return + tempDate.getFullYear();
			f.txt_flg_return_date.value = complete_return;
			f.returnDate.value  = tempDate.getDate();
			f.returnMonth.value = tempDate.getMonth() + 1;
			f.returnYear.value  = tempDate.getFullYear();
		} else {
			tempDate = new Date(cal.date.getTime() - ctn_min_booking_time *24*60*60*1000);
			var complete_depart = tempDate.getDate() + "/";
			if (tempDate.getDate()<10) 
			   complete_depart = "0" + complete_depart;
			if ((tempDate.getMonth() + 1)<10)
			    complete_depart  = complete_depart + "0"  + (tempDate.getMonth() + 1) + "/";
			else
			    complete_depart  = complete_depart + (tempDate.getMonth() + 1) + "/";
			complete_depart  = complete_depart + tempDate.getFullYear();
			f.txt_flg_departure_date.value = complete_depart;
			f.departureDate.value 	= tempDate.getDate();
			f.departureMonth.value = tempDate.getMonth() + 1;
			f.departureYear.value 	= tempDate.getFullYear();
		}
	}
}

function sfb_flg_departure_date_changed(calendar) {
	if (calendar.dateClicked) {
		var f = document.getElementById("frm_sfb_search_box");
		f.departureYear.value  	= calendar.date.getFullYear();
		f.departureMonth.value 	= calendar.date.getMonth() + 1;
		f.departureDate.value   = calendar.date.getDate();
		sfb_synchronize_flg_calendars(calendar);
	}
}

function sfb_flg_return_date_changed(calendar) {
	if (calendar.dateClicked) {
		var f = document.getElementById("frm_sfb_search_box");
		f.returnYear.value  	= calendar.date.getFullYear();
		f.returnMonth.value 	= calendar.date.getMonth() + 1;
		f.returnDate.value   	= calendar.date.getDate();
		sfb_synchronize_flg_calendars(calendar);
	}
}

function sfb_change_flg_type(flight_type) {
	if (flight_type=='return_flight'){
		document.frm_sfb_search_box.rg_flg_type[0].checked				= true;
		document.getElementById('sfb_tr_flg_return_date').style.display 	= "";
	}
	else{
		document.frm_sfb_search_box.rg_flg_type[1].checked				= true;
		document.getElementById('sfb_tr_flg_return_date').style.display 	= "none";
	}
}

function sfb_commercial_client_type_changed() {
	var f = document.getElementById("frm_sfb_search_box");
	var _ct = f.ClientType.value;
	if ((_ct.toUpperCase() == "TravelAgency".toUpperCase()) || (_ct.toUpperCase() == "Turoperator".toUpperCase())) {
		setStyleDisplay("tr_ac", "")
	} else { 
		setStyleDisplay("tr_ac", "none")
	}
}


//	Funcion para crear los campos que se van a enviar a la página de SFB
function sfb_populatePhantomForm(formId, arrIdVal)
{
	for (i=0;i<arrIdVal.length;i=i+2)
	{
		var optionElement = document.createElement('INPUT');
		optionElement.setAttribute('id', arrIdVal[i]);
		optionElement.setAttribute('name', arrIdVal[i]);
		optionElement.setAttribute('value', arrIdVal[i+1]);
		document.getElementById(formId).appendChild(optionElement);
	}

}


function setStyleDisplay(elementId, displayValue) {
	var e;
	if (e = document.getElementById(elementId)) e.style.display= displayValue;	
}


//	Funcion que toma todos los valores del formulario de busqueda y rellena los del formulario de enviar informacion 
//	Envia solo los campos requeridos por SFB
function sfb_searchFlight() {
	
var theURL = 'http://www.netssa.com/timer_flights.html';
var width  = 500;
var height = 400;
newWindow = window.open(theURL,'newWindow','toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no,width='+width+',height='+height);


    var error = false;	
	var submit_data = true;
	f_i = document.getElementById("frm_sfb_search_box_info");
	f = document.getElementById("frm_sfb_search_box");
	
	var need_typed_a_code = ((f.ClientType.value.toUpperCase() == "TravelAgency".toUpperCase()) ||
		(f.ClientType.value.toUpperCase() == "Turoperator".toUpperCase()));
	
	if((!error) && (f.AccessCode.value == "") && (need_typed_a_code))
	{
		alert(msg_a_code);
		f.AccessCode.focus();
		error = true;
	}	
	
	if((!error) && (f.cbx_flg_departure_city.value == ""))
	{
		alert(msg_departure_city);
		f.cbx_flg_departure_city.focus();
		error = true;
	}
	
	if((!error) && (f.cbx_flg_arrival_city.value == ""))
	{
		alert(msg_arrival_city);
		f.cbx_flg_arrival_city.focus();
		error = true;
	}	

	if(!error)
    {
		if (ctn_show_city_code == 1 && f.txt_flg_departure_city_title.value.replace(" ","").length == 3)
		   f_i.DeptAirPort.value = f.txt_flg_departure_city_title.value;
		else   
		   f_i.DeptAirPort.value = f.cbx_flg_departure_city.value;
		   
		if (ctn_show_city_code == 1 && f.txt_flg_arrival_city_title.value.replace(" ","").length == 3)
		   f_i.DestAirPort.value = f.txt_flg_arrival_city_title.value;
		else   
		   f_i.DestAirPort.value = f.cbx_flg_arrival_city.value;
		   
		f_i.departureDate.value = f.departureDate.value;
		f_i.departureMonth.value = f.departureMonth.value;
		f_i.departureYear.value = f.departureYear.value;
		f_i.Class.value = f.cbx_flg_class.value;
		
		if (f.rg_flg_type[0].checked){
			f_i.OR.value = "R";
	
			f_i.returnDate.value = f.returnDate.value;
			f_i.returnMonth.value = f.returnMonth.value;
			f_i.returnYear.value = f.returnYear.value;
		}
		else {
			f_i.OR.value = "O";
	
			f_i.returnDate.value = "";
			f_i.returnMonth.value = "";
			f_i.returnYear.value = "";
		}
		
		if (f.sfb_rg_product_type[0].checked) {f_i.FlightType.value = "International";}	else {f_i.FlightType.value = "Domestic";}
		
		f_i.Adults.value = f.cbx_flg_number_of_adults.value;
		f_i.Children.value = f.cbx_flg_number_of_children.value;
		f_i.Infants.value = f.cbx_flg_number_of_infants.value;
	
		f_i.CurrCode.value = f.cbxCurr.value;
	
		f_i.commercial_client_type.value = f.ClientType.value ;
		if (need_typed_a_code) {
			f_i.commercial_client_code.value = f.AccessCode.value; 
		} else if (f.ClientType.value.toUpperCase() == "CTN".toUpperCase()) f_i.commercial_client_code.value = "ctn";
	
		if (ctn_refering_url != '') f_i.refSite.value = ctn_refering_url; else f_i.refSite.value = parent.location ? parent.location : window.location;
		if (ctn_box_mode == "book-ol") frmAction = book_url;
		if (ctn_box_mode == "test") {
			frmAction = test_url;
			var msg_test = "Testing Mode"
			msg_test = msg_test + "\n----------------------------------------------------";
			msg_test = msg_test + "\nURL:" + frmAction;
			for (var i = 0; i < f_i.length; i++) {
				msg_test = msg_test + "\n" + f_i.elements[i].name + ": " + f_i.elements[i].value;
			}
			msg_test = msg_test + "\n----------------------------------------------------";
			msg_test = msg_test + "\nSubmit data?";
			submit_data = window.confirm (msg_test);
		}
	
		f_i.action = frmAction;
		if (submit_data) f_i.submit();
	}

}

function sfb_initializeSearchBox(){
   
	Calendar.setup({
	inputField     :    "txt_flg_return_date",     
	ifFormat       :    "%d/%m/%Y",     
	button         :    "img_flg_return_date",  
	align          :    "B1",           
	singleClick    :    true,
	electric       :    false,
	onUpdate       :    sfb_flg_return_date_changed,
	dateStatusFunc :    sfb_flg_arrival_date_status	
	});

	Calendar.setup({
	inputField     :    "txt_flg_departure_date",     
	ifFormat       :    "%d/%m/%Y",     
	button         :    "img_flg_departure_date", 
	align          :    "B1",          
	singleClick    :    true,
	electric       :    false,
	onUpdate       :    sfb_flg_departure_date_changed,
	dateStatusFunc :    sfb_flg_departure_date_status	
	});

    var searchflights_box
	searchflights_box = document.getElementById("tbl_sfb_search_box");
	elements = searchflights_box.getElementsByTagName("A");
	for (i=0; i < elements.length; i++) {
	    if (elements[i].className == "help") {
		    elements[i].href = "#";
			elements[i].onmouseout = function(){htm()};
		}
	}
	
	searchflights_box.width = ctn_width;
	if (ctn_use_external_css == "0") {
		document.getElementById("td_top").style.backgroundColor = ctn_color_dark;
		document.getElementById("td_top").style.border = "1px solid " + ctn_color_dark;
	
//		document.getElementById("td_bottom").style.backgroundColor = ctn_color_medium;

		document.getElementById("img_flg_departure_date").style.border= "1px solid " + ctn_color_dark;
		document.getElementById("img_flg_return_date").style.border= "1px solid " + ctn_color_dark;
		document.getElementById("sfb_cell_out").style.border  = "1px solid " + ctn_color_dark;
		document.getElementById("sfb_cell_out").style.backgroundColor  = ctn_color_clear;
		document.getElementById("btn_search_flight").style.border  = "1px solid " + ctn_color_dark;
		document.getElementById("btn_search_flight").style.backgroundColor  =  ctn_color_dark;
	}
	document.getElementById('txt_flg_departure_city_title').maxLength = "3";
	document.getElementById('txt_flg_arrival_city_title').maxLength = "3";
	document.getElementById('txt_flg_departure_city_title').style.width = "3em"
	document.getElementById('txt_flg_arrival_city_title').style.width = "3em"
	
	document.getElementById('img_flg_departure_date').src = ctn_site_from + "\/comun\/calendar/img.gif";
	document.getElementById('img_flg_return_date').src = ctn_site_from + "\/comun\/calendar/img.gif";

	if (ctn_title != "") {document.getElementById("td_top").innerHTML = "<h2>" + ctn_title + "</h2>";}
	
	if (ctn_show_title == "0") {setStyleDisplay("tr_top", "none");} else {setStyleDisplay("tr_top", "");}
	
	if (ctn_show_currency == "1") {setStyleDisplay('sfb_tr_curr', '');} else {setStyleDisplay('sfb_tr_curr', 'none');}
	   	   
	if (ctn_show_city_code == 0) {
		setStyleDisplay('txt_flg_departure_city_title', 'none');
		setStyleDisplay('txt_flg_arrival_city_title', 'none');
	} else {
		setStyleDisplay('txt_flg_departure_city_title', '');
		setStyleDisplay('txt_flg_arrival_city_title', '');
	}
	
	for (var j=0; j < ctn_currencies.length; j++){
		cur_found = false;
		for (var y=0; y < currency_array.length && !cur_found; y++) cur_found = (ctn_currencies[j]==currency_array[y][0]);
		if ((!cur_found) && (ctn_currencies[j] != ctn_exclusion_currency)) currency_array[currency_array.length] = [ctn_currencies[j], ctn_currencies[j], ['']];
	}
	sfb_populateSelect('cbxCurr', currency_array, '', '', ctn_currency);
	
	if ((pt_flights == 0) || (pt_dflights == 0)) {
		ctn_show_group = "0";
		if (pt_flights == 0) {ctn_group_id = 'Domestic';};
		if (pt_dflights == 0) {ctn_group_id = 'International';};
	}

	if(ctn_show_group == "0"){setStyleDisplay("tr_group", "none");} else {setStyleDisplay("tr_group", "");};

	if(ctn_show_class == "0"){setStyleDisplay("sfb_tr_class", "none");} else {setStyleDisplay("sfb_tr_class", "");};
	
	found = false;
	if ((ctn_departure_city != '') && (ctn_arrival_city != '')){
		for (i=0; ((i < _r.length) && (!found)); i++) {
			if  ((String (_r[i][0][0]).toLowerCase() == ctn_arrival_city.toLowerCase() || String (_r[i][0][1]).toLowerCase() == ctn_arrival_city.toLowerCase()) &&
			(String (_r[i][1][0]).toLowerCase() == ctn_departure_city.toLowerCase() || String (_r[i][1][1]).toLowerCase() == ctn_departure_city.toLowerCase())) {
					sfb_show_product_type((_r[i][2][0] == 'Domestic' ) ? 'domestic_flight' : 'flight');
					found = true;
			}
		}
		if (!found) sfb_show_product_type((ctn_group_id == 'Domestic' ) ? 'domestic_flight' : 'flight');
	} else {sfb_show_product_type((ctn_group_id == 'Domestic' ) ? 'domestic_flight' : 'flight');}
	
	var ct = commercial_client_type.split(',');	
	for (var i = 0; i < ct.length; i++) ct[i] = [ct[i], ct[i], ['']];

	sfb_populateSelect('ClientType', ct, '', '', '', ct[0][0]);
	sfb_commercial_client_type_changed();
	if ((ct.length <= 1) || (ctn_site_from != "")) ctn_show_commercial_client_type = "0";
	
	if(ctn_show_commercial_client_type == "1"){setStyleDisplay("tr_ct", "");} else {setStyleDisplay("tr_ct", "none");};

	if(ctn_contact_us_ta_link == ""){setStyleDisplay("ta_link", "none");} 
	else {
		document.getElementById("ta_link").href = ctn_contact_us_ta_link;
		setStyleDisplay("ta_link", "");
	}

    var init_depart = sfb_min_flg_departure_date.getDate() + "/";

	if (sfb_min_flg_departure_date.getDate()<10) 
	   init_depart = "0" + init_depart;
	if ((sfb_min_flg_departure_date.getMonth() + 1)<10)
		init_depart  = init_depart + "0"  + (sfb_min_flg_departure_date.getMonth() + 1) + "/";
	else
		init_depart  = init_depart + (sfb_min_flg_departure_date.getMonth() + 1) + "/";
	init_depart  = init_depart + sfb_min_flg_departure_date.getFullYear();

	f = document.getElementById("frm_sfb_search_box");
	f.txt_flg_departure_date.value = init_depart;
	f.departureDate.value  = sfb_min_flg_departure_date.getDate();
	f.departureMonth.value  = (sfb_min_flg_departure_date.getMonth() + 1);
	f.departureYear.value  =  sfb_min_flg_departure_date.getFullYear();
	
    var init_return = sfb_min_flg_return_date.getDate() + "/";

	if (sfb_min_flg_return_date.getDate()<10) 
	   init_return = "0" + init_return;
	if ((sfb_min_flg_return_date.getMonth() + 1)<10)
		init_return  = init_return + "0"  + (sfb_min_flg_return_date.getMonth() + 1) + "/";
	else
		init_return  = init_return + (sfb_min_flg_return_date.getMonth() + 1) + "/";
	init_return  = init_return + sfb_min_flg_return_date.getFullYear();

	f.txt_flg_return_date.value = init_return;
	f.returnDate.value  = sfb_min_flg_return_date.getDate();
	f.returnMonth.value  = (sfb_min_flg_return_date.getMonth() + 1);
	f.returnYear.value  =  sfb_min_flg_return_date.getFullYear();

	document.getElementById("cbx_flg_departure_city").onchange = function(){sfb_populate_ArrivalSelect('cbx_flg_arrival_city', _r, ctn_group_id, ctn_arrival_city, document.frm_sfb_search_box.cbx_flg_departure_city.value)
};
	document.getElementById("sfb_button_flight").onclick = function(){sfb_show_product_type('flight')};
	document.getElementById("sfb_button_domestic_flight").onclick = function(){sfb_show_product_type('domestic_flight')};
	document.getElementById("lb_flg_round").onclick = function(){sfb_change_flg_type('return_flight')};
	document.getElementById("lb_flg_one").onclick = function(){sfb_change_flg_type('one_way_flight')};
	document.getElementById("ClientType").onchange = function(){sfb_commercial_client_type_changed()};
	document.getElementById("btn_search_flight").onclick = function(){sfb_searchFlight()};

	//Arreglo de campos ocultos con los datos que se envían a SFB //window.reseller_id == null
	var arrayParamValues = new Array("commercial_client_code", commercial_client_code,
	    "point_of_sale", point_of_sale, "commercial_client_type", commercial_client_type,
	    "bccode", ctn_affiliate_id, "reseller_id", reseller_id, "refSite", "", "ctn_site_name", ctn_site_name,
		"DeptAirPort", "", "DestAirPort", "",
		"Class", "",	"OR", "",
		"departureDate", "", "departureMonth", "", "departureYear","", 
		"returnDate", "", "returnMonth" ,"", "returnYear", "",
		"Adults", "", "Children", "", "Infants", "", "CurrCode", "", "ClientCountryCode", "GR", "FlightType", "");
	sfb_populatePhantomForm('frm_sfb_search_box_info', arrayParamValues);
}


function gup(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    //alert(name);
    if (results == null)
        return "";
    else
       // alert(name + ':' + results[1]);
        return results[1];
}


function sfb_paintform(){
document.writeln('<div id="sfb_div"></div>\r\n');
    sfb_paintform_innerElement("sfb_div");
}


function setBox() {
	var f = document.getElementById("frm_sfb_search_box");
   	if (gup("DeptAirPort") != "") {
    	if (gup("FlightType") != "") {
            ctn_group_id = gup("FlightType");
            if (gup("FlightType") == "International") {
                sfb_show_product_type('flight');
                
            }
            else {
                sfb_show_product_type('domestic_flight');
            }
        }
        f.departureDate.value = gup("departureDate");
        f.departureMonth.value = gup("departureMonth");
        f.departureYear.value = gup("departureYear");
        f.txt_flg_departure_date.value = gup("departureDate") + "/" + gup("departureMonth") + "/" + gup("departureYear");
        //f.txt_flg_return_date.value = gup("returnDate") + "/" + gup("returnMonth") + "/" + gup("returnYear");
		f.returnDate.value = gup("returnDate");
		f.returnMonth.value = gup("returnMonth");
		f.returnYear.value = gup("returnYear");
		f.txt_flg_return_date.value = gup("returnDate") + "/" + gup("returnMonth") + "/" + gup("returnYear");
        f.cbx_flg_class.value = gup("Class");
        if (gup("OR") != "") {
            if (gup("OR") == "R") {
                f.rg_flg_type[0].checked = true;
                sfb_change_flg_type('return_flight');
            }
            else {
                f.rg_flg_type[1].checked = true;
                sfb_change_flg_type('one_way_flight');
            }
        }
        f.cbx_flg_number_of_adults.value = gup("Adults");
        f.cbx_flg_number_of_children.value = gup("Children");
        f.cbx_flg_number_of_infants.value = gup("Infants");

        f.cbxCurr.value = gup("CurrCode");
        
		sfb_populate_DepartureSelect('cbx_flg_departure_city', _r, ctn_group_id, gup("DeptAirPort"))
		sfb_populate_ArrivalSelect('cbx_flg_arrival_city', _r, ctn_group_id, gup("DestAirPort"), f.cbx_flg_departure_city.value)
    }
	
}
