
var elementos = new Array();
var opciones = new Array();

function desplegar(nom)
{
var div_obj=document.getElementById('categoriaA');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaS');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaD');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaF');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaG');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaH');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaJ');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaK');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaL');
div_obj.style.display="none";

var div_obj=document.getElementById('categoriaQ');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaW');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaE');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaR');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaT');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaY');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaU');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaI');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaO');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaP');
div_obj.style.display="none";



var div_obj=document.getElementById('categoriaZ');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaC');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaV');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaB');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaN');
div_obj.style.display="none";
var div_obj=document.getElementById('categoriaM');
div_obj.style.display="none";

var div_obj=document.getElementById(nom);
div_obj.style.display ='block';

};



function solonum(dato,valor)
{		
	var x=0,dat;	
	for(x=0;x<valor.length;x++)
	{
		dat=valor.charAt(x);
		if(dat<'0' || dat>'9')
		{
			alert(dato+' debe contener únicamente números');
			return false;
		}
	}
	return true;
}
function verifica_fecha(dato,fecha)
{		
	var dia,mes,ano;

	if(fecha.length>0)
	{
		dia=fecha.substr(0,fecha.search('/'));
		fecha=fecha.substr(fecha.search('/')+1);
		mes=fecha.substr(0,fecha.search('/'));
		fecha=fecha.substr(fecha.search('/')+1);
		if(fecha.search('/')>0)
			ano=fecha.substr(0,fecha.search('/'));
		else
			ano=fecha	
		if(dia=='' || mes=='' || ano=='' || ano.length<2 || ano.lenght>4)
		{
			alert(dato+'\rdebe tener un formato de dd/mm/yyyy.');
			return false;
		}
		if(mes>12 || mes<1) 
		{
			alert(dato+'\rEl mes indicado no es válido');
			return false;
		}
		if(DaysInMonth(mes,ano)<dia)
		{
			alert(dato+'\rLa fecha indicada no es valida');
			return false;
		}
	}
	else
	{
		if(dato!='Fecha de caducidad. ')
		{
			alert(dato+'\rdebes indicar una fecha con formato dd/mm/yyyy');
			return false;
		}
	}	
return true;
}
function DaysInMonth (month,year) {
		a=new Date(year, month-1, 32).getDate()
		return 32 - new Date(year, month-1, 32).getDate();
}
function verifyaddress(address) 
{
	var ch = '';
	var as = 0;
	var pu = 0;
	var allValid = true;
	var desppu = 0;
	var despas = 0;

  	var checkStr = address;
	if (checkStr.length==0) {return false;} //return(false) si es campo obligatorio

    	for (i = 0;  i < checkStr.length;  i++)
    	{	ch = checkStr.charAt(i);
		if (as==1) {despas++;}
		if (ch=='@') {as++; if (desppu==0) {allValid=false;break;} else {desppu=0;}}
		if (ch=='.') {pu++; if (desppu==0) {allValid=false;break;} else {desppu=0;}}
		if ((ch!='@')&&(ch!='.')) {desppu++;}
		if (!(((ch>='a')&&(ch<='z'))||((ch>='A')&&(ch<='Z'))||((ch>='0')&&(ch<='9'))||(ch=='@')||(ch=='.')||(ch=='_')||(ch=='-'))) {allValid=false;break;}
	}
	if ((!allValid)||(as!=1)||(desppu==0)||(despas<=desppu)) {return (false);}

	return (true);
}





function NavRollOver(oTd,col){if(!oTd.contains(event.fromElement)){oTd.bgColor=col;}}
function NavRollOut(oTd,col){if(!oTd.contains(event.toElement)){oTd.bgColor=col;}}

function NavRollOver1(oTd,col){if(!oTd.contains(event.fromElement)){oTd.bgColor=col;}}
function NavRollOut1(oTd,col){if(!oTd.contains(event.toElement)){oTd.bgColor=col;}}

function ventanaSecundaria (URL,ancho,alto,resize,scroll,titulo){ 
var ventana=window.open(URL,"ventana","width="+ancho+",height="+alto+",status=no,resizable="+resize+",scrollbars="+scroll+",left=0,top=0" ) 
}

