/* Declare a namespace for the site */
var Site = window.Site || {};

var submittable = true;

/* Create a closure to maintain scope of the '$'
   and remain compatible with other frameworks.  */
(function($) {
	
	//same as $(document).ready();
	$(function() {

                if(navigator.userAgent.match(/iPad/i)!=null || 
                navigator.userAgent.match(/iPhone/i)!=null)
                      $('body').css('background','white');
		
                if($.browser.webkit) {
			if(parseInt($.browser.version) <= 5) $('section > header > h1').css('padding', '4px');
			$('#home aside').not('.mid-sidebar').css('padding-top','18px');
		}

		$('#tour-list .tour-more-info').hide();
		$('#tour-list > tbody').not('#no-shows').prepend('<span class="tour-list-arrow">&#9654;</span>');

		$('#tour-list .tour-list-arrow').toggle(function () {
			$('.tour-more-info').slideUp();
			$('#tour-list .tour-list-arrow').html('&#9654;');
			$(this).parent().find('.tour-more-info').slideDown(400,function () {
				var map = $(this).find('iframe');
				var src = map.attr('src');
				map.attr('width','296').attr('height','244').attr('src',src);
			});
			$(this).html('&#9660;');
		}, function () {
			$(this).parent().find('.tour-more-info').slideUp();
			$(this).html('&#9654;');
		});

		$('section.news p a, .social-network-small a').attr('target','_blank');

		$('a.fancybox').fancybox();

		/////////////////////////////////////////
		// Discography

		var current_album_path = location.href.split('#');
		current_album_path = current_album_path[current_album_path.length-1];

		$('ul.discography > li').hide();
		$('li#'+current_album_path).fadeIn('slow');
		$('#album-nav a[title="'+current_album_path+'"]').addClass('currentAlbum');

		$('#album-nav a').click(function() {
			$('#album-nav a').removeClass('currentAlbum');
			$(this).addClass('currentAlbum');
			$('ul.discography > li').hide();
			$('li#'+$(this).attr('title')).fadeIn('slow');
			//window.location.hash = $(this).attr('title');
		});	
		if(current_album_path.search('http://') != -1) $('#album-nav a').first().click();

		$('#agreeterms').change(function () {
			if($(this).attr('checked')) 
				$('#submitapplication').attr('disabled',false);
			else
				$('#submitapplication').attr('disabled',true);
		});

		$('#submitapplication').click(function() {
			$('input.required').each(function() {
				if($(this).val().length < 1) {
					alert('Please fill in all required fields');
					$(this).css('border-color','red');
					return preventSubmit();
				}
				if($(this).is(':last-child'))
					$('#camp-form').submit();
			});
		});

	});


	$(window).bind("load", function() {});})(jQuery);

function preventSubmit() {
	return submittable = false;
}

//////////////////////////////////////////////////////////////////////////////////////////
// Music player

var params = {
	quality: "high"
};

var flashvars = {
	content_path: "../../media",
	color_path: "/scripts/flashmp3player/default.xml",
	script_path: "/scripts/flashmp3player/flashmp3player.php"
};

var attributes = {};

swfobject.embedSWF("/scripts/flashmp3player/flashmp3player.swf","music-player","252","234","9",false,flashvars,params,attributes);
