	$(document).ready(function(){
		
		//Set Current Page Default
		
		var curr_page = 'home';
		
		//Animate Intro
			
		$('#' + curr_page).animate (
			{
				style: 'margin-top: 0px;'   //was 150
			},
				1000
		);
		
		
		//Load Flash
		//$('#hill').flash(
		//	{
		//		src: 'flash/hills.swf',
		//		wmode: 'transparent',
		//		scale: 'noscale',
		//		width: 960,
		//		height: 300,
		//		id: 'hills',
		//		allowScriptAccess: 'local'
		//	});
		
		//When flash is done loading flash calls this function to drop nav in
		
		window.flashFunc.loaded = function loaded(){
			
			
		
		//Navigate Content when user clicks the nav
		
		function getQuery(variable) {
			var query = window.location.search.substring(1);
			var vars = query.split("&");
			for (var i=0;i < vars.length; i++) {
				var pair = vars[i].split("=");
				if (pair[0] == variable) {
					return pair[1];
				}
			} 
		}
		
		var t; 

		if (getQuery("default")) {
			clearTimeout(t); 
			t = setTimeout(function() {
				new_page = getQuery("default");
				navigateSite(new_page);
			},
			1000);
		}
		else {
			$('#nav').animate (
				{
					style: 'margin-top: 20px;'
				},
				1000
			);
			
		};
		
		
		
		};
		
		
		
		$('#nav>ul>li>a').click(function () {
		
			var new_page = this.title
			
			if (new_page != curr_page){
				navigateSite(new_page);
			}
		
		});
		
		function navigateSite(new_page) {
			//Moves the current content off the page
			
			$('#nav').animate (
				{
					style: 'margin-top: -100px;'
				},
				1000 , function() {
					$('#' + curr_page).animate (
						{
							style: 'margin-top: -1000px;'
						},
						1000, function () {
							
						}
					);
				}
				
			);
			
			//Sets the name of the content we want to load
	

			if (new_page == 'videos') {
				openVideo('http://images.popcap.com/www/images/product/videos/large/pvz/pvz_gametrailer_r2.flv');
				$('.vid1').addClass('selected');
			};
			
			if (curr_page == 'videos') {
				$('#myPlayerGoesHere').html('');
				$('.vid1').removeClass('selected');
			};
			
			
			if (new_page == 'home') {

				$('#trybuy_global').animate (
					{
						style: 'margin-top: -500px;'
					},
					1000
				);
			};
			
			//Call Flash Roll Function and pass it new_page var
			
			sendToActionScript(new_page,curr_page);
		};
		
		window.flashFunc.loadPage = function loadPage(new_page){
			
			<!--Create Background Variables -->
			
			var new_bg;
			var curr_bg;
			
			//Set the current and new backgrounds to fade in and out
			
			if (new_page == 'videos' || new_page == 'reviews') {
				new_bg = 'bg_3';
			};
			if (new_page == 'zombatar' || new_page == 'characters') {
				new_bg = 'bg_2';
			};
			if (new_page == 'home' || new_page == 'downloads') {
				new_bg = 'bg';
			};
			if (curr_page == 'videos' || curr_page == 'reviews') {
				curr_bg = 'bg_3';
			};
			if (curr_page == 'zombatar' || curr_page == 'characters') {
				curr_bg = 'bg_2';
			};
			if (curr_page == 'home' || curr_page == 'downloads') {
				curr_bg = 'bg';
			};
			
			if (curr_bg != new_bg) {
				//Shuffle layers around and fade in new background while fading out the current one
				
				$('#' + new_bg).css({ "z-index" : "3" });
				$('#' + new_bg).fadeIn(1000, function() {
					
					$('#' + curr_bg).hide();
					$('#' + new_bg).css({ "z-index" : "1" });
					
					$('#' + new_page).animate (
						{
							style: 'margin-top: 0px;' // was 150
						},
						1000, function() {
							
							
							//Set Button State 
							$("body").removeClass(curr_page);
							$("body").addClass(new_page);
							
							if (curr_page == 'home') {

								$('#trybuy_global').animate (
									{
										style: 'margin-top: 20px;'
									},
									1000
								);
							};
							
							//Set Current page to the new page
							curr_page = new_page;
            	
							$('#nav').animate (
								{
									style: 'margin-top: 20px;'
								},
								1000
							);
							
						});
					
					});
					
					
				
			}
			else {
				$('#' + new_page).animate (
					{
						style: 'margin-top: 0px;' // was 150
					},
					1000, function() {
						
						//Set Button State 

						$("body").removeClass(curr_page);
						$("body").addClass(new_page);
						
						if (curr_page == 'home') {

							$('#trybuy_global').animate (
								{
									style: 'margin-top: 20px;'
								},
								1000
							);
						};
						
						//Set Current page to the new page
						curr_page = new_page;
        	
						$('#nav').animate (
							{
								style: 'margin-top: 20px;'
							},
							1000
						);
						
					});
			}
		};
	
		drop_click = true;
		$(".mini").click(function(){
			if (drop_click == true) {
				$(this).next(".sizes").show();
				drop_click= false;
			} else {
				$(this).next(".sizes").hide();
				drop_click = true;
				}
			})

		$(".sizes").mouseover( function() { 
			$(".rolloff").show();
			} 
			);

		$(".rolloff").mouseover( function() { 
			$('.sizes').hide();
			$('.rolloff').hide();
			drop_click = true;
			} 
			);
			
			//jcarousel
	    jQuery('#mycarousel').jcarousel({
	        size: 6,
					visible: 380
	    });
			
		//video player
			function openVideo(swf) {
				$('#myPlayerGoesHere').flash(
				{
					src: 'flash/AkamaiFlashPlayer.swf',
					wmode: 'transparent',
					scale: 'noscale',
					width: 546,
					height: 446,
					allowFullScreen: 'true',
					allowScriptAccess: 'sameDomain',
					type: 'application/x-shockwave-flash',
					flashvars: { src: swf, autostart: 'true', themeColor: '33ff00', mode: 'sidebyside', scaleMode: 'fit', frameColor: '000000', fontColor: 'cccccc', link: '' }
					},
		        { version: 10 }
				);
			};

$(".vid").click(function(){
			var swf = this.href;
			$('#myPlayerGoesHere').html('');
			$('.vid').removeClass('selected');
			$(this).addClass('selected');
			openVideo(swf);
			return false;
		});
			
			
			
			
			
			
		
	});
	
	window.flashFunc = {};
	
	function getFlashMovieObject(movieName){
		
		if (window.document[movieName]){
			return window.document[movieName];
		}
		if (navigator.appName.indexOf("Microsoft Internet")==-1){
			if (document.embeds && document.embeds[movieName])
			return document.embeds[movieName];
		}
		else
		{
			return document.getElementById(movieName);
		}
	}
	
	function sendToActionScript(new_hill,curr_hill) {
		var flashMovie=getFlashMovieObject('hills');
		flashMovie.rollHill(new_hill,curr_hill);
	}