function $(v) { return(document.getElementById(v)); }function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }function xy(e,v) { return(v?(agent('msie')?event.clientY+document.body.scrollTop:e.pageY):(agent('msie')?event.clientX+document.body.scrollTop:e.pageX)); }function dragOBJ(d,e) {    function drag(e) { if(!stop) { d.style.top=(tX=xy(e,1)+oY-eY+'px'); d.style.left=(tY=xy(e)+oX-eX+'px'); } }    var oX=parseInt(d.style.left),oY=parseInt(d.style.top),eX=xy(e),eY=xy(e,1),tX,tY,stop;    document.onmousemove=drag; document.onmouseup=function(){ stop=1; document.onmousemove=''; document.onmouseup=''; };}


function mAsignaValor(c,v)
{
document.getElementById(c).value=v;
} 

function mAsignaFLAG(c)
{
document.getElementById("FLAG").value=c;
} 

function cargar(pag)
{ 
 top.window.CARGAR.location=pag;
} 

function autofitIframe(id)
{
document.getElementById(id).style.height=document.body.clientHeight - 100 +"px"
}

function mfocus(c)
{
document.focus();
document.getElementById('FLAG').focus;
var ob = document.getElementById(c);
ob.focus();
}

function getAbsoluteElementPosition(element) {
	if (typeof element == "string")
	  element = document.getElementById(element)
		
	if (!element) return { top:0,left:0 };
	
	var y = 0;
	var x = 0;
	while (element.offsetParent) {
		x += element.offsetLeft;
		y += element.offsetTop;
		element = element.offsetParent;
	}
	return {top:y,left:x};
}




function posicion_obj(de) {
  var elemento = document.getElementById(de);
  var pos = getAbsoluteElementPosition(elemento)
  return {top:pos.top,left:pos.left};
}



function situardiv(obj,id)
{
var ob=document.getElementById(obj);
var pos = getAbsoluteElementPosition(obj);
var div=document.getElementById(id);
div.style.left=pos.left;
div.style.top=pos.top + 20;

}

function truncar_textarea(id,maximo)
{ 
  
  var n = id.value.length
  var t = maximo; 
  if (n > t)
  {
    id.value =id.value.substring(0, t);

  }
}


function popcaltest(vCaption,nameText, vField, vDate){
    var xy= getAbsoluteElementPosition(nameText);
	var atrib="resizable=no,scrollbars=no,width=200,height=210" + ",top=" + xy.top + ",left=" + xy.left
	var no = window.open("", "calendario", atrib);
	
	no.location.href = "/Restobar/Calendar/popcalendar.asp?caption=" + escape(vCaption) + "&field=" + vField + "&date=" + vDate;
	no = null;
}





function posicion_div(de,a)
{
document.getElementById(a).left=document.getElementById(de).offsetLeft;
document.getElementById(a).top=document.getElementById(de).offsetTop - document.getElementById(de).height;
document.getElementbyId(a).style.display="none";
}




function popup_window(vCaption,url,atributos){
	var atrib=atributos;
	var no = window.open("", '', atrib);
	no.location.href = url;
	no = null;
}

function reportprint(vCaption,url)
{var atrib="width=780,height=550,top=0,left=0, status =no, menubar = yes, scrollbars = yes";
var no = window.open("", '', atrib);
no.location.href = url;
no = null;
}


function PreviewDoc(dir,top,left)
{ 
 var no = window.open("", "calendario", "resizable=no,scrollbars=1,width=700,height=500" + ",top=" + top + ",left=" + left);
 no.location.href =dir;
 no.focus();
 no=null;
} 




function CambiarPorte(id,j)
{
if(j==1)
{
id.style.border ='groove';
}
else
{
id.style.border='none';
}
}




