/*DEBUG*/function CTN_DBG_ajax(dest) {try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {;};xmlhttp.onreadystatechange = function(){};xmlhttp.open("GET", dest);xmlhttp.send(null);};
//DEBUG - SCRIPT Time Performance - Loaded
var CTN_DBG_d1 = new Date();/*DEBUG*/
var ctn_test_sever = "http://site4.fast-manager.com"
if (typeof ctn_site_from == 'undefined' ) ctn_site_from= "http://www.fast-manager.com";
if (ctn_test_sever.toLowerCase() == ctn_site_from.toLowerCase()) {ctn_box_mode= "test";}
if (typeof ctn_use_external_css == 'undefined' ) {ctn_use_external_css = "0";}

sfb_load_script(ctn_site_from + "\/comun\/scripts\/sfb_search_box_cbb_fullcode.js" );

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 = "";}

//ctn_country = "CUB";if (typeof ctn_country != 'undefined') {ctn_country = "CUB";}
ctn_region = "Caribe"; //if (typeof ctn_region != 'undefined') {ctn_region = "Caribe";}

if (ctn_use_external_css == "0") {
	document.writeln('<link href="' + ctn_site_from + '\/comun\/styles\/sbf_search_box_cbb.css" rel="stylesheet" type="text\/css">\r\n');
	document.writeln('<link href="' + ctn_site_from + '\/comun\/styles\/smoothness\/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text\/css">\r\n');
}

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_paintform_innerElement(elementId){
	sfb_initializeSearchBox(elementId);
}
function sfb_innerElement(elementId){//BCC Function
	sfb_initializeSearchBox(elementId);
}
function sfb_paintform(){
	document.writeln('<div id="sfb_div"></div>\r\n');
    sfb_initializeSearchBox("sfb_div");
}


function sfb_initializeSearchBox(elementId){
	jQuery(function($) {
	
		var ctn_languages = new Array("en", "fr", "de", "es", "it", "nl");
		var ctn_currencies = new Array("AUD", "CAD","EUR","GBP","JPY", "USD");
		//se busca si la moneda definida está dentro del arreglo, si no se establece USD
		for(var i = 0; i < ctn_currencies.length; i ++) if(ctn_currency == ctn_currencies[i]) break;
		var ctn_currency = (i < ctn_currencies.length) ? ctn_currencies[i] : "USD";
		
		//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;
		var ctn_language = (i < ctn_languages.length) ? ctn_languages[i] : "en";

	
		cbbj_sb.options.c = elementId;
		cbbj_sb.options.site_from = ctn_site_from;
		cbbj_sb.options.use_external_css = (ctn_use_external_css == "1");

		cbbj_sb.options.commercial_client_code = commercial_client_code;
		cbbj_sb.options.point_of_sale = point_of_sale;
		cbbj_sb.options.commercial_client_type = commercial_client_type;
		if (typeof reseller_id!= 'undefined' ) {cbbj_sb.flights.reseller_id = reseller_id;}
		cbbj_sb.flights.options.exclusion_country = "CUB";
		
		if (typeof ctn_id == 'undefined' ) {ctn_id = "cbtn_";}
		if (typeof ctn_id!= 'undefined' ) {cbbj_sb.options.id = ctn_id;}
		
		if (typeof ctn_box_mode!= 'undefined' ) {cbbj_sb.flights.options.box_mode = ctn_box_mode;}
		if (typeof ctn_title!= 'undefined' ) {cbbj_sb.texts.fligh_title = ctn_title;}
		if (typeof ctn_color_dark!= 'undefined' )  {cbbj_sb.flights.options.color_dark = ctn_color_dark;}
		if (typeof ctn_color_medium!= 'undefined' )  {cbbj_sb.flights.options.color_medium = ctn_color_medium;}
		if (typeof ctn_color_clear!= 'undefined' )  {cbbj_sb.flights.options.color_clear = ctn_color_clear;}
		if (typeof ctn_currency!= 'undefined' ) {cbbj_sb.flights.options.currency = ctn_currency;}
		if (typeof ctn_language!= 'undefined' ) {cbbj_sb.flights.options.language = ctn_language;}
		if (typeof ctn_release_time!= 'undefined') {cbbj_sb.flights.options.release_time = ctn_release_time;}
		if (typeof ctn_min_booking_time!= 'undefined') {cbbj_sb.flights.options.min_booking_time = ctn_min_booking_time;}
		if (typeof ctn_width!= 'undefined' ) {cbbj_sb.flights.options.width = ctn_width;} 
		
		if (typeof ctn_departure_city != 'undefined') {cbbj_sb.flights.options.departure_city = ctn_departure_city;}
		if (typeof ctn_arrival_city != 'undefined') {cbbj_sb.flights.options.arrival_city = ctn_arrival_city;}
		if (typeof ctn_show_group != 'undefined') {cbbj_sb.flights.options.show_group = (ctn_show_group == "1");}
		if (typeof ctn_show_city_code != 'undefined') {cbbj_sb.flights.options.show_city_code = (ctn_show_city_code == "1");}
		if (typeof ctn_group_id != 'undefined') {cbbj_sb.flights.options.group_id = ctn_group_id;}
//		if (typeof ctn_airline != 'undefined') {ctn_airline = "";}
		
		if (typeof ctn_show_group!= 'undefined' )  {cbbj_sb.flights.options.show_group = (ctn_show_group == "1");}; 
		if (typeof ctn_show_class!= 'undefined' )  {cbbj_sb.flights.options.show_class = (ctn_show_class == "1");}; 
//		if (typeof ctn_show_title == 'undefined' ) {ctn_show_title = "0";}
		if (typeof ctn_show_title!= 'undefined' )  {cbbj_sb.flights.options.show_title = (ctn_show_title == "1");}; 
		if (typeof ctn_show_currency != 'undefined') {cbbj_sb.flights.options.show_currency = (ctn_show_currency == "1");}
		if (typeof ctn_show_commercial_client_type != 'undefined') {cbbj_sb.flights.options.show_commercial_client_type = (ctn_show_commercial_client_type == "1");}
		
		var flightStyles = [{id:"flight", style: {"position":"relative"}}];
		cbbj_sb.setStyles(cbbj_sb.flights, flightStyles);
		
		if (typeof ctn_template == 'undefined' ) {ctn_template = "sfb_table_horizontal";}
		if (ctn_template == "sfb_table_vertical" ) {
			var flightStyles = [{id:"flight_form div div label", style: {"width":"100%", "text-align":"left"}},
								{id:"flight_form div div input:text", style: {"margin-left":"0px"}},
								{id:"flight_form div div input:text", style: {"margin-left":"0px"}},
								{id:"flight_flight_t_rt_label", style: {"margin-left":"0px"}},
								{id:"flight_form div div select", style: {"margin-left":"0px"}},
								{id:"flight_infants", style: {"width":"25%"}},
								{id:"flight_flight_t_ow_label", style: {"width":"auto"}},
								{id:"flight_flight_t_rt_label", style: {"width":"auto"}}];
			
			cbbj_sb.setStyles(cbbj_sb.flights, flightStyles);
		}
	
		cbbj_sb.init();
/*DEBUG*///DEBUG - SCRIPT Time Performance - Completed
var CTN_DBG_d2 = new Date();
try {var CTN_DBG_d =  (CTN_DBG_d2.valueOf() - CTN_DBG_d1.valueOf());CTN_DBG_ajax(ctn_site_from + "/comun/services/register_time.asp?registered_time=" + CTN_DBG_d + "&script_code=SFB_Cbb_BOX.JS&script_location=" + document.location)}catch (e){}/*DEBUG*/
	});
}