/* LINKIN PARK */
/* Section Functions - Network
----------------------------------------------------------------------------- */


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

	$(document).ready(function() {
	

/* HIDE LINKIN PARK AND LPU LOGOS IF SITE HAS NO IMAGE HEADER
----------------------------------------------------------------------------- */

	if (page == "site") {
	
		if ($('#info #site-header img.header').length == 0) {
		
			$('#info #site-header ul.actions li').css('background-image', 'none');
		
		}
	
	}


/* LPN BAR NAVIGATION OPTIONS
----------------------------------------------------------------------------- */

	if (subdomain == "brad" || subdomain == "chester" || subdomain == "joehahn" || subdomain == "mike" || subdomain == "phoenix" || subdomain == "rob") {

		$('li.band').addClass('hover');
		$('li.band').css( { width: "276px" } );
	
	}

	if (subdomain == "brad") {
				
		highlightPageName("brad", true);
	
	}

	if (subdomain == "chester") {
				
		highlightPageName("chester", true);
	
	}

	if (subdomain == "joehahn") {
				
		highlightPageName("joehahn", true);
	
	}

	if (subdomain == "mike") {
				
		highlightPageName("mike", true);
	
	}

	if (subdomain == "phoenix") {
				
		highlightPageName("phoenix", true);
	
	}

	if (subdomain == "rob") {
				
		highlightPageName("rob", true);
	
	}
		
	if (page == "projektrevolution") {

		$('li.live').addClass('hover');
		$('li.live').css( { width: "276px" } );
		
	}

	if (page == "projektrevolution") {
				
		highlightPageName("pr", false);
	
	}
	
	
/* REMOVE EMPTY TABS
----------------------------------------------------------------------------- */

	if (page == "site") {

		removeEmptyTabs("#events");
		removeEmptyTabs("#site-visuals");

	}
	
		
/* REMOVE EMPTY SLIDESHOW PANEL
----------------------------------------------------------------------------- */

	if ($('#slideshow').children('div.widget-photo').length == 0) {
			
		$('#slideshow').remove();
			
	}	


/* TRUNCATE TEXT
----------------------------------------------------------------------------- */
	
	if (page == "blog") {
	
		$(".headlines a").truncate( 75 );
		
	}
	
	if (page == "site") {
	
		$("div.widget-event.program em").truncate( 50 );
		
	}	
	
	if (page == "post" || page == "blog" || page == "review"  || page == "site") {

		$("#member dt.alias").truncate( 55 );
		$("#member dd.status").truncate ( 90 );
		$("#info h3").truncate ( 60 );
	
	}
	
	
/* RENAME SUCCESS MESSAGE FOR SUBMITTING Q&A
----------------------------------------------------------------------------- */

	$('div.widget-alert.qa h3').text("Thank you for submitting your Q&A question!");
	$('div.widget-alert.qa p').text("Stay tuned to see if your question gets answered a band member.");
	
	
/* ADD BACK BUTTON ON RSVP LISTING
----------------------------------------------------------------------------- */

	if (page == "network") {
	
		$('#event ul.actions').append('<li class="modify"><a class="action goback" href="/show/' + tag + '/' + topic + '">Back To Show Details</a></li>');
	
	}
	
	
/* SIFR REPLACEMENTS
----------------------------------------------------------------------------- */

	if (page == "blog" || page == "review" || page == "post" || page == "qa" || page == "site" || page == "ask") {
	
		replace();
		
	}


/* SITE SUB-TABS
----------------------------------------------------------------------------- */

	if (page == "site") {

		$('#events > ul').tabs({fxSlide: false});
		$('#site-visuals > ul').tabs({fxSlide: false});

	}
	
	
/* FANS TABS
----------------------------------------------------------------------------- */
	
	if (page == "fans" || page == "site" || page == "network") {

		$('#fans > ul').tabs({
		
			fxSlide: false,

			click: function() {
			
				/* SHOW PRELOADING ANIMATION */	
				$("#loader").fadeIn();
			
			},
			load: function(ui) {

				/* SIFR REPLACEMENTS */	
				replace();


				/* HIDE PRELOADING ANIMATION */			
				$("#loader").fadeOut();
				
				
				/* CHANGE LANGUAGE FOR COMMENTS */
				$('#member dt.comments').text('Comments');


				/* ADD QUOTES TO FEATURED FANS */
				$('#featured-fan dd.status').append('"');
				$('#featured-fan dd.status').prepend('"');

			}
			
		});

	}	
	

/* CHANGE LANGUAGE FOR ACTIONS
----------------------------------------------------------------------------- */
	
	if (page == "site") {
	
		$('#friends.latest a.next').text('See More Friends');	
		$('#myphotos a.browse').text('See More Photos');
		$('#myartwork a.browse').text('See More Artwork');
		$('#myfavorites a.browse').text('See More Favorites');
		$('#latest-posts a.browse').text('Read More Posts');
		$('#myreviews a.change').text('Change Review');	
			
	}

	$('#profile a.change').text('Change Your Profile');	
	$('#comments.latest a.next').text('See More Comments');
	$('#member a.profile').text('View Site');
	$('a.unfriend').text('Unfriend');
	
	if (page == "review") {
	
		$('#blog a.change').text('Change Review');
	
	}
	
	
/* CHANGE LANGUAGE FOR COMMENTS
----------------------------------------------------------------------------- */

	if (page == "questions") {

		$('#comments h3').each(function() {
	
			var $this = $(this);
			$this.html( $this.html().replace("Comments", "Submitted Questions") );
	
		});
		
	}
	
	if (page == "blog" || page == "post" || page == "review" || page == "qa" || page == "site" || page == "ask" ) {
	
		$('#member dt.comments').text('Comments');
	
	}
	
	
/* END READY FUNCTION
----------------------------------------------------------------------------- */

	});
	



