$(document).ready(function(){

  //$('#loader').loader();
  
  $('#newsTicker').jcarousel({
    vertical: true, auto: 10
  });

  // animated link anchors
  var anchor = new String(window.location);
  if(anchor.indexOf('#')) {
		var $target = $(window.location.hash), target = window.location.hash;
		if (target) {
			var targetOffset = $target.offset().top;
			$('html').animate({scrollTop: targetOffset}, 400, function() {
				location.hash = target;
			});
		}
	}

	$('a[href*=#]').each(function() {
		if ( location.hostname == this.hostname || !this.hostname && this.hash.replace(/#/,'') ) {
			var $target = $(this.hash), target = this.hash;
			if (target) {
				var targetOffset = $target.offset().top;
				$(this).click(function(event) {
					event.preventDefault();
					$('html').animate({scrollTop: targetOffset}, 400, function() {
						location.hash = target;
					});
				});
			}
		}
	}); 

  // Pool voting animated
  $("#pool a").live("click", function(){ 
    var $link = $(this).attr("href");
    $("#pool .ctt").load("/app/helper.php?action=poolVote&string="+$link, function(){
      $("#poolResults div").each(function(){
        var txt = $(this).next().html();
    		var percentage = $(txt).next().text();
        $(this).css({width: "0%"}).animate({width: percentage}, 'slow');
      });
    });
    return false;  
  });
  
  if ($("#poolResults").length > 0 ) { 
    $("#poolResults div").each(function(){
      var txt = $(this).next().html();
  		var percentage = $(txt).next().text();
      $(this).css({width: "0%"}).animate({width: percentage}, 'slow');
    });
  }
  
  $(".galImage").lightBox();
  	
});