/* bookmark */
function bookmarksite(title,url){
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
		window.external.AddFavorite(url, title);
}

$(document).ready(function(){
	$('#urlSocializar').attr('value', window.location.href);
	$('.btTwitter').attr('href', 'http://twitter.com/home?status='+window.location.href);
	$('.btFacebook').attr('href', 'http://www.facebook.com/sharer.php?u='+window.location.href+'&t='+document.title);
	$('.btDelicious').attr('href', 'http://delicious.com/post?url='+window.location.href+'&title='+document.title+'&notes=');
});

function validaFormSocializar(){
	var validator = $("#formSocializar").validate({
		//errorContainer: $(".msgErrorAssine"), 
		//errorLabelContainer: $(".msgError"),
		errorClass: "error",
		
		highlight: function(element, errorClass) {
		     $(element).addClass(errorClass);
		     $(element.form).find("label[for=" + element.name + "]").addClass('erro');
		  },
		
		unhighlight: function(element, errorClass) {
			$(element).removeClass(errorClass);
			$(element.form).find("label[for=" + element.name + "]").removeClass('erro');
			$(element.form).find("label[for=" + element.name + "]").show();
		},
		submitHandler: function(form) {
			$('#loading').ajaxStart(function(){
	                //$('#alvo').hide();
	                //$('#loading').show();   
	        });
	        $('#loading').ajaxStop(function(){
	                //$('#loading').hide();   
	        });
	        $.get('/inc/processa-socializar.php',
		        {nomeSocializar: $('input[name=nomeSocializar]').val(),
				 emailSocializar: $('input[name=emailSocializar]').val(),
				 emailAmigoSocializar: $('input[name=emailAmigoSocializar]').val(),
				 URL: $('input[name=url]').val(),
				 nomeAmigoSocializar: $('input[name=nomeAmigoSocializar]').val()},
		        function(data){
		        	$('#mensagemretorno').empty().html(data);
		        }
	        );
		}
		
	});
}

