// JavaScript Document

var ie = /MSIE/.test(navigator.userAgent); 

var Emerge = {
	init: function() {
		$("#contact-link").click(
			function () { 
				$('html,body').animate({scrollTop: $(".footer").offset().top - 170}, 1000, 'easeOutExpo'); 
				return false;
		});
		$(".footer-back").click(
			function () { 
				$('html,body').animate({scrollTop: 0}, 1000, 'easeOutExpo'); 
				return false;
		});
		
		$("#footer_contact_submit_button").click(function() {
			$.post($("#contactForm").attr("action"), $("#contactForm").serialize(), 
				function(data) {
					if(data == "Success")
					{
						alert("Message has been submitted. Thank you.");
					}
					else
					{
						alert("Please fix the following errors: \n"+data);
					}
				});												  
		    return false;
		});
		
		
		
		<!--
		// Click Fade Removed
		// $("a:[href^=/]").click(function() { 
		//	$('html').fadeOut(250); 
		//	var that = this;
		//	setTimeout(function() { window.location = $(that).attr("href"); }, 250);
		//	return false;
	    // });
		
		// $('body').fadeOut(0);
		
		$(window).load(function() {
			$('html,body').scrollTop(0);
			$('body').fadeIn(500, function() {
				if(window.location.hash.length > 0)
				{
					if(window.location.hash.length > 0 && $("a[name='"+window.location.hash.substring(1)+"']").length > 0)
						$('html,body').animate({scrollTop: $("a[name='"+window.location.hash.substring(1)+"']").offset().top}, 500, 'easeOutExpo'); 
				}
			});
		});
		
	}
};

Emerge.Home = {
		init: function() {
			$(window).bind("load", function() { 
											
				$("#homepage-picture-slide").slideViewerPro(
					{
						galBorderWidth: 0,
						thumbsVis: false,
						autoslide: true
					});
				
				$("#thumbSlider0").appendTo(".home-banner-module").addClass("slide-gui").removeClass("thumbSlider").attr("style","");
				$("#thumbSlider0 ul li a").appendTo(".slide-gui");
				$("#thumbSlider0").find("ul").remove();
				$(".slide-gui a").each(function(index, value) {
					if(index == 0)
						$(this).addClass("selected");
					$(this).empty().html(index+1);		
				});
				
				
				
			}); 
			
			//$("#news-video-player").width(265).height(148);
			
			flowplayer("news-video-player", {"src":"/swf/flowplayer.swf", "wmode":"opaque", cachebusting: ie},
					   {
						   plugins: {
							   controls: {
								   
								  
							   }
						  	},
							
							 
							playlist: [
								{url: "/img/parnell_vid_clip.jpg"},
								{ url: "/videos/Parnell_BeingGenuine.flv", autoPlay: false}
							],
							onBegin : Emerge.Home.expandVideo,
							onResume: Emerge.Home.expandVideo,
							onStop: Emerge.Home.contractVideo,
							onPause: Emerge.Home.contractVideo/*,
							log: {
									level: 'debug',
									filter: "org.flowplayer.view.PlayButtonOverlayView"
							}*/
					   });
			
			
		},
		expandVideo: function() {
			if($f(0).getClip().type =="image")
			{
				$f(0).getControls().hide();
				return true;
			}
			else
			{
				$f(0).getControls().show();
			}
			$('html,body').animate({scrollTop: $("#news-module").offset().top}, 500, 'easeOutExpo');
			$("#news-video-player").width(650).height(320);
			$("#news-module-right").hide("fast");
		},
		contractVideo: function() {
			$f(0).getControls().hide();
			$("#news-video-player").width(265).height(148);
			$("#news-module-right").show("fast");
		}
		
};

Emerge.Reel = {
		init: function() {
			flowplayer("videoPlayer", {"src":"/swf/flowplayer.swf", "wmode":"opaque", cachebusting: ie},
		   {
			   plugins: {
				   controls: {
					   autoHide: "always",
					   hideDelay: 1000
					  
				   }
				},
				
				 
				playlist: [
					"/videos/Emerge Reel 2009-2010.flv"
				]
		   });
		}
};

Emerge.Bio = {
		init: function(videoURL) {
			
			if(videoURL)
			{
				flowplayer("videoPlayer", {"src":"/swf/flowplayer.swf", "wmode":"opaque", cachebusting: ie},
			   	{
				   plugins: {
					   controls: {
						   autoHide: "always",
						   hideDelay: 1000
						  
					   }
					},
					
					 
					playlist: [
						"/videos/Parnell_WhoWeAre.flv"
					]
			   	});
			}
		}
};
