window.addEvent('domready', function(){
	//Campos obligatorios - title="x"
	$$('input[type=text], input[type=password]').each(function(obj, index){															 
		obj.set({				  
			'styles': {				
				'background': obj.match('[title^=""]') ? '#fff url(base/ast.gif) no-repeat right center' : obj.getStyle('background-color')
			},
			'events': {				
				'keypress': function(ev){
					 if(ev.key == 'v' && ev.control) ev.stop()
				}
			},
			'autocomplete' : 'off',
			'oncontextmenu' : 'return false',
			'onpaste' : 'return false'
		});
	});
});
//hoteles
hGetPrice = function(o, did, id, productID,host,moneda){
	var _o = $('hpreciosDiv'+did);
	if(_o.hasClass('act')){
		_o.removeClass('act');
		_o.empty();
		$(o).set('html','ver precio').removeClass('act');
	}else{
		_o.set('html','<img src="hoteles/img/load.gif" height="10" width="10" style="margin:5px;" alt="" />');
		var page_Req = new Request({
			url: 'hoteles/' + host + "/precios_xhr.asp",
			method: 'post',
			noCache: false,
			evalScripts: true,		
			onSuccess: function(rText, rXML) {			
				_o.set('html',rText).addClass('act');		
			}
		}).send('id='+id+'&productID='+productID+'&moneda='+moneda);
		$(o).set('html','ocultar precio').addClass('act');
	}
	return false;
}

function GE(obj) {
	return $(obj);
}

function volver(){
	window.history.back();
	return false;
}
var win_ancho = screen.availWidth;
var win_alto = screen.availHeight;
///
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 overCeld(obj){
	obj.style.backgroundColor='#ffffcc';
}
function outCeld(obj, id){
	var color='#EFF3F1';
	if(id=='1'){
		color='#F5F7F6';	
	}
	obj.style.backgroundColor=color;
}
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){
	var key = (e.keyCode) ? e.keyCode : e.which;
	if(key == 46) return true;
	return (key <= 13 || (key >= 48 && key <= 57));
}
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));
}
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;
}
//
_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 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};
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;
}
traerEstilo = 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(traerEstilo(oSe[i],'visibility'));
		vMemSelectsObject.push(oSe[i]);
		oSe[i].style.visibility = "hidden";
	}
}
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;');
}

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;
	}
}


var winL = null;
function verLegal(o){
	_Width = 320;
	_path = o.href;	
	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 overCel(obj){
	obj.style.backgroundColor='#EFF5E5';
}
function outCel(obj, id){
	color='#F9F9F2';
	
	if(id=='1'){
		color='#F5F7F6';	
	}
	if(id=='2'){
		color='#EFF3F1';	
	}
	
	obj.style.backgroundColor=color;
}
function wo(ruta){
	window.open(ruta);
}
function wl(ruta){
	window.location=ruta;
}
function verThumb(o){
	GE('thumbB').src = o.firstChild.src;
	return 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 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};
//////
//
var exe_epm = null;
EnviarXemail = function(a,i,t){
	exe_epm = new ProcessLight();
	exe_epm.opciones.Cerrar = true;
	exe_epm.setURL('winemailprint/form_email_xhr.asp?epm_asunto='+encodeStr(a)+'&epm_id='+i+'&epm_tipo='+t);
	exe_epm.show();
}
var id_epm = null;
ImprimirDetalle = function(i,t){
	id_epm = new ProcessLight();
	id_epm.opciones.Cerrar = true;
	id_epm.setURL('winemailprint/det_wiz_print.asp?ser_id='+i+'&ser_tipo='+t);
	id_epm.show();
}
ValidarEmailEPM= function(o){
	if(o.epm_asunto.value.length<1){
		alert("Ingrese el Asunto.");
		o.epm_asunto.focus();
		return false;
	}else if(o.epm_remitente_nombre.value.length<1){
		alert("Ingrese su nombre.");
		o.epm_remitente_nombre.focus();
		return false;
	}else if(o.epm_remitente_email.value.length<1){
		alert("Ingrese su e-mail.");
		o.epm_remitente_email.focus();
		return false;
	}else if(o.epm_remitente_email.value.indexOf("@") < 1 || o.epm_remitente_email.value.indexOf(".") < 1 || o.epm_remitente_email.value.length < 6 ){
		alert('Formato de e-mail incorrecto.');
		o.epm_remitente_email.focus();
		return false;
	}else if(o.epm_destinatarios_emails.value.length<1){
		alert("Ingrese el Destinatario/s.");
		o.epm_destinatarios_emails.focus();
		return false;
	}		
	WINirStepTP(2,1);
	
	var exe_Req = new Request({
		url: 'winemailprint/enviar_detalle_xmail.asp',
		method: 'get',
		onSuccess: function(rText, rXML){
			if(rText == 0){
				exe_epm.close();
			}else{			
				WINirStepTP(3,2);
				(function(){exe_epm.close();}).delay(3000);
			}
		}
	}).send($(o).toQueryString());
	return false;
}

WINimpresion = function(t){
	
	$$('iframe[id=pl_WINprintHide]').dispose();
	
	var _url = 'winemailprint/det_print.asp?'+$(t).toQueryString();
	
	var pl_iframePrintHide = new Element('iframe', {
		id : 'pl_WINprintHide',
		name : 'pl_WINprintHide',
		src: _url,
		styles: {
			top : '-200px',
			left : '-200px',
			width: '1px',
			height: '1px',
			position: 'absolute',
			'z-index' : 70003
		}
	}).injectInside(document.body);
	
	id_epm.close();
	
	return false;
}

WINirStepTP = function(s,h){
	$('WIN_step'+s).setStyle('display', 'block');
	$('WIN_step'+h).setStyle('display', 'none');	
	return false;
}
