var userAgent = navigator.userAgent.toLowerCase();
 
// Figure out what browser is being used
jQuery.browser = {
	version: (userAgent.match( /.+(?:rv|it|ra|ie|me)[\/: ]([\d.]+)/ ) || [])[1],
	chrome: /chrome/.test( userAgent ),
	safari: /webkit/.test( userAgent ) && !/chrome/.test( userAgent ),
	opera: /opera/.test( userAgent ),
	msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
	mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
};

jQuery(function( $ ){
	/**
	 * Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
	 * @see http://flesler.demos.com/jquery/scrollTo/
	 * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
	 */
	
	// The default axis is 'y', but in this demo, I want to scroll both
	// You can modify any default like this
	$.localScroll.defaults.axis = 'xy';
	
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		target: '#content', // Could be a selector or a jQuery object too.
		queue:true,
		duration:1500
	});
	
	/**
	 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
	 * also affect the >> and << links. I want every link in the page to scroll.
	 */
	$.localScroll({
		target: '#content', // could be a selector or a jQuery object too.
		queue:true,
		duration:1000,
		hash:true,
		onBefore:function( e, anchor, $target ){
			// The 'this' is the settings object, can be modified
		},
		onAfter:function( anchor, settings ){
		    
		     // The 'this' contains the scrolled element (#content)
		}
	});
});



$(window).load(function(){ 

    	$('.scrolldiv').jScrollPane();
    		
		$('.boxgrid.caption').hover(function(){
			$(".cover", this).stop().animate({top:'180px'},{queue:false,duration:160});
		}, function() {
			$(".cover", this).stop().animate({top:'235px'},{queue:false,duration:160});
		});
		
		
		
		$('.submenu_link').click(function(){
		     $('.submenu_visible_content span').remove();
		     $('div#'+this.className.split(" ")[1]+" span").clone().appendTo($('.submenu_visible_content',$(this).parent().parent()[0]))
		     $('.submenu_content').slideDown('slow', function() {});
		});
		$('.submenu').hover(function(){
		}, function() {
		    
		        $('.submenu_content').slideUp('slow', function() {
                      // Animation complete.
                    });
		});
		
		
		
        
        $('.news_element').click(function(){
            if($('.news_content',this)[0].style.display == "block")
                $('.news_content',this).slideUp('slow', function() {});
            else
                $('.news_content',this).slideDown('slow', function() {});
		});
		
		$('.news_element').hover(function(){
		  //$('.news_content',this).slideDown('slow', function() {});
		}, function() {
		        $('.news_content',this).slideUp('slow', function() {});
		});
              
        $('.news_content').hide()
        
        
        $('.rounded_header').click(
            function(){
                if($('.rounded_content',$(this).parent())[0].style.display == "block")
                {
                    $('.rounded_content',$(this).parent()).slideUp('slow', function() {});
                }
                else
                {
                    $('.rounded_content',$(this).parent()).slideDown('slow', function() {});
    		    }
		    }
		);
		
		
		$('.rounded_content').css("display","block")
		
        
        
	  
    	$(document).ready(function(){
    		$("a[rel^='prettyPhoto']").prettyPhoto({theme: 'dark_square',allowresize: true,animationSpeed: 'fast'});
    		$('.slideshow').cycle({
           		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
           		pager: '#navigation',
           		timeout: 0
           	});
           	$('.page_box').css("visibility","visible")
    	    $('#loading').css("display","none")
            $('.slideshow').css("display","block")
            $('h2').css("display","block")
    	});
    	
	
        if(location.href.split("#").length < 2)
        {
            window.location.href+="#news";
        }
        else
        {
            var t=setTimeout("update_image('"+location.href.split('#')[1]+"')",500);
            
        };
        
        
	if (!$.browser.msie && !$.browser.chrome && !$.browser.opera) {
	    $('.rounded').corners();
		$('.menu').corners();
		$('.news_element').corners();
	}
	else 
	{
	     DD_roundies.addRule('.rounded', '5px', true);
         DD_roundies.addRule('.menu', '5px', true);
	     DD_roundies.addRule('.news_element', '5px', true);
         
	}
	
	
	$('.multimedia_link').qtip({
       content: $('.multimedia_link').title,
       show: 'mouseover',
       hide: { when: 'mouseout', fixed: true },
       position: {
             corner: {
                target: 'rightTop',
                tooltip: 'leftMiddle'
             }
          },
        style: { 
           background: '#444',
           color: '#fff',
           tip: true,
           border: {
                 radius: 8,
                  color: '#444'
              },
        }
    });
    
    //$("#accordion").accordion({ navigation: true });
        
});


var previous_visited = "";
function check_visited()
{
    var locationparts = location.href.split("#");
	if(locationparts.length < 2)
    {
            ;
    }
    else
    {
            if(locationparts[1]!=previous_visited)
            {
                $(".menu").removeClass("menu_over");
        	    var category = location.href.split("#")[1].replace("old_","");
        	    category = category.replace("_remixes","");
        	    category = category.replace("_other","");
        	    $("#"+category+"_button").addClass("menu_over");
        	    
        	   
                update_image(category);
                
                previous_visited = locationparts[1];
            }
            
    }	 
    
   setTimeout("check_visited()", 500);
}

function update_image(category)
{
    switch(category)
    {
        case 'news':
        $('#link_for_image_1').click();
        break;
        case 'about':
        $('#link_for_image_2').click();
        break;
        case 'discography':
        $('#link_for_image_3').click();
        break;
        case 'multimedia':
        $('#link_for_image_4').click();
        break;
        case 'services':
        $('#link_for_image_5').click();
        break;
        case 'contact':
        $('#link_for_image_6').click();
        break;
        default:
        break;
    }
}

var t = setTimeout("check_visited()", 500);


