	// When the DOM is ready, initialize the scripts.
	jQuery(function( $ ){
		
		$.localScroll.hash({
				duration:1500
			});
		
		$.localScroll({
				duration:1000,
				hash:true
		});
		
		if($.browser.msie){
			$("#merch-link").css('zIndex', 600);
			$("#calendar-link").css('zIndex', 600);
		}
		
		$(window).resize(function() {
			 clearTimeout(this.id);
			 this.id = setTimeout(doneResizing, 50);
		});
			
		// Places icons correctly depending on the window size and browser type
		function doneResizing(){
		  	if($("#main-wrapper").width() % 2 == 0 || $("#main-wrapper").width() < 1200 || $.browser.mozilla){
				$("#tv-static").css("margin-left", -427);
				$("#newspaper-link").css("margin-left", -457);
				$("#address-link").css("margin-left", -337);
				$("#cdplayer").css("margin-left", -458);
				$("#laptop-link").css("margin-left", -238);
				$("#phone-link").css("margin-left", -399);
				$("#merch-link").css("margin-left", -211);
				$("#calendar-link").css("margin-left", -225);
				$("#pictureframe").css("margin-left", -450);
			} else {
				$("#tv-static").css("margin-left", -426);
				$("#newspaper-link").css("margin-left", -456);				
				$("#address-link").css("margin-left", -336);
				$("#laptop-link").css("margin-left", -237);
				$("#cdplayer").css("margin-left", -458);
				$("#phone-link").css("margin-left", -398);
				$("#merch-link").css("margin-left", -210);
				$("#calendar-link").css("margin-left", -224);
				$("#pictureframe").css("margin-left", -449);
			}   
		}	
		
		// Tie menu to images
		$(".home-link a").hover(function(){
				var item = "#" + $(this).parent().attr('id') + "-link";
				$(item).css('border-bottom', 'dotted thin white');
				$(this).stop().animate({"opacity":1}, 200);
			},
			function(){
				var item = "#" + $(this).parent().attr('id') + "-link";
				$(item).css('border-bottom', '');
				$(this).stop().animate({"opacity":0}, 200);
			}
		);
		$("#tv-static").hover(function(){
			var item = "#" + $(this).attr('id') + "-link";
			$(item).css('border-bottom', 'dotted thin white');
		},
		function(){
			var item = "#" + $(this).attr('id') + "-link";
			$(item).css('border-bottom', '');
			}
		);
		$("#logo").hover(function(){
			var item = "#" + $(this).attr('id') + "-link";
			$(item).css('border-bottom', 'dotted thin white');
		},
		function(){
			var item = "#" + $(this).attr('id') + "-link";
			$(item).css('border-bottom', '');
			}
		);
		$("#logo a").hover(function(){
				$(this).children("span").animate({"opacity" : 1}, 200);
			},
			function(){
				$(this).children("span").animate({"opacity" : 0}, 200);
			}
		);
		$("#dropcards-small").hover(function(){
			$(this).children("span").animate({"opacity" : 1}, 200);
			},
			function(){
				$(this).children("span").animate({"opacity" : 0}, 200);
			}
		);
		$("#tv-static a").hover(function(){
				$(this).children("span").animate({"opacity" : 1}, 200);
			},
			function(){
				$(this).children("span").animate({"opacity" : 0}, 200);
			}
		);
		
		$("div#main ul li a").hover(function(){
				var item = "#" + $(this).attr('id');
				item = item.slice(0,-5);
				if(item != "#tv-static" && item != "#logo"){
					$(item).children("a").animate({"opacity" : 1}, 200);	
				} else {
					$(item).children("a").children("span").animate({"opacity" : 1}, 200);
				}
			},
			function(){
				var item = "#" + $(this).attr('id');
				item = item.slice(0,-5);
				if(item != "#tv-static" && item != "#logo"){
					$(item).children("a").animate({"opacity" : 0}, 200);					
				} else {
					$(item).children("a").children("span").animate({"opacity" : 0}, 200);
				}
			}
		);
		$("#logo-link").hover(function(){
			$("#logo a span").animate({"opacity" : 1}, 200);
		},
		function(){
			$("#logo a span").animate({"opacity" : 0}, 200);
		}
		);

		
		$("#mailing-list-pic-link").prettyPhoto({
			theme: 'light_square',
			social_tools: false,
			default_width: 300,
			default_height: 70,
			show_title: true
		});
		$("#address-link-link").prettyPhoto({
			theme: 'light_square',
			social_tools: false,
			default_width: 300,
			default_height: 70,
			show_title: true
		});
		$("#mailing-list-link2").prettyPhoto({
			theme: 'light_square',
			social_tools: false,
			default_width: 300,
			default_height: 70,
			show_title: true
		});
	   
	   $("#photos-wrapper a[rel^='prettyPhoto']").prettyPhoto({theme:'light_square'});
	   $("#tour-wrapper a[rel^='prettyPhoto']").prettyPhoto({theme:'light_square'});
		
		$("ul.videos").ytplaylist({addThumbs:true, autoPlay: false, holderId: 'ytvideo', showRelated: false, playerHeight: 350, playerWidth: 525});
		 
		 // Get a reference to the message whose position
		 // we want to "fix" on window-scroll.
		 var message = $( "#main" );
		  
		 // Get the origional position of the message; we will
		 // need this to compare to the view scroll for
		 // reverting back to the original display position.
		 var originalMessageTop = message.offset().top;
		  
		 // Get a reference to the window object; we will use
		 // this several time, so cache the jQuery wrapper.
		 var view = $( window );
		  
		  
		 // Bind to the window scroll and resize events.
		 // Remember, resizing can also change the scroll
		 // of the page.
		 view.bind(
		 "scroll resize",
		 function(){
		  
			 // Get the current scroll of the window.
			 var viewTop = view.scrollTop();
			  
			 // Check to see if the view had scroll down
			 // past the top of the original message top
			 // AND that the message is not yet fixed.
			 if ((viewTop > originalMessageTop) && !message.is( ".main-fixed" )){
			  
				 // Toggle the message classes.
				 message.removeClass( "main-absolute" ).addClass( "main-fixed" );
			  
			 // Check to see if the view has scroll back up
			 // above the message AND that the message is
			 // currently fixed.
			 } else if ((viewTop <= originalMessageTop) && message.is( ".main-fixed" )){
				  
				// Toggle the message classes.
				message.removeClass( "main-fixed" ).addClass( "main-absolute" );
			 
			}
		}
	);	 
			doneResizing();
	});
