// JavaScript Document
var helpers = {
	createPlayer : function() {
		var flashvars = {
			file:templateURL + "/video/animoto_high_res.mp4", 
			//image:templateURL + "/images/vidContainer2.jpg",
			autostart:"true",
			controlbar:"bottom",
			mute:true,
			stretching:"fill"
		}
	
		var params = {
			allowfullscreen:"true", 
			allowscriptaccess:"always",
			wmode:"transparent"
		}
	
		var attributes = {
			id:"player1",  
			name:"player1"
		}
	
		//swfobject.embedSWF(templateURL + "/video/player.swf", "vidcontainer", "970", "342", "9.0.115", false, flashvars, params, attributes);
		
		if ($("#vidcontainer").length>0) {
		
			jwplayer("vidcontainer").setup({
				flashplayer: templateURL +"/js/jwplayer/player.swf",
				file:templateURL + "/video/animoto_high_res.mp4",
				skin: templateURL + "/js/jwplayer/skins/whotube.zip",
				height: 342,
				width: 970,	
				repeat: 'always',
				'display.showmute': true,
				mute: false,			
				autostart:"true",
				stretching:"fill",
				events: {
				   onMute: function(mute) {
						//$("#vidcontainer-music").addClass("on");
						var muteState = jwplayer().getMute();
						if (muteState) {
							$("#vidcontainer-music").removeClass("mute-off");
						} else {
							$("#vidcontainer-music").addClass("mute-off");
						}
						
				   },
				   onComplete: function() {
						$(".vidcontainer").html('').append('<div id="vidcontainer"></div>');
				   }
				}			
			});		
		}
	}
}

$(document).ready(function() {
	$("#bgStretch").height($("#bg").height() + 35);
	//$(".email h1, #menu-item-461 a, a.ctc").colorbox({width:550, inline:true, href:"#click_to_call"});	
	
	$(".email h1, #menu-item-461 a, a.ctc").fancybox({
		'type'			: 'inline',
		'href'			: '#click_to_call',
		'overlayShow'	: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});

	
	$("#slideshow").easySlider({
		loop: true,                           // Looping
		orientation: 'fade',                  // Fading
		autoplayDuration: 5000,               // Autoplay with 1 second intervals
		autogeneratePagination: true,         // Automatically generate pagination links
		restartDuration: 5000,                // In case of user interaction, restart the autoplay after 2.5 seconds
		pauseable: true 
	});
	
	$("a.fancybox").fancybox({
		'overlayShow'	: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});


	$("form").submit(
		function(){
			var fID = $(this).attr("id");
			var _data = $(this).serialize() + "&ajax=yes";
			var _url = $(this).attr("action");
			var pform = $(this);
			$(".c_msg", pform)
			.css("display","none")
			.html("<p class='info'>Sending data. Please wait...</p>")
			.fadeIn("slow");
			
			jQuery.ajax({
			   type: "POST",
			   url: _url,
			   data: _data,
			   success: function(msg){
				    $(".c_msg", pform).html(msg)
					.delay(3000)
					.fadeOut("slow");
					
				  if(msg.indexOf("<!--RESET-->") > -1){
					   $("input[type=text], textarea").each(
							function(index,item){
								$(item).val($(item).attr("title"));
							}
					   );
				   }
			   }
			});
			return false;
		}
	);
	
	$(".txt").click(
		function(){
			if($(this).val() == $(this).attr("title")){
				$(this).val("");	
			}
		}
	
	);
	$(".txt").blur(
		function(){
			if($(this).val() == ""){
				$(this).val($(this).attr("title"));	
			}
		}					
	)
	
	$("#vidcontainer").live('click', 
	 	function(){
			helpers.createPlayer();	
		}
	);
	
	//helpers.createPlayer();
	
});

	
