﻿/* Teddy Geiger */
/* Javascript Functions
----------------------------------------------------------------------------- */


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

	$(window).load(function() {
		

/* FRIENDS REQUEST POPUP
----------------------------------------------------------------------------- */

		if (page == "index") {
						
			$("a.nothanks").click(function(){ 

				$("#friend-requests").hide();
				$.cookie('friend_requests', 'hide', { expires: 1 });
				return false;

			});

			// Check if cookie exists, if not, show the selected element

			var friend_requests = $.cookie('friend_requests');
			if (friend_requests != "hide") {
			
				$('#friend-requests').show();
			
			}

			// If there are no friend requests, hide the containing div
	
			if ($("div.widget-friend").length == 0) {

		 		$("#friend-requests").hide();

			}
						
			
		}
		


/* EXTERNAL LINKS WITH REL=EXTERNAL
----------------------------------------------------------------------------- */

		$('a[rel=external]').click(function(){

		link = $(this).attr('href');
		window.open(link);
		return false;

		});
		
		
/* COMMENT SLIDING
----------------------------------------------------------------------------- */
		
		$('a#note').click(function() {
	
			$('#leave-note').slideToggle('fast');
			return false;
			
		});

		$('a#firstnote').click(function() {
	
			$('#leave-note').slideToggle('fast');
			return false;
			
		});
		

/* END LOAD FUNCTION
----------------------------------------------------------------------------- */
		
	});





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

	$(document).ready(function() {
		
		
/* HIDE COMMENT FIELD
----------------------------------------------------------------------------- */

		$('#leave-note').hide();



/* HIDE FRIEND REQUESTS
--------------------------------------------------------------------------- */

		$("#friend-requests").hide();



/* TABS
----------------------------------------------------------------------------- */

		// TAB DEFINITION

		if (section == "tedheads") {

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

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

			$('#panel-merch > ul').tabs({ fxSlide: false });

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

			$('#panel-pics > ul').tabs({ fxSlide: false });

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

			$('#panel-answers > ul').tabs({ fxSlide: false });			

		}

		// PAGINATION FIX

		if (page == "pics") {

			$('#shared ul.pages a').each(function() { 
	
				var $this = $(this); 
				$this.attr('href', $this.attr('href') + '#shared'); 
	
			});

			$('#personal ul.pages a').each(function() { 
	
				var $this = $(this); 
				$this.attr('href', $this.attr('href') + '#personal'); 
	
			});

			$('#favorite ul.pages a').each(function() { 
	
				var $this = $(this); 
				$this.attr('href', $this.attr('href') + '#favorite'); 
	
			});

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

	});
