/* BARON DAVIS */
/* Common Functions
----------------------------------------------------------------------------- */


	function closeViewer() {

		$('#enlarged').fadeOut();
		$('#enlarged img').attr('src','#');
		$('#enlarged h4').text('');

		return false;

	}


/* BEGIN: READY FUNCTION
----------------------------------------------------------------------------- */

	$(document).ready(function() {


		if (page != "index") {
		
			$('#news ul.stories, #page-press-story #main #news, div.legal').jScrollPane();
	
		}


/* END: READY FUNCTION
--------------------------------------------------------------------------- */

	});



/* BEGIN: LOAD FUNCTION
----------------------------------------------------------------------------- */

	$(window).load(function() {


/* SIFR REPLACEMENTS
--------------------------------------------------------------------------- */


	if (page != "index") {
	
		replace();

	}


/* MAILING LIST
----------------------------------------------------------------------------- */


	if ($('div.widget-subscribe.modify').length > 0) {

		$('#mailing_list_entry_email').val("Please enter your E-mail address").attr('title', "Please enter your E-mail address");

		$('div.widget-subscribe.modify input.save').click(function() {

			if ($('#mailing_list_entry_email').val() == "Please enter your E-mail address") {
				$('#mailing_list_entry_email').val("");
			}

		});

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

			var label = $(this).attr('title');
			if (label == $(this).val()) {

				$(this).val('');

			}	

		});

		$('#mailing_list_entry_email').blur(function() {

			var label = $(this).attr('title');
			if ($(this).val() == '') {

				$(this).val(label);

			}

		});

	}


/* VIDEO PLAYER
----------------------------------------------------------------------------- */

	if (page == "video") {

		$('ul.clips li > div a').click(function() {

			var clip = this.pathname.split('/').pop();
			var player = $('div.widget-media.player div.flash div').attr('class');

			document[player].playClip(clip);

			return false;

		});

    }



/* ADD PORTRAIT CLASS TO IMAGES
--------------------------------------------------------------------------- */

  		$('ul.photos li > a img').each(function() {

			if ($(this).hasClass('portrait')) {

				$(this).parent().parent().addClass('portrait');

			}

		});


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


	$('div.widget-photo.thumbnails ul.photos li a').click(function() {

		var photo = $(this).parent().children('a:first-child').children('img').attr('src').replace('thumb.',''); 
		var caption = $(this).parent().children('a:first-child').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 img').click(closeViewer);
	$('#enlarged a').click(closeViewer);


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


	});
