





function cambiaActividad()
    {
        
	  window.document.Formulario.submit();
		
	} 



	//var expandFirstItemAutomatically = 1;	// Expand first menu item automatically ?
	
	var expandMenuItemByUrl = false;	// Menu will automatically expand by url - i.e. if the href of the menu item is in the current location, it will expand
	var initMenuIdToExpand = false;
	
	var initialMenuItemAlwaysExpanded = true;	// NOT IMPLEMENTED YET
	
	var dhtmlgoodies_slmenuObj;
	var divToScroll = false;
	var ulToScroll = false;	
	var divCounter = 1;
	var otherDivsToScroll = new Array();
	var divToHide = false;
	var parentDivToHide = new Array();
	var ulToHide = false;
	var offsetOpera = 0;
	if(navigator.userAgent.indexOf('Opera')>=0)offsetOpera=1;	
	var slideMenuHeightOfCurrentBox = 0;
	var objectsToExpand = new Array();
	var initExpandIndex = 0;
	var alwaysExpanedItems = new Array();
		
	function popMenusToShow()
	{
		var obj = divToScroll;
		var endArray = new Array();
		while(obj && obj.tagName!='BODY'){
			if(obj.tagName=='DIV' && obj.id.indexOf('slideDiv')>=0){
				var objFound = -1;
				for(var no=0;no<otherDivsToScroll.length;no++){
					if(otherDivsToScroll[no]==obj){
						objFound = no;		
					}					
				}	
				if(objFound>=0){
					otherDivsToScroll.splice(objFound,1);	
				}		
			}	
			obj = obj.parentNode;
		}	
	}

	function showSubMenu(e,inputObj)
	{

		if(this && this.tagName)inputObj = this.parentNode;
		if(inputObj && inputObj.tagName=='LI'){
			divToScroll = inputObj.getElementsByTagName('DIV')[0];
			for(var no=0;no<otherDivsToScroll.length;no++){
				if(otherDivsToScroll[no]==divToScroll)return;
			}			
		}
		hidingInProcess = false;
		if(otherDivsToScroll.length>0){
			if(divToScroll){				
				if(otherDivsToScroll.length>0){
					popMenusToShow();
				}
				if(otherDivsToScroll.length>0){	
					autoHideMenus();
					hidingInProcess = true;
				}
			}	
		}		
		if(divToScroll && !hidingInProcess){
			divToScroll.style.display='';
			otherDivsToScroll.length = 0;
			otherDivToScroll = divToScroll.parentNode;
			otherDivsToScroll.push(divToScroll);	
			while(otherDivToScroll && otherDivToScroll.tagName!='BODY'){
				if(otherDivToScroll.tagName=='DIV' && otherDivToScroll.id.indexOf('slideDiv')>=0){
					otherDivsToScroll.push(otherDivToScroll);					
				}
				otherDivToScroll = otherDivToScroll.parentNode;
			}			
			ulToScroll = divToScroll.getElementsByTagName('UL')[0];
			if(divToScroll.style.height.replace('px','')/1<=1)scrollDownSub();
		}	
		

	}
	
	

	function autoHideMenus()
	{
		if(otherDivsToScroll.length>0){
			divToHide = otherDivsToScroll[otherDivsToScroll.length-1];
			parentDivToHide.length=0;
			var obj = divToHide.parentNode.parentNode.parentNode;
			while(obj && obj.tagName=='DIV'){			
				if(obj.id.indexOf('slideDiv')>=0)parentDivToHide.push(obj);
				obj = obj.parentNode.parentNode.parentNode;
			}
			var tmpHeight = (divToHide.style.height.replace('px','')/1 - slideMenuHeightOfCurrentBox);
			if(tmpHeight<0)tmpHeight=0;
			if(slideMenuHeightOfCurrentBox)divToHide.style.height = tmpHeight  + 'px';
			ulToHide = divToHide.getElementsByTagName('UL')[0];
			slideMenuHeightOfCurrentBox = ulToHide.offsetHeight;
			scrollUpMenu();		
		}else{
			slideMenuHeightOfCurrentBox = 0;
			showSubMenu();			
		}
	}

	
	function scrollUpMenu()
	{

		var height = divToHide.offsetHeight;
		height-=15;
		if(height<0)height=0;
		divToHide.style.height = height + 'px';
	
		for(var no=0;no<parentDivToHide.length;no++){	
			parentDivToHide[no].style.height = parentDivToHide[no].getElementsByTagName('UL')[0].offsetHeight + 'px';
		}
		if(height>0){
			setTimeout('scrollUpMenu()',5);
		}else{
			divToHide.style.display='none';
			otherDivsToScroll.length = otherDivsToScroll.length-1;
			autoHideMenus();			
		}
	}	
	
	function scrollDownSub()
	{
		if(divToScroll){			
			var height = divToScroll.offsetHeight/1;
			var offsetMove =Math.min(15,(ulToScroll.offsetHeight - height));
			height = height +offsetMove ;
			divToScroll.style.height = height + 'px';
			
			for(var no=1;no<otherDivsToScroll.length;no++){
				var tmpHeight = otherDivsToScroll[no].offsetHeight/1 + offsetMove;
				otherDivsToScroll[no].style.height = tmpHeight + 'px';
			}			
			if(height<ulToScroll.offsetHeight)setTimeout('scrollDownSub()',5); else {
				divToScroll = false;
				ulToScroll = false;
				if(objectsToExpand.length>0 && initExpandIndex<(objectsToExpand.length-1)){
					initExpandIndex++;
					
					showSubMenu(false,objectsToExpand[initExpandIndex]);
				}
			}
		}
	}
		
	function initSubItems(inputObj,currentDepth)
	{		
		divCounter++;		
		var div = document.createElement('DIV');	// Creating new div		
		div.style.overflow = 'hidden';	
		div.style.position = 'relative';
		div.style.display='none';
		div.style.height = '1px';
		div.id = 'slideDiv' + divCounter;
		div.className = 'slideMenuDiv' + currentDepth;		
		inputObj.parentNode.appendChild(div);	// Appending DIV as child element of <LI> that is parent of input <UL>		
		div.appendChild(inputObj);	// Appending <UL> to the div
		var menuItem = inputObj.getElementsByTagName('LI')[0];
		while(menuItem){
			if(menuItem.tagName=='LI'){
				var aTag = menuItem.getElementsByTagName('A')[0];
				aTag.className='slMenuItem_depth'+currentDepth;	
				var subUl = menuItem.getElementsByTagName('UL');
				if(subUl.length>0){
					initSubItems(subUl[0],currentDepth+1);					
				}
				aTag.onclick = showSubMenu;				
			}			
			menuItem = menuItem.nextSibling;						
		}		
	}
	
	function initSlideDownMenu()
	{
		dhtmlgoodies_slmenuObj = document.getElementById('dhtmlgoodies_slidedown_menu');
		dhtmlgoodies_slmenuObj.style.visibility='visible';
		var mainUl = dhtmlgoodies_slmenuObj.getElementsByTagName('UL')[0];		
		var mainMenuItem = mainUl.getElementsByTagName('LI')[0];
		mainItemCounter = 1;
		while(mainMenuItem){			
			if(mainMenuItem.tagName=='LI'){
				var aTag = mainMenuItem.getElementsByTagName('A')[0];
				aTag.className='slMenuItem_depth1';	
				var subUl = mainMenuItem.getElementsByTagName('UL');
				if(subUl.length>0){
					mainMenuItem.id = 'mainMenuItem' + mainItemCounter;
					initSubItems(subUl[0],2);
					aTag.onclick = showSubMenu;
					mainItemCounter++;
				}				
			}			
			mainMenuItem = mainMenuItem.nextSibling;	
		}		
		
		if(location.search.indexOf('mainMenuItemToSlide')>=0){
			var items = location.search.split('&');
			for(var no=0;no<items.length;no++){
				if(items[no].indexOf('mainMenuItemToSlide')>=0){
					values = items[no].split('=');
					showSubMenu(false,document.getElementById('mainMenuItem' + values[1]));	
					initMenuIdToExpand = false;				
				}
			}			
		}else if(expandFirstItemAutomatically>0){
			if(document.getElementById('mainMenuItem' + expandFirstItemAutomatically)){
				showSubMenu(false,document.getElementById('mainMenuItem' + expandFirstItemAutomatically));
				initMenuIdToExpand = false;
			}
		}

		if(expandMenuItemByUrl)
		{
			var aTags = dhtmlgoodies_slmenuObj.getElementsByTagName('A');
			for(var no=0;no<aTags.length;no++){
				var hrefToCheckOn = aTags[no].href;				
				if(location.href.indexOf(hrefToCheckOn)>=0 && hrefToCheckOn.indexOf('#')<hrefToCheckOn.length-1){
					initMenuIdToExpand = false;
					var obj = aTags[no].parentNode;
					while(obj && obj.id!='dhtmlgoodies_slidedown_menu'){
						if(obj.tagName=='LI'){							
							var subUl = obj.getElementsByTagName('UL');
							if(initialMenuItemAlwaysExpanded)alwaysExpanedItems[obj.parentNode] = true;
							if(subUl.length>0){								
								objectsToExpand.unshift(obj);
							}
						}
						obj = obj.parentNode;	
					}
					showSubMenu(false,objectsToExpand[0]);
					break;					
				}			
			}
		}
				
		if(initMenuIdToExpand)
		{
			objectsToExpand = new Array();
			var obj = document.getElementById(initMenuIdToExpand)
			while(obj && obj.id!='dhtmlgoodies_slidedown_menu'){
				if(obj.tagName=='LI'){
					var subUl = obj.getElementsByTagName('UL');
					if(initialMenuItemAlwaysExpanded)alwaysExpanedItems[obj.parentNode] = true;
					if(subUl.length>0){						
						objectsToExpand.unshift(obj);
					}
				}
				obj = obj.parentNode;	
			}
			
			showSubMenu(false,objectsToExpand[0]);

		}
		

			
	}
	



