	/*WRUD - Show Hide comments begin*/
$(function(){
	$("#mostrar").click(function(event) {
		event.preventDefault();
		$("#last_wrapper").slideToggle();
	});

	$("#add_comment_1").click(function(event) {
		event.preventDefault();
		$("#comment_1").slideToggle();
	});
	
	$("#add_comment_2").click(function(event) {
		event.preventDefault();
		$("#comment_2").slideToggle();
	});
	
	$("#add_comment_3").click(function(event) {
		event.preventDefault();
		$("#comment_3").slideToggle();
	});
	
	$("#add_comment_4").click(function(event) {
		event.preventDefault();
		$("#comment_4").slideToggle();
	});
	
	$("#add_comment_5").click(function(event) {
		event.preventDefault();
		$("#comment_5").slideToggle();
	});
	
	$("#close_last a").click(function(event) {
		event.preventDefault();
		$("#last_wrapper").slideUp();
	});
	
	$("#comment_1 a").click(function(event) {
		event.preventDefault();
		$("#comment_1").slideUp();
	});
	
	$("#comment_2 a").click(function(event) {
		event.preventDefault();
		$("#comment_2").slideUp();
	});
	
	$("#comment_3 a").click(function(event) {
		event.preventDefault();
		$("#comment_3").slideUp();
	});
	
	$("#comment_4 a").click(function(event) {
		event.preventDefault();
		$("#comment_4").slideUp();
	});
	
	$("#comment_5 a").click(function(event) {
		event.preventDefault();
		$("#comment_5").slideUp();
	});
	
	$("#show_comments_1").click(function(event) {
		event.preventDefault();
		$("#comments_1").slideToggle();
	});
	
	$("#show_comments_2").click(function(event) {
		event.preventDefault();
		$("#comments_2").slideToggle();
	});
	
	$("#show_comments_3").click(function(event) {
		event.preventDefault();
		$("#comments_3").slideToggle();
	});
	
	$("#show_comments_4").click(function(event) {
		event.preventDefault();
		$("#comments_4").slideToggle();
	});
	
	$("#show_comments_5").click(function(event) {
		event.preventDefault();
		$("#comments_5").slideToggle();
	});
	
});
/*WRUD - Show Hide comments end*/

/*WRUD - Watermark begin*/
jQuery(function($){
   $("#wrud_now").Watermark("What R U doing?...");
});
/*WRUD - Watermark end*/

/*WRUD - Modal begin*/
$(document).ready(function() {	
	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		var id = $(this).attr('href');
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
	
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
	
});
/*WRUD - Modal end*/

/*WRUD - Enter begin*/
$(function(){
  $("#wrud_now").keydown(function(event){
    if(event.keyCode == 13){
		texto = document.getElementById('wrud_now').value;
        $('#wrud_now_hidden').val(texto);
		$('#comment_hidden').val('');
		$('#wrud_id').val('');
		var id = $('a[name=modal]').attr('href');
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
		}
  });
});
/*WRUD - Enter end*/

/*WRUD - Radius begin*/
/*
$(function(){ 
	settings = {
        tl: { radius: 8 },
        tr: { radius: 8 },
        bl: { radius: 8 },
        br: { radius: 8 },
        antiAlias: true,
        autoPad: true,
        validTags: ["div"]
    }
	$('.last_item').corner(settings);
});;
*/
/*WRUD - Radius end*/

