if(document.location.hostname == '192.168.0.13') 
{ 		
	var dir = document.location.pathname.split('/');
	var end = 'http://'+document.location.hostname+'/'+dir[1]+'/'+dir[2];
} else
	var end = 'http://'+document.location.hostname+'/';


var funcoes = function() 
{

    return {
		
		/*
		 * incializa todas as funções;
		 */		
        incializar: function() 
		{
			newsletter(end);
       	}
		
	}	
	
	/*
	 * Newsletter [ página inicial ];
	 */					
	function newsletter()
	{
		var campoNews = jQuery("form[name='formNews']").find('input[type="text"]');
		var msgNews = "Digite seu e-mail";
		campoNews.val(msgNews);
		
		jQuery(".ok").click(function() 
		{
			if ((campoNews.val().indexOf("@") == -1) || (campoNews.val().indexOf(".") == -1) || (campoNews.val().indexOf("@.") != -1) || (campoNews.val().indexOf('.') < 5)) 
			{
				campoNews.focus();
				campoNews.addClass("erro");
			} 
			else 
			{
				jQuery.post(end+"auxiliar.php", {emailNews: ""+campoNews.val()+""}, function(retorno) 
				{
					switch (retorno) 
					{
						case '1': jQuery("#boxNews").html('E-mail j&aacute; existe no sistema.'); break;
						case '2': jQuery("#boxNews").html('E-mail cadastrado com sucesso.'); break;
						default:  jQuery("#boxNews").html('Mensagem de erro n&atilde;o definida.'); break;
					}	
				}); 	
			}
		});
		
		jQuery(campoNews).blur(function() { if(campoNews.val() == '') jQuery(this).val(msgNews); }); 	
		jQuery(campoNews).focus(function() { if(campoNews.val() == msgNews) jQuery(this).val(''); }); 
	}	
}();

$(document).ready(funcoes.incializar);
