
	$(document).ready(function(){
		//When you click on a link with class of poplight and the href starts with a #
		$('a.poplight[href^=#]').click(function() {
			var popID = $(this).attr('rel'); //Get Popup Name
			var popURL = $(this).attr('href'); //Get Popup href to define size

			//Pull Query & Variables from href URL
			var query= popURL.split('?');
			var dim= query[1].split('&');
			var popWidth = dim[0].split('=')[1]; //Gets the first query string value

			//Fade in the Popup and add close button
			$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<div class="btn_close"><a href="#" class="close">Cerrar</a></div>');

			//Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css
			var popMargTop = ($('#' + popID).height() + 80) / 2;
			var popMargLeft = ($('#' + popID).width() + 80) / 2;

			//Apply Margin to Popup
			$('#' + popID).css({
				'margin-top' : -popMargTop,
				'margin-left' : -popMargLeft
			});

			//Fade in Background
			$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
			$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer

			return false;
		});


		//Close Popups and Fade Layer
		$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
			$('#fade , .popup_block').fadeOut(function() {
				$('#fade, a.close').remove();
		}); //fade them both out

			return false;
		});


	});


	$(document).ready(function(){
		var first = 0;
		var speed = 700;
		var pause = 3500;

			function removeFirst(){
				first = $('ul#listticker li:first').html();
				$('ul#listticker li:first')
				.animate({opacity: 0}, speed)
				.fadeOut('slow', function() {$(this).remove();});
				addLast(first);
			}

			function addLast(first){
				last = '<li style="display:none">'+first+'</li>';
				$('ul#listticker').append(last)
				$('ul#listticker li:last')
				.animate({opacity: 1}, speed)
				.fadeIn('slow')
			}

		interval = setInterval(removeFirst, pause);
	});



	$(document).ready(function(){
		$("#toggleContactPanel").click(function() {
			$("#ContactPanel").slideToggle(500);
			$("#toggleContactPanel").toggleClass("hidden");
			$(this).toggleClass("active");
			return false;
		});
		$("#hideContactPanel").click(function() {
			$("#ContactPanel").slideUp(500);
			$("#toggleContactPanel").toggleClass("hidden");
		return false;
		});
	});



	$(document).ready(function(){
		$(".menu_mt > li").click(function(e){
			switch(e.target.id){
				case "news":
					$("#news").addClass("active");
					$("#tagsNews").removeClass("active");
					$("div.news").fadeIn();
					$("div.tagsNews").css("display", "none");
				break;
				case "tagsNews":
					$("#news").removeClass("active");
					$("#tagsNews").addClass("active");
					$("div.tagsNews").fadeIn();
					$("div.news").css("display", "none");
				break;
			}
			//alert(e.target.id);
			return false;
		});
	});


	$(document).ready(function(){
		//$(".accordion div:first").addClass("active");
		$('.accordion ul').hide();
		$(".accordion div").click(function(){
			$(this).siblings("ul").slideToggle("slow");//.siblings("ul:visible").slideUp("slow");
			$(this).toggleClass("active");
			$(this).siblings("div").removeClass("active");
		});
	});


	$(function () {
		$(window).scroll(function () {
			if ($(this).scrollTop() != 0) {
				$('#toTop').fadeIn();
			} else {
			$('#toTop').fadeOut();
			}
		});
			$('#toTop').click(function () {
			$('body,html').animate({
			scrollTop: 0
			},
			800);
		});
	});


	$(function(){
	$(".myMenu").buildMenu(
		{
		  template:"menuVoices.html",
		  additionalData:"pippo=1",
		  menuWidth:200,
		  openOnRight:false,
		  menuSelector: ".menuContainer",
		  iconPath:"ico/",
		  hasimg:true,
		  fadeInTime:100,
		  fadeOutTime:300,
		  adjustLeft:2,
		  minZindex:"auto",
		  adjustTop:10,
		  opacity:.95,
		  shadow:false,
		  shadowColor:"#000",
		  hoverIntent:0,
		  openOnClick:true,
		  closeOnMouseOut:false,
		  closeAfter:1000,
		  submenuHoverIntent:200
		});

		$(document).buildContextualMenu(
		{
		  template:"menuVoices.html",
		  menuWidth:200,
		  overflow:2,
		  menuSelector: ".menuContainer",
		  iconPath:"ico/",
		  hasimg:true,
		  fadeInTime:100,
		  fadeOutTime:100,
		  adjustLeft:0,
		  adjustTop:0,
		  opacity:.99,
		  closeOnMouseOut:false,
		  onContextualMenu:function(o,e){}, //params: o = the contextual menu,e = the event
		  shadow:false
		});
	  });

	 function showMessage(msg){
		var msgBox=$("<div>").addClass("msgBox");
		$("body").append(msgBox);
		msgBox.append("You click on: <br>"+msg);
		setTimeout(function(){msgBox.fadeOut(500,function(){msgBox.remove();})},3000)
	 }


	$(document).ready(function(){
		$("#slider").easySlider({
			auto: true,
			continuous: true
		});
	});


	$(function(){
		$(".someClass").tipTip({maxWidth: 250, edgeOffset: 0});
	});


	//Funciones de HIKARI
	$(document).ready(function(){
		$('.reply_post').click(function(){
			num = $(this).parents('.replies').attr('id');
			$('#PostCommentParentId').attr('value',num);
			$('#inReplyTo').html( '<table style="width:100%;"><tr><td>Respondiendo a: <b>' + $(this).parent().children('span').html() + '</b></td><td><img src="http://www.hakudoushi.zawarudo.org/new/img/cross.png" id="noReplyTo" class="simpleTooltip someClass" title="Eliminar respuesta a comentario" /></td></tr></table><br />');
			$('#noReplyTo').click(function() {
				$('#PostCommentParentId').attr('value',0);
				$('#inReplyTo').html('');
			});
		});

		$('.toggleSummary').click(function(){
			$(this).next().slideToggle('fast');
		});

		$('.message').click(function(){
			$(this).slideUp('fast','');
		});
	});

