// Site wide javascript

			// ------ Start Twitter

function getTwitterForHolding() {
	
	//$.get(contentPath + 'proxy.php?url=http://pipes.yahoo.com/pipes/pipe.run?_id=79aaaaf042c9c198bbc44496d7f1ad8a&_render=rss', function(d) {
	$.get(contentPath + 'proxy.php?url=http://twitter.com/statuses/user_timeline/19483745.rss', function(d) {									
										
 //$.get("youtube.xml", function(d) {
		//find each 'item' in the file and parse it
		$(d).find('item').each(function() {
										
 			var theItem = $(this);
			var title = theItem.find('title').text();
			title = title.replace("Parachute_Music: ","");
			title = title.replace(" #fb","");
			
			var date = new Date(theItem.find('pubDate').text());
			var alink = theItem.find('link').text();
			//alert(date);
			
			$("#facebook_text_text").empty().append("<a href=\"" + alink + "\">" + title + "</a>");
			
			if((new Date().getTime() - new Date(theItem.find('pubDate').text()).getTime()) > 86400000) // greater than number of milliseconds in a day
			{
				$('#holding_facebook .sent_ago').countdown({since: date, layout: ' Sent {dn} {dl} ago'});
			}
			else if((new Date().getTime() - new Date(theItem.find('pubDate').text()).getTime()) > 3600000) // greater than number of milliseconds in an hour
			{
				$('#holding_facebook .sent_ago').countdown({since: date, layout: ' Sent {hn} {hl} ago'});
			}
			else
			{
				$('#holding_facebook .sent_ago').countdown({since: date, layout: ' Sent {mn} {ml} ago'});
			}
			
			if(title != "")
			{
				
				//$("#home_tweet_text").truncate(85);
				return false;
			}
 		});
		
		});
		

};
// -------- End Twitter

function openHolding()
{
	$.cookie('has-seen-holding1',true);
	$("body").append('<div id="holding_shadow"> </div><div id="holding_box"> <a class="holding_map" id="holding_close" href="#"><span>Close</span></a> <a class="holding_map" id="parachute_music" href="http://www.parachutemusic.com"><span>Parachute Music</span></a> <a class="holding_map" id="photo_gallery" href="http://www.parachutemusic.com/festival/index.php?option=com_content&amp;view=article&amp;id=223&amp;Itemid=60"><span>Photo Gallery</span></a> <a class="holding_map" id="holding_sign_up" href="#"><span>Mailing List</span></a> <a class="holding_map" id="holding_applications" href="http://www.sonicbids.com/Opportunity/OpportunityView.aspx?opportunity_id=105413" onclick="window.open(this.href,  null); return false" title="Parachute 2012 Artist Applications:"><span>Expression of Interest</span></a><div id="holding_thanks"> </div><div id="holding_box_inner"><div id="holding_box_news">  <h3 id="holding_countdown"><span>200</span> Days 10 Hours 10 Minutes 30 Seconds Until</h3>  <div class="latest_news_holding">        <h3>Loading Latest News...</h3>        <h4>&nbsp;</h4>        <p>&nbsp;</p>      </div>  <h3>Who do you want to see at Parachute 2012?</h3>  <p>Enter in your first, second and third preferences for the Parachute 2012 lineup.</p>  <iframe width="1" height="1" style="position:absolute; top:0; right:0;" frameborder="0" name="vote_frame" id="vote_frame" allowtransparency="true"></iframe>  <form id="vote_form_form" action="' + contentPath + 'process_votes.php" method="post" target="vote_frame">        <input class="vote_form one" name="first_choice" type="text" />        <input class="vote_form two" name="second_choice" type="text" />        <input class="vote_form three" name="third_choice" type="text" />        <input class="vote_form submit" type="submit" value="Submit" />      </form>  <div id="holding_facebook">        <p class="facebook_text"><span class="quote">&quot;</span> <span id="facebook_text_text">Loading...</span> <span class="quote quote_end">&quot;</span><span class="sent_ago"></span></p>      </div></div></div></div>');
	$("#holding_shadow").css({"display" : "block"});
	$("#holding_shadow").height($(document).height() + 100);
	
	//$("#holding_box").corner("32");
	$("#holding_shadow").animate({"opacity" : 0.8});
// Setup countdown

			var theDate = new Date();

			//d1 = new Date("October 13, 1975 11:13:00")

			//theDate = new Date(2011, 1-1, 28);

			theDate = new Date("January 28, 2012 11:00:00");

			$('#holding_countdown').countdown({until: theDate, layout: '<span>{dn}</span> {dl} <span>{hn}</span> {hl} <span>{mn}</span> {ml} <span>{sn}</span> {sl} Until'});

	$(".latest_news_holding").empty().append($(".moduletablelatestnews").html());
	
	getTwitterForHolding();
	
	$("#holding_close").click(function()
	{
		
		$("#holding_box").fadeOut(function()
		{
			$("#holding_shadow").fadeOut();
		});
		
	});
	$('#holding_sign_up').click(function() {

											 $("#holding_box").fadeOut(function()
										{
											$("#holding_shadow").fadeOut();
										});

							$('#signup_wrapper').fadeIn("fast");				 

			 });
			$("#vote_form_form").submit(function()
			 {
					$("#holding_thanks").slideDown("slow");	
					$("#vote_form_form").submit();
			 });
			$("#holding_thanks").click(function()
			{
					 $("#holding_box").fadeOut(function()
										{
											$("#holding_shadow").fadeOut();
										});
			});

}