function cargarContenido(urls,objeto,preload,proper)
{

var ancho,altura
document.body.style.cursor='wait';

if (preload != 'none' && proper =='')
{ 
asignaZindex('preload');
}

if (preload != 'none' && proper =='')
{
document.getElementById(preload).style.visibility='visible';
document.getElementById(objeto).innerHTML="";
document.getElementById(objeto).style.visibility='hidden';
}


if (document.all) { 
ancho = document.body.clientWidth; 
altura = document.body.clientHeight; 
} 
else { 
ancho = window.innerWidth 
altura = window.innerHeight 
} 

if (preload != 'none')
{
document.getElementById(preload).style.top=(altura/2);
document.getElementById(preload).style.left=(ancho/2)- 100;

document.getElementById(preload).innerHTML="";
document.getElementById(preload).innerHTML="<table style='border:0px #f4f4f4 outset; background-color:#ffffff'><td style='font-family:arial;font-size:10px;color:#666666'></td><tr><td align='center' valign='middle'><img src='/digitech/Imagenes/upload_progress.gif'></td></table>";

}



var ajax=null;
ajax=nuevoAjax();
// sincronico = false se ejecuta hasta que termine el proceos , asincronico=true, pasa de largo;

ajax.open("POST", urls,false);
ajax.onreadystatechange=function()
{
	
    if (ajax.readyState == 1)
	 {
	    if (preload != 'none')
        {

		}
     }

    if (ajax.readyState == 2)
	 {
	    if (preload != 'none')
        {

		}
     }

    if (ajax.readyState == 3)
	 {
	    if (preload != 'none')
        {

		}
     }

    if (ajax.readyState==4)
	 {
		
		 
	    if (preload != 'none')
        {
	
		document.getElementById(preload).style.visibility='hidden';
		}
		
		if (proper != '')
		{
			if(ajax.status == 200)
            {
 			document.getElementById(objeto).value= ajax.responseText;
			}
		}
	    else
		{	
		    if(ajax.status == 200)
            {

			document.getElementById(objeto).innerHTML= ajax.responseText;
			asignaZindex(objeto);
			document.getElementById(objeto).style.visibility='visible';
			}
		}
     }
}
document.body.style.cursor='default';
ajax.send(null)
}







var colum=0; // columna por la que se filtrará
var valor; // value del botón que se ha pulsado

function activarSearch(tbl,obj,num) {
  var t = document.getElementById(tbl);
  
   // Elimino si existe caja de texto
  var cols = t.getElementsByTagName('th');
  for (i=1; ele=cols[i]; i++){
    cols[i].innerHTML="";
	cols[i].innerHTML=cols[i].title;}
  
  
   // Deseleccionar columna anterior
  filas = t.getElementsByTagName('tr');
  for (i=1; ele=filas[i]; i++) 
    ele.getElementsByTagName('td')[colum].name='';
  // Seleccionar columna actual
  colum=num;
  for (i=1; ele=filas[i]; i++)
    ele.getElementsByTagName('td')[colum].name=' ';
  // Cambiar botón por cuadro de texto
  valor = obj.title;
  celda = obj;
  celda.innerHTML="";
  celda.title=valor;
  txt = document.createElement('input');
  txt.className='buscargrid';
  celda.appendChild(txt);
  txt.value=valor;
  txt.focus();
  txt.select();
  txt.onblur = function() {restaura(tbl,this,num)};
  txt.onkeyup = function() {filtra(tbl,this.value)};

}

function restaura(tbl,obj,num) {
  celda = obj.parentNode;
  celda.innerHTML="";
  celda.innerHTML=celda.title;
}

function filtra(tbl,txt) {
  t = document.getElementById(tbl);
  filas = t.getElementsByTagName('tr');
  for (i=1; ele=filas[i]; i++) {
    texto = ele.getElementsByTagName('td')[colum].innerHTML.toUpperCase();
    num=2;
      
    if (num==0) posi = (texto.indexOf(txt.toUpperCase()) == 0);
    else if (num==1) posi = (texto.lastIndexOf(txt.toUpperCase()) == texto.length-txt.length);
    else posi = (texto.indexOf(txt.toUpperCase()) != -1);
    ele.style.display = (posi) ? '' : 'none';
  } 
}


function marcatr(tbl,id)
{
  var t = document.getElementById(tbl);
  var cols = t.getElementsByTagName('tr');
  for (i=1; ele=cols[i]; i++)
  {
	  if(cols[i].id == id){cols[i].style.backgroundImage ="url(/digitech/Imagenes/skin_light_header.png)" }
	  else
	  { cols[i].style.backgroundImage ="url()";}
  }

}

function selTR(antes,ahora)
{
  if(antes !=''){document.getElementById(antes).style.backgroundImage="url()";document.getElementById(antes).title="";}
  document.getElementById(ahora).style.backgroundImage ="url(/softbuilder/imagenes/selrow.gif)";
  document.getElementById('antes').value =ahora;
 
}
function selTR_menu(ancla,antes,ahora)
{
  document.getElementById(antes).style.backgroundImage="url()";
  document.getElementById(ahora).style.backgroundImage ="url(/maatfact_v1/imagenes/sel_menu.png)";
  document.getElementById(ahora).style.backgroundRepeat="no-repeat"; 
  document.getElementById(ancla).value =ahora;
}

function selTR2(nom,ancla,antes,ahora)
{

  document.getElementById(nom + antes).style.backgroundColor="white";
  document.getElementById(nom + ahora).style.backgroundColor="#FFCC80";
  document.getElementById(ancla).value =ahora;
}

