main.addFunction("initPrincipal()");

var principal;
function initPrincipal(){
	principal = new Principal();
}

function Principal(){
	
	setupZoom();
	var inputs = document.getElementsByClassName("titulotxt");
	
	for(var i = 0; i < inputs.length; i++)
	{		
		inputs[i].style.visibility = "hidden";
	}
	
	this.trocaFotos = function()
	{
		var fotos = document.getElementsByClassName("trocaFoto");
		for(var i = 0; i < fotos.length; i++)
		{
			fotos[i].onclick= function()
			{				
				var string = this.id;
				
				var ids = string.split("#", 2)
				
				document.getElementById("imgGrande").setAttribute("href", ids[1]);
				document.getElementById("imgBlueScoop").src = ids[0];
			//alert(document.getElementById("imgBlueScoop").getAttribute("pbSrcNL"));
				
			}
		}
	}
	
	this.trocaFotos();
	
	this.trocaFotosGaleria = function()
	{
		var fotos = document.getElementsByClassName("trocaFotosGaleria");
		for(var i = 0; i < fotos.length; i++)
		{
			fotos[i].onclick= function()
			{				
				document.getElementById("foto").src = "./galeria/"+this.id;
			}
		}
	}
	
	this.trocaFotosGaleria();
	
	
	
	this.exibeTxtAcabamento = function()
	{
		var inputs = document.getElementsByClassName("imglink");
		var inputsp = document.getElementsByClassName("titulotxt");
		for(var i = 0; i < inputs.length; i++)
		{
			inputs[i].onmouseover= function()
			{
				
				var idimg = this.id;
								
				for(var j=0; j<inputsp.length; j++)
				{				
					var id = inputsp[j].id;															
					if(id == idimg)
					{						
						document.getElementById(id).style.visibility="visible";
						break;
					}					
				}				
			}
			inputs[i].onmouseout= function()
			{
				
				var idimg = this.id;
								
				for(var j=0; j<inputsp.length; j++)
				{				
					var id = inputsp[j].id;															
					if(id == idimg)
					{						
						document.getElementById(id).style.visibility="hidden";
						break;
					}					
				}				
			}
		}
	}
	this.exibeTxtAcabamento();
	
	
	
	this.popup = function()
	{
		
		var nome = "popup";
		var altura = 190;
		var largura = 400;
		var rolagem = "yes";
		
		var inputs = document.getElementsByClassName("indique");
		
		for(var i = 0; i < inputs.length; i++)
		{
			inputs[i].onclick= function()
			{
				
				var codigo = this.id;
				var caminho = "indique.php?produto="+codigo;
				var esquerda = (screen.width - largura) / 2;
				var cima = (screen.height - altura) / 2 -50;
				window.open(caminho,nome,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + rolagem + ',resizable=no,copyhistory=no,top=' + cima + ',left=' + esquerda + ',width=' + largura + ',height=' + altura);
			}
		}		
	}
	
	this.popup();
	
}
// JavaScript Document
