/* DJ AM */
/* Javascript
----------------------------------------------------------------------------- */


	function expand() {
	
		$('#events').css("width","980px");
	
	}

	function contract() {
	
		$('#events').css("width","550px");
	
	}

	function closeViewer() {

		$('#enlarged').fadeOut();

		return false;		

	}

	function fixPaging(pane) {

		$(pane + ' ul.paging a').each(function() { 
		
			var $this = $(this); 
			$this.attr('href', $this.attr('href') + pane); 
	
		});

	}


/* READY FUNCTION
----------------------------------------------------------------------------- */


	$(document).ready(function() {
	
		$('#page-photos ul.photos').css('visibility','hidden');
		$('#past, #upcoming', '#news', '#blog', '#onthedecks', '#kickinit', '#ohjeez').css('display', 'none');
		$('#past').css('display', 'none');
		$('#upcoming').css('display', 'none');
		$('#editorial #blog, #editorial #news').css('display', 'none');

		if (page == "photos") $('#tags').css('visibility', 'hidden');

	});


/* LOAD FUNCTION
----------------------------------------------------------------------------- */


	$(window).load(function() {


/* PHOTO TAGS
----------------------------------------------------------------------------- */

		
		
	if (page == "photos") {
	
		if (tag == "" || tag == "all") $('#tags > ul > li:first-child > a').wrap('<strong></strong>');
		Cufon.replace('#tags a', { hover: true });
		$('#tags').removeAttr('style');
	
	}
	
	
/* FLYER BROWSER
----------------------------------------------------------------------------- */


	if (section == "home") {

		var so = new SWFObject( asset_host + '/flash/flyers.swf', 'flyerBrowser', '980', '620', '9', '#000000');
		so.addParam('wmode', 'transparent');
		so.addParam( "allowScriptAccess", "always" );
		
		so.addVariable( "asset_host", "" );
		so.addVariable( "xml_loc", "http://www.djam.com/feeds/upcoming.xml?items=100" );
		so.useExpressInstall( asset_host + "/flash/expressinstall.swf" );
		so.write('flyers');
	
	}


/* VIDEOS
----------------------------------------------------------------------------- */


	if (section == "home") {

		var so = new SWFObject( asset_host + '/flash/video.swf', 'video', '100%', '100%', '9', '#000000');
		so.addParam('wmode', 'transparent');
		so.write('video');
	
	}
	
	
/* HEADER NEEDLES
----------------------------------------------------------------------------- */


	var so = new SWFObject( asset_host + '/flash/needle.swf', 'needle-left', '100%', '100%', '9', '#000000');
	so.addParam('wmode', 'transparent');
	so.write('needle-left');
	so.write('needle-right');


/* ENLARGED PHOTO VIEWER
----------------------------------------------------------------------------- */


	if (section == "photos") {

		$('#page-photos ul.photos').css('visibility','visible');
		$('#layout').prepend('<div id="enlarged"><div id="viewer"><div id="crop"><img /></div><h4>Caption Goes Here</h4><a class="action close" href="#">Close</a></div></div>');
		$('#enlarged').hide();
	
		$('div.widget-photo.thumbnails ul.photos li > a').click(function() {
	
			var photo = $(this).children('img').attr('src').replace('thumb.',''); 
			var caption = $(this).children('img').attr('title');
	
			if ($('#enlarged').hasClass('portrait')) {
			
				$('#enlarged').removeClass('portrait');
			
			}
			
			if ($(this).children('img').hasClass('portrait')) {
			
				$('#enlarged').addClass('portrait');
			
			}
			
			$('#enlarged img').attr('src',photo);
			$('#enlarged img').attr('title',caption);
			$('#enlarged h4').text(caption);
			$('#enlarged').fadeIn();
			
			return false;
	
		});
	
		$('#enlarged div img').click(closeViewer);
		$('#enlarged div a.close').click(closeViewer);


	}


/* DEFINE TAB PANELS
----------------------------------------------------------------------------- */


	if (page == "events") {

		$('#appearances > ul').tabs({ fxSlide: false });

	} else if (section == "photos") {

		$('#page-photos #main > ul').tabs({ fxSlide: false });

	} else if (section == "home") {
	
		$('#editorial > ul').tabs({ fxSlide: false });
		$('#editorial > ul').tabs({ show: function(ui) { replace(browser); } });
		replace(browser);

	}
	
	fixPaging('#upcoming');
	fixPaging('#past');
	fixPaging('#onthedecks');
	fixPaging('#kickinit');
	fixPaging('#ohjeez');


/* POPUP EXTERNAL LINKS
----------------------------------------------------------------------------- */


	$('a[rel=external]').click(function(){
	
		link = $(this).attr('href');
		window.open(link);
		return false;

	});


/* END LOAD FUNCTION
----------------------------------------------------------------------------- */


	});