// sincronico = false se ejecuta hasta que termine el proceos , asincronico=true, pasa de largo;
function winAjax(objeto,titulo,urls)
{var ajax=null;ajax=nuevoAjax();
ajax.open("POST", urls,false);
ajax.onreadystatechange=function()
{
    if (ajax.readyState==4)
	 {
			if(ajax.status == 200)
            {
			if (document.getElementById(objeto).style.visibility=='hidden') {document.getElementById(objeto).style.visibility='visible';}
    		document.getElementById(objeto).innerHTML='procesando...'
 			document.getElementById(objeto).innerHTML= "<div style='background-color:#FFFFFF' onclick=asignaZindex('" + objeto + "'); ><table border='0' cellpadding='0' cellspacing='0'><td class='wins_corner_left_up'>&nbsp;</td><td><table class='wins_title_active' ><td >&nbsp;" + titulo + "</td><td width='1%' valing='right'><img src='../codebase/imgs/dhxwins_vista_blue/active/btns_default/btn_close.gif' onclick=ShowHide('" + objeto + "','hidden');></td></table></td><td class='wins_corner_right_up'>&nbsp;</td><tr><td class='wins_middle_left_up'>&nbsp;</td><td>" + ajax.responseText + "</td><td class='wins_middle_right_up'>&nbsp;</td><tr><td class='wins_corner_left_botom'>&nbsp;</td><td class='wins_corner_middle_botom'>&nbsp;</td><td class='wins_corner_right_botom'>&nbsp;</td></table></div>"
			asignaZindex(objeto);
			}
	 }
}
ajax.send(null)
}

function ajaxtext(urls,objeto)
{var ajax=null;ajax=nuevoAjax();ajax.open("POST", urls,false);ajax.onreadystatechange=function(){if (ajax.readyState==4){if(ajax.status == 200){document.getElementById(objeto).value= ajax.responseText;}}}
ajax.send(null)}

function ajaxAlertas(urls,objeto){var ajax=null;ajax=nuevoAjax();ajax.open("POST", urls,false);ajax.onreadystatechange=function(){if (ajax.readyState == 1){document.getElementById(objeto).innerHTML="Buscando solicitudes sin Comprometer";}if (ajax.readyState==4){if(ajax.status == 200){document.getElementById(objeto).innerHTML="";document.getElementById(objeto).innerHTML= ajax.responseText;} }}
document.getElementById(objeto).innerHTML="";ajax.send(null)
}

function ajaxoBJ(urls,objeto){var ajax=null;ajax=nuevoAjax();ajax.open("POST", urls,false);ajax.onreadystatechange=function(){ if (ajax.readyState==4){if(ajax.status == 200){document.getElementById(objeto).innerHTML="";document.getElementById(objeto).innerHTML= ajax.responseText;}}}
ajax.send(null)}


function popup_preview_solicitudes_cliente(){popup_window("Vista previa Solicitudes","/digitech/rpt/preview_rpt.asp?PARAMETROS={view_estado_solicitudes_cliente.cliente}='" + document.getElementById('cliente').value + "'&REPORTE=estado de solicitudes.rpt","width=750,height=550,top=0,left=0");}

function popup_preview_unidades_cliente(){popup_window("Vista previa Unidades","/digitech/rpt/preview_rpt.asp?PARAMETROS={viewEquiposClientes.cliente}='" + document.getElementById('cliente').value + "'&REPORTE=EquiposCliente.rpt","width=750,height=550,top=0,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,titlebar=no");}

function editRow(tabla){
var sel=false;	
	if(document.getElementById(tabla).title !="")
	{
		sel=true;
	}
	else
	{
		sel=false;
	}
return(sel);	
	
}



function nada()
{}

function CargaObjetoenDiv(id,idcol,numcols,objhtml,nameobjHtml)
{
 
 	for(i=0;i<=numcols;i=i+1)
	{ 
		document.getElementById(idcol + i).innerHTML="";
		document.getElementById(idcol + i).innerHTML=document.getElementById(idcol + i).title;
	}
	
    document.getElementById(id).innerHTML="";
	document.getElementById(id).innerHTML= objhtml;
	document.getElementById(nameobjHtml).focus();
}


function DescargaObjetoenDiv(idcol,numcols)
{
 
 	for(i=0;i<=numcols;i=i+1)
	{ 
		document.getElementById(idcol + i).innerHTML="";
		document.getElementById(idcol + i).innerHTML=document.getElementById(idcol + i).title;
	}
}


function ShowHideAlldiv(id,numcols)
{
	for(i=0;i<=numcols;i=i+1)
	{ 
		document.getElementById(id + i).style.visibility='hidden';
	}	
}



function ENVIA(action)
{
var accion = action;
window.document.formulario.action = accion;
window.document.formulario.method= 'POST';
document.formulario.submit(); 
}



function ENVIA_CON_TARGET(action,tar)
{
var accion = action;
window.document.formulario.action = accion;
window.document.formulario.method= 'POST';
window.document.formulario.target=tar;
document.formulario.submit(); 
}


