/* LINKIN PARK */
/* General Functions
----------------------------------------------------------------------------- */


/* FUNCTIONS
---------------------------------------------------------------------------- */

	/* HIDE EMPTY LISTS */
	function hideEmptyLists() {
	
		$('ul.paging').each(function() {
	
			if ($(this).children('li').length == 0) {
			
				$(this).hide();
			
			}
		
		});
	
	}

	/* REMOVE SUBDOMAIN FROM LINKS */
	function removeSubDomain(selector) {
	
		var link = $(selector).attr('href');
		var newLink = site_host + link;
		$(selector).attr('href', newLink);
	
	}


	/* ADD SUBDOMAIN TO LINKS */
	function addSubDomain(selector, subdomain) {

		$(selector).find('h4 a').each(function() {

			var link = $(this).attr('href');
			var newSiteHost = site_host.replace("http://", "http://" + subdomain + ".");
			var newLink = newSiteHost + link;
			$(this).attr('href', newLink);
			
		});

		$(selector).find('a.comments').each(function() {

			var link = $(this).attr('href');
			var newSiteHost = site_host.replace("http://", "http://" + subdomain + ".");
			var newLink = newSiteHost + link;
			$(this).attr('href', newLink);
			
		});

		$(selector).find('a.display').each(function() {

			var link = $(this).attr('href');
			var newSiteHost = site_host.replace("http://", "http://" + subdomain + ".");
			var newLink = newSiteHost + link;
			$(this).attr('href', newLink);
			
		});
		
	}
	
	
	/* REMOVE EMPTY TABS */	
	function removeEmptyTabs(selector) {
	
		var tabsArray = new Array();
		
		$(selector).children('div').each(function(){
		
			var tab = $(this).attr("id");
			tabsArray.push(tab);
			
		});
		

		$(selector).children('ul.tabs').children('li').children('a').each(function() {
		
			var link = $(this).attr('href').replace("#","");
			var j = 0;

			for (i = 0; i < tabsArray.length; i++) {
			
				if (link == tabsArray[i])
				{
					
					j++;

				}
	
			}
			
			if (j == 0) {
			
				$(this).parent().remove();
			
			}
			
		});
		
		$(selector).children('ul.tabs').children('li:last').addClass("last");
		
		if ($(selector).children('ul.tabs').children('li').length == 0) {
		
			$(selector).remove();
		
		}
		
		if (tabsArray.length == 1) {
		
			$(selector).children('ul.tabs').children('li:last').addClass("selected");
			
		}
		
	}
	
	/* REMOVE PANE & RESPECTIVE TAB IF PANE IS EMPTY */	/*
	function removeEmptyPane(panel) {
		
		$(panel).children('ul.tabs').children('li').each(function() {
		
			var pane = $(this).find('a').attr('href');

			if ($(this).parent().siblings(pane).find('ul').not($('ul.actions')).length == 0) {

				$(this).parent().siblings(pane).remove(); // REMOVE EMPTY PANE
				$(this).remove(); // REMOVE RESPECTIVE TAB
			
			}

		});
		
		// HIGHLIGHT FIRST TAB
		$(panel).children('ul.tabs').children('li').each(function() {
		
			$(this).removeClass('selected');
			
		});

		$(panel).children('ul.tabs').children('li:first').addClass('selected');		

		// SHOW FIRST PANE
		$(panel).children('div').each(function() {
		
			$(this).addClass('hide');
			$(this).hide();

		});

		$(panel).children('div:first').removeClass('hide').show();

		// REMOVE ENTIRE PANEL IF ALL PANES ARE EMPTY
		if ($(panel).children('ul.tabs').children('*').length == 0) {
		
			$(panel).remove();
		
		}
	
	}	*/
	
	

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

	$(document).ready(function() {


/* HEADER ANIMATION
----------------------------------------------------------------------------- */

	$('body h2:first').animate( { width: "704px" }, 1000);
	

/* FRIEND CONFIRMATION
----------------------------------------------------------------------------- */

	$('div.widget-alert h3:contains("people would like to be your friend")').parent().append('<ul class="actions"><li><a class="action approve" href="/friends#requests">Approve Requests</a></li><li><a class="action friendsupto" href="/friends#friends">See What Your Friends Are Up To</a></li></ul>');


/* ADDED REVIEWS
----------------------------------------------------------------------------- */

	if (tag == "Reviews") {

		$('div.widget-alert h3:contains("blog")').text("Your review has been successfully updated.");
	
	}
	

/* HIDE EMPTY LISTS
----------------------------------------------------------------------------- */

	hideEmptyLists();
	

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

	});
	
	
	

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

	$(window).load(function() {


/* CALULATE OVERLAY HEIGHT
----------------------------------------------------------------------------- */

		$('#overlay').css('height', $('#page').height());
		

/* ADD HOVER CLASS TO TABS
----------------------------------------------------------------------------- */

		$('ul.tabs li').hover(
		
			function() {

				$(this).addClass('hover');			
			
			},
			function() {
			
				$(this).removeClass('hover');			
			
			}			
		
		);
					

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

	
	});