///
if (navigator.appName == "Microsoft Internet Explorer") {brw=true;} else {brw=false;}
///

function GE(obj) {
	return document.getElementById(obj);
}

win_ancho=screen.availWidth;
win_alto=screen.availHeight;
function abrePopup(path){
	win_w=300;
	win_h=200;
	posLeft=(win_ancho/2)-(win_w/2);
	posTop=(win_alto/2)-(win_h/2);
	winB = window.open(path, 'ventanaF', 'width='+win_w+', height='+win_h+', top='+posTop+', left='+posLeft+', scrollbars=no, status=no, resizable=no, toolbar=no, menubar=no');
	winB.focus();
}

function abreCond(id){
	win_w=400;
	win_h=280;
	posLeft=(win_ancho/2)-(win_w/2);
	posTop=(win_alto/2)-(win_h/2);
	winC = window.open('condiciones.asp?id='+id, 'ventanaC', 'width='+win_w+', height='+win_h+', top='+posTop+', left='+posLeft+', scrollbars=no, status=no, resizable=no, toolbar=no, menubar=no');
	winC.focus();
}
//
function wl(ruta){
	window.location=ruta;
}
function wlt(ruta){
	window.top.location=ruta;
}
function volver(){
	window.history.back();
}
///
function GEBI(obj){
	return document.getElementById(obj);
}
///
function imprimir() {
	if (window.print){ 
		window.print();
	}else{
		alert("Disculpe, opción no disponible\nIntente imprimir desde el menu archivo.");
	}
}
/*
arrayCacheImgJpg = ['btn_mas','btn_menos','btn_seleccionarida','btn_seleccionarvuelta','btn_orden','ord_aero','ord_precio','ord_hora','ord_clase','btn_vertodas','btn_versolonegociadas','btn_versolononegociadas','btn_ingresar','btn_agregar','btn_eliminar','btn_consultar','btn_seleccionar','btn_reservar','btn_cancelar','btn_enviar','btn_buscar','btn_volver','btn_detalle','btn_consultar','btn_selaero','btn_emision'];
arrayCacheImgGif = ['olvido','nuevo','btn_vermas','verreglas','btn_detalle','btn_reservar','tc','btn_verdet'];
*/
cacheJpgOver=[];
function cacheJpg(){	
	for(im=0; im<cacheJpg.arguments.length; im++){		
		cacheJpgOver[im] = new Image();
		cacheJpgOver[im].src = 'img/'+cacheJpg.arguments[im]+'.jpg';
	}
}
cacheGifOver=[];
function cacheGif(imagen){
	for(im=0; im<cacheGif.arguments.length; im++){
		cacheGifOver[im] = new Image();
		cacheGifOver[im].src = 'img/'+cacheGif.arguments[im]+'.gif';
	}
}
function deslizarTop(){
	var vel1 = 3;
	var vel2 = 5;
	var sec = 20;
	var y;
	var cy;
	var gy = 0;
	var scrollEngine;
	if(document.all){
		cy = document.body.scrollTop;
	}
	else if(document.layers || document.getElementById){
		cy = pageYOffset;
	}
	y = cy-gy;
	if(Math.abs(y)>400){
		cy = cy-(y/vel1);
		window.scroll(0,cy);
		scrollEngine = setTimeout("deslizarTop()",sec);	
	}else if(Math.abs(y)>0){
		cy = cy-(y/vel2);
		window.scroll(0,cy);
		scrollEngine = setTimeout("deslizarTop()",sec);	
	}else{
		window.scroll(0,0);
		clearTimeout(scrollEngine);
	}
}
//
function abreBuscador(path){
	win_w=298;
	win_h=185;
	posLeft=(win_ancho/2)-(win_w/2);
	posTop=(win_alto/2)-(win_h/2);
	winB = window.open(path, 'ventanaB', 'width='+win_w+', height='+win_h+', top='+posTop+', left='+posLeft+', scrollbars=no, status=no, resizable=no, toolbar=no, menubar=no');
	winB.focus();
}
//
function abreDetalles(tipo,id){
	win_w=450;
	win_h=105;
	posLeft=(win_ancho/2)-(win_w/2);
	posTop=(win_alto/2)-(win_h/2)-30;
	winB = window.open('popupdetalles.asp?tipo='+tipo+'&id='+id, 'ventanaD', 'width='+win_w+', height='+win_h+', top='+posTop+', left='+posLeft+', scrollbars=no, status=yes, resizable=no, toolbar=no, menubar=no');
	winB.focus();
}
//
function abreDetallesHotel(tipo,id){
	win_w=465;
	win_h=105;
	posLeft=(win_ancho/2)-(win_w/2);
	posTop=(win_alto/2)-(win_h/2)-30;
	winB = window.open('popupdetalles.asp?tipo='+tipo+'&id='+id, 'ventanaD', 'width='+win_w+', height='+win_h+', top='+posTop+', left='+posLeft+', scrollbars=yes, status=yes, resizable=no, toolbar=no, menubar=no');
	winB.focus();
}
//
function abrePrecios(tipo,id){
	win_w=455;
	win_h=105;
	posLeft=(win_ancho/2)-(win_w/2);
	posTop=(win_alto/2)-(win_h/2)-30;
	winB = window.open('popupprecios.asp?tipo='+tipo+'&id='+id, 'ventanaD', 'width='+win_w+', height='+win_h+', top='+posTop+', left='+posLeft+', scrollbars=yes, status=yes, resizable=no, toolbar=no, menubar=no');
	winB.focus();
}
pageHome=false;