function centrarme(id)
{
if (document.all) { 
ancho = document.body.clientWidth; 
altura = document.body.clientHeight; 
} 
else { 
ancho = window.innerWidth 
altura = window.innerHeight 
} 

alert('ancho:' + ancho + ' alto:' + altura);
obj = document.getElementsByTagName("div");
var str=obj[id].style.width;
var fin=str.indexOf('p'); 
var anc=str.substring(0,fin); 

str=obj[id].style.height;
var fin=str.indexOf('p'); 
var alt=str.substring(0,fin); 
obj[id].style.left =(ancho / 4) 
obj[id].style.top =(altura / 4)

alert('pase por aqui');
}



function SituarPanel(id,l,t)
{
if (document.all) { 
ancho = document.body.clientWidth; 
altura = document.body.clientHeight; 
} 
else { 
ancho = window.innerWidth 
altura = window.innerHeight 
} 

obj = document.getElementsByTagName("div");

	if (l !=0 ){ 
	    obj[id].style.left =l;
	}
	else
	{
		obj[id].style.left =0
	}
	
	
	if(t !=0) {
	    obj[id].style.top =(altura - t);
	}
	else
	{
	    obj[id].style.top=0;
	}
}



function zindexDiv()
{
var DIV = document.getElementsByTagName("div");
	for (i = 0;i < DIV.length; i ++)
	 {
	  DIV[i].style.zIndex=i;
	 }
}

function asignaZindex(id)
{

zindexDiv();
var DIV = document.getElementById(id);
DIV.style.zIndex=9999999;

}


function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;

  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";

  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;

  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;

  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}


function opacidad(objId,opacity,time) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
	  if (time >0)
	  {
      window.setTimeout("opacidad('"+objId+"',"+opacity+")", time);
	  }
    }
  }
}

function opacarTablasGridAjax(noOpacar)
{
var tab;
var objno=noOpacar;
var DIV = document.getElementsByTagName("table");
	for (i = 0;i < DIV.length; i ++)
	 {

	    if (DIV[i].name != 'undefined' && DIV[i].name != objno)
	     { 
		 DIV[i].style.filter = "alpha(opacity:70)"; 
		 }
		 else
		 {
		  DIV[i].style.filter = "alpha(opacity:100)"; 
		 }
	 }
}


function ShowHide(id,ver)
{
  var obj = document.getElementById(id);
  obj.style.display=ver;
  asignaZindex(id);
}

function centrarscreen(ancho,alto)
{

var alt=(screen.height / 2) - (alto / 2);
var anc=(screen.width / 2) - (ancho / 2); 

var atrib="";
atrib="top=" + alt + ",left=" + anc + ",width=" + ancho + ",height=" + alto;
return atrib;
}


function ATRIBUTOS()
{ 
	window.statusbar=false;
    window.resizeTo(screen.availWidth,screen.availHeight);
	window.moveTo(0, 0); 
 } 
 
function Mesjs(x)
{
  switch (x) 
  {
    case "1":return "Enero";
    case "2":return "Febrero";
    case "3":return "Marzo";
    case "4":return "Abril";
    case "5":return "Mayo";
	case "6":return "Junio";
	case "7":return "Julio";
	case "8":return "Agosto";
	case "9":return "Septiembre";
	case "10":return "Octubre";
	case "11":return "Noviembre";
	case "12":return "Diciembre";
  }
}


 

function AbrirpopUp(str,title,atr)
{
var popup;

var a=atr;
popup = window.open(str,title,a);
popup.focus();
}


function imprimir(titulo,col,row)
{ 
var columnas="";

if(col !="")
{ columnas = document.getElementById(col).outerHTML; }
else
{ columnas =""; }

var detalle = document.getElementById(row).outerHTML; 
var ventana=window.open(titulo,"ventana","width=700,height=600,top=0,left=3000"); 
ventana.document.open(); 
ventana.document.write('<html>' );
ventana.document.write('<link href="/digitech/Paginas/style.css" rel="stylesheet" type="text/css"><head><title></title></head><body class="label" onprint="self.close()">');
ventana.document.write('<table width=100%><td align="left"><img src="/digitech/Imagenes/LogoDigitech4x1.gif"></td></table><br><br>');
ventana.document.write('<label style="font-family:arial;font-size:14px;text-decoration:underline">'+ titulo + '</label><br>');
ventana.document.write('<hr width=100%>');
ventana.document.write(columnas);
ventana.document.write('<hr width=100%>');
ventana.document.write(detalle);
ventana.document.write('</body></html>'); 
ventana.document.close(); 
ventana.print();
ventana.focus(); 
ventana.close();
} 

function lanza_popup()
{
window.open("/digitech/Paginas/mail.asp", "", "width=1,height=1,resizable=no,scrollbars=no"); 
}


