 	
  	function ChangeImg(id, src)
  	{
  		document.getElementById(id).src = src;
		}
		
		function SetHeader(menu,idioma)
		{
			switch(menu)
			{
				case "menu1":
					document.getElementById(menu).src = "img/menu_inicio_over"+idioma+".jpg";
					
					document.getElementById('menu2').onmouseover=function(){ChangeImg('menu2', 'img/menu_productos_over'+idioma+'.jpg');}
					document.getElementById('menu2').onmouseout=function(){ChangeImg('menu2', 'img/menu_productos'+idioma+'.jpg');}
					
					document.getElementById('menu3').onmouseover=function(){ChangeImg('menu3', 'img/menu_empresa_over'+idioma+'.jpg');}
					document.getElementById('menu3').onmouseout=function(){ChangeImg('menu3', 'img/menu_empresa'+idioma+'.jpg');}
					
					document.getElementById('menu4').onmouseover=function(){ChangeImg('menu4', 'img/menu_novedades_over'+idioma+'.jpg');}
					document.getElementById('menu4').onmouseout=function(){ChangeImg('menu4', 'img/menu_novedades'+idioma+'.jpg');}
					
					document.getElementById('menu5').onmouseover=function(){ChangeImg('menu5', 'img/menu_noticias_over'+idioma+'.jpg');}
					document.getElementById('menu5').onmouseout=function(){ChangeImg('menu5', 'img/menu_noticias'+idioma+'.jpg');}
					
					document.getElementById('menu6').onmouseover=function(){ChangeImg('menu6', 'img/menu_aplicaciones_over'+idioma+'.jpg');}
					document.getElementById('menu6').onmouseout=function(){ChangeImg('menu6', 'img/menu_aplicaciones'+idioma+'.jpg');}
				break;
				
				case "menu2":
					document.getElementById(menu).src = "img/menu_productos_over"+idioma+".jpg";
					
					document.getElementById('menu1').onmouseover=function(){ChangeImg('menu1', 'img/menu_inicio_over'+idioma+'.jpg');}
					document.getElementById('menu1').onmouseout=function(){ChangeImg('menu1', 'img/menu_inicio'+idioma+'.jpg');}
					
					document.getElementById('menu3').onmouseover=function(){ChangeImg('menu3', 'img/menu_empresa_over'+idioma+'.jpg');}
					document.getElementById('menu3').onmouseout=function(){ChangeImg('menu3', 'img/menu_empresa'+idioma+'.jpg');}
					
					document.getElementById('menu4').onmouseover=function(){ChangeImg('menu4', 'img/menu_novedades_over'+idioma+'.jpg');}
					document.getElementById('menu4').onmouseout=function(){ChangeImg('menu4', 'img/menu_novedades'+idioma+'.jpg');}
					
					document.getElementById('menu5').onmouseover=function(){ChangeImg('menu5', 'img/menu_noticias_over'+idioma+'.jpg');}
					document.getElementById('menu5').onmouseout=function(){ChangeImg('menu5', 'img/menu_noticias'+idioma+'.jpg');}
					
					document.getElementById('menu6').onmouseover=function(){ChangeImg('menu6', 'img/menu_aplicaciones_over'+idioma+'.jpg');}
					document.getElementById('menu6').onmouseout=function(){ChangeImg('menu6', 'img/menu_aplicaciones'+idioma+'.jpg');}
				break;
				
				case "menu3":
					document.getElementById(menu).src = "img/menu_empresa_over"+idioma+".jpg";
					
					document.getElementById('menu2').onmouseover=function(){ChangeImg('menu2', 'img/menu_productos_over'+idioma+'.jpg');}
					document.getElementById('menu2').onmouseout=function(){ChangeImg('menu2', 'img/menu_productos'+idioma+'.jpg');}
					
					document.getElementById('menu1').onmouseover=function(){ChangeImg('menu1', 'img/menu_inicio_over'+idioma+'.jpg');}
					document.getElementById('menu1').onmouseout=function(){ChangeImg('menu1', 'img/menu_inicio'+idioma+'.jpg');}
					
					document.getElementById('menu4').onmouseover=function(){ChangeImg('menu4', 'img/menu_novedades_over'+idioma+'.jpg');}
					document.getElementById('menu4').onmouseout=function(){ChangeImg('menu4', 'img/menu_novedades'+idioma+'.jpg');}
					
					document.getElementById('menu5').onmouseover=function(){ChangeImg('menu5', 'img/menu_noticias_over'+idioma+'.jpg');}
					document.getElementById('menu5').onmouseout=function(){ChangeImg('menu5', 'img/menu_noticias'+idioma+'.jpg');}
					
					document.getElementById('menu6').onmouseover=function(){ChangeImg('menu6', 'img/menu_aplicaciones_over'+idioma+'.jpg');}
					document.getElementById('menu6').onmouseout=function(){ChangeImg('menu6', 'img/menu_aplicaciones'+idioma+'.jpg');}
				break;
				
				case "menu4":
					document.getElementById(menu).src = "img/menu_novedades_over"+idioma+".jpg";
					
					document.getElementById('menu2').onmouseover=function(){ChangeImg('menu2', 'img/menu_productos_over'+idioma+'.jpg');}
					document.getElementById('menu2').onmouseout=function(){ChangeImg('menu2', 'img/menu_productos'+idioma+'.jpg');}
					
					document.getElementById('menu3').onmouseover=function(){ChangeImg('menu3', 'img/menu_empresa_over'+idioma+'.jpg');}
					document.getElementById('menu3').onmouseout=function(){ChangeImg('menu3', 'img/menu_empresa'+idioma+'.jpg');}
					
					document.getElementById('menu1').onmouseover=function(){ChangeImg('menu1', 'img/menu_inicio_over'+idioma+'.jpg');}
					document.getElementById('menu1').onmouseout=function(){ChangeImg('menu1', 'img/menu_inicio'+idioma+'.jpg');}
					
					document.getElementById('menu5').onmouseover=function(){ChangeImg('menu5', 'img/menu_noticias_over'+idioma+'.jpg');}
					document.getElementById('menu5').onmouseout=function(){ChangeImg('menu5', 'img/menu_noticias'+idioma+'.jpg');}
				
					document.getElementById('menu6').onmouseover=function(){ChangeImg('menu6', 'img/menu_aplicaciones_over'+idioma+'.jpg');}
					document.getElementById('menu6').onmouseout=function(){ChangeImg('menu6', 'img/menu_aplicaciones'+idioma+'.jpg');}
				break;
				
				case "menu5":
					document.getElementById(menu).src = "img/menu_noticias_over"+idioma+".jpg";
					
					document.getElementById('menu2').onmouseover=function(){ChangeImg('menu2', 'img/menu_productos_over'+idioma+'.jpg');}
					document.getElementById('menu2').onmouseout=function(){ChangeImg('menu2', 'img/menu_productos'+idioma+'.jpg');}
					
					document.getElementById('menu3').onmouseover=function(){ChangeImg('menu3', 'img/menu_empresa_over'+idioma+'.jpg');}
					document.getElementById('menu3').onmouseout=function(){ChangeImg('menu3', 'img/menu_empresa'+idioma+'.jpg');}
					
					document.getElementById('menu4').onmouseover=function(){ChangeImg('menu4', 'img/menu_novedades_over'+idioma+'.jpg');}
					document.getElementById('menu4').onmouseout=function(){ChangeImg('menu4', 'img/menu_novedades'+idioma+'.jpg');}
					
					document.getElementById('menu1').onmouseover=function(){ChangeImg('menu1', 'img/menu_inicio_over'+idioma+'.jpg');}
					document.getElementById('menu1').onmouseout=function(){ChangeImg('menu1', 'img/menu_inicio'+idioma+'.jpg');}
					
					document.getElementById('menu6').onmouseover=function(){ChangeImg('menu6', 'img/menu_aplicaciones_over'+idioma+'.jpg');}
					document.getElementById('menu6').onmouseout=function(){ChangeImg('menu6', 'img/menu_aplicaciones'+idioma+'.jpg');}
				break;
				
				case "menu6":
					document.getElementById(menu).src = "img/menu_aplicaciones_over"+idioma+".jpg";
					
					document.getElementById('menu2').onmouseover=function(){ChangeImg('menu2', 'img/menu_productos_over'+idioma+'.jpg');}
					document.getElementById('menu2').onmouseout=function(){ChangeImg('menu2', 'img/menu_productos'+idioma+'.jpg');}
					
					document.getElementById('menu3').onmouseover=function(){ChangeImg('menu3', 'img/menu_empresa_over'+idioma+'.jpg');}
					document.getElementById('menu3').onmouseout=function(){ChangeImg('menu3', 'img/menu_empresa'+idioma+'.jpg');}
					
					document.getElementById('menu4').onmouseover=function(){ChangeImg('menu4', 'img/menu_novedades_over'+idioma+'.jpg');}
					document.getElementById('menu4').onmouseout=function(){ChangeImg('menu4', 'img/menu_novedades'+idioma+'.jpg');}
					
					document.getElementById('menu1').onmouseover=function(){ChangeImg('menu1', 'img/menu_inicio_over'+idioma+'.jpg');}
					document.getElementById('menu1').onmouseout=function(){ChangeImg('menu1', 'img/menu_inicio'+idioma+'.jpg');}
					
					document.getElementById('menu5').onmouseover=function(){ChangeImg('menu5', 'img/menu_noticias_over'+idioma+'.jpg');}
					document.getElementById('menu5').onmouseout=function(){ChangeImg('menu5', 'img/menu_noticias'+idioma+'.jpg');}
					
				break;
				
				default:
				
					document.getElementById('menu1').onmouseover=function(){ChangeImg('menu1', 'img/menu_inicio_over'+idioma+'.jpg');}
					document.getElementById('menu1').onmouseout=function(){ChangeImg('menu1', 'img/menu_inicio'+idioma+'.jpg');}
					
					document.getElementById('menu2').onmouseover=function(){ChangeImg('menu2', 'img/menu_productos_over'+idioma+'.jpg');}
					document.getElementById('menu2').onmouseout=function(){ChangeImg('menu2', 'img/menu_productos'+idioma+'.jpg');}
					
					document.getElementById('menu3').onmouseover=function(){ChangeImg('menu3', 'img/menu_empresa_over'+idioma+'.jpg');}
					document.getElementById('menu3').onmouseout=function(){ChangeImg('menu3', 'img/menu_empresa'+idioma+'.jpg');}
					
					document.getElementById('menu4').onmouseover=function(){ChangeImg('menu4', 'img/menu_novedades_over'+idioma+'.jpg');}
					document.getElementById('menu4').onmouseout=function(){ChangeImg('menu4', 'img/menu_novedades'+idioma+'.jpg');}
					
					document.getElementById('menu5').onmouseover=function(){ChangeImg('menu5', 'img/menu_noticias_over'+idioma+'.jpg');}
					document.getElementById('menu5').onmouseout=function(){ChangeImg('menu5', 'img/menu_noticias'+idioma+'.jpg');}
					
					document.getElementById('menu6').onmouseover=function(){ChangeImg('menu6', 'img/menu_aplicaciones_over'+idioma+'.jpg');}
					document.getElementById('menu6').onmouseout=function(){ChangeImg('menu6', 'img/menu_aplicaciones'+idioma+'.jpg');}
				break;
			}

		}
		
		function Blank(obj)
		{
			obj.reset();
			
			for(var i=0;i<obj.elements.length;i++)
			{
				if(obj.elements[i].type=="file" || obj.elements[i].type=="text")
				{
					obj.elements[i].value="";
				}
				else if (obj.elements[i].tagName=="SELECT")
				{
					obj.elements[i].selectedIndex=0;
				}
				else if (obj.elements[i].tagName=="TEXTAREA")
				{
					obj.elements[i].value="";
				}
			}
			
		}
		
		function checkform_form_contacto(idioma)
		{
			if((idioma=="")||(idioma=="cast"))
			{
				if(document.form_contacto.Empresa.value == "")
				{
					alert("Introducir el nombre de la empresa.");
					return false;
				}
				
				/*if(document.form_contacto.Titular.value == "")
				{
					alert("Introducir el titular.");
					return false;
				}*/
				
				/*if(document.form_contacto.Actividad.value == "")
				{
					alert("Introducir la actividad.");
					return false;
				}*/

				/*if(document.obj.Direccion.value == "")
				{
					alert("Introducir la dirección.");
					return false;
				}*/
				
				/*if(document.form_contacto.Poblacion.value == "")
				{
					alert("Introducir la población.");
					return false;
				}*/
				
				/*if(document.form_contacto.CP.value == "")
				{
					alert("Introducir C.P.");
					return false;
				}*/
								
				/*if(document.form_contacto.Provincia.value == "")
				{
					alert("Introducir la provincia.");
					return false;
				}*/
				
				/*if(document.form_contacto.NIF.value == "")
				{
					alert("Introducir NIF/CIF.");
					return false;
				}*/

				/*if(document.form_contacto.Tel.value == "")
				{
					alert("Introducir el Teléfono.");
					return false;
				}*/
				
				if(document.form_contacto.Email.value == "")
				{
					alert("Introducir el Email.");
					return false;
				}
				
				document.form_contacto.submit();
				return true;
				
			}
			else if(idioma=="eng")
			{
				if(document.form_contacto.Empresa.value == "")
				{
					alert("Introduce the company.");
					return false;
				}
				
				/*if(document.form_contacto.Titular.value == "")
				{
					alert("Introduce the title.");
					return false;
				}*/
				
				/*if(document.form_contacto.Actividad.value == "")
				{
					alert("Introduce the activity.");
					return false;
				}*/

				/*if(document.obj.Direccion.value == "")
				{
					alert("Introducir la dirección.");
					return false;
				}*/
				
				/*if(document.form_contacto.Poblacion.value == "")
				{
					alert("Introduce the city.");
					return false;
				}*/
				
				/*if(document.form_contacto.CP.value == "")
				{
					alert("Introduce the ZipCode");
					return false;
				}*/
								
				/*if(document.form_contacto.Provincia.value == "")
				{
					alert("Introduce the State.");
					return false;
				}*/
				
				if(document.form_contacto.NIF.value == "")
				{
					alert("Introduce the NIF/CIF.");
					return false;
				}

				/*if(document.form_contacto.Tel.value == "")
				{
					alert("Introduce the Telephone.");
					return false;
				}*/
				
				if(document.form_contacto.Email.value == "")
				{
					alert("Introduce the Email.");
					return false;
				}
				
				//document.form_contacto.submit();
				return true;
			}
		}
		
		function check_form_clientes(obj)
		{
			//comprobamos login
			if(obj.Usr.value == "")
			{
				alert("Introducir nombre de usuario y contraseña.");
				return false;
			}
			
			//comprobamos password
			if(obj.Pwd.value == "")
			{
				alert("Introducir nombre de usuario y contraseña.");
				return false;
			}
			
			//obj.submit();
			return true;
		}

		 function Es_num(num){ 
      if(num != "") 
       { 
           if(!isNaN(num)){ 
               for(var i = 0; i<num.length;i++){ 
                     if(num.charCodeAt(i)<48 || num.charCodeAt(i)>57){ 
                          alert("Formato de orden incorrecto."); 
                          return false;                           
                     } 
               } 
           }else{ 
              alert("Formato de número incorrecto."); 
              return false;                
           }            
        }else{ 
            alert("Formato de número incorrecto."); 
              return false;    
        } 
          return true; 
      }


		function CalculoDBs(db_sirena, db_ambiente, dist, idioma)
		{
			if(Es_num(db_sirena) && Es_num(db_ambiente) && Es_num(dist) )
			{
				db = db_sirena + (20 *log10(1/dist));
				//alert(db);
				dist_calc = 1/Math.pow(10,((15+(db_ambiente-db_sirena))/20));
				//alert(dist);
				
				switch(idioma)
				{
					case "cast":
						txt="Con "+db_ambiente+" dBs de ruido ambiente, la potencia sonora de la sirena a "+dist+" metros será de <b>"+Math.floor(db)+" dBs</b>.<br>";
						txt=txt + "La distancia máxima a la que se oirá la sirena 15 dBs por encima del ruido ambiente será de <b>"+Math.floor(dist_calc)+" metros</b>.";
					break;
					case "eng":
						txt="With "+db_ambiente+" dBs of environment noise, the siren's acoustic power at "+dist+" metres will be of <b>"+Math.floor(db)+" dBs</b>.<br>";
						txt=txt + "The maximum distance the siren will be heard with a power of 15 dBs over the environment noise will be of <b>"+Math.floor(dist_calc)+" metres</b>.";
				
					break;
					default:
						txt="Con "+db_ambiente+" dBs de ruido ambiente, la potencia sonora de la sirena a "+dist+" metros será de <b>"+Math.floor(db)+" dBs</b>.<br>";
						txt=txt + "La distancia máxima a la que se oirá la sirena 15 dBs por encima del ruido ambiente será de <b>"+Math.floor(dist_calc)+" metros</b>.";
					break;
				}
				
				createCustomAlert(txt);
				
			}
		}
		
		function log10(x)
		{
			return (Math.log(x)/Math.log(10));
		}

		function createCustomAlert(txt) {
			var ALERT_TITLE = "Resultado";
			var ALERT_BUTTON_TEXT = "Volver";

			// shortcut reference to the document object
			d = document;
		
			// if the modalContainer object already exists in the DOM, bail out.
			if(d.getElementById("modalContainer")) return;
		
			// create the modalContainer div as a child of the BODY element
			mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
			mObj.id = "modalContainer";
			 // make sure its as tall as it needs to be to overlay all the content on the page
			mObj.style.height = document.documentElement.scrollHeight + "px";
		
			// create the DIV that will be the alert 
			alertObj = mObj.appendChild(d.createElement("div"));
			alertObj.id = "alertBox";
			
			var arrayPageSize = getPageSize();
			var arrayPageScroll = getPageScroll();
				
	    alertObj.style.top = (arrayPageSize[3]/2 - 75 + arrayPageScroll[1]) + "px";
			alertObj.style.left = (arrayPageSize[2]/2 - 250 + arrayPageScroll[0]) + "px";
			
			// MSIE doesnt treat position:fixed correctly, so this compensates for positioning the alert
			//if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
			// center the alert box
			//alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";
		
			// create an H1 element as the title bar
			h1 = alertObj.appendChild(d.createElement("h1"));
			h1.appendChild(d.createTextNode(ALERT_TITLE));
		
			// create a paragraph element to contain the txt argument
			msg = alertObj.appendChild(d.createElement("p"));
			//msg.appendChild(d.createTextNode(txt));
			
			msg.innerHTML = txt;
		
			// create an anchor element to use as the confirmation button.
			btn = alertObj.appendChild(d.createElement("a"));
			btn.id = "closeBtn";
			btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
			btn.href = "#";
			// set up the onclick event to remove the alert when the anchor is clicked
			btn.onclick = function() { removeCustomAlert();return false; }
	}

