var es_n4=(document.layers)?true:false;
var es_n6=(document.getElementById)?true:false;
var es_ie=(document.all)?true:false;
var es_opera=(navigator.userAgent.indexOf("Opera")!=-1)?true:false;
var es_firefox=(navigator.userAgent.indexOf("Firefox")!=-1)?true:false;

function IrA(D){location.href=D;}
function IrAN(D,P){IrAN2(D,'',P);}
function IrAN2(D,N,P){if(P.length==0)P='width=700,height=500,top=10,left=10,resizable=yes,scrollbars=yes';window.open(D,N,P);return true;}

var tRecarga=tPasado=600; //segundos
function timerRecarga(){var tComprueba=30;tPasado-=tComprueba; setTimeout('timerRecarga()',tComprueba*1000); if(tPasado<=0){tPasado=tRecarga;window.location.reload();}}

function VentanaRedimensionar(w,h){if(window.outerWidth){window.outerWidth=w;window.outerHeight=h;}else if(window.resizeTo){window.resizeTo(w,h);}else{alert("Redimensionado no soportado.");}}
function VentanaAncho(){if(es_ie)return document.body.clientWidth; if(es_n6)return window.innerWidth;}
function VentanaAlto(){if(es_ie)return document.body.clientHeight; if(es_n6)return window.innerHeight;}
function VentanaMover(x,y){window.moveTo(x,y);}
function EsVentanaHija(){if(typeof(window.opener)!='object'||window.opener==null)return false;else return true;}

var separaAVaC=',';
function ValorDeCampo(F,C,e)
{
	var O=eval('window.document.forms.'+F+'.'+C);
	if(!HayCampoValor(F,C,'',true)){alert('No se encuentra '+F+'.'+C);return e;}
	else
	{
		var i,l='',T=O.type;if(typeof(T)!='string')T=O[0].type;
		switch(T)
		{
			case'select-one':return O.options[O.selectedIndex].value;
			case'select-multiple':for(i=0;i<O.length;i++)if(O.options[i].selected){if(l.length>0)l+=separaAVaC;l+=O.options[i].value;}return l;
			case'button':case'submit':case'text':case'textarea':case'hidden':case'password':return O.value;
			case'checkbox':case'radio':if(!isFinite(O.length)){if(O.checked)l=O.value;}else{for(i=0;i<O.length;i++)if(O[i].checked){if(l.length>0)l+=separaAVaC;l+=O[i].value;}} return l;
		}
	}
	return e;
}

function EsOEsta(V,L)
{
	if(V==L)return true;
	if(L.substr(0,1)==separaAVaC && L.substr(L.length-1,1)==separaAVaC)if(L.indexOf(separaAVaC+V+separaAVaC,0)>-1)return true;
	return false;
}
function AsignaValorACampo(F,C,V)
{
	if(!HayCampoValor(F,C,'',true))
	{
		var hay=false;try{if(window.document.getElementById(C)!=null)hay=true;}catch(e){}
		while(V.search('\n')>-1)V=V.replace('\n','<br>');
		if(hay)window.document.getElementById(C).innerHTML=V;
		else alert('No se encuentra: '+F+'.'+C+' ni objeto: '+C);
	}
	else
	{
		var O=eval('window.document.forms.'+F+'.'+C);
		var i,T=O.type;if(typeof(T)!='string')T=O[0].type;
		switch(T)
		{
			case'select-one':for(i=0;i<O.length;i++)if(O.options[i].value==V)O.selectedIndex=i;break;
			case'select-multiple':for(i=0;i<O.length;i++)if(EsOEsta(O.options[i],V))O.options[i].selected=true;break;
			case'button':case'submit':case'text':case'textarea':case'hidden':case'password':O.value=V;break;
			case'checkbox':case'radio':/*1*/if(!isFinite(O.length))if (EsOEsta(O.value,V))O.checked=true;else O.checked=false;/*>1*/else for(i=0;i<O.length;i++)if (EsOEsta(O[i].value,V))O[i].checked=true;else O[i].checked=false;break;
		}
	}
}
function AVaC(F,R,V){if(HayCampoValor(F,R,V,false))AsignaValoresACampos(F,'radio',R,'raiz',V);}
function AsignaValoresACampos(F,T,R,m,V){for(var O=eval("window.document.forms."+F+".elements"),i=0;i<O.length;i++)if ( ((m=='raiz'&&O[i].name.indexOf(R)==0)||(m=='igual'&&O[i].name==R)||(m=='contenido'&&O[i].name.indexOf(R)>=0)) &&O[i].type==T)AsignaValorACampo(F,O[i].name,V);}
function HayCampoValor(F,R,V,M){for(var O=eval("window.document.forms."+F+".elements"),i=0;i<O.length;i++)if(((!M&&O[i].name.indexOf(R)==0)||(M&&O[i].name==R))&&(O[i].value==V||V==''))return true;return false;}