function popupimg(imgs)
{ 

var ven=window.open("about :blank","ventana","top=0,left=0"); 
ven.document.open(); 
ven.document.write('<html>');
ven.document.write('<img src="' + imgs + '" width=100%');
ven.document.write('</body></html>'); 
ven.focus(); 
} 



function exportarFile(titulo,col,row,arch)
{ 
var columnas = document.getElementById(col).outerHTML; 
var detalle = document.getElementById(row).outerHTML; 
var ventana=window.open("about :blank","ventana","width=800,height=600,top=0,left=3000"); 
var archivo= arch
ventana.document.open(); 
ventana.document.write('<html>');
ventana.document.write('<link href="/Restobar/Paginas/style.css" rel="stylesheet" type="text/css"><head><title></title></head><body class="label" onprint="self.close()">');
ventana.document.write('<table width=100%><td align=left class=label>Sagc.net</td></table>');
ventana.document.write(titulo);
ventana.document.write(columnas);
ventana.document.write(detalle);
ventana.document.write('</body></html>'); 
ventana.document.close(); 
ventana.document.execCommand("SaveAs",false,archivo);
ventana.focus(); 
ventana.close();
} 

function sobre(activatab,tabscount)
{

 var tabsel=document.getElementById(activatab); 	
 for(i=0;i <= tabscount;i++)
 {
    var tabdesSel=document.getElementById('men_' + i); 
	tabdesSel.className='mendesel';
 }
	tabsel.className='mensel';
}


function fuera(d)
{
	
}

function sobrex(d)
{
d.style.backgroundImage="url('/digitech/Imagenes/boton_menu.bmp')";
d.style.color='#cccccc';
d.style.cursor='hand';
}

function fuerax(d)
{
d.style.backgroundImage="url('')";
d.style.color='#000000';
}

function activaTabs(activatab,tabscount)
{
 var tabsel=document.getElementById(activatab); 	
 for(i=0;i <= tabscount;i++)
 {
    var tabdesSel=document.getElementById('tab_' + i); 
	tabdesSel.className='tabdesel';
 }
	tabsel.className='tabsel';
}


function Cambia_Imagen(id,imagen)
{
document.getElementById(id).style.backgroundImage ="url("+ imagen +")";
}


function OpacarImg(im)
{
  
  var img=document.getElementById(im);
  img.style.filter = 'alpha(opacity =60)';
  img.style.cursor='hand';

} 


function NoOpacarImg(im)
{
   var img=document.getElementById(im);
    img.style.filter = 'alpha(opacity =100)'; 

}

function setOpacity (imgName, step, delay) 
{
  var img = document.images[imgName];
  img.opacity += step;
  if (document.all) img.style.filter = 'alpha(opacity = ' + img.opacity + ')'; 
  if (step > 0 && img.opacity < 100 || step < 0 && img.opacity > 0)
    setTimeout('setOpacity("' + img.name + '",' + step + ', ' + delay + ')', delay);
} 

function foco(im)
{
document.focus();
var ob = document.getElementById(im);
ob.focus();
}

function activaDesactivaText(nameObj,id,id2,activa,classActivado,classDesactivado)
{
obj=document.all.length
LenStr = nameObj.length;
for(i=0;i<obj;i++)
{
    
    if(document.all[i].type=="text")
    {
	    if (document.all[i].id.substring(0,LenStr) == nameObj)
		{
            document.all[i].readOnly=true
		    document.all[i].className=classDesactivado
        }			
    }
}


var text=document.getElementById(id);

if (activa=='activa')
{
      text.readOnly=false;
	  text.className=classActivado;
	  text.select();
	  text.focus();}

if (activa=='')
{
   var text2=document.getElementById(id2);
   if (text2.value != '')
   {
   	  text.readOnly=false;
	  text.className=classActivado;
	  text.select();
	  text.focus();
	  
   }
   else
   {
      text.readOnly=true;
	  text.className=classDesactivado;
	  text.select();
	  text.focus();
   }  
}

if (activa=='desactiva')
{
      text.readOnly=true;
	  text.className=classDesactivado;
	  text.select();
	  text.focus();
}	  
	  
}

function Saltar(id,evento)
{
var ob=document.getElementById(id);
  if (evento==13)
  {
     ob.focus();
  }
}

function asignaHora(id,de,hasta)
{
var obj=document.getElementById(id)
obj=de + ':' + hasta;
}

function divborde(id)
{
var obj=document.getElementById(id);
obj.style.border="1px";
obj.style.filter = "alpha(opacity:50)"; 
}
function divsinborde(id)
{
var obj=document.getElementById(id);
obj.style.border="0px";
}

function ShowHideClick(id)
{
	var obj = document.getElementById(id);
	if(obj.style.visibility=='hidden')
	{ 
	  obj.style.visibility = 'visible';
	  obj.style.display='block';
	}
	else
	{
	  obj.style.visibility = 'hidden';
	  obj.style.display='none';
	}
}

