// JavaScript Document

function baseUrl()
{
	return $('meta[name="url"]').attr('content');
}

function hashToVoid()
{
	$('a[href="#"]').attr('href', 'javascript:void(0);');
}

$(document).ready(function(){
	
	//muda o href de # para void(0);
	hashToVoid();
	
	var srcImg = $('meta[name="baseImages"]').attr('content');	
	$('#procura a img').hover(function(){
		var altImg = $(this).attr('alt');	
		$(this).attr('src',srcImg+'/'+altImg+'Hover.gif');
	}, function(){
		var altImg = $(this).attr('alt');
		$(this).attr('src', srcImg+'/'+altImg+'.gif');
	});
	
	
	$('#procura input').focus(function(){
		$(this).attr('value','');
	});


	
	//Botão de translate
	$('#procura button.toEnglish').click(function() {
		document.location = baseUrl() + '/idioma/english?_redirect=' + window.location.pathname;
	});
	$('#procura button.toPortuguese').click(function() {
		document.location = baseUrl() + '/idioma/portugues?_redirect=' + window.location.pathname;
	});
	
	//Contato Validation
	$('.formContato form').validate({
		errorLabelContainer: '#error',
		wrapper: "li",
		rules: {
			nome: 'required',
			email: {
				required: true,
				email: true
			},
			mensagem: 'required'
		},
		messages : {
			nome: '* Preencha seu nome completo',
			email: '* Informe um email válido',
			mensagem: '* Digite sua mensagem'
		}
	});
});
