	function _$(x){
		return document.getElementById(x);
	} 
	function ancho_pantalla(){
		if (navigator.appName.indexOf('Explorer') != -1)
			return document.body.parentNode.scrollWidth;
		else
			return window.innerWidth;
	}
	function alto_pantalla(){
		if (navigator.appName.indexOf('Explorer') != -1)
			return document.body.parentNode.scrollHeight;
		else
			return window.innerHeight;
	}
	function tecla_pres(event){
		var theCode = (document.all) ? event.keyCode : event.which;
		return theCode;
	}
	function resize_div(div,aoa,dif){
		var div=_$(div);
		if(aoa=='alto'){
			if (navigator.appName.indexOf('Explorer') != -1)
				var addp=document.body.parentNode.scrollHeight-dif;
			else
				var addp=window.innerHeight-dif;
			div.style.height=addp;
		}
		if(aoa=='ancho'){
			if (navigator.appName.indexOf('Explorer') != -1)
				var addp=document.body.parentNode.scrollWidth-dif;
			else
				var addp=window.innerWidth-dif;
			div.style.width=addp;
		}
	}
	function capLock(e){
		var kc=e.keyCode?e.keyCode:e.which;
		var sk=e.shiftKey?e.shiftKey:((kc==16)?true:false);
		if(((kc>=65&&kc<=90)&&!sk)||((kc>=97&&kc<=122)&&sk)){
			var posx=findPosX(_$('nick_login'),1);
			var posy=findPosY(_$('nick_login'));
			_$('caps_lock_div').style.display = 'block';
			_$('caps_lock_div').style.left = posx+'px';
			_$('caps_lock_div').style.top = posy+'px';
		}else
			_$('caps_lock_div').style.display = 'none';
	}
	function findPosX(obj,der){
		var obor=obj;
		var curleft = 0;
		if(obj.offsetParent)
			while(1){
				curleft += obj.offsetLeft;
				if(!obj.offsetParent)
					break;
				obj = obj.offsetParent;
			}
		else if(obj.x)
			curleft += obj.x;
		if(der==1)
			curleft=curleft+obor.offsetWidth;
		return curleft;
	}
	function findPosY(obj){
		var curtop = 0;
		if(obj.offsetParent)
			while(1){
				curtop += obj.offsetTop;
				if(!obj.offsetParent)
					break;
				obj = obj.offsetParent;
			}
		else if(obj.y)
			curtop += obj.y;
		return curtop;
	 }
	function valida_login(){
		if(_$('nick_login').value==''){
			_$('nick_login').focus();
			alert('Por favor indique el usuario');
			return false;
		}
		if(_$('contrasenia_login').value==''){
			alert('Por favor indique el password');
			_$('contrasenia_login').focus();
			return false;
		}
		xajax_valida_login(_$('nick_login').value,_$('contrasenia_login').value,navigator.appName);
	}
    function smilies_window(idtar,e,tipo){
		ventana_con('smilies_'+idtar,'Smilies','','smilies',400,250,'',e);
		xajax_smilies('wc_smilies_'+idtar,idtar,'',tipo);
	}
	function posicion_mouse(e) {
		var posx = 0;
		var posy = 0;
		if(!e){ var e = window.event }
		posx = (e.pageX) ? e.pageX : window.event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = (e.pageY) ? e.pageY : window.event.clientY + document.body.scrollTop + document.documentElement.scrollTop;

		return {y: posy, x:posx}
	}
	function oculta_div(div,o){
		var d=_$(div);
		if(o)
			d.style.display='none';
		else
			d.style.display='';
	}
	function resize_div2(div,w,h){
		resize_div(div,'ancho',w);
		resize_div(div,'alto',h);
	}
	function icon(fr,sitio,theicon,tipo){
		if(tipo){
			var editor=_$(fr).document || _$(fr).contentWindow.document;
			editor.execCommand('InsertImage', false, sitio+'/'+theicon);
			_$(fr).focus();		
		}else
			_$(fr).value=_$(fr).value+' <:'+theicon+':> ';
	}
	function j_f_calc(event,elem){
		var theCode = tecla_pres(event);
		if (theCode == '08')
			return false;
		if(elem.value.length==2)
			elem.value=elem.value+'/';
		if(elem.value.length==5)
			elem.value=elem.value+'/';
	}
	function insertAtCaret(areaId,text) {
		var txtarea = document.getElementById(areaId);
		var scrollPos = txtarea.scrollTop;
		var strPos = 0;
		var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ? 
			"ff" : (document.selection ? "ie" : false ) );
		if (br == "ie") { 
			txtarea.focus();
			var range = document.selection.createRange();
			range.moveStart ('character', -txtarea.value.length);
			strPos = range.text.length;
		}
		else if (br == "ff") strPos = txtarea.selectionStart;
		
		var front = (txtarea.value).substring(0,strPos);  
		var back = (txtarea.value).substring(strPos,txtarea.value.length); 
		txtarea.value=front+text+back;
		strPos = strPos + text.length;
		if (br == "ie") { 
			txtarea.focus();
			var range = document.selection.createRange();
			range.moveStart ('character', -txtarea.value.length);
			range.moveStart ('character', strPos);
			range.moveEnd ('character', 0);
			range.select();
		}
		else if (br == "ff") {
			txtarea.selectionStart = strPos;
			txtarea.selectionEnd = strPos;
			txtarea.focus();
		}
		txtarea.scrollTop = scrollPos;
	}
	
	function crea_window(id_div,css){
		var plat=_$(id_div);
		if(css==undefined)
			css='windoww';
		if(plat==undefined){
			plat=document.createElement('div');
			plat.setAttribute('id',id_div);
			plat.setAttribute('class',css);plat.setAttribute('className',css);
			var pad=_$('master');
			pad.appendChild(plat);
			return true;
		}else{
			alertx('Ya tiene abierto este documento o ventana',2);
			return false;
		}
    }
	function close_window(id_div){
		if(_$(id_div)==undefined)
			return;
		var div=_$(id_div);
		var pdiv=div.parentNode;
		pdiv.removeChild(div);
	}
    function window_block(id_div,css){
		var plat=_$(id_div);
		if(css==undefined)
			css='window_block';
		if(plat==undefined){
			plat=document.createElement('div');
			plat.setAttribute('id',id_div);
			plat.setAttribute('class',css);plat.setAttribute('className',css);
			plat.style.zIndex=2147483647;
			plat.style.height=alto_pantalla();
			plat.style.width=ancho_pantalla();
			var medw=(ancho_pantalla()/2)-72;
			var medh=(alto_pantalla()/2)-50;
			plat.innerHTML='<div style="position: absolute;left:'+medw+'px;top:'+medh+'px;"><h1>Procesando</h1><img src="skin/'+skin+'/progress_bars/progress_bar.gif"><br/><h1>Por favor espere... <h1></div>';
			_$('master').appendChild(plat);
			return true;
		}else{
			alertx('Ya tiene abierto este documento o ventana',2);
			return false;
		}
    }
	function ventana_con(id,titulo,contenido,css,tamx,tamy,fun,ev,res_move){
		if(fun!=undefined)
			var xfun=fun;
		else
			var xfun='';
		if(isNaN(parseInt(tamx))){
			alert('El ancho '+tamx+' no es un numero');
			return false;
		}
		if(isNaN(parseInt(tamy))){
			alert('El alto '+tamy+' no es un numero');
			return false;
		}
		if(crea_window(id,css)){
			var close='<div class="barra_tit" id="arras_'+id+'"> '+titulo+'<a onclick="close_window(\''+id+'\');'+xfun+'"><img src="skin/'+skin+'/img/close.png" alt=\"Cerrar ventana\" title=\"Cerrar ventana\"></a>';
			var resize='<a onclick="_$(\''+id+'\').style.display=\'block\';_$(\''+id+'\').style.top=\'30px\';_$(\''+id+'\').style.left=\'0px\';resize_div2(\''+id+'\',10,42);_$(\'res_'+id+'\').style.display=\'block\';_$(\'max_'+id+'\').style.display=\'none\';res_ven_con(\'wc_'+id+'\',\''+id+'\',\'arras_'+id+'\');"><img src="skin/'+skin+'/img/maximize.png" alt="Maximizar" title="Maximizar" id="max_'+id+'"></a><a onclick="_$(\''+id+'\').style.width=\''+tamx+'px\'; _$(\''+id+'\').style.height=\''+tamy+'px\';oculta_div(\'wc_'+id+'\',0);_$(\'res_'+id+'\').style.display=\'none\';_$(\'max_'+id+'\').style.display=\'block\';_$(\'min_'+id+'\').style.display=\'block\';res_ven_con(\'wc_'+id+'\',\''+id+'\',\'arras_'+id+'\');"><img src="skin/'+skin+'/img/restore.png" style="display:none;"  alt="Restaurar" title="Restaurar" id="res_'+id+'"></a><a onclick="_$(\''+id+'\').style.width=\''+tamx+'px\';_$(\''+id+'\').style.height=\'24px\';_$(\'min_'+id+'\').style.display=\'none\';_$(\'res_'+id+'\').style.display=\'block\';_$(\'max_'+id+'\').style.display=\'block\';"><img src="skin/'+skin+'/img/minimize.png" alt="Minimizar" title="Minimizar" id="min_'+id+'"></a>';
			var con='</div><div id="wc_'+id+'" class="window_con">'+contenido+'</div>';
			_$(id).style.zIndex=2147483643; 
			if(res_move==undefined)
				_$(id).innerHTML=close+resize+con;
			else
				_$(id).innerHTML=close+con;
			if(res_move==undefined)
				arrastrable.call(_$('arras_'+id),_$('arras_'+id).parentNode);
			if(ev!=undefined){
				var pos=posicion_mouse(ev);
				if((pos.x+tamx)>ancho_pantalla())
					pos.x=ancho_pantalla()-tamx;
				if((pos.y+tamy)>alto_pantalla())
					pos.y=alto_pantalla()-tamy;
				_$(id).style.position='absolute';
				_$(id).style.top=pos.y+'px';
				_$(id).style.left=pos.x+'px';
			}else{
				_$(id).style.position='absolute';
				_$(id).style.top=0+'px';
				_$(id).style.left=0+'px';
			}
			_$(id).style.width=tamx+'px';
			_$(id).style.height=(tamy+_$('arras_'+id).offsetHeight)+'px';
			res_ven_con('wc_'+id,id,'arras_'+id);
		}
	 }
	function res_ven_con(id,idpad,idbar){
		_$(id).style.height=(_$(idpad).offsetHeight-_$(idbar).offsetHeight)+'px';
	 }
	function activa_pes(id){
		var hijos=_$('div_pes').childNodes;
		for(x=0;x<hijos.length;x++){
			hijos[x].setAttribute('class','div_pes_off');
			hijos[x].setAttribute('className','div_pes_off');
			var idc=hijos[x].id.split("_");
			//alert(idc);
			if(_$('option_'+idc[1])!=undefined)
				_$('option_'+idc[1]).style.visibility='hidden';
			if(_$('save_'+idc[1])!=undefined)
				_$('save_'+idc[1]).style.visibility='hidden';
			if(_$('save_part_'+idc[1])!=undefined)
				_$('save_part_'+idc[1]).style.visibility='hidden';
			if(_$('pdf_'+idc[1])!=undefined)
				_$('pdf_'+idc[1]).style.visibility='hidden';
			if(_$('excel_'+idc[1])!=undefined)
				_$('excel_'+idc[1]).style.visibility='hidden';
		}
		_$('mpes_'+id).setAttribute('class','div_pes_on');
		_$('mpes_'+id).setAttribute('className','div_pes_on');
		var hijos=_$('div_pes_con').childNodes;
		for(x=0;x<hijos.length;x++)
			hijos[x].style.display='none';
		_$('mpes_con_'+id).style.display='block';
		_$('mpes_con_'+id).style.height=(alto_pantalla()-_$('div_pes').offsetHeight-_$('dhtmlgoodies_menu').offsetHeight-2);
		if(_$('option_'+id)!=undefined)
			_$('option_'+id).style.visibility='visible';
		if(_$('save_'+id)!=undefined)
			_$('save_'+id).style.visibility='visible';
		if(_$('save_part_'+id)!=undefined)
			_$('save_part_'+id).style.visibility='visible';
		if(_$('pdf_'+id)!=undefined)
			_$('pdf_'+id).style.visibility='visible';
		if(_$('excel_'+id)!=undefined)
			_$('excel_'+id).style.visibility='visible';
	}
	function setOpacity(obj,value) {
		if(_$(obj)==undefined)
			return;
		var testObj=_$(obj);
		testObj.style.opacity = value/10;
		testObj.style.filter = 'alpha(opacity=' + value*10 + ')';
	}	 
	function alertx(contenido,retardo,css){
		if(retardo==undefined)
			retardo=3000;
		else
			retardo*=1000;
		if(css==undefined)
			css='alertx';
		if(crea_window('div_alert',css)){
			_$('div_alert').style.zIndex=2147483645;
			_$('div_alert').innerHTML='<a onclick="close_window(\'div_alert\');"><img src="skin/'+skin+'/img/close.png" style="float:right;"><a><br/>'+contenido;
			window.setTimeout('close_window(\'div_alert\');',retardo+(retardo/30));
			for(x=0;x<10;x+=0.2)
				setTimeout("setOpacity('div_alert',"+x+");",retardo-(x*60));
		}else
			alert(contenido);
	 }
	function min_res(b1,b2,b3,t){
		if(_$(b1)==undefined){
			alert(b1+' No esta definido');
			return false
		}
		if(_$(b2)==undefined){
			alert(b2+' No esta definido');
			return false
		}
		if(_$(b3)==undefined){
			alert(b3+' No esta definido');
			return false
		}
		_$(b1).style.display='none';
		_$(b2).style.display='block';
		if(t){
			if(_$(b3)!=undefined)
				_$(b3).style.display='block';
		}else
			if(_$(b3)!=undefined)
				_$(b3).style.display='none';
	}
	function number_format(num,formato) {
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		if(formato=="moneda")
			return (((sign)?'':'-') + '$' + num + '.' + cents);
		if(formato=="porcentaje")
			return (((sign)?'':'-')  + num + '.' + cents+ '%');
		if(formato=="decimal")
			return (((sign)?'':'-') +  num + '.' + cents);
		if(formato=="entero")
			return (((sign)?'':'-') +  num );
		else
			return (((sign)?'':'-') + '$' + num + '.' + cents);
	}
	function resize_pant_res(nom,maxmin,zin){
		if(maxmin=='max'){
			_$(nom+'_con').style.position='absolute';
			_$(nom+'_con').style.zIndex=2147483645;
			_$(nom).style.width=ancho_pantalla()+'px';
			_$(nom).style.height=alto_pantalla()+'px';
			_$('max_'+nom).style.display='none';
			_$('min_'+nom).style.display='block';
		}else{
			_$(nom+'_con').style.position='static';
			_$(nom+'_con').style.zIndex=zin;
			_$(nom).style.width=(((ancho_pantalla()-24)/3))+'px';
			_$(nom).style.height=((alto_pantalla()-20-_$('dhtmlgoodies_menu').offsetHeight)/2)+'px';
			_$('max_'+nom).style.display='block';
			_$('min_'+nom).style.display='none';
		}
	}
	function adjuntos(field,dir,fil,id,tam,maxtam,img,funex){
		xajax_render_ad(_$('iut_'+field+id).value,field,dir,fil,id,tam,maxtam,img,funex);
	}
	function print_ticket(id,hist){
		var contenido=_$('tick_dat_gen'+id).innerHTML+'<br/><hr/>'+_$('tick_mens'+id).innerHTML;
		if(hist==undefined)
			contenido=contenido+'<br/><hr/>'+_$('tick_hist'+id).innerHTML
		var ventana=window.open('lib/php/print.php', 'print'+id, 'width=600, height=400, scrollbars=yes');
		contenido='<html>\n<head>\n<title>Imprimir ticket</title>\n<link rel="stylesheet" type="text/css" href="skin/'+skin+'/style_print.css"/>\n<link rel="stylesheet" type="text/css" href="skin/'+skin+'/style_print.css" media="print"/>\n</head>\n<body onload="window.print();">\n'+contenido+'</body>\n</html>';
		ventana.document.open();
		ventana.document.write(contenido);
		ventana.document.close();
	}
	function print_gen(lobs,title){
		lobs=lobs.split(',');
		var contenido='';
		for(x=0;x<lobs.length;x++)
			contenido=contenido+_$(lobs[x]).innerHTML+'<br/>';
		var ventana=window.open('lib/php/print.php', 'print', 'width=600, height=400, scrollbars=yes');
		contenido='<html>\n<head>\n<title>'+title+'</title>\n<link rel="stylesheet" type="text/css" href="skin/'+skin+'/style_print.css"/>\n<link rel="stylesheet" type="text/css" href="skin/'+skin+'/style_print.css" media="print"/>\n</head>\n<body onload="window.print();">\n'+contenido+'</body>\n</html>';
		ventana.document.open();
		ventana.document.write(contenido);
		ventana.document.close();
	}
	
	function addEvent(obj,fun,type){ 
		if(obj.addEventListener){ 
			obj.addEventListener(type,fun,false); 
		}else if(obj.attachEvent){ 
			var f=function(){ 
				fun.call(obj,window.event); 
			} 
			obj.attachEvent('on'+type,f); 
			obj[fun.toString()+type]=f; 
		}else{ 
			obj['on'+type]=fun; 
		} 
	} 

	function removeEvent(obj,fun,type){ 
		if(obj.removeEventListener){ 
			obj.removeEventListener(type,fun,false); 
		}else if(obj.detachEvent){ 
			obj.detachEvent('on'+type,obj[fun.toString()+type]); 
			obj[fun.toString()+type]=null; 
		}else{ 
			obj['on'+type]=function(){} 
		} 
			 
	} 
	function cancelEv(e){ 
		e=e || window.event; 
		if(e.preventDefault) 
			e.preventDefault(); 
		else 
			e.returnValue=false; 
	} 
	function stopEv(e){ 
		e=e || window.event; 
		if(e.stopPropagation) 
			e.stopPropagation(); 
		else 
			e.cancelBubble=true; 
	} 
	function arrastrable(o){ 
		var o=o || this; 
		this.style.cursor='move'; 
		o.style.cssFloat=o.style.styleFloat='none'; 
		o.style.position='absolute'; 
		addEvent(this,function(e){ 
			e=e || window.event; 
			cancelEv(e); 
			stopEv(e); 
			this.cx0=e.clientX; 
			this.cy0=e.clientY; 
			this.ox=parseInt(o.style.left) || 0; 
			this.oy=parseInt(o.style.top) || 0; 
			addEvent(this,this.arrastrar,'mousemove'); 
		},'mousedown'); 
		this.arrastrar=function(e){ 
			e=e || window.event; 
			cancelEv(e); 
			stopEv(e); 
			o.style.left=this.ox-this.cx0+e.clientX+'px'; 
			o.style.top=this.oy-this.cy0+e.clientY+'px'; 
		} 
		addEvent(this,function(e){ 
			e=e || window.event; 
			cancelEv(e); 
			stopEv(e); 
			removeEvent(this,this.arrastrar,'mousemove'); 
		},'mouseup'); 
		addEvent(this,function(e){ 
			e=e || window.event; 
			cancelEv(e); 
			stopEv(e); 
			removeEvent(this,this.arrastrar,'mousemove'); 
		},'mouseout'); 
	} 