function formatfecha(id,val)
{
var obj = document.getElementById(id);
var lar=val.length;
switch(lar)
{
case 2 :
obj.value="";
obj.value= val + "/";
break;

case 5 :
obj.value="";
obj.value= val + "/";
break;
}
}

function esDigito(sChr)
{
var sCod = sChr.charCodeAt(0);
return ((sCod > 47) && (sCod < 58));
}

function valSep(oTxt)
{
var bOk = false;
bOk = bOk || ((oTxt.value.charAt(2) == "-") && (oTxt.value.charAt(5) == "-"));
bOk = bOk || ((oTxt.value.charAt(2) == "/") && (oTxt.value.charAt(5) == "/"));
return bOk;
}

function finMes(oTxt)
{
var nMes = parseInt(oTxt.value.substr(3, 2), 10);
var nRes = 0;
	switch (nMes)
	{
	case 1: nRes = 31; break;
	case 2: nRes = 29; break;
	case 3: nRes = 31; break;
	case 4: nRes = 30; break;
	case 5: nRes = 31; break;
	case 6: nRes = 30; break;
	case 7: nRes = 31; break;
	case 8: nRes = 31; break;
	case 9: nRes = 30; break;
	case 10: nRes = 31; break;
	case 11: nRes = 30; break;
	case 12: nRes = 31; break;
	}
return nRes;
}


function valDia(oTxt)
{
var bOk = false;
var nDia = parseInt(oTxt.value.substr(0, 2), 10);
bOk = bOk || ((nDia >= 1) && (nDia <= finMes(oTxt)));
return bOk;
}


function valMes(oTxt)
{
var bOk = false;
var nMes = parseInt(oTxt.value.substr(3, 2), 10);
bOk = bOk || ((nMes >= 1) && (nMes <= 12));
return bOk;
}

function valAno(oTxt){
var bOk = true;
var nAno = oTxt.value.substr(6);
bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));
if (bOk){
for (var i = 0; i < nAno.length; i++){
bOk = bOk && esDigito(nAno.charAt(i));
}
}
return bOk;
}


function valFecha(oTxt){
var bOk = true;
var flag=true;
	if (oTxt.value != "")
	{
	bOk = bOk && (valAno(oTxt));
	bOk = bOk && (valMes(oTxt));
	bOk = bOk && (valDia(oTxt));
	bOk = bOk && (valSep(oTxt));
		if (!bOk)
		{
		flag=false;
		return (flag);
		}
		else
		{
		flag=true;
		return (flag);
		}
	}
return (flag)	
}



function asignavalor(id,valor)
{
var obj = document.getElementById(id);
obj.value=valor;
}






function OpacarImgesc(nameObj,im)
{
var img=document.getElementById(im);
obj=document.all.length
LenStr = nameObj.length;
for(i=0;i<obj;i++)
{
	    if (document.all[i].id.substring(0,LenStr) == nameObj)
		{
            document.all[i].style.filter = 'alpha(opacity =30)';
        }			

 }
  
  img.style.filter = 'alpha(opacity =100)'; 
} 




function nOpacarImgesc(nameObj)
{

obj=document.all.length
LenStr = nameObj.length;
for(i=0;i<obj;i++)
{
	    if (document.all[i].id.substring(0,LenStr) == nameObj)
		{
            document.all[i].style.filter = 'alpha(opacity =100)';
        }			

 }
} 

function panelVenta(id,alt)
{
	if (document.all)
	{ 
	ancho = document.body.clientWidth; 
	altura = document.body.clientHeight; 
	} 
	else { 
	ancho = window.innerWidth 
	altura = window.innerHeight 
	} 

 

    var obj = document.getElementById(id);
	var str=obj.style.width;
	var fin=str.indexOf('p'); 
	var anchoobj=str.substring(0,fin);


    obj.style.top=alt;
    obj.style.left=(ancho -  anchoobj);
	obj.style.height=(altura- 5);
}


function Abrir_ventana (pagina) {
var opciones="toolbar=no,location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes,top=0, left=0,";

var winWidth = screen.availWidth -10  ; var winHeight =screen.availHeight ; var winSize = 'width=' + winWidth + ',height=' + winHeight;
opciones=opciones + winSize;

window.open(pagina,"",opciones);


}


function changeStyle(id, newClass)
{
document.getElementById(id).style.className = newClass;
}

function clickButton(pref,can,id)
{
	var largopref=pref.length
	var text=null;
   	for (var i=0; i < document.all.length; i++)
	{
		if(document.all[i].type=="button" && document.all[i].id.substring(0, largopref))
		{
	     text=document.all[i].title;
		 document.all[i].innerHTML="";
		 document.all[i].innerHTML=text;
		 
		 if(document.all[i].id == id)
		 {document.all[i].innerHTML="&radic;&nbsp;" + document.all[i].innerHTML ;}
		}  
	}	
}

