function strpos (haystack, needle, offset) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Onno Marsman    
    // +   bugfixed by: Daniel Esteban
    // *     example 1: strpos('Kevin van Zonneveld', 'e', 5);
    // *     returns 1: 14 (or false if not found)
 
    var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
    return i === -1 ? false : i;
}

$(document).ready(function(){
	
var hash = window.location.hash;
	switch(hash)
	{
	case "#Venues":
	  gotoBlock2("");
	  break;

	case "#A-Z":
	  gotoBlock("");
	  break;
	case "#Art":
	  gotoBlock("art");
	  break;
	case "#Dance":
	  gotoBlock("dance");
	  break;
	case "#Music":
	  gotoBlock("music");
	  break;
	case "#Workshop":
	  gotoBlock("workshop");
	  break;
	case "#Screening":
	  gotoBlock("screening");
	  break;
	case "#Timetable":
	  gotoProgram("");
	  break;
	case "#Friday":
	  gotoProgram("friday");
	  break;
	case "#Saturdayafternoon":
	  gotoProgram("saturdayafternoon");
	  break;
	case "#Saturday":
	  gotoProgram("saturday");
	  break;
	case "#Ticket":
	  openGB("http://portal.todaysart.nl/ticketshopwindow.html",920,600);
	  break;
	case "#About":
	  openGB("http://portal.todaysart.nl/fest/about_todaysart.php",920,600);
	  break;
	case "#Map":
	  openGB("http://portal.todaysart.nl/fest/festival_map.php",920,600);
	  break;
	case "#Info":
	  openGB("http://portal.todaysart.nl/fest/festival_info.php",920,600);
	  break;
	case "#Partners":
	  openGB("http://portal.todaysart.nl/fest/partner.php",920,600);
	  break;
	case "#Volunteer":
	  openGB("http://portal.todaysart.nl/languageSelect.html",920,600);
	  break;
	case "#Contact":
	  openGB("http://portal.todaysart.nl/fest/contact.php",920,600);
	  break;
	case "#Accreditation":
	  openGB("http://todaysart.nl/portal/press/accred/press_acrr.php",920,600);
	  break;
	case "#Pressreleases":
	  openGB("http://portal.todaysart.nl/fest/press_releases.php",920,600);
	  break;
	case "#Statement_olof":
	  openGB("http://portal.todaysart.nl/fest/statements.php?id=39",920,600);
	  break;
	case "#Statement_janet":
	  openGB("http://portal.todaysart.nl/fest/statements.php?id=28",920,600);
	  break;
	case "#Statement_peter":
	  openGB("http://portal.todaysart.nl/fest/statements.php?id=34",920,600);
	  break;
	case "#Statement_bjorn":
	  openGB("http://portal.todaysart.nl/fest/statements.php?id=29",920,600);
	  break;
	case "#Statement_relja":
	  openGB("http://portal.todaysart.nl/fest/statements.php?id=37",920,600);
	  break;
	case "#Statement_european":
	  openGB("http://portal.todaysart.nl/fest/statements.php?id=44",920,600);
	  break;
	case "#Statement_jan":
	  openGB("http://portal.todaysart.nl/fest/statements.php?id=30",920,600);
	  break;
	case "#Statement_cornelius":
	  openGB("http://portal.todaysart.nl/fest/statements.php?id=33",920,600);
	  break;
	case "#Statement_david":
	  openGB("http://portal.todaysart.nl/fest/statements.php?id=35",920,600);
	  break;
	case "#Statement_marieke":
	  openGB("http://portal.todaysart.nl/fest/statements.php?id=36",920,600);
	  break;


	default:
	}
	
	if(strpos(hash, 'Artist_', 0) === false) {
	
	//no artist hash found..	
	} else {
	//open artist page
		openGB("http://portal.todaysart.nl/fest/artist_page.php?id="+hash.substr(8),920,600);
	}
	
	if(strpos(hash, 'Page_', 0) === false) {
	
	//no page hash found..	
	} else {
	//open Page/Statement page
		openGB("http://portal.todaysart.nl/fest/statements.php?id="+hash.substr(6),920,600);
	}
	
	
	//$("#block7section")[0].scrollTo(100);
	$(".venues").click(function () {gotoBlock2("");});
	$(".artists").click(function () {gotoBlock("");});
	$(".art").click(function () {gotoBlock("art");});
	$(".dance").click(function () {gotoBlock("dance");});
	$(".music").click(function () {gotoBlock("music");});
	$(".screening").click(function () {gotoBlock("screening");});
	$(".workshop").click(function () {gotoBlock("workshop");});
	$("#timetable").click(function () {gotoProgram("");});
	$("#timetablefriday").click(function () {gotoProgram("friday");});
	$("#timetablesaturdayafternoon").click(function () {gotoProgram("saturdayafternoon");});
	$("#timetablesaturday").click(function () {gotoProgram("saturday");});
	$(".aboutbtn").click(function() {document.location="#About";});
	$(".mapbtn").click(function() {document.location="#Map";});
	$(".infobtn").click(function() {document.location="#Info";});
	$(".partnerbtn").click(function() {document.location="#Partners";});
	$(".volunteerbtn").click(function() {document.location="#Volunteer";});
	$(".contactbtn").click(function() {document.location="#Contact";});
	$(".accreditationbtn").click(function() {document.location="#Accreditation";});
	$(".pressreleasebtn").click(function() {document.location="#Pressreleases";});
	$('[href^=#Statement_]').click(function() {document.location=this.href;});
	$('[href^=#Page]').click(function() {document.location=this.href;});

	$('.artisthash').click(function() { document.location="#Artist_"+this.id.substr(7);});
	
	$("#block").click(function () {gohome();});
	$("#block2").click(function () {gohome();});
	$("#block3").click(function () {gohome();});
	$("#block4").click(function () {gohome();});
	$("#block5").click(function () {gohome();});
	$("#block6").click(function () {gohome();});
	
	function gotoBlock(s){
		$("#block7section").jScrollPane({animateTo:true,wheelSpeed:0});
		$("#block").animate({ 
		width: "50px",
		marginLeft:"0px"
	    }, 700 );
		$("#block2").animate({ 
		width: "50px",
		marginLeft:"60px"
	    }, 700 );
		$("#block3").animate({ 
		width: "50px",
		marginLeft:"120px"
	    }, 700 );
		$("#block4").animate({ 
		width: "50px",
		marginLeft:"0px"
	    }, 700 );
		$("#block5").animate({ 
		width: "50px",
		marginLeft:"60px"
	    }, 700 );
		$("#block6").animate({ 
		width: "50px",
		marginLeft:"120px"
	    }, 700 );
		$("#block7").animate({ 
		marginLeft:"180px"
	    }, 700 );
		$("#slideProgram").animate({ 
		marginLeft:"-1000px"
	    }, 700 );
	    $('#block7').load('artist.php?sort='+s);

	}
	
	function gotoBlock2(s){
		$("#block7section").jScrollPane({animateTo:true,wheelSpeed:0});
		$("#block").animate({ 
		width: "50px",
		marginLeft:"0px"
	    }, 700 );
		$("#block2").animate({ 
		width: "50px",
		marginLeft:"60px"
	    }, 700 );
		$("#block3").animate({ 
		width: "50px",
		marginLeft:"120px"
	    }, 700 );
		$("#block4").animate({ 
		width: "50px",
		marginLeft:"0px"
	    }, 700 );
		$("#block5").animate({ 
		width: "50px",
		marginLeft:"60px"
	    }, 700 );
		$("#block6").animate({ 
		width: "50px",
		marginLeft:"120px"
	    }, 700 );
		$("#block7").animate({ 
		marginLeft:"180px"
	    }, 700 );
		$("#slideProgram").animate({ 
		marginLeft:"-1000px"
	    }, 700 );
	    $('#block7').load('venue.php');

	}

		
	function gotoProgram(s){
		$("#block").animate({ 
		marginLeft:"950px"
	    }, 700 );
		$("#block2").animate({ 
		marginLeft:"1010px"
	    }, 700 );
		$("#block3").animate({ 
		marginLeft:"1130px"
	    }, 700 );
		$("#block4").animate({ 
		marginLeft:"950px"
	    }, 700 );
		$("#block5").animate({ 
		marginLeft:"1010px"
	    }, 700 );
		$("#block6").animate({ 
		marginLeft:"1130px"
	    }, 700 );
		$("#block7").animate({ 
		marginLeft:"950px"
	    }, 700 );
		$("#slideProgram").animate({ 
		marginLeft:"0px"
	    }, 700 );
	    switch(s)
		{
		case "friday":
		  $("#blockBodyProgram").load("timetable.php?day=friday&time=1900");
		  $("#continuous").load("timetable_continuous.php?day=friday");
		  $("#friday").html("<img src='images/friday_on.png'  />");
		  $("#saturday").html("<img id='saturday' style='cursor:pointer' src='images/saturday_off.png'  />");
		  break;
		case "saturdayafternoon":
		  $("#blockBodyProgram").load("timetable.php?day=saturday&time=1300");
		  $("#continuous").load("timetable_continuous.php?day=saturday");
		  $("#friday").html("<img id='friday' style='cursor:pointer' src='images/friday_off.png'  />");
	   	  $("#saturday").html("<img src='images/saturday_on.png'  />");
		  break;
		case "saturday":
		  $("#blockBodyProgram").load("timetable.php?day=saturday&time=1900");
		  $("#continuous").load("timetable_continuous.php?day=saturday");
		  $("#friday").html("<img id='friday' style='cursor:pointer' src='images/friday_off.png'  />");
	   	  $("#saturday").html("<img src='images/saturday_on.png'  />");
		  break;
		}
	}

	
	
	function gohome(){
		$("#block").animate({ 
		width: "215px",
		marginLeft:"0px"
	    }, 700 );
		$("#block2").animate({ 
		width: "286px",
		marginLeft:"232px"
	    }, 700 );
		$("#block3").animate({ 
		width: "362px",
		marginLeft:"532px"
	    }, 700 );
		$("#block4").animate({ 
		width: "215px",
		marginLeft:"0px"
	    }, 700 );
		$("#block5").animate({ 
		width: "287px",
		marginLeft:"232px"
	    }, 700 );
		$("#block6").animate({ 
		width: "362px",
		marginLeft:"532px"
	    }, 700 );
		$("#block7").animate({ 
		marginLeft:"950px"
	    }, 700 );
		$("#slideProgram").animate({ 
		marginLeft:"-1000px"
	    }, 700 );

	}
	
	
});