//nav accordion
    ddaccordion.init({
        headerclass: "accordion",    	
		contentclass: "accordioncontent", 
        revealtype: "click",
        collapseprev: true, 
        defaultexpanded: [],
        onemustopen: false, 
		animatedefault: false, 
        persiststate: false,
        toggleclass: ["", "openitemdd"],
        togglehtml: ["none","",""],
        animatespeed: "normal",
        oninit:function(headers, expandedindices){
        },
        onopenclose:function(header, index, state, isuseractivated){
		}
    })

//functions

//timers 
jQuery.timer = function(time,func,callback){
	var a = {timer:setTimeout(func,time),callback:null}
	if(typeof(callback) == 'function'){a.callback = callback;}
	return a;
};

jQuery.clearTimer = function(a){
	clearTimeout(a.timer);
	if(typeof(a.callback) == 'function'){a.callback();};
	return this;
};

//navigation header elements loop
  function loop(newswords,colors,divid){
       
        var colorindex = Math.floor(Math.random()*(colors.length));
		
		var currentword = $('div#'+divid).find('span.title').text();
		var currentcolor =  $('div#'+divid).find('span.title').css("color");
		
				
		var replacement;
		var replacementcolor;
		
		do
		{
			replacement = newword();
		}		
		while(replacement==currentword)
		
		do
		{
			replacementcolor = newcolor();
		}		
		while(replacementcolor==currentcolor)
		
		
		
        
		$('div#'+divid).find('span.title').text(replacement).css('color',replacementcolor);
		//$('div#'+divid).find('span.title').text(currentcolor + ' === ' + replacementcolor).css('color',replacementcolor);
		
				
		function newword(){
			 var wordindex = Math.floor(Math.random()*(newswords.length));
			 return newswords[wordindex];
		}
		
		function newcolor(){
			 var colorindex = Math.floor(Math.random()*(colors.length));
			 return colors[colorindex];
		}
		
};

function reinitialiseScrollPane(){
	
if(!($.browser.msie && parseFloat($.browser.version) < 8)){
myTimer = $.timer(500,function(){
	  	$('#playlist_area').jScrollPane({scrollbarWidth:15, scrollbarMargin:10, showArrows:false, maintainPosition:false, reinitialiseOnImageLoad:true})
		
	})
		
		myTimer2 = $.timer(750,function(){
	  	$('#playlist_area').jScrollPane({scrollbarWidth:15, scrollbarMargin:10, showArrows:false, maintainPosition:false, reinitialiseOnImageLoad:true})
		
	})
		
}
}
function playTrack(t)
{

	$('#jp-controls').hide();
	$("#jquery_jplayer").jPlayer("clearFile");
	
	var jpPlayTime = $("#jplayer_play_time");
	var jpTotalTime = $("#jplayer_total_time");
	
	
	$("#jquery_jplayer").jPlayer({
	ready: function () {
			//this.element.jPlayer("setFile", t).jPlayer("play");
			
		},
		volume: 70,
		oggSupport: false,
		errorAlerts:false,
		warningAlerts:false,
		nativeSuport:false
	})
	
	
	$("#jquery_jplayer").jPlayer("onProgressChange", function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
		jpPlayTime.text($.jPlayer.convertTime(playedTime));
		jpTotalTime.text($.jPlayer.convertTime(totalTime));

	})
	
}

function changeTrack(t,d) {
		$('.jp-controls').fadeTo('slow',0.2);	
		$("#jquery_jplayer").jPlayer("clearFile").jPlayer("setFile", t).jPlayer("play");
		$('.jp-controls').delay(400).fadeTo('slow',1);	
		$('div.current_playing').toggle().removeClass('current_playing');
		$('div.'+d).toggle().addClass('current_playing');
	}
	