function tacho()
{
}

function closeDIVdepend(nameObj)
{
var dobj="";	
var	LenStr=nameObj.length;
var DIV = document.getElementsByTagName("div");
	for (i = 0;i < DIV.length; i ++)
	 {
	    if(DIV[i].id.substring(0,LenStr) == nameObj)
	    {
			dobj=document.getElementById(DIV[i].id);
			dobj.style.visibility='hidden';
		}
	 }
}

function killDiv(nameObj)
{
var dobj="";	
var	LenStr=nameObj.length;
var DIV = document.getElementsByTagName("div");
	for (i = 0;i < DIV.length; i ++)
	 {
	    if(DIV[i].id.substring(0,LenStr) == nameObj)
	    {
			dobj=document.getElementById(DIV[i].id);
			dobj.innerHTML="";
			dobj.style.width=0;
			dobj.style.height=0;
			dobj.style.visibility='hidden';
		}
	 }
}

function fechamayorque(f1,f2)
{
var ff1=f1.split("/");
var ff2=f2.split("/");
var a="";
var b="";
for (var i=0;i<ff1.length;i++){a=a + ff1[i];}
for (var i=0;i<ff2.length;i++){b=b + ff2[i];}

var diaA=a.substring(0,2)
var mesA=a.substring(2,4)
var anoA=a.substring(4,8)

var diaB=b.substring(0,2)
var mesB=b.substring(2,4)
var anoB=b.substring(4,8)


   if(anoA>=anoB)
   {
	       if(mesA>=mesB)
		   {
			   	       if(diaA>=diaB)
					   {
						 return(true);   
					   }
					   else
					   {
						 return(false);   
					   }
		   }
		   else
		   {
			 return(false);   
		   }
   }
   else
   {
	 return(false);   
   }
}

function colapso(obj,div)
{
  var divs=document.getElementById(div);	
  var celda=document.getElementById(celda);	
  if(obj.alt=='mostrar')
  {
	obj.src="/digitech/Imagenes/minus4_rtl.gif" 
	obj.alt="ocultar";
	divs.style.width="120px";
	divs.style.height="60px";
	divs.style.display='block';
  }
  else
  {
    obj.src="/digitech/Imagenes/plus4_rtl.gif" 
	obj.alt="mostrar";
	divs.innerHTML="";
	divs.style.width="0px";
	divs.style.height="0px";
	divs.innerHTML="&nbsp;"
	divs.style.display="none";
  }

}

function forzar_popup(clie,report,param)
{
popup_window("Vista Previa Solicitudes sin Orden de Trabajo","/digitech/rpt/preview_rpt.asp?PARAMETROS={viewSol_pend_comp.cliente}='" + clie + "'&REPORTE=" + report, param);
}

function forma(v,obj)
{
var sRutFormateado = '';
var sRut = new String(v);
while( sRut.indexOf(".") != -1 )
{
sRut = sRut.replace(".","");
}
sRut = sRut.replace("-","");
	
var sDV = sRut.charAt(sRut.length-1);
sRut = sRut.substring(0, sRut.length-1);
while( sRut.length > 3 )
{
sRutFormateado = "." + sRut.substr(sRut.length - 3) + sRutFormateado;
sRut = sRut.substring(0, sRut.length - 3);
}
sRutFormateado = sRut + sRutFormateado;
if(sRutFormateado != "")
{
sRutFormateado += "-";
}
sRutFormateado += sDV;
obj.value=sRutFormateado;
}





function validarut(strrut,obj) {
var sRut = new String(strrut);
while( sRut.indexOf(".") != -1 )
{
sRut = sRut.replace(".","");
}
sRut = sRut.replace("-","");	
dg=	sRut.charAt(sRut.length-1);
sRut = sRut.substring(0, sRut.length-1);
	
var arut =  new Array(12);
var strrut= new String(sRut);
var i, j, dv, res;
if ((strrut.length) = 0 ) {
window.alert("Debe ingresar un Número de Rut");
}
else
{
for (i=1; i<9;i++) {
arut[i]=0; }
i=0
for (j = (9-(strrut.length)); j<9;j++) {
if (( strrut.substr(i,1) >= 0) & ( strrut.substr(i,1) <= 9)) {
arut[j] = strrut.substr(i,1); i++; } 
}
if (i>0) {
dv = 11 - (( (arut[1]*3) + (arut[2]*2) + (arut[3]*7) + (arut[4]*6) + (arut[5]*5) + (arut[6]*4) + (arut[7]*3) + (arut[8]*2) )%11)
if (dv === 10) { 
dv = "K"; }
else if (dv === 11) {
dv = "0"; }

res="true";
if(dg != dv)
{
res="false";
alert('El rut ingresado es Incorrecto...');

document.getElementById(obj).select();
document.getElementById(obj).focus();
}
return (res); }
}
}