var baseopacity=99


function slowhigh(which2){
imgobj=which2
browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
highlighting=setInterval("gradualfade(imgobj)",50)
}

function slowlow(which2){
cleartimer()
instantset(baseopacity)
}

function instantset(degree){
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}

function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity>0.5)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)-0.1)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity>50)
cur2.filters.alpha.opacity-=10
else if (window.highlighting)
clearInterval(highlighting)
}






/* BACK*/


var contenido=""
    var Letra;
    var letra;
    var LETRA;
    function comprobar(esto){
                    palabra=esto.value;
                    contenido="";
                    for (numeroDeLetra=0;numeroDeLetra<palabra.length;numeroDeLetra++){
                                        Letra=palabra.charAt(numeroDeLetra);
                                        LETRA=Letra.toUpperCase();
                                        letra=Letra.toLowerCase();
										
                                        if (LETRA!=letra || Letra=="." || Letra=="@" || Letra=="-" || Letra==" " || LETRA=="_" || LETRA=="0" || LETRA=="1" || LETRA=="2" || LETRA=="3" || LETRA=="4" || LETRA=="5" || LETRA=="6" || LETRA=="7" || LETRA=="8" || LETRA=="9"){
                                                contenido=contenido+Letra;
                                                }
                                        else
										{
										//alert('El Caracter Introducido NO ES VÁLIDO [Sólo se permiten Números y Letras]');
										}
									   }
                            return contenido;
}