function conv_fecha(fecha,h,m,s){
	fecha=fecha.split('/');
	var fecha_actual=new Date();
	fecha_actual.setFullYear(fecha[2]);
	fecha_actual.setMonth(fecha[1]-1);
	fecha_actual.setDate(fecha[0]);
	fecha_actual.setHours(h);
	fecha_actual.setMinutes(m);
	fecha_actual.setSeconds(s);
	var funix_ms=fecha_actual.getTime();
	var funix=Math.floor(funix_ms.valueOf() * 0.001);
	return funix;
}

function in_fecha(name,val){
	return '<div class="img_calen"><a onclick="calendario(_$(\''+name+'\').value,\''+name+'\',event,\'\');"><img src="skin/'+skin+'/img/calen.png" alt="Ver calendario" title="Ver calendario"></a></div><input type="text" id="'+name+'" name="'+name+'" value="'+val+'" maxlength="10" onkeyup="j_f_calc(event,this);" class="i_calen" />';
}
var meses = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
function calendario(fecha,input,e,div,action){
	actions=action.replace(/\\/g,"\\\\");
	actions=actions.replace(/\'/g,"\\'");
	actions=actions.replace(/\"/g,"\\\"");
	if(div==undefined){
		div='calendario_div_'+input;
		if(!crea_window(div,'div_calen'))
			return false;
	}
	if(e!=undefined){
		var pos=posicion_mouse(e);
		if((pos.x+254)>ancho_pantalla())
			pos.x=ancho_pantalla()-254;
		if((pos.y+194)>alto_pantalla())
			pos.y=alto_pantalla()-194;
		_$(div).style.top=pos.y+'px';
		_$(div).style.left=pos.x+'px';
	}
	if(fecha !=''){
		fecha=fecha.split('/');
		var mesx=parseInt(fecha[1],10)-1;
		var fecha_actual=new Date();
		fecha_actual.setFullYear(fecha[2]);
		fecha_actual.setMonth(mesx,1);
		//fecha_actual.setDate(fecha[0]);
		//fecha_actual.setDate(1);
	}else
		var fecha_actual = new Date();
	//alert(fecha);
	//alert(mesx);
	//alert(fecha_actual);
	var mes = fecha_actual.getMonth() + 1;
	var dia_mes = fecha_actual.getDate();
	var anio = fecha_actual.getFullYear();
	var dia_semanact=primer_dia_mes(mes,anio);
	var dias_mes=dias_del_mes(mes,anio);
	var sel_mes='<a onclick="calendario(arma_fec('+dia_mes+','+(mes-1)+','+anio+'),\''+input+'\',undefined,\''+div+'\',\''+actions+'\');"><img src="skin/'+skin+'/img/left.png" style="float:left;margin-top:5px;" alt="Mes anterior" title="Mes anterior"></a><select onchange="calendario(arma_fec('+dia_mes+',this.value,'+anio+'),\''+input+'\',undefined,\''+div+'\',\''+actions+'\');" class="selec_cal">';
	for(x=0;x<meses.length;x++){
		sel_mes=sel_mes+'<option value="'+(x+1)+'"';
		if((x+1)==mes)
			sel_mes=sel_mes+' selected '
		sel_mes=sel_mes+'>'+meses[x]+'</otion>';
	}
	sel_mes=sel_mes+'</select><a onclick="calendario(arma_fec('+dia_mes+','+(mes+1)+','+anio+'),\''+input+'\',undefined,\''+div+'\',\''+actions+'\');"><img src="skin/'+skin+'/img/right.png" style="float:left;margin-top:5px;" alt="Mes siguiente" title="Mes siguiente"></a>';
	sel_mes=sel_mes+'<a onclick="calendario(arma_fec('+dia_mes+','+mes+','+(anio-1)+'),\''+input+'\',undefined,\''+div+'\',\''+actions+'\');"><img src="skin/'+skin+'/img/left.png" style="float:left;margin-top:5px;" alt="A&ntilde;o anterior" title="A&ntilde;o anterior"></a><select onchange="calendario(arma_fec('+dia_mes+','+mes+',this.value),\''+input+'\',undefined,\''+div+'\',\''+actions+'\');"  class="selec_cal">';
	for(x=anio-7;x<(anio+8);x++){
		sel_mes=sel_mes+'<option value="'+(x)+'"';
		if((x)==anio)
			sel_mes=sel_mes+' selected '
		sel_mes=sel_mes+'>'+x+'</otion>';
	}
	sel_mes=sel_mes+'</select><a onclick="calendario(arma_fec('+dia_mes+','+mes+','+(anio+1)+'),\''+input+'\',undefined,\''+div+'\',\''+actions+'\');"><img src="skin/'+skin+'/img/right.png" style="float:left;margin-top:5px;" alt="A&ntilde;o siguiente" title="A&ntilde;o siguiente"></a>';
	sel_mes=sel_mes+'<a onclick="close_window(\''+div+'\');"><img src="skin/'+skin+'/img/close.png" style="float:right;" alt="Cerrar calendario" title="Cerrar calendario"></a>';
	var html=sel_mes+'<table class="tabla_calen"><thead><tr><th>Dom</th><th>Lun</th><th>Mar</th><th>Mier</th><th>Jue</th><th>Vie</th><th>Sab</th></tr></thead><tr>';
	var cd=dia_semanact;
	if(dia_semanact)
		html=html+'<td colspan="'+(dia_semanact)+'"></td>';
	for (i = 0; i < dias_mes; i++){
		if(i)
			if(cd%7==0)
				html=html+'</tr><tr>';
		var fec=arma_fec(i+1,mes,anio);
		if(i%2)
			var color='class="odd"';
		else
			var color='';
		html=html+'<td '+color+'onclick="_$(\''+input+'\').value=\''+fec+'\';_$(\''+input+'\').focus();close_window(\''+div+'\');'+action+'">'+(i+1)+'</td>';
		cd++;
	}
	html=html+'</tr></table>';
	_$(div).innerHTML=html;
	_$(div).style.display='block';
	if(e!=undefined){
	//if(_$(div).style.display=='none'){
		setOpacity(div,0);
		var y=10;
		for(x=0;x<10;x+=0.1){
			setTimeout("setOpacity('"+div+"',"+y+");",500-(x*60));
			y-=0.1;
		}
	}
}
function dias_del_mes(mes,anio){
	if((mes==1)||(mes==3)||(mes==5)||(mes==7)||(mes==8)||(mes==10)||(mes==12))
		return 31;
	else if(mes==2){
		if ((anio % 4 == 0) && ((anio % 100 != 0) || (anio % 400 == 0)))
			return 29;
		else
			return 28;
	}else
		return 30;
}
function arma_fec(d,m,a){
	if(d<10)
		d='0'+d;
	if(m<10)
		m='0'+m;
	return (d+'/'+m+'/'+a);
}
function primer_dia_mes(mes,anio){
	var fect=new Date();
	fect.setFullYear(anio);
	fect.setMonth((mes-1),1);
	//fect.setDate(1);
	return fect.getDay();
}
var meses_rev = new Array();
meses_rev['Enero']=1;
meses_rev['Febrero']=2;
meses_rev['Marzo']=3;
meses_rev['Abril']=4;
meses_rev['Mayo']=5;
meses_rev['Junio']=6;
meses_rev['Julio']=7;
meses_rev['Agosto']=8;
meses_rev['Septiembre']=9;
meses_rev['Octubre']=10;
meses_rev['Noviembre']=11;
meses_rev['Diciembre']=12;


	rev_cuenta=function(e,val){
		tecla = (document.all) ? e.keyCode : e.which;
		if(tecla==8)
			return true;
		te = String.fromCharCode(tecla);
		if(te==' '){
			var d=val.split(' ');
			for(x=0;x<d.length-1;x++){
				if(x<2)
					a=5;
				else
					a=4;
				if(d[x].length<a){
					for(y=d[x].length;y<a;y++)
						d[x]='0'+d[x];
				}
			}
			val=d.join(' ');
		}else{
			if(val.length==5 || val.length==11)
				val=val+' ';
		}
		if(val.length>16)
			val=val.substr(16);
		var cuenta=_$('cuenta');
		cuenta.value=val;
	}
	rev_cuenta2=function(val){
		var d=val.split(' ');
		for(x=0;x<d.length;x++){
			if(x<2)
				a=5;
			else
				a=4;
			//alert(d[x].length+' '+x);
			if(d[x].length<a && d[x].length>0){
				for(y=d[x].length;y<a;y++)
					d[x]='0'+d[x];
			}
		}
		val=d.join(' ');
		if(val.length>16)
			val=val.substr(16);
		var cuenta=_$('cuenta');
		cuenta.value=val;
	}
	calc_col=function(e){
		var cord=posicion_mouse(e);
		cord.x=cord.x-findPosX(_$('div_mcex_con'),0)-18;
		var col=Math.round(cord.x/6);
		if(cord.x>=6){
			//alert('columna '+col);
			lista=_$('cols').value.split(',');
			var ex=0;
			var lista2=new Array();
			var y=0;
			for(x=0;x<lista.length;x++){
				if(lista[x]==col)
					ex=1;
			}
			if(!ex){
				lista[x]=col;
				linea=document.createElement('div');
				linea.setAttribute('id','div_'+col);
				linea.setAttribute('class','linea');linea.setAttribute('className','linea');
				linea.style.top=findPosY(_$('div_mcex_con'));
				linea.style.left=col*6+18;
				linea.style.height=_$('div_mcex_con').offsetHeight;
				var pad=_$('div_mcex');
				pad.appendChild(linea);
			}else{
				var linea=_$('div_'+col);
				var pad=linea.parentNode;
				pad.removeChild(linea);
				for(x=0;x<lista.length;x++){
					if(lista[x]!=col){
						lista2[y]=lista[x];
						y++;
					}
				}
				lista=lista2;
			}
			_$('cols').value=lista.join(',');
			if(_$('sep1').value!=''){
				_$('sep1').value='';
				_$('sep2').value='';
				render_exfile();
			}
		}
	}
	rem_col=function(){
		lista=_$('cols').value.split(',');
		for(x=1;x<lista.length;x++){
			var linea=_$('div_'+lista[x]);
			var pad=linea.parentNode;
			pad.removeChild(linea);
		}
		_$('cols').value=0;
	}






	function mail_baja_mail(t){
		_$('email_status').innerHTML='Estableciendo conexion con el servidor....<img src="skin/'+skin+'/loading/loading6.gif\">';
		if(t==0)
			xajax_universal('mail_baja_mail_pop3');
		else
			xajax_universal('mail_busca_mail_imap');
	}
	function reem_coma(obj){
		obj.value=obj.value.replace(/;/,',');
	}
	function valEmail(id){
		if(_$('mailto'+id).value==''){
			alertx('Debe escribir al menos una direccion de correo');
			_$('mailto'+id).focus();
			return false;
		}
		reem_coma(_$('mailto'+id));
		reem_coma(_$('mailcc'+id));
		reem_coma(_$('mailbcc'+id));
		re=/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/
		var para=_$('mailto'+id).value.split(',');
		for(x=0;x<para.length;x++){
			var valor=para[x];
			if(!re.exec(valor)){
				alert('Por favor verifique que la direccion '+valor+' este correctamente escrita');
				_$('mailto'+id).focus();
				return false;
			}
		}
		if(_$('mailcc'+id).value!=''){
			var para=_$('mailcc'+id).value.split(',');
			for(x=0;x<para.length;x++){
				var valor=para[x];
				if(!re.exec(valor)){
					alert('Por favor verifique que la direccion '+valor+' este correctamente escrita');
					_$('mailcc'+id).focus();
					return false;
				}
			}
		}
		if(_$('mailbcc'+id).value!=''){
			var para=_$('mailbcc'+id).value.split(',');
			for(x=0;x<para.length;x++){
				var valor=para[x];
				if(!re.exec(valor)){
					alert('Por favor verifique que la direccion '+valor+' este correctamente escrita');
					_$('mailbcc'+id).focus();
					return false;
				}
			}
		}
		return true;
	}
	pop3del=function(id){
		if(confirm('Desea borrar permanentemente este mensaje?'))
			xajax_universal('mail_borra_pop3',id);
		else
			return false;
	}

    function Notifier() {}
    // Returns "true" if this browser supports notifications.
    Notifier.prototype.HasSupport = function() {
		if (window.webkitNotifications)
			return true;
		else
			return false;
    }
    // Request permission for this page to send notifications. If allowed,
    // calls function "cb" with true.
	Notifier.prototype.RequestPermission = function(cb) {
		if(window.webkitNotifications.checkPermission()==0)
			alertx('Ya tiene permitidas las notificaciones de escritorio',3,'alerty');
		if(window.webkitNotifications.checkPermission()==2)
			alertx('Tiene bloquedas la notificaciones, para autorizarlas debe configurar su navegador',8);
		window.webkitNotifications.requestPermission(
			function(){
				if (cb)
					cb(window.webkitNotifications.checkPermission() == 0);
			}
		);
    }
    // Popup a notification with icon, title, and body. Returns false if
    // permission was not granted.
    Notifier.prototype.Notify = function(icon, title, body) {
		if (window.webkitNotifications.checkPermission() == 0) {
			var popup = window.webkitNotifications.createNotification(icon, title, body);
			popup.show();
			setTimeout(function(){popup.cancel();}, '15000');
			return true;
		}
		return false;
    }
    var notifier = new Notifier();
	function pide_permiso_not(){
		if (!notifier.HasSupport()){
			alertx('Su navegador no soporta notificaciones, utilice Sware Iron o Google Chrome.');
			return;
		}
        notifier.RequestPermission();
    }
	function notifica_esc(icon,tit,men){
        if (!notifier.Notify(icon, tit, men)) {
          alertx('No es posible generar notificaciones.');
        }
	}
	function clickea(ob){
		var nouEvent = document.createEvent("MouseEvents");
		nouEvent.initMouseEvent("click", true, true, window,0, 0, 0, 0, 0, false, false, false, false, 0, null);
		var objecte = _$(ob);
		var canceled = !objecte.dispatchEvent(nouEvent);
	}
