window["miVariable"] = 0;

 $(document).ready(function(){
                        // Muestra y oculta los menÃºs
						$('#menuSuperior li:has(ul)').hover(function(e){
							
								$(this).find('ul').stop(true,true).fadeIn('slow');
						
                        }, function(e){
						
                            	$(this).find('ul').stop(true,true).fadeOut('slow');

							
                        });
						
						$("#actualizacion").click(function(evento){
						
							evento.preventDefault();
							$("#destino2").load("downloads/actualizacionDoc.php");
							$("#ul_menu_ajax").find("a").removeClass("seleccionado");
							
							$(this).addClass("seleccionado");
							
							
						});
						
						$("#Matcap_lib").click(function(evento){
							evento.preventDefault();
							$("#destino2").load("downloads/matcap_lib.php");
							$("#ul_menu_ajax").find("a").removeClass("seleccionado");
							$(this).addClass("seleccionado");
							
						});
						$("#pluginsZ3").click(function(evento){
							evento.preventDefault();
							$("#imagenTipo").attr('src','imagenes/title_Z3.gif');
							$("#pluginsZBrush").load('downloads/pluginsZBrush3.php');
								
							});
							
						$("#pluginsZ4").click(function(evento){
								evento.preventDefault();
								$("#imagenTipo").attr('src','imagenes/title_Z4.gif');
								$("#pluginsZBrush").load('downloads/pluginsZBrush4.php');
									
							});
							
						$("#plugins").click(function(evento){
							evento.preventDefault();
							$("#destino2").load("downloads/plugins.php", function(evento){
								$("#pluginsZ3").click(function(evento){
								evento.preventDefault();
								$("#imagenTipo").attr('src','imagenes/title_Z3.gif');
								$("#pluginsZBrush").load('downloads/pluginsZBrush3.php');
									
								});
								
								$("#pluginsZ4").click(function(evento){
									evento.preventDefault();
									$("#imagenTipo").attr('src','imagenes/title_Z4.gif');
									$("#pluginsZBrush").load('downloads/pluginsZBrush4.php');
										
									});
							});
							$("#ul_menu_ajax").find("a").removeClass("seleccionado");
							$(this).addClass("seleccionado");
							
						});
						
						$("#Alpha_lib").click(function(evento){
							evento.preventDefault();
							$("#destino2").load("downloads/alpha_lib.php");
							$("#ul_menu_ajax").find("a").removeClass("seleccionado");
							$(this).addClass("seleccionado");
							
						});
						
						$("#Textura_lib").click(function(evento){
							evento.preventDefault();
							$("#destino2").load("downloads/texture_lib.php");
							$("#ul_menu_ajax").find("a").removeClass("seleccionado");
							$(this).addClass("seleccionado");
							
						});

						/*PARA EL MENU LATERAL DE CARACTERISTICAS*/
						$("#zbrush4").click(function(evento){
							evento.preventDefault();
							$('#banner').load('zbrushSection/zbrush4Banner.php'); 
							$('#destino').load('zbrushSection/zbrush4.php',function(evento){
								$("#info").click(function(evento){
									evento.preventDefault();
									$('#banner').load('zbrushSection/zbrush4Banner.php');
									$("#des").load("zbrushSection/info.php",function(){
										/*PARA LA GALERIA DE IMAGENES*/
										$("#yoxview").yoxview({backgroundColor: '#A9A9A9',
										    playDelay: 5000,
										    backgroundOpacity:0.8,
										    lan: 'es',
										    langFolder:'/javascript/'
											});
									});
									$("#menu_ajax").find("a").removeClass("seleccionado");
									$(this).addClass("seleccionado");
								});
								
								$("#listaFunciones").click(function(evento){
									evento.preventDefault();
									$("#des").load("zbrushSection/lista.php");
									$('#banner').load('zbrushSection/funcionesbanner.php');
									$("#menu_ajax").find("a").removeClass("seleccionado");
									$(this).addClass("seleccionado");
									
								});
								$("#paint").click(function(evento){
									evento.preventDefault();
									$("#des").load("zbrushSection/paint.php");
									$('#banner').load('zbrushSection/paintbanner.php');
									$("#menu_ajax").find("a").removeClass("seleccionado");
									$(this).addClass("seleccionado");
									
								});
								$("#escultura").click(function(evento){
									evento.preventDefault();
									$("#des").load("zbrushSection/escultura.php");
									$('#banner').load('zbrushSection/esculturasbanner.php');
									$("#menu_ajax").find("a").removeClass("seleccionado");
									$(this).addClass("seleccionado");
									
								});
								
							});
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#overview").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/overview.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
							
						});
						$("#goz").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/goz.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#3dbrushes").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/3dbrushes.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#polypaint").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/polypaint.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#ilustracion").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/ilustracion.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#transponer").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/transponer.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#zspheres").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/zspheres.php',function(){
								$.getScript('http://localhost/pixologic.es/javascript/thickbox/thickbox.js');
							});
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#ruido").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/ruido.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#capas").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/capas.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#materiales").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/materiales.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#subtools").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/subtools.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#extraccion").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/extraccion.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#projection").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/projection.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#deformacion").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/deformaciones.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#geometria").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/geometria.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#primitivas").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/primitivas.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#mapas").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/mapas.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#decimationmaster").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/decimationmaster.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#paintstop").click(function(evento){
							evento.preventDefault();							
							$('#destino').load('zbrushSection/paintstop.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						$("#uvmaster").click(function(evento){
							evento.preventDefault();
							$('#destino').load('zbrushSection/uvmaster.php');
							$('#banner').load('zbrushSection/bannerVacio.php');
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						
						/*ZBrush 4 menu superior	*/
						$("#info").click(function(evento){
							evento.preventDefault();
							$('#banner').load('zbrushSection/zbrush4Banner.php');
							$("#des").load("zbrushSection/info.php");
							$("#menu_ajax").find("a").removeClass("seleccionado");
							$(this).addClass("seleccionado");
						});
						
						$("#listaFunciones").click(function(evento){
							evento.preventDefault();
							$("#des").load("zbrushSection/lista.php");
							$('#banner').load('zbrushSection/funcionesbanner.php');
							$("#menu_ajax").find("a").removeClass("seleccionado");
							$(this).addClass("seleccionado");
							
						});
						$("#paint").click(function(evento){
							evento.preventDefault();
							$("#des").load("zbrushSection/paint.php");
							$('#banner').load('zbrushSection/paintbanner.php');
							$("#menu_ajax").find("a").removeClass("seleccionado");
							$(this).addClass("seleccionado");
							
						});
						$("#escultura").click(function(evento){
							evento.preventDefault();
							$("#des").load("zbrushSection/escultura.php");
							$('#banner').load('zbrushSection/esculturasbanner.php');
							$("#menu_ajax").find("a").removeClass("seleccionado");
							$(this).addClass("seleccionado");
							
						});
					
						//PARA LA WEB INDUSTRIA
						
						$("#zbrushIndustria").click(function(evento){
							evento.preventDefault();
							$("#destino").load("industria/zbrushIndustria.php");
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						
						$("#movie").click(function(evento){
							evento.preventDefault();
							$("#destino").load("industria/movie.php");
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
							
						});
						
						$("#videoGames").click(function(evento){
							evento.preventDefault();
							$("#destino").load("industria/games.php");
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						
						$("#illustration").click(function(evento){
							evento.preventDefault();
							$("#destino").load("industria/illustration.php");
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						
						$("#figure").click(function(evento){
							evento.preventDefault();
							$("#destino").load("industria/figure.php");
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						
						$("#conceptDesign").click(function(evento){
							evento.preventDefault();
							$("#destino").load("industria/conceptDesign.php",function(evento){
								$(".agrandar").yoxview({backgroundColor: '#A9A9A9',
							    playDelay: 5000,
							    backgroundOpacity:0.8,
							    lan: 'es',
							    langFolder:'/javascript/'
							    
								});}
							);
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						
						$("#scientific").click(function(evento){
							evento.preventDefault();
							$("#destino").load("industria/scientific.php",function(evento){
								$(".agrandar").yoxview({backgroundColor: '#A9A9A9',
							    playDelay: 5000,
							    backgroundOpacity:0.8,
							    lan: 'es',
							    langFolder:'/javascript/'
							    
								});}
							);
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						
						$("#jewelry").click(function(evento){
							evento.preventDefault();
							$("#destino").load("industria/jewelry.php");
							$("#navbarVert_list").find("a").removeClass("seleccion");
							$(this).addClass("seleccion");
						});
						
						//Para comprar.php
						$("#formularioCompra").validate();
						$("#formularioContactar").validate();
						$("#form_noticias").validate(); 
						
						$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
						
						
						$("#send").click(function(evento){
							alert("hola");
							$("#popform").load("enviarMensaje.php");
						});
						
						//Para gestion, en detalles de compra
						
						$("#masCompra").click(function(event){
							event.preventDefault();
							if($("#datosCompra").is(":hidden")){
								$("#datosCompra").slideDown("slow");
								document.getElementById('masCompra').innerHTML = '<img src="imagenes/borrar.png" />';
							}else{
								$("#datosCompra").slideUp("slow");
								document.getElementById('masCompra').innerHTML = '<img src="imagenes/nuevo.png" />';
							}
	                    });
						
						$("#masCliente").click(function(event){
							event.preventDefault();
							if($("#datosCliente").is(":hidden")){
								$("#datosCliente").slideDown("slow");
								document.getElementById('masCliente').innerHTML = '<img src="imagenes/borrar.png" />';
							}else{
								$("#datosCliente").slideUp("slow");
								document.getElementById('masCliente').innerHTML = '<img src="imagenes/nuevo.png" />';
							}
	                    });
						
						$("#masDetalleCompra").click(function(event){
							event.preventDefault();
							if($("#detallesCompra").is(":hidden")){
								$("#detallesCompra").slideDown("slow");
								document.getElementById('masDetalleCompra').innerHTML = '<img src="imagenes/borrar.png" />';
							}else{
								$("#detallesCompra").slideUp("slow");
								document.getElementById('masDetalleCompra').innerHTML = '<img src="imagenes/nuevo.png" />';
							}
	                    });
						

					
						
 });

 function archivarCompra(compraID){
	 
	 $("#accionesRealizadas").load("gestion/archivarCompras.php?compraID="+compraID);
	 $("#accionesRealizadas").removeClass("hidden");
	 $("#compra"+compraID).addClass("hidden");
	 
 }
 
 
 function enviarMensaje(form){

		$("#popform").load("enviarMensaje.php",{nombre: form.nombreContacto, email: form.email, 
													comentario: form.comments});
	 	alert("llega");

 }
 function SetOpacity(object,opacityPct)
{
  // IE.
  object.style.filter = 'alpha(opacity=' + opacityPct + ')';
  // Old mozilla and firefox
  object.style.MozOpacity = opacityPct/100;
  // Everything else.
  object.style.opacity = opacityPct/100;
}
function ChangeOpacity(id,msDuration,msStart,fromO,toO)
{
  var element=document.getElementById(id);
  var opacity = element.style.opacity * 100;
  var msNow = (new Date()).getTime();
  opacity = fromO + (toO - fromO) * (msNow - msStart) / msDuration;
  if (opacity<0) 
    SetOpacity(element,0)
  else if (opacity>100)
    SetOpacity(element,100)
  else
  {
    SetOpacity(element,opacity);
    element.timer = window.setTimeout("ChangeOpacity('" + id + "'," + msDuration + "," + msStart + "," + fromO + "," + toO + ")",1);
  }
}
function FadeIn(id)
{
  var element=document.getElementById(id);
  if (element.timer) window.clearTimeout(element.timer); 
  var startMS = (new Date()).getTime();
  element.timer = window.setTimeout("ChangeOpacity('" + id + "',300," + startMS + ",0,100)",1);
}
function FadeOut(id)
{
  var element=document.getElementById(id);
  if (element.timer) window.clearTimeout(element.timer); 
  var startMS = (new Date()).getTime();
  element.timer = window.setTimeout("ChangeOpacity('" + id + "',300," + startMS + ",100,0)",1);
}
function FadeInImage(foregroundID,newImage,backgroundID)
{
  var foreground=document.getElementById(foregroundID);
  if (backgroundID)
  {
    var background=document.getElementById(backgroundID);
    if (background)
    {
      background.style.backgroundImage = 'url(' + foreground.src + ')';
      background.style.backgroundRepeat = 'no-repeat';
    }
  }
  SetOpacity(foreground,0);
  foreground.src = newImage;
  if (foreground.timer) window.clearTimeout(foreground.timer); 
  var startMS = (new Date()).getTime();
  foreground.timer = window.setTimeout("ChangeOpacity('" + foregroundID + "',1000," + startMS + ",0,100)",10);
}

/*PARA COMPRAR.PHP*/
function actualizaPrecio(precU, IVA, id){
	var unid = document.getElementById('unidades'+id).value;
	var p = unid*precU*(1+IVA/100);
	if (unid<1) {
//		alert('Introduzca una cantidad mayor o igual que 1');
		document.getElementById('unidades'+id).value='';
		document.getElementById('total'+id).childNodes[0].innerHTML = '0';
	}else{
		p = Math.round(p*100)/100;
		document.getElementById('total'+id).childNodes[0].innerHTML= p;
	}
	var precioTotal = 0;
	for (var i=0;i<document.getElementById('numLineas').value;i++) {
		precioTotal = precioTotal + parseFloat(document.getElementById('total'+i).textContent); 
	}
	document.getElementById('total').textContent = Math.round(precioTotal*100)/100 + " Euros";
	document.getElementById('totalCesta').value=Math.round(precioTotal*100)/100;
}
function seguirComprando(){
	document.getElementById('formularioCompra').action="tienda/actualizaUnidades.php";
	document.getElementById('formularioCompra').submit();
}
function select(id){
	var sel= document.getElementById(id);
	var cont1= document.createElement('input');
	
	var label1= document.createElement('label');
	var label2= document.createElement('label');
	switch (sel.value){
	case 'Pago personalizado':
		cont1.value='';
		cont1.id='precio';
		cont1.setAttribute('class','required digits');
		label1.setAttribute('for', 'precio');
		label1.textContent = 'Precio:';
		document.getElementById('i').innerHTML='<label for="precio">Precio*:</label>';
		document.getElementById('d').innerHTML='<input id="unidades" class="required digits" value= "">';
		document.getElementById('iz').innerHTML='';
		document.getElementById('de').textContent="";
		break; 
	default :
		cont1.value='';
		cont1.id='unidades';
		cont1.setAttribute('class','required digits');
		label1.setAttribute('for', 'unidades');
		label1.textContent = 'Unidades*:';
		document.getElementById('i').innerHTML='<label for="unidades">Unidades*:</label>';
		document.getElementById('d').innerHTML='<input id="unidades" class="required digits" value= "">';
		var precio="precio";
		label2.setAttribute('for', 'unidades');
		label2.textContent = 'Precio:';
		document.getElementById('iz').innerHTML='<label for="precio">Precio*:</label>';
		document.getElementById('de').textContent=precio;
		break;
	} 
	
}
function AntiSpam(nm,dm){
mailurl = "mailto:" + nm + "@" + dm;
window.location = mailurl;
}