function NewWindow(mypage, myname, w, h, scroll) { 
var winl = (screen.width - w) / 2; 
var wint = (screen.height - h) / 2; 
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable' 
win = window.open(mypage, myname, winprops) 
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } 
} 

 
var ventanaCalendario=false

function abreficha(URL,formulario_destino,campo_destino)
{

    if (typeof ventanaCalendario.document == "object")
    {
       ventanaCalendario.close()
    }
    ventanaCalendario = window.open(URL + "&formulario=" + formulario_destino + "&nomcampo=" + campo_destino,"calendario", "width=430,height=160, left=480,top=300, scrollbars=no,menubars=no,statusbar=NO, status=NO, resizable=no,location=NO")

}



function Confirmar(borrado)
	{
		if (confirm("¿Desea Eliminar el Registro?"))
			{
				window.location = borrado;
			}
	}





function checkDecimals(fieldName, fieldValue) {

decallowed = 3;  // how many decimals are allowed?

if (isNaN(fieldValue) || fieldValue == "") {
alert("Introduzca un Valor Válido Por Favor.Para los Decimales Use el Punto.");
//fieldName.select();
fieldName.focus();
}
else {
if (fieldValue.indexOf('.') == -1) fieldValue += ".";
dectext = fieldValue.substring(fieldValue.indexOf('.')+1, fieldValue.length);

if (dectext.length > decallowed)
{
alert ("Introduzca " + decallowed + " decimales Por Favor");
//fieldName.select();
fieldName.focus();
      }
else {
//alert ("OK!! Numero correcto.");
      }
   }
}




function cif(cif)
{
par = 0
non = 0
letras="ABCDEFGHKLMNPQS"
let=cif.charAt(0)

if (!isNaN(let))
  {
  nif=cif
  validar(nif)
  return false
  }

if (cif.length!=9)
  {
  alert('El CIF debe tener 9 dígitos')
  document.formulario.DNIClientes.focus()
  
  
  
 

 
 
  return false
  }

if (letras.indexOf(let.toUpperCase())==-1)
  {
  alert("El comienzo del CIF no es válido")
 

document.formulario.DNIClientes.focus()



  return false
  }

for (zz=2;zz<8;zz+=2)
  {
  par = par+parseInt(cif.charAt(zz))
  }

for (zz=1;zz<9;zz+=2)
  {
  nn = 2*parseInt(cif.charAt(zz))
  if (nn > 9) nn = 1+(nn-10)
  non = non+nn
}

parcial = par + non

control = (10 - ( parcial % 10))

if (control!=cif.charAt(8))
  {
  alert("El CIF Introducido no es válido")

  

document.formulario.DNIClientes.focus()


 
   
  return false
  }

}


function validar(abc)
{
dni=abc.substring(0,abc.length-1)
let=abc.charAt(abc.length-1)

if (abc.length!=9)
  {
  alert('El NIF debe tener 9 dígitos')
 
  
  
  
 
document.formulario.DNIClientes.focus()


 
 
  return false
  }


if (!isNaN(let))
 {
  alert('Falta la letra')

 
  

document.formulario.DNIClientes.focus()


 
 
  return false
 }
else
 {
  cadena="TRWAGMYFPDXBNJZSQVHLCKET"
  posicion = dni % 23
  letra = cadena.substring(posicion,posicion+1)
  if (letra!=let.toUpperCase())
   {
    alert("El NIF Introducido no es válido ")
   
  
document.formulario.DNIClientes.focus()


   
    return false
   }
 }

}


/*FIN BACK*/

