function textoMaximo(campo,valor,faltan) {
	var campo_texto=document.getElementById(campo);
	var quedan=document.getElementById(faltan);
	valor_limit=valor-1;
	if (campo_texto.value.length > valor) { 
		alert('Máximo '+valor+' caracteres');
		campo_texto.value = campo_texto.value.substring(0,valor_limit); 
	}
	quedan.innerHTML=160-campo_texto.value.length;
} 





function confirmarEnvioForm(mensaje,nombre_formulario) {
	if ( confirm(mensaje) ) { 
		var formulario=document.getElementById(nombre_formulario);
		formulario.submit();
	}
	else {
		return false;
	}
}


function setInputValue(campo,valor) {
	var input=document.getElementById(campo);
	if (input) {
		input.value=valor;
	}
	else {
		return false;
	}
}


function irA(destino) {
	if (destino!='') {
		self.location =destino;
	}
}



function mostrarCapa(id) {
	document.getElementById(id).style.display = '';
}

function ocultarCapa(id) {
	document.getElementById(id).style.display = 'none';
}

function mostrarOcultarCapa(id) {
	if (document.getElementById(id).style.display == '') 
		document.getElementById(id).style.display = 'none'
	else
	   document.getElementById(id).style.display = '';
}


function confirma(mensaje,destino) {
	if ( confirm(mensaje) ) { 
		self.location =destino;
	}
}

function borrarInput(id)	{
	document.getElementById(id).value='';
}



/*
	Funcion que borra el elemento seleccionado de un select
	Argumento[0] Select 
*/
function borrarDeSelect(selectDe) {
	if (document.getElementById(selectDe).selectedIndex!=-1) {
		document.getElementById(selectDe).options[document.getElementById(selectDe).selectedIndex]=null;
	}
}

/****
	Muestra o oculta un span o div con ID.
	Solo para IE. Respeta el texto. Tablas completas.
*****/


	function cambiafondo(obj) 
		{ obj.bgColor = '#DC9102'; } 
	function restaurafondo(obj, color) 
		{ obj.bgColor = ''; } 



function hideAll() {
	hideData('submenu01');
	hideData('submenu02');
	hideData('submenu03');
	hideData('submenu04');
	hideData('submenu05');
	hideData('submenu06');	
	
	cambiarFondo('pestana01','#425E14');
	cambiarColorFuente('link_pestana01','#FFFFFF');				

	cambiarFondo('pestana02','#425E14');
	cambiarColorFuente('link_pestana02','#FFFFFF');								

	cambiarFondo('pestana03','#425E14');
	cambiarColorFuente('link_pestana03','#FFFFFF');								

	cambiarFondo('pestana04','#425E14');
	cambiarColorFuente('link_pestana04','#FFFFFF');								

	cambiarFondo('pestana05','#425E14');
	cambiarColorFuente('link_pestana05','#FFFFFF');								

	cambiarFondo('pestana06','#425E14');
	cambiarColorFuente('link_pestana06','#FFFFFF');				
}



/*
muestras el texto en las capas ocultas
*/
	
function cambiarFondo(nombreCapa,color)
{	
document.getElementById(nombreCapa).style.background=color;
}

function cambiarColorFuente(nombreCapa,color)
{
	document.getElementById(nombreCapa).style.color=color;
	document.getElementById(nombreCapa).style.textDecoration='underline';
}	

function subrayar(nombreCapa)
{
	document.getElementById(nombreCapa).style.textDecoration='underline';
}			


function mostrar(nombreCapa)
{
	document.getElementById(nombreCapa).style.visibility="visible";
}
function ocultar(nombreCapa)
{
	document.getElementById(nombreCapa).style.visibility="hidden";
}
		
function showHideData(id) {
	if (document.getElementById(id).style.display == '') 
		document.getElementById(id).style.display = 'none'
	else
	   document.getElementById(id).style.display = '';
}

function showData(id) {
	document.getElementById(id).style.display = '';
}

function hideData(id) {
	document.getElementById(id).style.display = 'none';
}


function openWinClean(fichero,nombre,tam) {
	ventana=window.open(fichero,nombre,tam+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes");	
	return ventana;
}
function openWinScroll(fichero,nombre,tam) {
	ventana=window.open(fichero,nombre,tam+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars,resizable=no,copyhistory=yes");	
	return ventana;
}

function openWin(fichero,nombre,tam) {
	ventana=window.open(fichero,nombre,tam+",toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes");
	return ventana;	
}


function esVacio(campo)
{   return ((campo == null) || (campo.length == 0))
}

//Campo vacio o lleno de espacios
function esBlanco(campo)
{
	var cadena = new String(campo.value);	
	if(esVacio(campo))
		return true;
	else
		for (var i=0;i<cadena.length;i++)
			if (cadena.charAt(i)!=" ") return false;
		return true;
}


function cargaGaleria() { 
	if(document.getElementById("galeriaID").value==0) {
		window.location.href = "index.php?s=galeria&id=1"; 
	} else {
		window.location.href = "index.php?s=galeria&id="+document.getElementById("galeriaID").value; 
	}
} 




function muestra_menu(id) {

	if (document.getElementById) {
		menu = document.getElementById(id);
		menu.className="on";
	}

}