$(document).ready(function() {

playTrack('http://cms.placeboworld.co.uk/mp3/56/12.mp3'); 
$('.jp-controls').fadeTo('fast',0.2);	

		$('#playlist_area').fadeOut('fast');
		$('#playlist_area').load("http://www.riverman.co.uk/playlist.php?album=Riverman%20Sampler",'');

	
$(".frame").fancybox({
				'titlePosition': 'inside',
				'transitionIn': 'none',
				'scrolling': 'no',
				'transitionOut': 'none'
			});



		
$('a.switcher').click(function(){
		 //swapPlayer($(this).attr('href'));		
		 var toLoad1 = $(this).attr('href');
		$('#playlist_area').fadeOut('fast');
		loadContent();
		function loadContent() {
			$('#playlist_area').load(toLoad1,'',showNewContent());
		}
		function showNewContent() {
			$('#playlist_area').delay(1000).fadeIn('normal');	
		}
		$('.jp-controls').fadeTo('fast',0.2);	
		$("#jquery_jplayer").jPlayer("clearFile");
		reinitialiseScrollPane();
		return false;	
	});	

$('div#what').mouseenter(function() {
intwhat = setInterval("loop(['Management','Publishing','Live Events','Digital','Sports'],['rgb(180, 4, 95)','rgb(4, 180, 4)','rgb(174, 180, 4)','rgb(255, 0, 0)'],'what');", 450);
}).mouseleave(function(){
    clearInterval(intwhat);
    intwhat = null;
    $(this).find("span.title").text("What").css('color','black');
	//$("span.what_title_default").css('opacity', 1)
	//$("span.what_title_flash").hide();
  });

$('div#records').mouseenter(function() {
intwhat = setInterval("loop(['Formed in 1995 ','London','Roxy music','Records'],['rgb(180, 148, 95)','rgb(5, 180, 4)','rgb(174, 182, 4)','rgb(255, 2, 0)'],'records');", 450);
}).mouseleave(function(){
    clearInterval(intwhat);
    intwhat = null;
    $(this).find("span.title").text("Riverman").css('color','black');
  });

$('div#artist').mouseenter(function() {
intartists = setInterval("loop(['Placebo','Expatriate','Evaline','Officers','Gary Nock','Shields'],['rgb(236, 42, 78)','rgb(42, 138, 236)','rgb(42, 138, 236)','rgb(174, 180, 4)' , 'rgb(88, 172, 250)', 'rgb(246, 42, 70)' ],'artist');", 450);
}).mouseleave(function(){
    clearInterval(intartists);
    intartists = null;
    $(this).find("span.title").text("Artists").css('color','black');
  });
  
$("div#news").mouseenter(function() {
intnews = setInterval("loop(['Twitter','Updates','Latest','Feeds'],['rgb(129, 247, 129)','rgb(215, 223, 1)','rgb(154, 46, 254)','rgb(255, 128, 0)','rgb(116, 223, 0)'],'news');", 450);
}).mouseleave(function(){
    clearInterval(intnews);
    intnews= null;
    $(this).find("span.title").text("News").css('color','black');
  });

$("div#listen").mouseenter(function() {
intlisten = setInterval("loop(['Electronic','Driving ','Euphoric','Emotional','Melancholic'],['rgb(250, 88, 88)','rgb(128, 0, 255)','rgb(50, 180, 255)','rgb(50, 180, 4)'],'listen');", 450);
}).mouseleave(function(){
    clearInterval(intlisten);
    intlisten = null;
    $(this).find("span.title").text("Listen").css('color','black');
  });

$("div#sports").mouseenter(function() {
intsports = setInterval("loop(['Football','Sports'],['rgb(250, 88, 88)','rgb(190, 247, 129)','rgb(154, 46, 254)','rgb(174, 180, 4)'],'sports');", 450);
}).mouseleave(function(){
    clearInterval(intsports);
    intsports = null;
    $(this).find("span.title").text("Sports").css('color','black');
  });

$("div#contacts").mouseenter(function() {
intcontacts = setInterval("loop(['Get in touch','Send','Email','Phone','Post'],['rgb(180, 4, 4)','rgb(190, 247, 129)','rgb(250, 88, 172)','rgb(116, 223, 0)'],'contacts');", 450);
}).mouseleave(function(){
    clearInterval(intcontacts);
    intcontacts = null;
    $(this).find("span.title").text("Contact").css('color','black');
  });

if($.browser.msie && parseFloat($.browser.version) < 8){
		$("div#listen").click(function(){
 	    $('#playlist_area').hide();
		$('#playlist_area').load("http://www.riverman.co.uk/playlist.php?album=Riverman%20Sampler",'');
		$('#playlist_area').delay(400).fadeIn('normal');	
		$('.jp-controls').fadeTo('fast',0.2);
		$("#jquery_jplayer").jPlayer("clearFile");
  });
}
else
{
$("div#listen").click(function(){
	reinitialiseScrollPane();							
  });
}
});



$(window).load(function() {
		$('#playlist_area').load("http://www.riverman.co.uk/playlist.php?album=Riverman%20Sampler",'');
		$('#playlist_area').delay(400).fadeIn('normal');	
		$('.jp-controls').fadeTo('fast',0.2);	
		$("#jquery_jplayer").jPlayer("clearFile");
});



  
