// begin lazy loading
(function($){$.fn.lazyload=function(options){var settings={threshold:0,failurelimit:0,event:"scroll",effect:"show",container:window};if(options){$.extend(settings,options);}
var elements=this;if("scroll"==settings.event){$(settings.container).bind("scroll",function(event){var counter=0;elements.each(function(){if(!$.belowthefold(this,settings)&&!$.rightoffold(this,settings)){$(this).trigger("appear");}else{if(counter++>settings.failurelimit){return false;}}});var temp=$.grep(elements,function(element){return!element.loaded;});elements=$(temp);});}
return this.each(function(){var self=this;$(self).attr("original",$(self).attr("src"));if("scroll"!=settings.event||$.belowthefold(self,settings)||$.rightoffold(self,settings)){if(settings.placeholder){$(self).attr("src",settings.placeholder);}else{$(self).removeAttr("src");}
self.loaded=false;}else{self.loaded=true;}
$(self).one("appear",function(){if(!this.loaded){$("<img />").bind("load",function(){$(self).hide().attr("src",$(self).attr("original"))
[settings.effect](settings.effectspeed);self.loaded=true;}).attr("src",$(self).attr("original"));};});if("scroll"!=settings.event){$(self).bind(settings.event,function(event){if(!self.loaded){$(self).trigger("appear");}});}});};$.belowthefold=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).height()+$(window).scrollTop();}
else{var fold=$(settings.container).offset().top+$(settings.container).height();}
return fold<=$(element).offset().top-settings.threshold;};$.rightoffold=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).width()+$(window).scrollLeft();}
else{var fold=$(settings.container).offset().left+$(settings.container).width();}
return fold<=$(element).offset().left-settings.threshold;};$.extend($.expr[':'],{"below-the-fold":"$.belowthefold(a, {threshold : 0, container: window})","above-the-fold":"!$.belowthefold(a, {threshold : 0, container: window})","right-of-fold":"$.rightoffold(a, {threshold : 0, container: window})","left-of-fold":"!$.rightoffold(a, {threshold : 0, container: window})"});})(jQuery);


// end lazy loading


// Animation & JQuery for main page
 function delayTimer(delay){
     var timer;
     return function(fn){
          timer=clearTimeout(timer);
          if(fn)
               timer=setTimeout(function(){
               fn();
               },delay);
          return timer;
     }
}

// Define the custom selector.
$.expr[':'].hasTitle = function(
objNode,
intStackIndex,
arrProperties,
arrNodeStack
){
// Create an array to hold the arguments passed to
// the custom jquery selector. The first several
// data items are just meta-data about the selector.
// The list of arguments gets passed as a string -
// we are eval'ing it into an array.
var arrArguments = eval(
"([" + arrProperties[ 3 ] + "])"
);
 
// Create a jQuery version of this node.
var jThis = $( objNode );
 
// Check to see if this node has any of the given
// titles. If so, return true (we only need to find
// one of the titles to qualify).
for (var i = 0 ; i < arrArguments.length ; i++){
 
// Check for title equality.
if (jThis.attr( "title" ) == arrArguments[ i ]){
 
// We found a title match, return true to
// indicate that this node should be included
// in the returned jQuery stack.
return( true );
 
}
 
}
 
// If we have made it this far, then we found no
// match. Return false to indicate that this node
// did not match our selector.
return( false );
}
 
 
 
$(
function(){
var myElms = $( "a:hasTitle( 'Phoca Gallery' )" );
 
myElms.each(
function( intI ){
			  		$(this).css("visibility", "hidden");

//alert( $( this ).text() );
}
);
}
); 