function SelectOptionBorrar(d){var obj=eval("window.document.forms."+d);var c=obj.options.length;for(var i=c-1;i>=0;i--)obj.remove(i);}
function SelectOptionInsertar(d,v,t){var opcion=document.createElement('option');opcion.text=t;opcion.value=v;var obj=eval("window.document.forms."+d);try{obj.add(opcion,null);}catch(ex){obj.add(opcion);}}


function CTArea(C,S,T){var t=T-T_CTArea(C);if(t<0){C_CTArea(C,T);t=T-T_CTArea(C);}if(S!='')eval('window.document.forms.'+S+'.value='+(t));}
function T_CTArea(C){var t=eval('window.document.forms.'+C+'.value'),D='\1\2\3',o='\n';if(es_firefox)D+='\4';while(t.search(o)>=0)t=t.replace(o,D);return t.length;}
function C_CTArea(C,T){var t=eval('window.document.forms.'+C+'.value'),D='\1\2\3',o='\n';if(es_firefox)D+='\4';while(t.search(o)>=0)t=t.replace(o,D);if (t.charAt(t.length-3)=='\1' && t.length>T)t=t.substring(0,t.length-4);t=t.substring(0,T);while(t.search(D)>=0)t=t.replace(D,o);t=t.replace('\1','');t=t.replace('\2','');t=t.replace('\3','');if(es_firefox)t=t.replace('\4','');eval('window.document.forms.'+C+'.value=t');}

function lTrim(S){for(var i=0;i<S.length;i++)if(S.charAt(i)!=' ')return S.substr(i);return'';}
function rTrim(S){for(var i=S.length-1;i>=0;i--)if(S.charAt(i)!=' ')return S.substr(0,i+1);return'';}

function aReal(c,vNaN,vNull){try{var n=parseFloat(c);if(isNaN(n))n=vNaN;return n;}catch(e){}return vNull;}
function aInt(c,vNaN,vNull){try{var n=parseInt(quita0izq(c));if(isNaN(n))n=vNaN;return n;}catch(e){}return vNull;}
function quita0izq(c){if(c.length==0)return'';for(var i=0;i<c.length-1&&c.charAt(i)=='0';i++);if(i<c.length)return c.substr(i);}

function Redondea(n,d){var m=Math.pow(10,d);return(Math.round(n*m)/m);}
function aStr(c,vNull){try{return eval(c+".value");}catch(e){}return vNull;}

function hayCampo(C){var a;try{a=eval(C+".length");return true;}catch(e){}return false;}

function CambiaImg(D,I){eval("document."+D+".src='"+I+"'");}

/*var overlibTiempo=4000;*/
function overlibON(C,I)
{
/*window.document.getElementById(C).style.zIndex=9999;*/
window.document.getElementById(C).style.visibility="visible";
if(I.length>0)window.document.getElementById(C).innerHTML=I;
/*setTimeout('overlibOFF("'+C+'")',overlibTiempo);*/
}
function overlibOFF(C){window.document.getElementById(C).style.visibility="hidden";}

function CtdElementosArray(a){var c=0;for(var e in a)c++;return c;}
