jQuery(document).ready(function($) {
			
		// First Last UL
		$("ul").each(function(){
			$("li:last-child", this).addClass("last");
			$("li:first-child", this).addClass("first");
		});
/*		
		$("table").each(function(){
			$("tr:odd", this).addClass("odd");
			$("tr:even", this).addClass("even");
		});
*/

		$("#archived-box li").each(function(idx, li)
		{
			if((idx+1) % 4 == 0)
			{
				$(li).addClass("last");
			}
		});

		// Cufon
		var trajan = "#main-menu ul li a span, #main-menu ul li ul li a";
		var titext = ".content-block h3, .rtl h4, .rtl h3, .rtl h5";
		var titextb = ".content-block h3 strong, .concert-list-date .month,  .concert-list-date .date, table thead tr th";
		var bebas = ".widget-header, .more-link, .content-header, .button, .table-menu-header, #label-2";

		Cufon.replace(trajan, {
			fontFamily: 'trajan',
			hover: 'true'
		});
		
		Cufon.replace(titext, {
			fontFamily: 'titext',
			hover: 'true'
		});
		
		Cufon.replace(titextb, {
			fontFamily: 'titext-b',
			hover: 'true'
		});
		
		Cufon.replace(bebas, {
			fontFamily: 'bebas',
			hover: 'true'
		});
		
		/* Scroller effect */
		var $panels = $('#slider .scrollContainer > div');
		var $container = $('#slider .scrollContainer');

		// if false, we'll float all the panels left and fix the width 
		// of the container
		var horizontal = true;
		
		// float the panels left if we're going horizontal
		if (horizontal && $panels[0]) {
		  $panels.css({
		    'float' : 'left',
		    'position' : 'relative' // IE fix to ensure overflow is hidden
		  });
		  
		  // calculate a new width for the container (so it holds all panels)
		  $container.css('width', $panels[0].offsetWidth * $panels.length);
		}
		// collect the scroll object, at the same time apply the hidden overflow
		// to remove the default scrollbars that will appear
		var $scroll = $('#slider .scroll').css('overflow', 'hidden');
		
		// apply our left + right buttons
		/*
		$scroll
		  .before('<img class="scrollButtons left" src="images/scroll_left.png" />')
		  .after('<img class="scrollButtons right" src="images/scroll_right.png" />');
		*/
		// handle nav selection
		function selectNav() {
		  $(this)
		    .parents('ul:first')
		      .find('a')
		        .removeClass('selected')
		      .end()
		    .end()
		    .addClass('selected');
		}
		$('#slider .navigation').find('a').click(selectNav);
		
		// go find the navigation link that has this target and select the nav
		function trigger(data) {
		  var el = $('#slider .navigation').find('a[href$="' + data.id + '"]').get(0);
		  selectNav.call(el);
		}
		
		if (window.location.hash) {
		  trigger({ id : window.location.hash.substr(1) });
		} else {
		  $('ul.navigation a:first').click();
		}
		
		// offset is used to move to *exactly* the right place, since I'm using
		// padding on my example, I need to subtract the amount of padding to
		// the offset.  Try removing this to get a good idea of the effect
		var offset = parseInt((horizontal ? 
		  $container.css('paddingTop') : 
		  $container.css('paddingLeft')) 
		  || 0) * -1;
		
		
		var scrollOptions = {
		  target: $scroll, // the element that has the overflow
		  
		  // can be a selector which will be relative to the target
		  items: $panels,
		  
		  navigation: '.navigation a',
		  
		  // selectors are NOT relative to document, i.e. make sure they're unique
		  prev: 'img.left', 
		  next: 'img.right',
		  
		  // allow the scroll effect to run both directions
		  axis: 'xy',
		  
		  onAfter: trigger, // our final callback
		  
		  offset: offset,
		  
		  // duration of the sliding effect
		  duration: 500,
		  
		  // easing - can be used with the easing plugin: 
		  // http://gsgd.co.uk/sandbox/jquery/easing/
		  easing: 'swing'
		};
		
		// apply serialScroll to the slider - we chose this plugin because it 
		// supports// the indexed next and previous scroll along with hooking 
		// in to our navigation.
		$('#slider').serialScroll(scrollOptions);
		
		// now apply localScroll to hook any other arbitrary links to trigger 
		// the effect
		$.localScroll(scrollOptions);
		
		// finally, if the URL has a hash, move the slider in to position, 
		// setting the duration to 1 because I don't want it to scroll in the
		// very first page load.  We don't always need this, but it ensures
		// the positioning is absolutely spot on when the pages loads.
		scrollOptions.duration = 1;
		$.localScroll.hash(scrollOptions);
		
		// Go Color
/*
		$("ul#disc-list li").hover(function() { //On hover...
				var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'

				//Set a background image(thumbOver) on the <a> tag - Set position to bottom
				$(this).find("a").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});

				//Animate the image to 0 opacity (fade it out)
				$(this).find("span").stop().fadeTo('normal', 0 , function() {
					$(this).hide() //Hide the image after fade
				});
			} , function() { //on hover out...
				//Fade the image to full opacity 
				$(this).find("span").stop().fadeTo('normal', 1).show();
		});
		
		$(".discography-item").hover(function() { //On hover...
		
		
				var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'

				//Set a background image(thumbOver) on the <a> tag - Set position to bottom
				$(this).css({'background' : 'url(' + thumbOver + ') no-repeat left bottom'});

				//Animate the image to 0 opacity (fade it out)
				$(this).find("img").stop().fadeTo('normal', 0 , function() {
					$(this).hide() //Hide the image after fade
				});
			} , function() { //on hover out...
				//Fade the image to full opacity 
				$(this).find("img").stop().fadeTo('normal', 1).show();
		});
*/

		$('#disc-list .switch-img img').fadeTo(0, 0.7);

        $(".switch-img").bind("mouseenter mouseleave click", function(event)
        {
            if (event.type == 'mouseenter')
            {
            	if ($(".des.color", this).hasClass('clicked') == false)
            	{
					$(".des.color", this).stop().fadeTo('normal', 1).show();
				}
            }
            
            if (event.type == 'mouseleave')
            {
            	if ($(".des.color", this).hasClass('clicked') == false)
            	{
	            	$(".des.color", this).stop().fadeTo('normal', 0 , function() {
						$(this).hide(); //Hide the image after fade
					});
				}
            }
            
            if (event.type == 'click')
            {
            	$(".des.color").removeClass("clicked");
              	$(".des.color").stop().fadeTo('normal', 0, function() {
					$(this).hide(); //Hide the image after fade
				});
             	

            	
            	$(".des.color", this).addClass("clicked");
            	
              	$(".des.color", this).stop().fadeTo(0, 1).show();
            }
        });

		
		// Validate Form
		$('form').validate({
			errorPlacement: function(error, element) {
				error.appendTo( element.next('.error-box'));
			} 
		});
		
		$('.submit').click(function(){
			$(this).parent('form').submit();
			return false;
		});
		
		// PNG Fix
		if ($.browser.msie && $.browser.version.substr(0,1)<7){
			$("#logo a, #footer-logo, #partikule-logo, #footer-wrapper").supersleight({shim: '../assets/images/x.gif'});
			$("#main-menu ul li").mouseover(function(){
				$(this).addClass("hover");
			});
			$("#main-menu").mouseout(function(){
				$("#main-menu ul li").removeClass("hover");
			});
		}
		
		// Supersub
		$("#main-menu ul").supersubs({ 
            minWidth:    12   // minimum width of sub-menus in em units 
        });
        
		$(".scrollto").click(function(event)
		{
			event.preventDefault();
			$(".scrollto").removeClass('current');
			$(this).parent().addClass('current');
			var full_url = this.href;
			
			var parts = full_url.split("#");
			var trgt = parts[1];
			
			var target_offset = $("#"+trgt).offset();
			var target_top = target_offset.top;
			
			$('html, body').animate({scrollTop:target_top}, 500);
		});

		$(function() {
		
		    var $sidebar   = $("#left-sidebar"),
		        $window    = $(window),
		        offset     = $sidebar.offset(),
		        topPadding = 15;

			if ($sidebar && offset != null)
			{
			    $window.scroll(function() {
			        if ($window.scrollTop() > offset.top) {
			            $sidebar.stop().animate({
			                marginTop: $window.scrollTop() - offset.top + topPadding
			            });
			        } else {
			            $sidebar.stop().animate({
			                marginTop: 0
			            });
			        }
			    });
		    }
		
		});
        
        
});

var paircount = 0;

var initDesaturate = function(obj)
{
        obj.onload = null;
        var $newthis = $(obj);
        if ($.browser.msie)
        {
          // You need this only if desaturate png with aplha channel
          $newthis = $newthis.desaturateImgFix();
        }
        // class for easy switch between color/gray version
        $newthis.addClass("pair_" + ++paircount);
        var $cloned = $newthis.clone();
        // reset onload event on cloned object
        $cloned.get(0).onload = null;
        // add cloned after original image, we will switch between
        // original and cloned later
        $cloned.insertAfter($newthis).addClass("color").hide();
        // desaturate original
        $newthis.desaturate();

};


      