function sendToFriend() {
	if(!$('#mailing_list_wrapper').is(':visible')) {
	 $("#send_friend_wrapper").show();
  $("#send_friend").show();
  $("#send_friend_wrapper").animate({"top": "40px"}, 700);
	}
}
/*
function animateMenu() {
	jQuery.each(jQuery.browser, function(i, val) {
		// needed for ie6, all styles from style_javascript
 		 if(i=="msie" && jQuery.browser.version.substr(0,1)=="6")
   		 $("#top_menu").css("top","-104px");
		});
	
	$("#search_box").focus(function() {
	if( this.value == this.defaultValue ) {
		this.value = "";
	}
}).blur(function() {
	if( !this.value.length ) {
		this.value = this.defaultValue;
	}
});

var inputDelayer=delayTimer(200);
 	inputDelayer(function(){
		$("#tickets_tv").animate({ 
       		 opacity: 0.9,
      	     marginTop: "90px"
     		 }, 800 );
						  });
	//	  $("#photo_box").effect("pulsate", { times:3 }, 200);
 	var inputDelayer=delayTimer(250);
 	inputDelayer(function(){
		$("#lineup_tv").animate({ 
        opacity: 0.9,
        marginTop: "90px"
      }, 800 );
	//	 $("#home_tv").effect("pulsate", { times:5 }, 200);
    });
	var inputDelayer=delayTimer(350);
 	inputDelayer(function(){
	$("#programme_tv").animate({ 
        opacity: 0.9,
        marginTop: "90px"
      }, 800 );
	//		 $("#home_content").effect("pulsate", { times:8 }, 200);

	});
	var inputDelayer=delayTimer(400);
 	inputDelayer(function(){
	$("#info_tv").animate({ 
        opacity: 0.9,
        marginTop: "90px"
      }, 800 );
		//		 $("#home_video").effect("pulsate", { times:5 }, 200);

	});


	
}
*/


function doFlicker(hasStarted){

if(hasStarted) {
 var inputDelayer=delayTimer(15000);
 } else {
 var inputDelayer=delayTimer(500);
 }
 var inputDelayer2=delayTimer(500);
 var inputDelayer3=delayTimer(200);
 var inputDelayer4=delayTimer(100);
 
 inputDelayer(function(){
					   		 
 			$("#drug_free").bob();

	
          if( $("#white-light").css("visibility") ) {
		  $("#white-light").css("visibility", "hidden");
		  inputDelayer2(function(){
		  		$("#white-light").css("visibility", "visible");
			});
			inputDelayer3(function(){
		  		$("#white-light").css("visibility", "hidden");
			});
			inputDelayer4(function(){
		  		$("#white-light").css("visibility", "visible");
			});
		  } else {
		  $("#white-light").css("visibility", "visible");
		  }
		  doFlicker(true);
			
     });
 
}




