// JavaScript Document


$(document).ready(function() {
//================================================//

//------------------------------------------------ CSS STYLES ------------------------------------------------//
$('#grid2').css({background: '-moz-linear-gradient(100% 100% 90deg, #333, #ccc)'}); //Mozilla
$('#grid2').css({background: '-webkit-linear-gradient(#333, #ccc)'}); //Google 10+ , Safari 5.1+
$('#grid2').css({background: '-webkit-gradient(linear, 0% 0%, 0% 100%, from(#ccc), to(#333))'}); //Google 1-9, Safari 4-5
$('#grid2').css('box-shadow','0px 3px 5px #000');
$('#grid2').css('-moz-box-shadow','3px 0px 5px #000');
$('#grid2').css('-webkit-box-shadow','3px 0px 5px #000');

$('#nav li a').hover(function(){ $(this).animate({color: '#333'}, 500); }, function(){ $(this).animate({color: '#e6e6e6'}, 500); });
$('#nav li a').hover(function(){ $(this).css('text-shadow', '#ccc 0px 0px 3px'); }, function(){ $(this).css('text-shadow', '#000 2px 2px 3px'); });

//--Connect--//
$('#find-us img, #sponsors img').hover(
	function(){ $(this).css({opacity: '0.5'}); },
	function(){ $(this).css({opacity: '1.0'}); }
);

//------------------------------------------------ POPUPS ------------------------------------------------//

$(".contact").fancybox({ 'scrolling'		: 'no', 'titleShow'		: false, 'onClosed'		: function() { $("#contact_error").hide(); } });
$(".booking").fancybox({ 'scrolling'		: 'no', 'titleShow'		: false, 'onClosed'		: function() { $("#booking_error").hide(); } });
$(".dlOutOfTheBox").fancybox({ 'scrolling'		: 'no', 'titleShow'		: false, 'onClosed'		: function() { $("#dowload_error").hide(); } });

//------------------------------------------------ IMAGE SLIDER ------------------------------------------------//
$('#sponsors').slides({
      container: 'slides_container',
      preload:true,
      effect:'slide',
      //crossfade:true,
      slidespeed: 500,
      play: 3000,
      pause: 2500,
      hoverPause: true,
      autoplay:true,
      generatePagination:false
});
    $("#banner").slides({
      container: 'slides_container',
      preload:true,
      effect:'fade',
      crossfade:true,
      fadespeed: 500,
      play: 5000,
      pause: 1000,
      hoverPause: true,
      autoplay:true,
      generatePagination:true
		});

//------------------------------------------------ TARGET=_BLANK FIX ------------------------------------------------//
	$("a[href^=http]").click( function(){ window.open(this.href); return false; });

	
//------------------------------------------------ CONTENT CHANGER ------------------------------------------------//

	// Check for hash value in URL
	var hash = window.location.hash.substr(1);
	var href = $('#nav li a, a.more').each(function(){
		var href = $(this).attr('href');
		if(hash==href.substr(0,href.length-4)){
			var toLoad = 'pages/'+hash+'.php #contents';
			$('#content').load(toLoad);
			document.title = "|SALTBOX||"+hash.toUpperCase()+"|";
		}	
	});

$('#nav li a, a.more').click(function(){
	var hash = window.location.hash.substr(1);
	var toLoad = 'pages/'+$(this).attr('href')+' #contents';
	$('#content').hide('fast',loadContent);
	$('#load').remove();
	$('#grid3a').append('<span id="load">LOADING...</span>');
	$('#load').fadeIn('normal');
	var title = $(this).attr('href').substr(0,$(this).attr('href').length-4);
	window.location.hash = title;
	document.title = "|SALTBOX||"+title.toUpperCase()+"|";
	function loadContent() { $('#content').delay(2000).load(toLoad,'',showNewContent()) }
	function showNewContent() { $('#content').show('normal',hideLoader()); }
	function hideLoader() { $('#load').delay(2000).fadeOut('normal'); }
	return false;
});


//================================================//
});

//------------------------------------------------ MUSIC  ------------------------------------------------//
$(document).ready(function(e) {
	$(".music").live('click', function (e) {
         //e.preventDefault();
        var id=$(this).attr("id");
				$("#a-player1").jPlayer("destroy");
				$("#a-player1").jPlayer( {
  				ready: function() {
	    			$(this).jPlayer( "setMedia", {
      				mp3: "/music/"+id+".mp3",
      				oga: "/music/"+id+".ogg"
    				}).jPlayer("play");
  				},ended: function(){ "destroy" },
  				supplied: "mp3, oga"
				});
    });
});	





//------------------------------------------------ ADD_THIS ------------------------------------------------//
//var addthis_config = {"data_track_clickback":true /*, "ui_use_css": false*/ };




//-- EVENTS DETAILS POPUP --//
function eventsPopup(url){ window.open(url,"event","height = 300, width = 400, scrollbars=0, resizable =0") }


