Cufon.replace('#contenido h1, #contenido h2');
$(document).ready(function(){
	$("#login_publico").validate();
	$("#form_contacto").validate();
	$("#form_registro").validate();
	$('#slider').nivoSlider({
		pauseTime: 5000
	});
	$('.lightbox').lightbox();
	$('#top').click(function () {
		$('body,html').animate({
			scrollTop: 0
		}, 800);
		return false;
	});
	//Tooltips
	//Tooltips
	var tip = '';
	$(".tooltip").hover(function(){

		//Caching the tooltip and removing it from container; then appending it to the body
		tip = $(this).find('.tip').remove();
		$('body').append(tip);

		tip.fadeIn('fast'); //Show tooltip

	}, function() {

		tip.hide().remove(); //Hide and remove tooltip appended to the body
		$(this).append(tip); //Return the tooltip to its original position

	}).mousemove(function(e) {
	//console.log(e.pageX)
		  var mousex = e.pageX - 130; //Get X coodrinates
		  var mousey = e.pageY + 20; //Get Y coordinates
		  var tipWidth = tip.width(); //Find width of tooltip
		  var tipHeight = tip.height(); //Find height of tooltip

		 //Distance of element from the right edge of viewport
		  var tipVisX = $(window).width() - (mousex + tipWidth);
		  var tipVisY = $(window).height() - (mousey + tipHeight);

		if ( tipVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
			mousex = e.pageX - tipWidth + 20;
			$(this).find('.tip').css({  top: mousey, left: mousex });
		} if ( tipVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
			mousey = e.pageY - tipHeight - 40;
			tip.css({  top: mousey, left: mousex });
		} else {
			tip.css({  top: mousey, left: mousex });
		}
	});
	//Tooltips
});
function show(id){
	$(id).fadeIn();
	$(id).addClass("active");
}
function hide(id){
	$(id).hide();
}

/* G+ */
window.___gcfg = {lang: 'es'};

(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
/* Twitter */
jQuery(function($){
	$(".tweet").tweet({
		username: ["GFORMARTE"],
		loading_text: "Cargando tweets...",
		refresh_interval: 60,
		join_text: "auto",
		avatar_size: 32,
		auto_join_text_default: ",",
		auto_join_text_ed: "",
		auto_join_text_ing: "",
		auto_join_text_reply: "",
		auto_join_text_url: "",
		count: 2
	});
});