$(document).ready(function(){
						   
						   
// ------- for the url / red coloring detecting
					   // for menu coloring
function getURLVar(urlVarName) {
//divide the URL in half at the '?' 
var urlHalves = String(document.location).split('?');
var urlVarValue = '';
if(urlHalves[1]){
//load all the name/value pairs into an array 
var urlVars = urlHalves[1].split('&');
//loop over the list, and find the specified url variable 
for(i=0; i<=(urlVars.length); i++){
if(urlVars[i]){
//load the name/value pair into an array 
var urlVarPair = urlVars[i].split('=');
if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
//I found a variable that matches, load it's value into the return variable 
urlVarValue = urlVarPair[1];
}
}
}
}
return urlVarValue;   
}
				
				
var pageID = getURLVar('id');
switch (pageID) {
	case "10:tickets":
		 $("#tickets_tv a").css("background-position","25px -61px");
		break;
	case "11:info":
		 $("#info_tv a").css("background-position","30px -73px");
		break;
		break;
	case "12:line-up":
		 $("#lineup_tv a").css("background-position","25px -125px");
		break;
	case "13:programme":
		 $("#programme_tv a").css("background-position","30px -66px");
		break;
	case "10%3Atickets":
		 $("#tickets_tv a").css("background-position","25px -61px");
		break;
	case "11%3Ainfo":
		 $("#info_tv a").css("background-position","30px -73px");
		break;
		break;
	case "12%3Aline-up":
		 $("#lineup_tv a").css("background-position","25px -125px");
		break;
	case "13%3Aprogramme":
		 $("#programme_tv a").css("background-position","30px -66px");
		break;
}
///----- end

						      
		 $('#left_menu').flash({
		// test_flashvars.swf is the flash document
		swf: '' + docPath + 'left-menu.swf',
		height: 604,
		width: 271,
		// these arguments will be passed into the flash document
		params: {
		wmode: 'transparent',
		flashvars: { pageID: pageID + ''}
		}
	});   
					$('.shadowbox-button-rim img').lazyload({ effect: "fadeIn" });
		   
						   //--------- MAIN ANIMATION
	if($.cookie("has-visited") == null)
	 {
	var inputDelayer=delayTimer(3000);
 	inputDelayer(function(){
	 $('#home_content_cover').effect('pulsate', { times:8, mode: 'hide' }, 200);
						  });
	var inputDelayer=delayTimer(9000);
 	inputDelayer(function(){
	 $('#home_tv_cover').effect('pulsate', { times:6, mode: 'hide' }, 200);
						  });

	var inputDelayer=delayTimer(12000);
 	inputDelayer(function(){
	 $('#home_video_cover').effect('pulsate', { times:4, mode: 'hide' }, 200);
						  });
	// set the cookie
	$.cookie("has-visited", 'true');
	 } else {
		 // just uncover the pics
$('#home_content_cover').css('visibility', 'hidden');
$('#home_video_cover').css('visibility', 'hidden');
$('#home_tv_cover').css('visibility', 'hidden');


	 }
	 	var inputDelayer=delayTimer(11000);
 	inputDelayer(function(){
	 $('#photo_load').effect('pulsate', { times:4, mode: 'hide' }, 200);
						  });
	var inputDelayer=delayTimer(12000);
 	inputDelayer(function(){
	 $('#photo_load').effect('pulsate', { times:4, mode: 'hide' }, 200);
	 $('#slideShow').show();
						  });
	var inputDelayer=delayTimer(18000);
 	inputDelayer(function(){
	$("#king_kong").animate({ 
        bottom: "250px"
      }, 800 );
	
						  });
		var inputDelayer=delayTimer(25000);
 	inputDelayer(function(){
	$("#king_kong").animate({ 
        bottom: "550px"
      }, 800 );
						  });
//$('#home_content_content').css('visibility', 'hidden');
//$('#home_tv_content').css('visibility', 'hidden');
	
// -------- END MAIN ANIMATION

			$("#drug_free").bob();
	

						   
			   
						
						         //hide the all of the elements that need to collapse
  $(".collapse-body").hide();
  
  if($("div:contains('Phoca Gallery')"))
  {
	//	 $("#main_content_content").css("margin-bottom","-250px");
	//			 $("#main_content_content").css("background","none");

}
  
  
// ------------- the collapse headers -------------//
    //When mouse rolls over  
     $(".collapse-header").mouseover(function(){  
         $(this).stop().animate({marginLeft:'10px'},{queue:false, duration:600})  
    });  
     $(".collapse-header").mouseout(function(){  
         $(this).stop().animate({marginLeft:'0px'},{queue:false, duration:600})  
     });  
//------------
						   
						   
						   
	$("#drug_free").hover(function () { $("#drug_free").bob() });  
	$(".lineup_band").hover(function () { $(this).animate({ 
        opacity: 0.6
      }, 300 ).animate({ 
        opacity: 1.0
		
      }, 300 ) });
	$("#mod_search_searchword").focus(function() {
	if( this.value == this.defaultValue ) {
		this.value = "";
	}
}).blur(function() {
	if( !this.value.length ) {
		this.value = this.defaultValue;
	}
});
 $('head').append('<link rel="stylesheet" href="style_javascript.css" type="text/css" />');

$('#king_kong').click(function() {
var maxBottom = 550;
var minBottom = 75;
var myValue = Math.floor(Math.random()*500)+75;
var myValue = myValue + "px";
$("#king_kong").animate({ 
        bottom: myValue
      }, 800 );
							   });
 //$(document).pngFix(); 
 $('#home_content_scroll').jScrollPane({showArrows:false});
  $('#home_tv_scroll').jScrollPane({showArrows:false});
 
 // -- open links off site
 $("a").filter(function() {
    return this.hostname && this.hostname !== location.hostname;
}).attr('target', '_blank');

 
 
  //---------------------

  //toggle the hide / show
  $(".collapse-header").click(function()
  {
    $(this).next(".collapse-body").slideToggle(600);
	 //   $(this).next(".collapse-body").next(".collapse-body").slideToggle(600);
			///	    $(this).next(".collapse-body").next(".collapse-body").next(".collapse-body").slideToggle(600);
				//	$(this).next(".collapse-body").next(".collapse-body").next(".collapse-body").next(".collapse-body").slideToggle(600);

  });
  $("h3").click(function()
  {
    $(this).next(".collapse-body").slideToggle(600);
  });
   $('#band_box').flash({
		// test_flashvars.swf is the flash document
		swf: '' + docPath + 'band.swf',
		height: 131,
		width: 534,
		// these arguments will be passed into the flash document
		params: {
		wmode: 'transparent'
		}
	});
  
  doFlicker();
  
 $(".close").click(function()
  {   $("#send_friend_wrapper").animate({"top": "-520px"}, 700);  });

  
});

// share links

function bebo_click() {u=location.href;t=document.title;window.open('http://www.bebo.com/c/share?Url='+encodeURIComponent(u)+'&Title='+encodeURIComponent(t)+'&MID=8974376238&TUUID=fc7850b8-964c-47bd-8a91-db1d2a5cad3c','sharer','toolbar=0,status=0,width=626,height=436');return false;}


