$(document).ready(function(){
	var current_nav = 'home';
	
	scroll_function = function(){
		
		$(".content").each(function(index) {
			var h = $(this).offset().top;
			var y = $(window).scrollTop();
						
			if(y + 360 >= h && y < h + $(this).height() && $(this).attr('id') != current_nav) {
				
				//alert($(this).attr('id') + " " + current_nav);
				//alert(index);
				current_nav = $(this).attr('id');
				
				$('.nav').removeClass('active');
				$('.nav_' + current_nav).addClass('active').show("fast");	
					
			}
		});	
	}
	
	$(window).scroll(function(){
		scroll_function();
	});
	
	//scroll_function();
	
	$(".nav").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();

		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;

		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];
					
		if(current_nav != trgt) {
		
			current_nav = trgt;		
				
			//$('.nav').removeClass('active');
			//$('.nav_' + current_nav).addClass('active').show("fast");
			//get the top offset of the target anchor
			var target_offset = $("#"+trgt).offset();
			var target_top = target_offset.top - 0;
			
			//goto that anchor by setting the body scroll top to anchor top
			if( $.browser.opera) {
				$('html').animate({scrollTop:target_top}, 700);
			} else {
				$('html, body').animate({scrollTop:target_top}, 700);
			}
		}
	});	
	
});


/* SORTING */ 

$(function(){
          
  var $container = $('#container');

  $container.isotope({
	itemSelector : '.element'
  });
    
  var $optionSets = $('#options .option-set'),
	  $optionLinks = $optionSets.find('a');

  $optionLinks.click(function(){
	var $this = $(this);
	// don't proceed if already selected
	if ( $this.hasClass('selected') ) {
	  return false;
	}
	var $optionSet = $this.parents('.option-set');
	$optionSet.find('.selected').removeClass('selected');
	$this.addClass('selected');

	// make option object dynamically, i.e. { filter: '.my-filter-class' }
	var options = {},
		key = $optionSet.attr('data-option-key'),
		value = $this.attr('data-option-value');
	// parse 'false' as false boolean
	value = value === 'false' ? false : value;
	options[ key ] = value;
	if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
	  // changes in layout modes need extra logic
	  changeLayoutMode( $this, options )
	} else {
	  // otherwise, apply new options
	  $container.isotope( options );
	}
	
	return false;
  });

  
});








/************************************************************************/// // NEWS ///************************************************************************/

/**
 * We use the initCallback callback
 * to assign functionality to the controls
 */
function mycarousel_initCallback(carousel) {

    jQuery('#newslist-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#newslist-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#newslist").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null,
        vertical: true
    });
});


$(function()
			{
				// this initialises the demo scollpanes and makes it reinitialise itself once it's images have loaded...
				var settings = {
					scrollbarWidth: 5,
					dragMaxHeight: 100
				};
				$('.scroll-pane')
					.jScrollPane(settings)
					$.featureList(
				$("#newslist ul li a"),
				$(".entry"), {
					start_item	:	0,
					transition_interval : 0
				}
			);
			});

$(window).load(function() {

 
$('.section-wraper').each(function () {
	locheight=$(this).height();
	$(this).children('.sidebar').height(locheight);
	$(this).children('.main-col').height(locheight);
});


$('.tricol').each(function () {
	tocheight=$(this).height();
	$(this).children('.column').height(tocheight);	
});


$('#submit-button-a').click(function(){$('#submit-button').click()});
$('#reset-button-a').click(function(){$('#reset-button').click()});

$('.nivo-controlNav a').html('&nbsp;');
$("#menu ul li:first a").click();


getTwitters('tweet', { 
  id: 'musikandfilm', 
  count: 8, 
  enableLinks: true, 
  ignoreReplies: true, 
  clearContents: true,
  template: '<p><span><a href="http://twitter.com/%user_screen_name%/statuses/%id_str%/">@%user_screen_name%</a></span> "%text%"</p> '
});
		
});

