var ie = (navigator.appName == "Microsoft Internet Explorer") ? true : false;
var ie6 = false;
if(ie){
	_navV = navigator.userAgent.split(';');
	ie6 = (_navV[1].substring(6)<7) ? true : 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 wl(ruta){
	window.location=ruta;
}
function volver(){
	window.history.back();
}
///
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 soloEmail(e){
	arrayBlock = [' ','ñ','Ñ','[',']',',',';',':','{','}','(',')','+','*','/','=','&','%','$','#','!','<','>','|','°','?','¿','¡','\'','"'];
	var tecla = (e.keyCode) ? e.keyCode : e.which;
	if(e.ctrlKey && tecla==118 || tecla==39){
		return false;
	}
	var l = String.fromCharCode(tecla)
	for(var i=0; i<arrayBlock.length; i++){
		if(arrayBlock[i] == l){
			return false;
		}
	}
}
function soloNumeros(e){
	tecla = (e.keyCode) ? e.keyCode : e.which;
	if(e.ctrlKey && tecla==118 || tecla==39){
		return false;
	}
    if (tecla==8 || tecla==0 || tecla==13) return true;
    patron = /\d/;
    te = String.fromCharCode(tecla); 
    return patron.test(te); 
}
function filtrarTecla(e){
	var tecla = (e.keyCode) ? e.keyCode : e.which;
	if(e.ctrlKey && tecla==118) return false;
    if(tecla==8 || tecla==9 || tecla==0 || tecla==13 || tecla==46 || tecla==35 || tecla==36 || tecla==37 || tecla==39) return true;
	patron = /[a-zA-Z-_áÁéÉíÍóÓúÚñÑ]/;
    te = String.fromCharCode(tecla);
    return patron.test(te);
}
//
function soloLetras(e){
	tecla = (e.keyCode) ? e.keyCode : e.which;
	if(e.ctrlKey && tecla==118 || tecla==39) return false;
    if (tecla==8 || tecla==0 || tecla==13 || tecla==9) return true;
    patron = /[A-Za-z]/;
    return patron.test(String.fromCharCode(tecla));
}
Number.prototype.biDig = function(){
                return Number(this)<10 ? "0"+this : this;
}

Date.Formatear = function(f){
                var A = f.split(/[\\\/]/);
                A = [A[1],A[0],A[2]];
                return new Date(Date.parse(A.join('/')));
}

Date.Diff = function(f1, f2){
                return (Date.Formatear(f2)-Date.Formatear(f1))/(24*60*60*1000);
}

Date.Add = function(f, d){
                var _s = "/";
                var _d = new Date(Date.Formatear(f).setDate(Date.Formatear(f).getDate() + Number(d)));
                return _d.getDate().biDig() + _s + (_d.getMonth()+1).biDig() + _s + _d.getFullYear();
}
var dateDiff = function(f1, f2){
                return Math.round(Date.Diff(f1, f2));
}

var dateAdd = function(f,d){
                return Date.Add(f, d);
}

//
_yscroll=_scrollto=0;
function scrollerTo(posv){
	_yscroll = getTopScroll();
	_scrollto=posv;
	intervalScroll=setInterval(scrollerMove,50);
	return false;
}
function scrollerMove(){
	_yscroll += (_scrollto-_yscroll)/2;
	_ymove=Math.round(_yscroll);
	if(_ymove==_scrollto){
		clearInterval(intervalScroll);
	}
	window.scrollTo(0,_ymove);
}
function getTopScroll(){
	if(self.pageYOffset){		
		scrolTop = self.pageYOffset;
	}else if (document.documentElement && document.documentElement.scrollTop){
		scrolTop = document.documentElement.scrollTop;
	}else if (document.body){
		scrolTop = document.body.scrollTop;
	}
	return scrolTop;
}
function AgregarOpcion(o,v,t,r) {
	if(r){
		for(var s=1; s<document.getElementById(o).options.length; s++){
			if(document.getElementById(o).options[s].text == t && document.getElementById(o).options[s].value == v) return false;
		}
	}
	var newOpt = document.createElement("OPTION");
	newOpt.text = t;
	newOpt.value = v;
	document.getElementById(o).options.add(newOpt);
}
function EliminarOpcion(o,v) {
	document.getElementById(o).remove(document.getElementById(o).options[v]);
}

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 LogOut(){
	ht = document.getElementsByTagName("html");
	ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
	if (confirm('Está seguro que desea salir?')){
		return true;
	}else{
		ht[0].style.filter = "";
		return false;
	}
}
/*HOTELES*/
Cachear('img/btn_vertarifa_op.jpg');
verTarifa = function(oc,ot){
	_img = GE(oc).src;
	if(_img.indexOf('_op.jpg')>-1){
		GE(oc).src = _img.split('_op.jpg').join('.jpg');
		GE(ot).style.display = 'none';
	}else{
		GE(oc).src = _img.split('.jpg').join('_op.jpg');
		GE(ot).style.display = 'block';
	}	
	return false;
}

verTodasTarifas = function(o){	
	for(var i=0; i<300; i++){
		if(GE('imgHta'+i)){	
			if(o.checked){
				if(GE('imgHta'+i).src.indexOf('_op.jpg')<0){
					GE('imgHta'+i).src = GE('imgHta'+i).src.split('.jpg').join('_op.jpg');
				}
				GE('gridHta'+i).style.display = 'block';
			}else{
				if(GE('imgHta'+i).src.indexOf('_op.jpg')>-1){
					GE('imgHta'+i).src = GE('imgHta'+i).src.split('_op.jpg').join('.jpg');
				}
				GE('gridHta'+i).style.display = 'none';				
			}	
		}
	}
}

function BookHotel(ID,Modo){	
	GE('frm'+ID).sHotelID.value = ID
	GE('frm'+ID).Modo.value = Modo
	GE('frm'+ID).submit()
}

function BookServicio(ID,Modo){	
	GE('frm'+ID).sServicioID.value = ID
	GE('frm'+ID).Modo.value = Modo
	GE('frm'+ID).submit()
}

function BookPaquete(ID,Modo){	
	GE('frm'+ID).sPaqueteID.value = ID
	GE('frm'+ID).Modo.value = Modo
	GE('frm'+ID).submit()
}


function BookTraslado(ID,Modo){		
	GE('frm'+ID).sTrasladoID.value = ID
	GE('frm'+ID).Modo.value = Modo
	GE('frm'+ID).submit()
}

function BookExcursion(ID,Modo){	
	GE('frm'+ID).sExcursionID.value = ID
	GE('frm'+ID).Modo.value = Modo
	GE('frm'+ID).submit()
}

function BookPaquete(ID,Modo){	
	GE('frm'+ID).sPaqueteID.value = ID
	GE('frm'+ID).Modo.value = Modo
	GE('frm'+ID).submit()
}
function BookAuto(ID,Modo){	
	GE('frm'+ID).sAutoID.value = ID
	GE('frm'+ID).Modo.value = Modo
	GE('frm'+ID).submit()
}
function VerDetalleTarifaAuto(id){
	sEst =  GE('detalleAuto' + id).style.display 
	if (sEst == 'none'){
		GE('detalleAuto' + id).style.display='block'
	}else{
		GE('detalleAuto' + id).style.display='none'
	}
}

var winL = null;
function verLegal(o){
	_Width = 320;
	_path = o;
	if(_path.indexOf('c=1')>-1) _Width = 500;
	if(winL) winL.close();
	winL = window.open(_path,'legal','width='+_Width+',scrollbars=yes,top=0,left=0,height='+screen.height);
	winL.focus();
	return false;
}

function cClase(o,css){o.className = css;}

function ponerHash(h){window.location.hash = h};
function traerHash(s){
		var wlh = window.location.hash;
		wlh = wlh.substring(1,wlh.length);
		v_wlh = wlh.split('&');
		var r_wlh = '';
		if(typeof(s) == 'undefined'){
			r_wlh = wlh;
		}else if(v_wlh.length>1){
			for(var v=0; v<v_wlh.length;v++){
				if(v_wlh[v].indexOf(s+'=')>-1)r_wlh = v_wlh[v].replace(s+'=','');
			}			
		}else{
			r_wlh = wlh.replace(s+'=','');
		}
		return r_wlh;
};
function hayHash(){return window.location.hash};
//
RequestToAjax = function(){
	var _r = '?';
	var _o = RequestToAjax.arguments[0];
	for(var i=0;i<_o.length;i++){
		_r += _o[i].name + '=' +_o[i].value + '&';
	}
	return _r;
}
function getWindowHeight() {
	_wh = 0;
	if (document.body.scrollHeight && navigator.appVersion.indexOf("Win") != -1) {
		_wh = document.body.scrollHeight;
	}
	else if (document.documentElement.scrollHeight) {
		_wh = document.documentElement.scrollHeight;
	}
	else if (document.documentElement.offsetHeight) {
		_wh = document.documentElement.offsetHeight;
	}
	return _wh;
}

BlockWindow = function(e){
	if(e){
		with(GE('div_BlockWindow').style){		
			display = 'block';
			height = getWindowHeight()+'px';
			width = getWidth()+'px';
			hideSelectBoxes();
		}
	}else{
		GE('div_BlockWindow').style.display = 'none';
		showSelectBoxes();
	}
}
document.write('<div id="div_BlockWindow" ondblclick="WinViewClose();" style="background:url(img/win_block.gif);position:absolute; z-index:300; display:none; top:0;left:0;" oncontextmenu="return false" ondragstart="return false" onselectstart="return false"></div>');

getStyle = function(el,styleProp){
	var x = typeof el == 'String' ? document.getElementById(el) : el;
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}

vMemSelectsStyle = [];
vMemSelectsObject = [];
showSelectBoxes = function(){	
	for (i = 0; i != vMemSelectsStyle.length; i++) {
		vMemSelectsObject[i].style.visibility = vMemSelectsStyle[i];
	}
}
hideSelectBoxes = function(){
	vMemSelectsStyle = [];
	vMemSelectsObject = [];
	var oSe = document.getElementsByTagName("select");
	for (i = 0; i != oSe.length; i++) {
		vMemSelectsStyle.push(getStyle(oSe[i],'visibility'));
		vMemSelectsObject.push(oSe[i]);
		oSe[i].style.visibility = "hidden";
	}
}

function verReglasTarifa(r){
	var w = window.open(r,"reglas","width=400,height=400,scrollbars=yes");
	w.focus();
	return false;
}

FormatNumber = function(num){
   num += '';
   var splitStr = num.split('.');
   var splitLeft = splitStr[0];
   var splitRight = splitStr.length > 1 ? '.' + splitStr[1] : '';
   var regx = /(\d+)(\d{3})/;
   while (regx.test(splitLeft)) {
      splitLeft = splitLeft.replace(regx, '$1' + ',' + '$2');
   }
   return splitLeft + splitRight;
}
UnFormatNumber = function(num) {
   return num.replace(/([^0-9\.\-])/g,'')*1;
}

encodeStr = function(s){
	return escape(s).replace(/\+/, "%2B");
}
html2js = function(s){
	return s.toString().split('"').join('&quot;');
}

//////////////////NUEVO
//
encodeStr = function(s){
	return escape(s).replace(/\+/, "%2B");
}
//
var exe_pl = null;
EnviarXemail = function(a,i,t){
	exe_pl = new ProcessLight();
	exe_pl.opciones.Cerrar = true;
	exe_pl.setURL('winemailprint/det_wiz_mail.asp?ser_asunto='+encodeStr(a)+'&ser_id='+i+'&ser_tipo='+t);
	exe_pl.show();
}
var id_pl = null;
ImprimirDetalle = function(i,t){
	id_pl = new ProcessLight();
	id_pl.opciones.Cerrar = true;
	id_pl.setURL('winemailprint/det_wiz_print.asp?ser_id='+i+'&ser_tipo='+t);
	id_pl.show();
}
var _paramsWIN = "";
ValidarEmailDET = function(o, i){
	if(i == 1){
		if(o.ser_asunto.value.length<1){
			alert("Ingrese el Asunto.");
			o.ser_asunto.focus();
			return false;
		}else if(o.ser_email_remitente.value.length<1 || o.ser_email_remitente.value == o.ser_email_remitente.title){
			alert("Ingrese el Email del Remitente.");
			o.ser_email_remitente.focus();
			return false;
		}else if(o.ser_email_remitente.value.indexOf("@") < 1 || o.ser_email_remitente.value.indexOf(".") < 1 || o.ser_email_remitente.value.length < 6 ){
			alert('Formato de Email incorrecto.');
			o.ser_email_remitente.focus();
			return false;
		}else if(o.ser_nombre_remitente.value.length<1 || o.ser_nombre_remitente.value == o.ser_nombre_remitente.title){
			alert("Ingrese el Nombre del Remitente.");
			o.ser_nombre_remitente.focus();
			return false;
		}else if(o.ser_email_destinatario.value.length<1 || o.ser_email_destinatario.value == o.ser_email_destinatario.title){
			alert("Ingrese el Email del Destinatario.");
			o.ser_email_destinatario.focus();
			return false;
		}else if(o.ser_email_destinatario.value.indexOf("@") < 1 || o.ser_email_destinatario.value.indexOf(".") < 1 || o.ser_email_destinatario.value.length < 6){
			alert('Formato de Email incorrecto.');
			o.ser_email_destinatario.focus();
			return false;
		}else if(o.ser_nombre_destinatario.value.length<1 || o.ser_nombre_destinatario.value == o.ser_nombre_destinatario.title){
			alert("Ingrese el Nombre del Destinatario.");
			o.ser_nombre_destinatario.focus();
			return false;
		}		
		_paramsWIN = $(o).toQueryString();
		WINirStepTP(2,1);
	}else{
		_paramsWIN += '&' + $(o).toQueryString();
		WINirStepTP(3,2);

		var exe_Req = new Request({
		url: 'winemailprint/enviar_detalle_xmail.asp',
		method: 'post',
		onSuccess: function(rText, rXML){
			if(rText == 0){
				WINirStepTP(4,3);
			}else{
				WINirStepTP(5,3);
			}
		}
		}).send(_paramsWIN);	
		
	}	
	return false;
}

WINvalidaInput = function(o){
	var _o = $(o);
	if(_o.get('value') == _o.get('title')){
		_o.set('value', '').setStyle('color', '#333');
	}
}
WINirStepTP = function(s,h){
	$('WIN_step'+s).setStyle('display', 'block');
	$('WIN_step'+h).setStyle('display', 'none');	
	return false;
}