function openProgChooser() {
	
 							var centerWidth = (screen.width - 1024) / 2;
                            var centerHeight = (screen.height - 700) / 2;

                            var slipWindow =  window.open('http://www.parachutemusic.com/festival/programme_chooser/','ParachuteProgrammeChooser','width=1024,height=700,left=' + centerWidth + ',top=' + centerHeight);
							slipWindow.focus();
							//return false;

}
		

			// Menu fixed coloring and background changing

		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;   

		}






//jQuery.noConflict();
//jQuery(document).ready(function($){

			 $(document).ready(function() {


	
	



			// ------ Menu colouring

	/*	

		#menu ul li #menu_lineup:hover { background-position:-1px 0px; }

#menu ul li #menu_bigstuff:hover { width:122px; background-position:-103px 0px; }



#menu ul li #menu_littlestuff:hover { width:175px; background-position:-240px 0px; }

#menu ul li #menu_interact:hover { width:127px; background-position:-426px 0px; }

#menu ul li #menu_gallery:hover { width:111px; background-position:-564px 0px; }

*/

	function colorPage(pageName)

		{

			

			switch(pageName) {

				case "home":

				

					break;

				case "tickets":

					$("#menu ul li #menu_tickets").css('backgroundPosition','-689px 0px');

					break;

				case "lineup":

					$("#menu ul li #menu_lineup").css('backgroundPosition','-1px 0px');

					break;

				case "bigstuff":

					$("#menu ul li #menu_bigstuff").css('backgroundPosition','-103px 0px');

					$("#menu ul li #menu_bigstuff").css('width','122px');

					break;

				case "littlestuff":

					$("#menu ul li #menu_littlestuff").css('backgroundPosition','-240px 0px');

					$("#menu ul li #menu_littlestuff").css('width','175px');

					break;

				case "interact":

					$("#menu ul li #menu_interact").css('backgroundPosition','-426px 0px');

					$("#menu ul li #menu_interact").css('width','127px');

					break;

				case "gallery":

					$("#menu ul li #menu_gallery").css('backgroundPosition','-564px 0px');

					$("#menu ul li #menu_gallery").css('width','111px');

					break;		

				default:

				//do nothing

					break;

			}

			

		}

		

			var pageID = getURLVar('id');

		switch (pageID) {

			

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

			case "129":

					//tickets page

					colorPage("tickets");

				break;

			case "130":

					//groups page

					colorPage("tickets");

				break;

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

			case "124":

					//groups page

					colorPage("lineup");

				break;

				case "162":

					//groups page

					colorPage("lineup");

				break;

				case "163":

					//groups page

					colorPage("lineup");

				break;

				case "165":

					//groups page

					colorPage("lineup");

				break;

				case "164":

					//groups page

					colorPage("lineup");

				break;

				case "166":

					//groups page

					colorPage("lineup");

				break;

				case "167":

					//groups page

					colorPage("lineup");

				break;

				case "178":

					//groups page

					colorPage("lineup");

				break;

				case "169":

					//groups page

					colorPage("lineup");

				break;

				case "168":

					//groups page

					colorPage("lineup");

				break;

				case "125":

					//groups page

					colorPage("lineup");

				break;

				case "126":

					//groups page

					colorPage("lineup");

				break;

				case "127":

					//groups page

					colorPage("lineup");

				break;

				case "128":

					//groups page

					colorPage("lineup");

				break;

				case "172":

					//groups page

					colorPage("lineup");

				break;

				case "170":

					//groups page

					colorPage("lineup");

				break;

				case "171":

					//groups page

					colorPage("lineup");

				break;

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

				case "137":

					//groups page

					colorPage("bigstuff");

				break;

				case "132":

					//groups page

					colorPage("bigstuff");

				break;

				case "133":

					//groups page

					colorPage("bigstuff");

				break;

				case "134":

					//groups page

					colorPage("bigstuff");

				break;

				case "145":

					//groups page

					colorPage("bigstuff");

				break;

				case "131":

					//groups page

					colorPage("bigstuff");

				break;

				case "135":

					//groups page

					colorPage("bigstuff");

				break;

				case "136":

					//groups page

					colorPage("bigstuff");

				break;

				case "138":

					//groups page

					colorPage("bigstuff");

				break;

				case "139":

					//groups page

					colorPage("bigstuff");

				break;

				case "173":

					//groups page

					colorPage("bigstuff");

				break;

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

				case "140":

					//groups page

					colorPage("littlestuff");

				break;

				case "141":

					//groups page

					colorPage("littlestuff");

				break;

				case "142":

					//groups page

					colorPage("littlestuff");

				break;

				case "143":

					//groups page

					colorPage("littlestuff");

				break;

				case "144":

					//groups page

					colorPage("littlestuff");

				break;

				case "146":

					//groups page

					colorPage("littlestuff");

				break;

				case "147":

					//groups page

					colorPage("littlestuff");

				break;

				case "148":

					//groups page

					colorPage("littlestuff");

				break;

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

				case "149":

					//groups page

					colorPage("interact");

				break;

				case "150":

					//groups page

					colorPage("interact");

				break;

				case "152":

					//groups page

					colorPage("interact");

				break;

				case "155":

					//groups page

					colorPage("interact");

				break;

				case "156":

					//groups page

					colorPage("interact");

				break;

				case "15":

					//groups page

					colorPage("interact");

				break;

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

				case "157":

					//groups page

					colorPage("gallery");

				break;

			default:

				// do nothign

				break;

		}

			// --- End menu colouring



 			

			$("#menu ul li a").jEffects('bomb');

			

			

			

			

			// Setup countdown

			var theDate = new Date();

			//d1 = new Date("October 13, 1975 11:13:00")

			//theDate = new Date(2011, 1-1, 28);

			theDate = new Date("January 28, 2011 11:00:00");

			$('#countdown').countdown({until: theDate, layout: '<span>{dn} {dl} {hn} {hl} {mn} {ml} {sn} {sl} </span>'});

			
			

			// Header flash

			 $('#header_flash').flash({

				

				swf: contentPath + 'images/header.swf',

				height: 403,

				width: 972,

				params: {

				wmode: 'transparent'

				}

			});
			
			$("#signup_form").submit(function(e) {
				
				allComplete = true;
				$("#signup_form .req").each(function()
				{
					if($.trim($(this).val()) == "")
					{
						allComplete = false;
						$(this).css({ "background-color" : "red" });
					}
					else
					{
						$(this).css({ "background-color" : "white" });
					}
				});
				if(!$("#privacy_agree").attr("checked"))
				{
					allComplete = false;
					alert("You must agree to the privacy policy to continue");
				}
				
				return allComplete;
											  
			});
			
			$(".artist_info_div").hide();
			$("#artist_info_title1").click(function()
			{
				//e.preventDefault();
				
				$("#artist_info_div1").slideToggle();
			});
			$("#artist_info_title2").click(function()
			{
				//e.preventDefault();
				
				$("#artist_info_div2").slideToggle();
			});
			

			$('#close_signup').click(function() {

											 

							$('#signup_wrapper').fadeOut("fast");				 

											 });

			$('#signup_drum').click(function() {

											 

							$('#signup_wrapper').fadeIn("fast");				 

											 });
			
			$('.page_sub_link').click(function() {

											   

							$('#signup_wrapper').fadeIn("fast");	

											   });

			// Search box

			$('.search_box').focus(function() {

											

											//$('.search_box').css('background','none');

											$('.search_box').css('background-position','0px -43px');

											

											});


			 

			//----- Begin Video Library

			

						function getVideoLibrary() {

			 

			 			$("ul.video_list").ytplaylist({addThumbs:true, autoPlay: false, playerWidth: 565, playerHeight: 310, showRelated: false, holderId: 'ytvideo'});

		

		};

			

			if($("ul.video_list").length != 0)

			{

				getVideoLibrary();

			}

			//------ End Video Library

			 
			 
			// ----- shuffle
			
			(function($){
  $.fn.shuffle = function() {
    return this.each(function(){
      var items = $(this).children();
      return (items.length)
        ? $(this).html($.shuffle(items))
        : this;
    });
  }
 
  $.shuffle = function(arr) {
    for(
      var j, x, i = arr.length; i;
      j = parseInt(Math.random() * i),
      x = arr[--i], arr[i] = arr[j], arr[j] = x
    );
    return arr;
  }
})(jQuery);
			
			// ---- end shuffle
			$('#tshirtcontainer').shuffle();
// SMP BLOCKED.
			//if(!$.cookie('has-seen-holding1'))
			//{
			//	openHolding();
			//}
			

		}); // end of document