// removes the custom alert from the DOM
function removeCustomAlert() {
	document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}


function getPageScroll(){

	var xScroll,yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

    if (self.pageXOffset) {
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollLeft){	 // Explorer 6 Strict
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		xScroll = document.body.scrollLeft;
	}
	
	arrayPageScroll = new Array(xScroll,yScroll) 
	//alert(arrayPageScroll[1]);
	return arrayPageScroll;
}


function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	//alert(arrayPageSize[1]);
	return arrayPageSize;
}

	var timer_on = false;
	var timerID = null;
	var id_play_now = null;
	var delay = 5000;

	function PlayStop(obj)
	{
		/****** VERSION DE XAVI DEOP ***********/
		
		if(obj.src.indexOf('play') != -1 )
		{
			if(timer_on)
			{
				document.getElementById("sound_container").innerHTML="";
				/*clearTimeout(timerID);
				id_play_now.src = 'img/play.gif';*/
			}
			
			obj.src = 'img/stop.gif';
			
			var mySplitResult = obj.id.split("_");
			var id_sonidos = "sonidos_"+ mySplitResult[2];
			
			document.getElementById("sound_container").innerHTML="<embed id='s_player' src='"+document.getElementById(id_sonidos).options[document.getElementById(id_sonidos).selectedIndex].value+"' hidden=\"true\" autostart=\"true\" loop=\"true\" enablejavascript=\"true\">";
			
			//timerID = setTimeout('Stop2segs()', delay);
			//timer_on = true;
			id_play_now = obj;
		}
		else
		{
			obj.src = 'img/play.gif';
			document.getElementById("sound_container").innerHTML="";
			if(timer_on)
			{
				clearTimeout(timerID);
			}
		}
		
		
	}
	
	function Stop2segs()
	{
		if(timer_on)
		{
			document.getElementById("sound_container").innerHTML="";
			clearTimeout(timerID);
			//document.getElementById('player_sonido').src = 'img/play.gif';
			id_play_now.src = 'img/play.gif';
			
		}
	}
	
	function SetVideoLink(obj)
	{
		
		if(obj.selectedIndex >= 0)
		{
			document.getElementById('video_link').href = obj.options[obj.selectedIndex].value;
		}
		
	}
	
	function descargaSonido(obj){
		var mySplitResult = obj.id.split("_");
		var id_sonidos = "sonidos_"+ mySplitResult[2];
		window.location.href="descarga.php?f=" + document.getElementById(id_sonidos).options[document.getElementById(id_sonidos).selectedIndex].value;
	}
