var enviarAmigo = {
	'opened': false,
	'show': function(){
		this.opened = true;
		bgSite.show();
		
		document.getElementById('seuemail').value = document.getElementById('seunome').value = document.getElementById('nomeemigo').value = document.getElementById('emailamigo').value = "";
		
		document.getElementById('detalhesEnviarAmigo').style.display = "block";
		this.alinha();
	},
	'alinha' : function(){
		if(!this.opened) return;
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('detalhesEnviarAmigo');
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-(SZ.y))/2;
		document.getElementById('detalhesEnviarAmigo').style.top = (newY+SC.y)+"px";
		document.getElementById('detalhesEnviarAmigo').style.left = (newX+SC.x)+"px";
		bgSite.alinha();
	},
	'hide': function(){
		this.opened = false;
		document.getElementById('detalhesEnviarAmigo').style.top = "-1000px";
		document.getElementById('detalhesEnviarAmigo').style.lef = "-1000px";
		document.getElementById('detalhesEnviarAmigo').style.display = "none";
		bgSite.hide();
	},
	'send': function(){
		msgErro = document.getElementById('mensagensAmigo');
		if(document.getElementById('seunome').value.isWhite()){
			msgErro.innerHTML = 'Digite o seu nome';
			return;
		}
		if(document.getElementById('seuemail').value.isWhite() || !validateEmail(document.getElementById('seuemail').value)){
			msgErro.innerHTML = 'Digite o seu e-mail';
			return;
		}
		if(document.getElementById('nomeemigo').value.isWhite()){
			msgErro.innerHTML = 'Digite o nome do amigo';
			return;
		}
		if(document.getElementById('emailamigo').value.isWhite() || !validateEmail(document.getElementById('emailamigo').value)){
			msgErro.innerHTML = 'Digite o e-mail do amigo';
			return;
		}

		var ajaxEnviarAmigo = new ajax({
			'method': 'POST',
			'url': '/'+getLinguagem()+'/enviarAmigo/',
			'oncomplete': function() {
				setClear();
				enviarAmigo.hide();
				delete ajaxEnviarAmigo;
			}
		});
		ajaxEnviarAmigo.push('seunome', document.getElementById('seunome').value);
		ajaxEnviarAmigo.push('seuemail', document.getElementById('seuemail').value);
		ajaxEnviarAmigo.push('nomeemigo', document.getElementById('nomeemigo').value);
		ajaxEnviarAmigo.push('emailamigo', document.getElementById('emailamigo').value);
		ajaxEnviarAmigo.push('idProd', document.getElementById('produtoid').value);
		ajaxEnviarAmigo.open();
	}
}

function setClear(){
	document.getElementById('seunome').value = '';
	document.getElementById('seuemail').value = '';
	document.getElementById('nomeemigo').value = '';
	document.getElementById('emailamigo').value = '';
	document.getElementById('mensagensAmigo').innerHTML = '';
}

window.onload = function(e){}

window.onresize = function(){
	enviarAmigo.alinha();	
}

window.onstopscroll = function(){
	enviarAmigo.alinha();
}


function trocarTabela(atual){
	var a = {
		'oProduto': 32,
		'valoresNutricionais': 160,
		'fichaTecnica': 310
	}	
	
	for(b in a) $("#"+b).hide();
	
	$("#"+atual).show();
	
	$('#setaTabelaProdutos').css('marginLeft', a[atual]+"px");
}

$(document).ready(function(){
	var galeriaProdutos = new GA({
		'idContent': 'content_produtos',
		'idMascara': 'mascara_produtos',
		'_xMover': 168,
		'btMais': 'mais',
		'btMenos': 'menos'		
	});
	galeriaProdutos.create();
});
