
$(document).ready(function() {
	var attributes = {};
	var flashvars = {};
	attributes.wmode = "transparent";
	swfobject.embedSWF(THEME_DIR+"imagenes/expedia-logo.swf", "logo", "236", "96", "9", THEME_URL+"js/swfobject/expressInstall.swf", flashvars, attributes);
	if($('#sidebar').length > 0){
		swfobject.embedSWF(THEME_DIR+"imagenes/menu/01.swf", "botonInstitucional", "110", "110", "9", THEME_URL+"js/swfobject/expressInstall.swf", flashvars, attributes);
		swfobject.embedSWF(THEME_DIR+"imagenes/menu/02.swf", "botonViajes", "110", "110", "9", THEME_URL+"js/swfobject/expressInstall.swf", flashvars, attributes);
		swfobject.embedSWF(THEME_DIR+"imagenes/menu/03.swf", "botonServicios", "110", "110", "9", THEME_URL+"js/swfobject/expressInstall.swf", flashvars, attributes);
		swfobject.embedSWF(THEME_DIR+"imagenes/menu/04.swf", "botonContacto", "110", "110", "9", THEME_URL+"js/swfobject/expressInstall.swf", flashvars, attributes);
	}
	if($('#cu3er-container').length > 0){
		//flashvars.xml = SITE_URL+"cuer.xml";
		flashvars.xml = SITE_URL+'index.php?accion=3';
		attributes.id = "slider";
		swfobject.embedSWF(THEME_DIR+"imagenes/cu3er.swf", "cu3er-container", "670", "250", "9", THEME_URL+"js/swfobject/expressInstall.swf", flashvars, attributes);
	}
	
	$('.promocion a').colorbox({width:"650px", height:"450px", iframe:true});
	$('.cboxElement').colorbox({width:"650px", height:"450px", iframe:true});
	var procesando = false;
	$("#btnSend").each(function(i, btn){
		$(btn).click(function(e){
			e.preventDefault();
			if(procesando == false){
				$('#results').html('<div class="pie">Procesando...</div>').fadeIn('slow');
				$('#results').val('');
				procesando = true;
				$.ajax({
					type: "POST",
					url: $("#contactoForm").attr('action'),
					data: $("#contactoForm").serialize(),
					success: function(data){
						$('#results').fadeOut("slow", function(){
							 $('#results').html('<div class="pie">'+data.replace('"', '')+'</div>')
							 if(data.search(/Solucione/i) == -1){
								 $("#nombre").val('');
								 $("#email").val('');
								 $("#telefono").val('');
								 $("#horario").val('');
								 $("#consulta").val('');
							 }
							 procesando = false;
						}).fadeIn("slow");
					}
				});
			}
		});
	});
	$(document).pngFix(); 
	if($('#tabcontrol a').length > 0){
		var tabscontrol = $('#tabcontrol a');
		var tabs = $('.tabs').hide();
		var subs = $('#subimgvuelos, #subimgpasajes, #subimghoteles').hide();
		$(tabscontrol).each(function(){
			$(this).click(function(e){
				e.preventDefault();
				$(tabs).hide();
				$(subs).hide();
				$('#tituloTab').attr('class', 'title'+$(this).attr('rel')).html($(this).attr('title'));
				$('#imgTab').attr('src', SITE_URL +'imagenes/secciones/'+$(this).attr('rel')+'_thumb.jpg');
				$('#imgTab').attr('alt', $(this).attr('title'));
				$('#mainTabimg').attr('src', SITE_URL +'imagenes/secciones/new/cabecera_'+$(this).attr('rel')+'.jpg');
				$('#mainTabimg').attr('alt', $(this).attr('title'));
				$('#tab'+$(this).attr('rel')).fadeIn();
				$('#subimg'+$(this).attr('rel')).fadeIn();
				
				$(tabscontrol).each(function(){
					$($(this).parent()).attr('class', 'li'+$(this).attr('rel'));
				});
				$($(this).parent()).attr('class', 'li'+$(this).attr('rel')+'active');
			});
		});
		$(tabscontrol.get(0)).click();
	}
	
});