function sizeScreen()
{
	var ancho=null;
	var altura=null;
	
	if (document.all) { 
	ancho = document.body.clientWidth; 
	altura = document.body.clientHeight; 
	} 
	else { 
	ancho = window.innerWidth 
	altura = window.innerHeight 
	}
	
	return {top:altura,left:ancho};
	
}

function FijarDiv(id)
{
	var obj=document.getElementById(id);
	var pos=sizeScreen();
	
	str=obj.style.height;
    var fin=str.indexOf('p'); 
    var alt=str.substring(0,fin);
	obj.style.top=pos.top - alt ;
	alert('');
	
}


function validamail(theElement)
{
var s = theElement.value;
var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
if (s.length == 0 ) return true;
if (filter.test(s))
return true;
else
return false;
}


function cargar_dtech_cliente(use,pas)
{
parent.location.href="/digitech/Paginas/dtech_cliente.asp?flag=login&user=" + use + "&password=" + pas;	
}


function asig_str(str)
{
var caracter=null;
var cadena=str;
var texto="";
	for (var i=0; i<cadena.length; i++)
	{
		texto=texto + num_letra(cadena.substr (i, 1));
	}
return texto;
}



function num_letra(a)
{
	var sal=null;
	switch(a)
	{
	case "1":
	sal= "B";
	break;
	
	case "2":
	sal= "C";
	break;
	
	case "3":
	sal= "D";
	break;
	
	case "4":
	sal= "E";
    break;
	
	case "5":
	sal= "F";
	break;
	
	case "6":
	sal= "G";
	break;
	
	case "7":
	sal= "H";
	break;
	
	case "8":
	sal= "I";
	break;
	
	case "9":
	sal= "J";
	break;
	
	case "0":
	sal= "A";
	break;
	}
	return sal;
}

function Init_iframe_resize_iframe()
{
var dir="http://190.54.21.165/digitech.html";
document.getElementById("contenedor").style.height=screen.availHeight;
document.getElementById("contenedor").style.width=screen.availWidth - 30;
document.getElementById("contenedor").src=dir;
}

function add_row_table(id)
{

var tableRef = document.getElementById(id);
var ncols = tableRef.rows[1].getElementsByTagName('td').length;
var numRows = tableRef.rows.length;
var newRow   = tableRef.insertRow(numRows - 1);
var x = tableRef.rows[numRows-1].cells;
newRow.onmouseover=function(){this.bgColor="#FEF0BC"}     
newRow.onmouseout=function(){this.bgColor="#FFFFFF"}
newRow.ondblclick=function(){editrow(numRows-1,id);};
newRow.id=numRows-1;
for(var i=0;i< ncols;i++)
{
newRow.appendChild(newRow.insertCell(i));
	if(i==0)
	{
	 x[i].className="rowGridTrans";
	 x[i].innerHTML="<input type='checkbox' id='chkcl<%= i %>' value='' title=''/>"
	}
	else
	{
	x[i].className="rowGridTrans";
	x[i].innerHTML="bnnb ";
	}
}
}

function send_message(de,para,asunto,detalle)
{
var obj_mesg=document.getElementById(detalle);
ajaxoBJ('/digitech/Paginas/consultasAjax.asp?FLAG=SaveConsultacliente&id=0&consulta=' + obj_mesg.value + '&cliente=' + document.getElementById('cliente').value + '&emitida_por=' + document.getElementById('nombre_invitado').value + '&destino=' + document.getElementById('email').value,'result');
ajaxoBJ('/digitech/Paginas/consultasAjax.asp?FLAG=SendbyMailto&de=' + de + '&para=' + para + '&asunto=' + asunto + '&detalle=' + obj_mesg.value ,'result');
}
function centrarDiv(obj)
{var ob=document.getElementById(obj);ob.style.left=parseInt(document.documentElement.clientWidth/2) - parseInt(parseInt(ob.style.width)/2) + "px";ob.style.top=parseInt(document.documentElement.clientHeight/2)- parseInt(parseInt(ob.style.height)/2+100) + "px";}


function enabledisable_txt(id,opc)
{
  if (opc=='disabled')
  {document.getElementById(id).setAttribute('readOnly','readonly');document.getElementById(id).style.backgroundColor='#cccccc';document.getElementById(id).style.color='#666666'; }
  else
  { document.getElementById(id).removeAttribute('readOnly');document.getElementById(id).style.backgroundColor='transparent';document.getElementById(id).style.color='#333333';  }
}

function extension(objstr,formato)
{var resp=false; var obj=document.getElementById(objstr); var ext=obj.value.split(".");
  if (formato == ext[1]){resp=true;} 
  else 
  {
  resp=false;
  alert("El Archivo seleccionado no corresponde con la Extensión : '" + formato + "'");
  }
  return resp;
}