/*WRUD - Comment limit begin*/
function limitChars(textid, limit, infodiv)
{
	var text = $('#'+textid).val();	
	var textlength = text.length;
	if(textlength > limit)
	{
		$('#' + infodiv).html('You cannot write more then '+limit+' characters!');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
	{
		$('#' + infodiv).html('You have '+ (limit - textlength) +' characters left.');
		return true;
	}
}

$(function(){
 	$('#text_comment_1').keyup(function(){
 		limitChars('text_comment_1', 140, 'charlimitinfo_1');
 	})
	$('#text_comment_buttom_1').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		var text = $('#text_comment_1').val();
		var id = $('#text_comment_wrud_id_1').val();
		$('#comment_hidden').val(text);
		$('#wrud_id').val(id);
		$('a[name=modal]').click();
	});
	$('#text_comment_buttom_2').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		var text = $('#text_comment_2').val();
		var id = $('#text_comment_wrud_id_2').val();
		$('#comment_hidden').val(text);
		$('#wrud_id').val(id);
		$('a[name=modal]').click();
	});	
	$('#text_comment_buttom_3').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		var text = $('#text_comment_3').val();
		var id = $('#text_comment_wrud_id_3').val();
		$('#comment_hidden').val(text);
		$('#wrud_id').val(id);
		$('a[name=modal]').click();
	});	
	$('#text_comment_buttom_4').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		var text = $('#text_comment_4').val();
		var id = $('#text_comment_wrud_id_4').val();
		$('#comment_hidden').val(text);
		$('#wrud_id').val(id);
		$('a[name=modal]').click();
	});	
	$('#text_comment_buttom_5').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		var text = $('#text_comment_5').val();
		var id = $('#text_comment_wrud_id_5').val();
		$('#comment_hidden').val(text);
		$('#wrud_id').val(id);
		$('a[name=modal]').click();
	});		
	
	$('#text_comment_2').keyup(function(){
 		limitChars('text_comment_2', 140, 'charlimitinfo_2');
 	})
	$('#text_comment_3').keyup(function(){
 		limitChars('text_comment_3', 140, 'charlimitinfo_3');
 	})
	$('#text_comment_4').keyup(function(){
 		limitChars('text_comment_4', 140, 'charlimitinfo_4');
 	})
	$('#text_comment_5').keyup(function(){
 		limitChars('text_comment_5', 140, 'charlimitinfo_5');
 	})
});
/*WRUD - Comment limit end*/

/*WRUD - Timer begin*/
/*
// Configure refresh interval (in seconds)
		var refreshinterval=15

		// Shall the coundown be displayed inside your status bar? Say "yes" or "no" below:
		var displaycountdown="no"

		// Do not edit the code below
		var starttime
		var nowtime
		var reloadseconds=0
		var secondssinceloaded=0

		function starttime() {
			starttime=new Date()
			starttime=starttime.getTime()
			countdown()
		}

		function countdown() {
			nowtime= new Date()
			nowtime=nowtime.getTime()
			secondssinceloaded=(nowtime-starttime)/1000
			reloadseconds=Math.round(refreshinterval-secondssinceloaded)
			if (refreshinterval>=secondssinceloaded) {
				var timer=setTimeout("countdown()",1000)
				if (displaycountdown=="yes") {
					window.status="Page refreshing in "+reloadseconds+ " seconds"
				}
			}
			else {
				clearTimeout(timer)
				
				window.location.reload(true)
			} 
		}
*/
/*WRUD - Timer end*/

/*WRUD - Tool tip*/
$(function () {
	$('.bubbleInfo').each(function () {
		var distance = 10;
		var time = 250;
		var hideDelay = 500;

		var hideDelayTimer = null;

		var beingShown = false;
		var shown = false;
		var trigger = $('.trigger', this);
		var info = $('.popup', this).css('opacity', 0);


		$([trigger.get(0), info.get(0)]).mouseover(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			if (beingShown || shown) {
				// don't trigger the animation again
				return;
			} else {
				// reset position of info box
				beingShown = true;

				info.css({
					top: -48,
					left: 300,
					display: 'block'
				}).animate({
					top: '-=' + distance + 'px',
					opacity: 1
				}, time, 'swing', function() {
					beingShown = false;
					shown = true;
				});
			}

			return false;
		}).mouseout(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			hideDelayTimer = setTimeout(function () {
				hideDelayTimer = null;
				info.animate({
					top: '-=' + distance + 'px',
					opacity: 0
				}, time, 'swing', function () {
					shown = false;
					info.css('display', 'none');
				});

			}, hideDelay);

			return false;
		});
	});
});