// JavaScript Document


// fondo home

if((screen.width<1024)&&(screen.height<768)){
	try{
		var sNav = typeof(navigator.appName)!="undefined"?navigator.appName:"";
		if (sNav == "Microsoft Internet Explorer"){
			document.styleSheets[0].rules[0].style.background = 'url("../img/home/fondo_home_800.jpg")';
		}else{
			document.styleSheets[0].cssRules[0].style.background = 'url("../img/home/fondo_home_800.jpg")';
		}
	}catch(e){}
}

function resizeSm() {
	
	var s = navigator.appVersion
	s = s.substring(s.indexOf("("),s.lastIndexOf(")"));
	var s2 = s.split("; ");
					
	
// tama&ntilde;o capa de texto de las secciones
	if((screen.width<1024)&&(screen.height<768)){
		try{
			if (navigator.appName != "Microsoft Internet Explorer"){
				document.styleSheets[0].cssRules[1].style.width = '280px';
				document.styleSheets[0].cssRules[2].style.width = '280px';
				document.styleSheets[0].cssRules[3].style.width = '280px';
				document.styleSheets[0].cssRules[4].style.width = '280px';
				document.styleSheets[0].cssRules[5].style.width = '60%';
				document.styleSheets[0].cssRules[6].style.left = '340px';
				document.styleSheets[0].cssRules[7].style.left = '340px';
				document.styleSheets[0].cssRules[8].style.width = '280px';

			}else if ((navigator.appName == "Microsoft Internet Explorer")&&(s2[1] == "MSIE 7.0")){
				
				document.styleSheets[0].rules[1].style.width = '280px';
				document.styleSheets[0].rules[2].style.width = '280px';
				document.styleSheets[0].rules[3].style.width = '280px';
				document.styleSheets[0].rules[4].style.width = '280px';
				document.styleSheets[0].rules[5].style.width = '90%';
				document.styleSheets[0].rules[6].style.left = '320px';
				document.styleSheets[0].rules[7].style.left = '320px';
				document.styleSheets[0].rules[8].style.width = '280px';		
			} else {
				document.styleSheets[0].rules[1].style.width = '280px';
				document.styleSheets[0].rules[2].style.width = '280px';
				document.styleSheets[0].rules[3].style.width = '280px';
				document.styleSheets[0].rules[4].style.width = '280px';
				document.styleSheets[0].rules[5].style.width = '90%';
				document.styleSheets[0].rules[6].style.left = '-250px';
				document.styleSheets[0].rules[7].style.left = '-250px';
				document.styleSheets[0].rules[8].style.width = '280px';		

			}
}catch(e){}
}
}
resizeSm();

function resizeBg() {
	
	var s = navigator.appVersion
	s = s.substring(s.indexOf("("),s.lastIndexOf(")"));
	var s2 = s.split("; ");
	if((screen.width>1024)&&(screen.height>768)){
		try{
			if (navigator.appName != "Microsoft Internet Explorer"){
				document.styleSheets[0].cssRules[1].style.width = '600px';
				document.styleSheets[0].cssRules[2].style.width = '600px';
				document.styleSheets[0].cssRules[3].style.width = '600px';
				document.styleSheets[0].cssRules[4].style.width = '600px';
				document.styleSheets[0].cssRules[5].style.width = '60%';
				document.styleSheets[0].cssRules[6].style.left = '620px';
				document.styleSheets[0].cssRules[7].style.left = '620px';
				document.styleSheets[0].cssRules[8].style.width = '600px';
			
			}else if (((navigator.appName == "Microsoft Internet Explorer")&&(s2[1] == "MSIE 7.0")) || ((navigator.appName == "Microsoft Internet Explorer")&&(s2[1] == "MSIE 8.0"))){
				document.styleSheets[0].rules[1].style.width = '600px';
				document.styleSheets[0].rules[2].style.width = '600px';
				document.styleSheets[0].rules[3].style.width = '600px';
				document.styleSheets[0].rules[4].style.width = '600px';
				document.styleSheets[0].rules[5].style.width = '90%';
				document.styleSheets[0].rules[6].style.left = '620px';
				document.styleSheets[0].rules[7].style.left = '620px';
				document.styleSheets[0].rules[8].style.width = '600px';			

			}else{
				document.styleSheets[0].rules[1].style.width = '600px';
				document.styleSheets[0].rules[2].style.width = '600px';
				document.styleSheets[0].rules[3].style.width = '600px';
				document.styleSheets[0].rules[4].style.width = '600px';
				document.styleSheets[0].rules[5].style.width = '90%';
				document.styleSheets[0].rules[6].style.left = '-250px';
				document.styleSheets[0].rules[7].style.left = '-250px';
				document.styleSheets[0].rules[8].style.width = '600px';			
		}
}catch(e){}
}
}
resizeBg();
// buscador

function ltrim(sCadena){
	if(sCadena.indexOf(' ')==0){
	    return ltrim(sCadena.substr(1));
	}else{
	    return sCadena;
	}
}

function rtrim(sCadena){
	if((sCadena.length==sCadena.lastIndexOf(' ')+1)&&sCadena.length!=0){
		return rtrim(sCadena.substr(0,sCadena.lastIndexOf(' ')));
	}else{
		return sCadena;
	}
}

function trim(sCadena){
	return ltrim(rtrim(sCadena));
}


function posBuscar() {
try{
			if (navigator.appName == "Microsoft Internet Explorer"){
				document.styleSheets[2].rules[0].style.top = '12px';
				document.styleSheets[2].rules[0].style.position = 'absolute';
				document.styleSheets[2].rules[0].style.color = '#000';
				document.styleSheets[2].rules[0].style.fontWeight = 'normal';				
		}else{
				document.styleSheets[2].cssRules[0].style.top = '15px';
				document.styleSheets[2].cssRules[0].style.position = 'absolute';
				document.styleSheets[2].cssRules[0].style.color = '#000';
				document.styleSheets[2].cssRules[0].style.fontWeight = 'normal';
}
}catch(e){}
}


function oculBuscar() {
	try{
			if (navigator.appName == "Microsoft Internet Explorer"){
				document.styleSheets[2].rules[0].style.display = 'none';
		}else{
				document.styleSheets[2].cssRules[0].style.display = 'none';
		}
}catch(e){}
}
function muesBuscar() {
	if (document.formulario_buscar.texto.value=="") {
			try{
					if (navigator.appName == "Microsoft Internet Explorer"){
						document.styleSheets[2].rules[0].style.display = 'block';
				}else{
						document.styleSheets[2].cssRules[0].style.display = 'block';
				}
	}catch(e){}
	}
}
function addListener(obj,evt,func) {
    if (obj.attachEvent)
        obj.attachEvent('on' + evt, func);

    else {
        if (obj.addEventListener) {
            obj.addEventListener(evt,func,false);
        }
        else {
            if (obj.eval) {
                obj["on"+evt] = func;
            } 
        }
    }
}
//addListener(window,"load",posBuscar);
posBuscar();

function validaSubmit(){
try{
	var sTexto = trim(document.formulario_buscar.texto.value.toLowerCase());
	if(sTexto=='' || sTexto=='buscador'){
		alert("Por favor introduzca el texto de búsqueda");
		document.formulario_buscar.texto.focus();
		return false;
	}else{
		if(sTexto.length < 3)
		{
			alert("El texto de búsqueda es demasiado corto");
			document.formulario_buscar.texto.focus();
		return false;
		}else{
			return true;
		}
	}
}catch(e){}
}