//AJAX
function newAjax(){
	var http_request = false;
	if (window.XMLHttpRequest) {
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');			
		}
	} else if (window.ActiveXObject) {
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}	
	if (!http_request) {            
		return false;
	}
	return http_request;
}


function setCookie(nombre, valor) {
	caduca=new Date(2010, 12, 31);
	document.cookie = nombre + "=" + escape(valor) + "; expires=" + caduca.toGMTString();
}
function getCookie(nombre) {
  var buscar = nombre + "=";
  if (document.cookie.length > 0) {
	i = document.cookie.indexOf(buscar);	
	if (i != -1) {
	  i += buscar.length;
	  j = document.cookie.indexOf(";", i);
	  return unescape(document.cookie.substring(i,j));
	}else{
		return ""
	}
  }
}
function verReglasTarifa(id){
	var w = window.open("ar_reglastarifas.asp?id="+id,"reglas","width=440,height=550,scrollbars=yes");
	w.focus();
	return false;
}

///
memSRC = "";
function rollOver(obj){memSRC = obj.src;obj.src =  memSRC.substr(0,memSRC.length-4) + "_over" + memSRC.substring(memSRC.length-4);}
function rollOut(obj){obj.src =  memSRC;}
function Cachear(){
	cacheOver=[];
	for(im=0; im<Cachear.arguments.length; im++){
		imagenCachear = Cachear.arguments[im];
		cacheOver[im] = new Image();
		cacheOver[im].src = imagenCachear;
	}
}
function BipCache(){
	var DI=document.images;
	for(var i=0;i<DI.length; i++){
		if(DI[i].className){			
			if(DI[i].className.toString().toLowerCase().indexOf('rollover')>-1){				
				path=DI[i].src;
				ext=path.substr(path.length-4,4);
				img=path.substr(0,path.length-4);
				Cachear(img+'_over'+ext);			
				DI[i].onmouseover=new Function('rollOver(this)');
				DI[i].onmouseout=new Function('rollOut(this)');			
			}
		}
	}
}
//
function dateDiff(f1, f2){
	_s = "/";
	vF1 = f1.split(_s);
	_f1 = new Date(vF1[1] + _s + vF1[0] + _s + vF1[2]);
	vF2 = f2.split(_s);
	_f2 = new Date(vF2[1] + _s + vF2[0] + _s + vF2[2]);
	return (_f2-_f1)/24/60/60/1000;
}
function dateAdd(fecha, dias){
	_s = "/";
	vFecha = fecha.split(_s);
	time = new Date(vFecha[2],vFecha[1]-1,vFecha[0]);
	time = new Date(time.valueOf()+dias*1000*3600*24);	
	return time.getDate().biDig() + _s + (time.getMonth()+1).biDig() + _s + time.getFullYear();
}
Number.prototype.biDig = function(){
	return Number(this)<10 ? "0"+this : this;
}
//
