/*
// Precarga de imánes
if (document.images) {
  var foto1 = new Image();
  foto1.src = "/img/<xsl:value-of select="substring-after(@foto1, '/')"/>";
  <xsl:if test="@foto2!=''">
     var foto2 = new Image();
     foto2.src = "/img/<xsl:value-of select="substring-after(@foto2, '/')"/>";
  </xsl:if>
  <xsl:if test="@foto3!=''">
     var foto3 = new Image();
     foto3.src = "/img/<xsl:value-of select="substring-after(@foto3, '/')"/>";
  </xsl:if>
  <xsl:if test="@foto4!=''">
     var foto4 = new Image();
     foto4.src = "/img/<xsl:value-of select="substring-after(@foto4, '/')"/>";
  </xsl:if>
  <xsl:if test="@foto5!=''">
     var foto5 = new Image();
     foto5.src = "/img/<xsl:value-of select="substring-after(@foto5, '/')"/>";
  </xsl:if>
}
*/
function entra(foto) {
  if (document.images) {
    if (foto == 'foto1') {
      document.images['foto'].src = foto1.src;
    }
    if (foto == 'foto2') {
      document.images['foto'].src = foto2.src;
    }
    if (foto == 'foto3') {
      document.images['foto'].src = foto3.src;
    }
     if (foto == 'foto4') {
      document.images['foto'].src = foto4.src;
    }
    if (foto == 'foto5') {
      document.images['foto'].src = foto5.src;
    }

  }
}

      // popups de noticias (cajas flotantes con el resumen de la noticia)
      function sendHttpRequest(url,callbackFunc,respXml){
         var xmlobj=null;
         try{
           xmlobj=new XMLHttpRequest();
         }
         catch(e){
           try{
             xmlobj=new ActiveXObject("Microsoft.XMLHTTP");
           }
           catch(e){
             alert('AJAX is not supported by your browser!');
             return false;
           }
         }
         xmlobj.onreadystatechange=function(){
           if(xmlobj.readyState==4){
             if(xmlobj.status==200){
               respXml?eval(callbackFunc+'(xmlobj.responseXML)'):eval(callbackFunc+'(xmlobj.responseText)');
             }
           }
         }
         // open socket connection
         xmlobj.open('GET',url,true);
         // send http header
         xmlobj.setRequestHeader('Content-Type','text/html;charset=UTF-8');
         // send http request
         xmlobj.send(null);
      }
      // display fill pop-up DIVS with server contents
      function displayResults(content){
         var popupdiv=document.getElementById('popup');
         if(!popupdiv){return};
         popupdiv.innerHTML='';
         popupdiv.innerHTML=content;
      }
      // display Pop Up div element
      function displayPopupDiv(e){
         var posx=0;
         var posy=0;
         if(!e){var e=window.event};
         // determine target DIV
         var targ=e.target?e.target:e.srcElement;
         // calculate mouse coordinates
         if(e.pageX||e.pageY){
           posx=e.pageX;
           posy=e.pageY;
         }
         else if(e.clientX||e.clientY){
           posx=e.clientX;
           posy=e.clientY;
           // check for scroll offsets in IE 6
           if(document.documentElement.scrollLeft || document.documentElement.scrollTop){
             posx+=document.documentElement.scrollLeft;
             posy+=document.documentElement.scrollTop;
           }
         }
         // assign attributes to pop-up DIV element and append
         // it to web document tree
         var div=document.getElementById('popup');
         if(!div){
           var div=document.createElement('div');
           div.setAttribute('id','popup');
           div.className='popupdiv';
           document.getElementsByTagName('body')[0].appendChild(div);
           sendHttpRequest('getdata.php?id='+targ.id,'displayResults');        
         }
         // move pop-up DIV element
         div.style.top=posy+5+'px';
         div.style.left=posx+5+'px';
      }
      // remove pop-up DIV element
      function hidePopupDiv(){
         var div=document.getElementById('popup');
         if(!div){return};
         div.parentNode.removeChild(div);
      }
      // activate pop-up DIV elements
      function activatePopupDivs(){
         var divs=document.getElementsByTagName('div');
         if(!divs){return};
         for(var i=0;i<divs.length;i++){
           if(divs[i].className=='popupcontainer'){
             // display pop-up DIV element
             divs[i].onmousemove=displayPopupDiv;
             // hide pop-up DIV element
             divs[i].onmouseout=hidePopupDiv;
           }
         }
      }
      // activate pop-up DIV elements when web page has been
      // loaded
      window.onload=function(){
         if(document.getElementById && document.createElement && document.createTextNode){
           activatePopupDivs();
         }
      }
	  function checkAceptacion(){
			if (document.form.aceptacion.checked){
				document.form.submit();
			}
			else {
				alert('Para continuar debe usted aceptar la Cláusula informativa Web');
			}

	  }
	  
	function mostrarConsumibles(marca,modelo) {
			var marca = $('input#marca').val();
			var modelo = $('select#modelo option:selected').val();
			
			if(modelo!='') {
				$("#listadoConsumibles").html('<img src="/img/procesando.gif"/>');
				//var consumibles = $.get("obtenerConsumibles.php", { marca: marca, modelo: modelo } );
				$.get("obtenerConsumibles.php", { marca: marca, modelo: modelo }, function(data){
					$("#listadoConsumibles").html(data);
				});
			//alert(consumibles);
			}
			else {
				$("#listadoConsumibles").html('<p>Seleccione Modelo</p>');
			}
	   }
	   
	function mostrar () {
			var imagen = $("select#selectorOtrosProds option:selected").val();
			if(imagen!='') {
				$("#imagenOtroProd").html("<img src='/gestor/upload/promociones/" + imagen + "' alt='' title=''/>");
			}
			else {
				$("#imagenOtroProd").html("");
			}
	   }

	  function mostrarAnno(anno){
		var filtroGrupo = $('#filtroGrupo').val();
		
		$('#menu_vertical ul.ppl li ul').attr('style','display:none;');
		$('#filtroAnno').val(anno);
		$('#filtroMes').val('');
		$('#menu_vertical ul.ppl li ul#mesesAnno'+anno).attr('style','display:block;');
		$('#menu_vertical ul.ppl li ul#mesesAnno'+anno).attr('class','current');
		$('#menu_vertical ul.ppl li ul#mesesAnno'+anno).parent().find('a').attr('class','current');
		$('#menu_vertical ul.ppl li ul#mesesAnno'+anno+' li.ghost').attr('style','display:block;');
		$('#noticiario div.noticia').attr('style','display:none;');
		if (filtroGrupo==''){
			$('#noticiario div.noticia.anno'+anno).attr('style','display:block;');
		$('#noticiario h4 span#filtroNoticia').html('('+anno+')');
		}
		else {
			$('#noticiario div.noticia.anno'+anno+'.'+filtroGrupo).attr('style','display:block;');
		$('#noticiario h4 span#filtroNoticia').html('('+filtroGrupo+', '+anno+')');
		}
	  }
	  
	  function mostrarMes(mes,anno){
		var filtroGrupo = $('#filtroGrupo').val();
		
		$('#noticiario div.noticia').attr('style','display:none;');
		$('#filtroAnno').val(anno);
		$('#filtroMes').val(mes);
		if (filtroGrupo==''){
			$('#noticiario div.noticia.anno'+anno+'.'+mes).attr('style','display:block;');
			$('#noticiario h4 span#filtroNoticia').html('('+mes+' del '+anno+')');
		}
		else{
			$('#noticiario div.noticia.anno'+anno+'.'+mes+'.'+filtroGrupo).attr('style','display:block;');
			$('#noticiario h4 span#filtroNoticia').html('('+filtroGrupo+', '+mes+' del '+anno+')');
		}
	  }
	  
	function filtrarNoticias(grupo){
		var filtroAnno = $('#filtroAnno').val();
		var filtroMes = $('#filtroMes').val();
		
		if(grupo!='Todas'){
			$('#noticiario div').attr('style','display:none;');
			$('#filtroGrupo').val(grupo);
			if (filtroAnno==''){
				$('#noticiario h4 span#filtroNoticia').html('('+grupo+')');
				$('#noticiario div.'+grupo).attr('style','display:block;');
			}
			else {
				if (filtroMes==''){
					$('#noticiario h4 span#filtroNoticia').html('('+grupo+', '+filtroAnno+')');
					$('#noticiario div.anno'+filtroAnno+'.'+grupo).attr('style','display:block;');
				}
				else {
					$('#noticiario h4 span#filtroNoticia').html('('+grupo+', '+filtroMes+' del '+filtroAnno+')');
					$('#noticiario div.'+filtroMes+'.anno'+filtroAnno+'.'+grupo).attr('style','display:block;');
				}
			}
			$('#selectorTiposNoticia ul li').removeClass('current');
			$('li#' + grupo).attr('class','current');
		}
		if(grupo=='Todas'){
			$('#filtroGrupo').val('');
			$('#filtroAnno').val('');
			$('#filtroMes').val('');
			$('#menu_vertical ul.ppl li ul').attr('style','display:none;');
			$('#noticiario div').attr('style','display:block;');
			$('#noticiario h4 span#filtroNoticia').html('');
			$('#selectorTiposNoticia ul li').removeClass('current');
			$('li#' + grupo).attr('class','current');
		}
	}
	
		function  validarFormulario(){
			
	/*		var nombre = $('form#contacto input#nombre').val();
			var apellidos = $('form#contacto input#apellidos').val();
			var empresa = $('form#contacto input#empresa').val();
			var telefono_oficina = $('form#contacto input#telefono_oficina').val();
			var email = $('form#contacto input#email').val();
			
			if (nombre == ''){
					alert('Por favor, compruebe que ha rellenado todos los campos obligatorios.');
					return false;
				}
			
			else if (apellidos == ''){
					alert('Por favor, compruebe que ha rellenado todos los campos obligatorios.');
					return false;
				}
			
			else if (empresa == ''){
					alert('Por favor, compruebe que ha rellenado todos los campos obligatorios.');
					return false;
				}
			
			else if (telefono_oficina == ''){
					alert('Por favor, compruebe que ha rellenado todos los campos obligatorios.');
					return false;
				}
			
			else if (email == ''){
					alert('Por favor, compruebe que ha rellenado todos los campos obligatorios.');
					return false;
				}
				
				else {*/
					$('form#contacto').submit();
		//		}
		}
	
		function  comprobarModelo(){
			var asunto = $('form#contacto select#asunto option:selected').val();
			
			if (asunto == 'Toner' || asunto == 'Averia'){
				$('form#contacto label span#modeloObligatorio').attr('style','display:inline;');
			}
			else {
				$('form#contacto label span#modeloObligatorio').attr('style','display:none;');
			}
			
		}
	
		function  validarFormularioBisa(){
			
			var empresa = $('form#contacto input#empresa').val();
			var telefono_oficina = $('form#contacto input#telefono_oficina').val();
			var nombre = $('form#contacto input#nombre').val();
			var email = $('form#contacto input#email').val();
			var asunto = $('form#contacto select#asunto option:selected').val();
			var modelo = $('form#contacto select#modelo option:selected').val();
			
			if (empresa == ''){
					alert('Por favor, compruebe que ha rellenado todos los campos obligatorios.');
					return false;
				}
			
			else if (telefono_oficina == ''){
					alert('Por favor, compruebe que ha rellenado todos los campos obligatorios.');
					return false;
				}
				
			else if (nombre == ''){
					alert('Por favor, compruebe que ha rellenado todos los campos obligatorios.');
					return false;
				}
			
			else if (email == ''){
					alert('Por favor, compruebe que ha rellenado todos los campos obligatorios.');
					return false;
				}
			
			else if (asunto == ''){
					alert('Por favor, compruebe que ha rellenado todos los campos obligatorios.');
					return false;
				}
			
			else if (asunto == 'Toner' || asunto == 'Averia'){
					if (modelo){
						if (modelo == ''){
							alert('Por favor, compruebe que ha rellenado todos los campos obligatorios.');
							return false;
						}
						else {
							$('form#contacto').submit();
						}
					}
					else {
						alert('Por favor, compruebe que ha rellenado todos los campos obligatorios.');
						return false;
					}
				}
				
				else {
					$('form#contacto').submit();
				}
		}