/* LOAD FUNCTION / ELEMENT INITIALIZATION
----------------------------------------------------------------------------- */

	$(window).load(function() {


/* FLASH ANIMATIONS
----------------------------------------------------------------------------- */

	/* JOE HAHN HEADER */
	if (subdomain == "joehahn" || alias == "mrhahn1" || user_alias == "mrhahn1" || topic == "Talk_To_Joe" ) {
	
		if ( (page == "site" && (joe_section == "neighborhood" || tab == "comments" || comment_page || member_page)) || page == "ask" || page == "questions" ) {
		
		var so = new SWFObject( wbrHost + "flash/joe_hahn_neighborhood.swf", "joehahn", "1024", "365", "9", "#000000");
		so.addParam("allowScriptAccess", "always");
		so.addParam("salign", "TL");
		so.useExpressInstall( "http://download.wbr.com/bandbuilder/lp/flash/expressinstall.swf");
		so.write("joe");
		
		}

		else if (page == "site" && joe_section == "theseed") {
		
		var so = new SWFObject( wbrHost + "flash/joe_hahn_theseed.swf", "joehahn", "1024", "768", "9", "#000000");
		so.addParam("allowScriptAccess", "always");
		so.addParam("salign", "TL");
		so.useExpressInstall( "http://download.wbr.com/bandbuilder/lp/flash/expressinstall.swf");
		so.write("joe");		
		
		}
	
		else if (page == "site" && joe_section == "videos") {
		
		var so = new SWFObject( wbrHost + "flash/joe_hahn_videos.swf", "joehahn", "1024", "768", "9", "#000000");
		so.addParam("allowScriptAccess", "always");
		so.addParam("salign", "TL");
		so.useExpressInstall( "http://download.wbr.com/bandbuilder/lp/flash/expressinstall.swf");
		so.write("joe");
		
		}
	
		else {
		
		var so = new SWFObject( wbrHost + "flash/joe_hahn_blog.swf", "joehahn", "1024", "365", "9", "#000000");
		so.addParam("allowScriptAccess", "always");
		so.addParam("salign", "TL");
		so.useExpressInstall( "http://download.wbr.com/bandbuilder/lp/flash/expressinstall.swf");
		so.write("joe");		
		
		}
	
	}

	/* LPN WIDGET */
	if (page == "site" && (!tab || tab == "whatsnew") && subdomain != "brad" && subdomain != "chester" && subdomain != "joehahn" && subdomain != "mike" && subdomain != "phoenix" && subdomain != "rob") {

		var loc = "http://widgets.linkinpark.com/o/47150cd6885d8f10/479fbdd28b952f26/47150cd6885d8f10/bdfd2e1d";
		var so = new SWFObject( loc, 'widget_flash.swf', '400', '427', '9', '#FFFFFF' );
		so.addParam( "wmode", "transparent" );
		so.write( 'widget' );
	
	}
		

	/* MUSIC VIDEO PLAYER */
	if (page == "site" && (!tab || tab == "whatsnew") && (subdomain == "brad" || subdomain == "chester" || subdomain == "mike" || subdomain == "phoenix" || subdomain == "rob" )) {
		//var wbrHost = "http://download.wbr.com/bandbuilder/lp/"
		var media_so = new SWFObject( wbrHost + "flash/lpn_musicvideos.swf", "media.swf", "704", "373", "9", "0x000000" );
		media_so.addVariable( "playlistXML", "http://linkinpark.com/playlists/musicvideos.xml" );
		media_so.addVariable( "autoPlay", "true" );
		media_so.addParam( "allowScriptAccess", "always" );
		media_so.addParam( "allowFullScreen", "true" );
		media_so.write( 'player' );
	
	}
	
	
/* UPDATE SITE SETTINGS
----------------------------------------------------------------------------- */
	
/*	function panel(selector, start) {

		var $first = $(selector + ':' + start);
		var $current = $first;

		$current.addClass("selected");

		var $next = $('#update-settings a.next');
		var $back = $('#update-settings a.back');

		if (!($current.next('div').attr('class'))) {
		
			$($back).hide();
				
		}
		
		if (!($current.prev('div').attr('class'))) {
		
			$($next).hide();
				
		}		

		$($next).click(function() {

			if ($current.prev('div').attr('class')) {

				$(this).show();
				$($back).show();		
				$current.removeClass("selected");
				if ($current.prev().attr('class') == "group picture") {

					$current = $current.prev().prev();
				
				}
				
				else {
				
					$current = $current.prev();
					
				}
				$current.addClass("selected");	

			}
			
			if (!($current.prev('div').attr('class'))) {
			
				$(this).hide();
						
			}

		});

		$($back).click(function() {

			if ($current.next('div').attr('class')) {
	
				$(this).show();
				$($next).show();
				$current.removeClass("selected");
				if ($current.next().attr('class') == "group picture") {

					$current = $current.next().next();
				
				}
				
				else {
				
					$current = $current.next();
					
				}
				$current.addClass("selected");
				
			}
			
			if (!($current.next('div').attr('class'))) {
			
				$(this).hide();
			
			}

		});

	}
	
	if ((author || moderator) && (page == "post" || page == "blog" || page == "site")) {
	
		var height = $('#info').height();
	
		$('#info #update-settings').css('height', height + "px" );
		$('#info #update-settings div.group.title').css('height', height - 192 + "px" );
		
		$('#info #update-settings div.group.header label em').text("New Site Header");
		
		$('#info #update-settings ul.actions').prepend('<li><a class="action back" href="#">Back</a></li>');
		$('#info #update-settings ul.actions').append('<li><a class="action cancel" href="#">Cancel</a></li><li><a class="action next" href="#">Next</a></li>');
		
		$('#info #update-settings a.cancel').click(function() {

			$('#info #update-settings').hide();
			$('#overlay').fadeOut(100);
			$('#info #update-settings').children('div').removeClass("selected");
			$('#info a:last').show();

		});

		$('#update-site').click(function() {

			$('#info #update-settings').show();
			$('#overlay').fadeIn(100);
			
			$(this).hide();
			panel('#info #update-settings div', 'last');

		});
										
	}
*/

/* UPDATE STATUS
----------------------------------------------------------------------------- */
/*	
	if ((author || moderator) && (page == "post" || page == "blog" || page == "site")) {

		$('#update-status label:first').hide();
	
		$('#change-status').click(function() {

			$(this).hide();
			$('#overlay').fadeIn(100);
			$('#update-status').show();

		});		
							
	}
*/

/* CREATE A SLIDESHOW / CHANGE SLIDESHOW
----------------------------------------------------------------------------- */
/*	
	if ((author || moderator)) {
	
		if ($('#left:contains("id="slideshow"")')) {
		
			$('#create-slideshow').attr('id','change-slideshow');
			$('#change-slideshow').text("Change Slideshow");
			
		}
	
	}
*/
	
/* ADD HOVER CLASS TO EVENT LISTINGS
----------------------------------------------------------------------------- */

	if (page == "site") {

		$('div.widget-event.program li').hover(
		
			function() {
	
				$(this).addClass('hover');			
			
			},
			function() {
			
				$(this).removeClass('hover');			
			
			}			
		
		);
		
		$('div.widget-event.list tr').hover(
		
			function() {
	
				$(this).addClass('hover');			
			
			},
			function() {
			
				$(this).removeClass('hover');			
			
			}			
		
		);
		
	}	
	
	
/* REPLACE HYPERLINKS
----------------------------------------------------------------------------- */

	if (page == "site") {
	
		$('#qa a.browse').attr('href','/?tab=qa');	
	
	}

	$('#comments.latest a.next').attr('href','?tab=comments');
	

/* REMOVE SUBDOMAIN FROM LINKS
----------------------------------------------------------------------------- */
	
	if (subdomain == "brad" || subdomain == "chester" || subdomain == "joehahn" || subdomain == "mike" || subdomain == "phoenix" || subdomain == "rob") {

		removeSubDomain('a.change');
		removeSubDomain('a#update-site');
		removeSubDomain('a#change-status');	

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

	
	});	