/*
 * Alertas Iberia.com
 * By Miguel Núñez
 */		
var alertIB={
	data:{
		content:"",
		returnFunction:function(){},
		acceptBtn:"Ok",
		cancelBtn:"",
		alertType:1 //1-Aviso(Amarillo), 2-Alerta(Rojo), 3-Confirmación(Tick)  
	},
	create:function(content, returnFunction, acceptBtn, cancelBtn, alertType){
		if(content!=undefined)this.data.content=content
		if(returnFunction!=undefined)this.data.returnFunction=returnFunction
		if(acceptBtn!=undefined)this.data.acceptBtn=acceptBtn
		if(cancelBtn!=undefined)this.data.cancelBtn=cancelBtn
		if(alertType!=undefined)this.data.alertType=alertType
		return this;
	},
	show:function(){
		try {
			if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
				$("body","html").css({height: "100%", width: "100%"});
				$("html").css("overflow","hidden");
				if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
					$("body").append("<iframe id='TB_HideSelect' src='/ibcomv3/js/blank.html'></iframe>");
					//$("#TB_overlay").click(loader_hide);
				}
			}
			//all others
			if(document.getElementById("TB_overlay") === null){
				var alertContent="<div id='TB_overlay'></div>"+
				'<div id="contentAlert"><div id="margenAlert"><img alt="Iberia.com" src="/ibcomv3/images/simplificacion/log_ibcom_alert.gif"/>'+
				this.data.content+
				'</div><form action="#" method="post" name="alertIBForm" id="alertIBForm">'+
          		'<div class="clear">'
				if(this.data.cancelBtn!=""){
					alertContent+='<span class="send_btn blanco ftl">'
                  	+'<input type="button" value="'+this.data.cancelBtn+'" class="submit_vol cancel" name="boton" id="alertIBCancel"/>'+
                	'</span>'
				}
				alertContent+='<span class="send_btn ftr">'
			 	+'<input type="button" value="'+this.data.acceptBtn+'" class="submit_vol" name="boton" id="alertIBOk"/>'+
            	'</span></div></form></div>'
				
				$("body").append(alertContent);
				$("#alertIBCancel").click(function(){
					alertIB.hide(); 
					alertIB.data.returnFunction(false); 
					return false;});
				$("#alertIBOk").click(function(){
					alertIB.hide(); 
					alertIB.data.returnFunction(true); 
					return false;});
				//$("#TB_overlay").click(loader_hide);
			}
			
			if(tb_detectMacXFF()){
				$("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
			}else{
				$("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
			}
			/*if(document.getElementById("TB_load") === null){
				$("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
			}
			$('#TB_load').show();//show loader*/
		} catch(e) {
			//nothing here
		}
	},
	hide:function(){
		$("#contentAlert").fadeOut("fast",function(){$('#contentAlert,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
		$("#TB_load").remove();
		if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
			$("body","html").css({height: "auto", width: "auto"});
			$("html").css("overflow","");
		}
		document.onkeydown = "";
		document.onkeyup = "";
		return false;
	}
		
}  

function tb_detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}
/* ----- Ejemplo -----
var alerta = alertIB.create(
	'<div id="encabezado_ancho"><strong>Información importante sobre la moneda</strong><ul><li>La reserva se calculará y cobrará en GB Pounds (GBP).</li><li>Va a abandonar el sitio web de Iberia de su país de residencia. Todas las reservas se rigen por las normativas de tarifas y las condiciones de reserva del país de salida del vuelo, lo que puede incluir también una tasa de reserva online.</li><li>Si la tarjeta de pago utilizada no se ha facturado en GB Pounds (GBP) puede haber una diferencia entre el importe final mostrado y el importe cobrado en su extracto.</li></ul></div>'
	,function(retValue){ }
	,"Continuar"
	, "Cancelar" )
alerta.show();
*/