function ventanaSecundaria_fichero(URL,ancho,alto,resize,scroll,titulo){ 
var ventana_fichero=window.open(' ','NuevaVentana','width=600,height=400,resizable=YES,scrollbars=YES');  
ventana_fichero.document.write("<HTML>"); 
ventana_fichero.document.write("<HEAD><TITLE>Stiga</TITLE></HEAD><body bgcolor='#ff6600'>"); 
ventana_fichero.document.write("<iframe src='" +URL+"' frameborder=0 width='100%' height='95%' scrolling=no name='I87' ></iframe>")

cadena = location.protocol +"//" + location.host + URL;
cadena = cadena.replace("../..","");
ventana_fichero.document.write("<center><font color='#000000' face='Arial' size='1'><a style='text-decoration: none;'href='" + cadena + "'>" + cadena + "</a></body></HTML>"); 
ventana_fichero.document.close(); 
}

function cambiablog(nombre,opcion)
{
cerrarblog(nombre,opcion)
actuarblog(nombre,opcion);
}

function cerrarblog(nom,op)
{
	for (i=0;i<elementos.length;i++){
			var div_obj=document.getElementById(elementos[i]);
			div_obj.style.display="none";
			var div_obj=document.getElementById(opciones[i]);
			div_obj.className='blog_UP';
	}cambiaboton
}

function actuarblog(nom,op) 
{ 

			var div_obj=document.getElementById(nom);
			if (div_obj.style.display=="block")
				{
					div_obj.style.display="none";
					op.className='blog_UP';
				}
			else
				{
					div_obj.style.display="block";
					op.className='blog_DOWN';
				}
	
				
}
	
	
function cambiaboton2(nombre)
{
			var div_obj=document.getElementById(nombre);
			if (div_obj.className=='BOTON70') {
				div_obj.className='BOTON71';
			} else {
				div_obj.className='BOTON70';
			};
}



function cambiaboton(nombre)
{
			var div_obj=document.getElementById(nombre);
			if (div_obj.className=='BOTON40') {
				div_obj.className='BOTON41';
			} else {
				div_obj.className='BOTON40';
			};
}



function cambia(nombre,opcion)
{
cerrar(nombre,opcion)
actuar(nombre,opcion);
}

function cerrar(nom,op)
{
	for (i=0;i<elementos.length;i++){
			var div_obj=document.getElementById(elementos[i]);
			div_obj.style.display="none";
			var div_obj=document.getElementById(opciones[i]);
			div_obj.className='BG_Options_UP';
	}
}

function actuar(nom,op) 
{ 

			var div_obj=document.getElementById(nom);
			if (div_obj.style.display=="block")
				{
					div_obj.style.display="none";
					op.className='BG_Options_UP';
				}
			else
				{
					div_obj.style.display="block";
					op.className='BG_Options_DOWN';
				}
	
				
}
		

function ChequearTodos(chkbox) 
{ 
	for (var i=0;i < document.forms["list"].elements.length;i++) 
	{ 
		var elemento = document.forms[0].elements[i]; 
		if (elemento.type == "checkbox") 
			{ 
				elemento.checked = chkbox.checked ;
			} 
	} 
} 

function kill()
{
	if(confirm("¿Está seguro que quiere eliminar de la lista los archivos seleccionados?"))
	{
		if(!document.layers)
		{
				var num=0;
				for (var i=0;i < document.forms["list"].elements.length;i++) 
				{ 
				
					var elemento = document.forms[0].elements[i]; 
					if (elemento.type == "checkbox")
						{ 
						   if (elemento.checked )
						      {
						          if (elemento.name =="all") {} else {num=num+1;} 
						           
						           
						       };

						} 
				} 	    		
	    		var frm=parent.window.frames;

	    		if (num >0) {document.forms["list"].submit();}
	    	
	    	
	    	}
	    	else
	    	{
	    		parent.window.frames.list.document.list.submit();
	    	}

	}
}
function recarga()
{

		if(!document.layers)
		{

for(j=0;j<doc.elements.length-1;j++) alert(doc.elements[j]);
	    	}
	    	else
	    	{

	    	}


}

function AddAtt()
{

		if(!document.layers)
		{
	    		var frm=parent.window.frames;
	    		frm(1).document.write('<html><center><font style="font-family:tahoma,geneva;font-size:11px;">Cargando archivo. Por favor, espere...</font></center></html>');
	    		document.fichero.submit();
	    	}
	    	else
	    	{
	    		parent.window.frames.list.document.write('<html><center><font style="font-family:tahoma,geneva;font-size:11px;">Cargando fichero. Por favor, espere...</font></center></html>')
	    		parent.window.frames.list.close();
	    		document.fichero.submit();
	    	}
}

