// Cosas que se hacen al inicio
window.onload = function alcargar(){ }

// PRINCIPIO desactivar boton derecho 

var mensaje = "JuFerma s.a.";
function derecho(e)
{
if (navigator.appName == 'Netscape' && e.which == 3)
alert(mensaje);
else if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2)
alert(mensaje);
}
document.onmousedown = derecho;

// FINAL desactivar boton derecho 

// Menu
var hijo;
var hijo2;
function abre_submenu(elemento,pos) {
	
	if(pos == 1){ document.getElementById('menuproductos').style.marginTop="5px"};
	if(pos == 0){document.getElementById('menuproductos').style.marginTop="64px"};
	
	
  var cual = document.getElementsByTagName('div');
  for (var i=0; i<cual.length; i++) { 
		if (cual[i].className=='hijo') {
			 cual[i].style.display='none';
		}
		
  }
	
	var cual = document.getElementsByTagName('a');
  for (var i=0; i<cual.length; i++) { 
		if (cual[i].className=='apartado'){
			 cual[i].style.background='#666666';
			 cual[i].onmouseover = function hola(){this.style.background='#000'; this.style.color = '#fff'}
			 cual[i].onmouseout = function hola(){this.style.background='#666666'; this.style.color = '#fff'}
		}
	}
	
	
	

	elemento.parentNode.parentNode.childNodes[1].style.display='block';
	elemento.style.background='#000000';elemento.style.color = '#ffffff';	
	elemento.onmouseover = function hola(){this.style.background='#E82A2A'; this.style.color = '#ffffff'}
	elemento.onmouseout = function adios(){this.style.background='#E82A2A'; this.style.color = '#ffffff'}	
	
	var cual = document.getElementsByTagName('a');
	for (var i=0; i<cual.length; i++) {
     if (cual[i].style.background =='#E82A2A') {
			 hijo = i;
	 }
    }
	//alert(hijo);	
	var cual = document.getElementsByTagName('a');
  for (var i=0; i<cual.length; i++) {
     if (cual[i].className=='apartado_sub') {
		cual[i].style.background='#eeeeee';
		cual[i].style.color = '#666666';
		cual[i].style.borderRight = '3px solid #666';
		cual[i].onmouseover = function hola(){this.style.background='#fff'; this.style.color = '#000'; this.style.borderRight = '3px solid #000';}
		cual[i].onmouseout = function adios(){this.style.background='#eeeeee'; this.style.color = '#666666'; this.style.borderRight = '3px solid #666';}
	 	}
  }
	
		for (var i=0; i<cual.length; i++) { 
		if (cual[i].className=='apartado_sub2' || cual[i].className=='apartado_sub2sobre'){
			cual[i].className='apartado_sub2';
		}
	}
	
		var cual = document.getElementsByTagName('div');
	
	for (var i=0; i<cual.length; i++) { 
		if (cual[i].className=='hijo2'){
			cual[i].style.display='none';
		}
	}
 	
	
}






function abre_submenu2(elemento) {
	
	
	var cual = document.getElementsByTagName('a');
  for (var i=0; i<cual.length; i++) {
     if (cual[i].className=='apartado_sub') {
		cual[i].style.background='#eeeeee';
		cual[i].style.color = '#666666';
		cual[i].style.borderRight = '3px solid #666';
		cual[i].onmouseover = function hola(){this.style.background='#fff'; this.style.color = '#000'; this.style.borderRight = '3px solid #000';}
		cual[i].onmouseout = function adios(){this.style.background='#eeeeee'; this.style.color = '#666666'; this.style.borderRight = '3px solid #666';}		
	 	}
  }
	elemento.style.background='#fff'; elemento.style.color = '#000'; elemento.style.borderRight = '3px solid #ff0000';	
	elemento.onmouseover = function hola(){this.style.background='#fff'; this.style.color = '#000'; this.style.borderRight = " 3px solid #ff0000"}
	elemento.onmouseout = function adios(){this.style.background='#fff'; this.style.color = '#000'; this.style.borderRight = " 3px solid #ff0000"}
	
	
	for (var i=0; i<cual.length; i++) { 
		if (cual[i].className=='apartado_sub2' || cual[i].className=='apartado_sub2sobre'){
			cual[i].className='apartado_sub2';
		}
	}
 	
	
	for (var i=0; i<elemento.parentNode.childNodes.length; i++) {
		if(elemento.parentNode.childNodes[i].className=='hijo2'){
			elemento.parentNode.childNodes[i].style.display='none';
			if(elemento.parentNode.childNodes[i-2]==elemento){
				elemento.parentNode.childNodes[i].style.display='block';
				}
			}
		}
		
}



function pincha_submenu3(elemento) {
	

			var cual = document.getElementsByTagName('a');
 		 for (var i=0; i<cual.length; i++) { 
		if (cual[i].className=='apartado_sub2' || cual[i].className=='apartado_sub2sobre'){
			cual[i].className='apartado_sub2';
		}
		
		 }
		elemento.className='apartado_sub2sobre';
}


// validar formulario

function validar(){
	//valido el nombre

	if (document.getElementById("fvalida").nombre.value.length==0){
		alert("Por favor, escriba su nombre.")
		document.getElementById("fvalida").nombre.focus()
		return 0;
	}

	if (document.getElementById("fvalida").telefono.value.length==0){
		alert("Por favor, escriba su teléfono.")
		document.getElementById("fvalida").telefono.focus()
		return 0;
	}


	
	//el formulario se envia

	document.getElementById("fvalida").submit();
}


function validar_eng(){
	//valido el nombre

	if (document.getElementById("fvalida").nombre.value.length==0){
		alert("Please, write your name.")
		document.getElementById("fvalida").nombre.focus()
		return 0;
	}

	if (document.getElementById("fvalida").telefono.value.length==0){
		alert("Please, write your telephone number.")
		document.getElementById("fvalida").telefono.focus()
		return 0;
	}


	
	//el formulario se envia

	document.getElementById("fvalida").submit();
}


// efectos en formulario


function dentro(elemento){
	elemento.style.borderColor='#666666';
	elemento.style.borderStyle='solid';
	elemento.style.borderWidth='1px';
	
}

function fuera(elemento){
	elemento.style.borderColor='#727272';
	elemento.style.borderStyle='solid';
	elemento.style.borderWidth='1px';
}


// popup

function abrepop(elemento){
window.open(elemento,'','width=595,height=842,top=0,left=0');
}











