// fridge productions

$(document).ready(function(){
	
	$("a[@rel*=facebox]").facebox();
	
	// load the showreel
    
    $('#showreel-holder').flash(
        { 
          src: 'player.swf?file=lib/video/CompositeShowReel.flv&amp;skin=nacht.swf&amp;autostart=false',
          width: 423,
          height: 250,
          bgcolor: '#000000',
		  wmode: 'transparent'
        },
        { version: 9 }
    );
	
	// auto scroll
	
	$("div.scroll a").click(function(){
  		$("html, body").animate({ 
                 scrollTop: $($(this).attr("href"))
                 .offset().top }, 1000);
   		return false;
 	});
	
	// you are here code
	
	$("div.scroll a").each(function(){	
		$(this).click(function(){
			$("div.scroll a").each(function(){
				$(this).removeClass("current");
			});
			// get the class value of clicked link
			var current_class = $(this).attr("class");
			//alert(class);
			// set the current link
			$("div.scroll a." + current_class + "").each(function(){
				//alert(class);
				$(this).addClass(current_class + " current");
			});
		});
	});
	
	// intial state
	
	$("div#services-content div").each(function(){
		$(this).hide();
	});
	
	$("div#services-1").show();
	
	// services
	
	$("ul#services-tabs a").each(function(){
		$(this).click(function(){
			// get the rel value for clicked link
			var rel = $(this).attr("rel");
			// hide all content
			$("div#services-content div").each(function(){
				$(this).hide();
			});
			// show the selected content
			$("div#services-" + rel).show();
			// set the active class to correct link
			$(".services-active").removeClass("services-active");
			$(this).addClass("services-active");
		});
	});
	
	// video tabs
	
	$("div#showreel-tabs a").each(function(){
		$(this).click(function(){
			// get the id of the clicked tab
			var id = $(this).attr("id");
			//alert(id);
			$("#showreel-holder").html("");
			// check if the user is wanting downloads or not
			if(id != "Downloads")
			{
				$("#showreel-holder").flash(
					{ 
					  src: 'player.swf?file=lib/video/' + id + '.flv&amp;skin=nacht.swf&amp;autostart=true',
					  width: 423,
					  height: 250,
					  bgcolor: '#000000',
					  wmode: 'transparent'
					},
					{ version: 9 }
				);
			}
			else
			{
				var download = "<h3>Showreel <span class=\"blue\">Downloads</span></h3>";
				download += "<ul class=\"no-list-margin\">";
				download += "<li class=\"bold\">Compilation</li>";
				download += "<li><img src=\"img/icon-quicktime.gif\" class=\"icon\"> <a href=\"lib/video/CompositeShowReel.mov\">Quicktime</a> (.mov, 9.4MB) | <img src=\"img/icon-windows.gif\" class=\"icon\"> <a href=\"lib/video/CompositeShowReel.wmv\">Windows Media</a> (.wmv, 8.7MB)</li>";
				download += "</ul>";
				download += "<ul class=\"no-list-margin\">";
				download += "<li class=\"bold\">Corporate</li>";
				download += "<li><img src=\"img/icon-quicktime.gif\" class=\"icon\"> <a href=\"lib/video/CorporateShowReel.mov\">Quicktime</a> (.mov, 8.0MB) | <img src=\"img/icon-windows.gif\" class=\"icon\"> <a href=\"lib/video/CorporateShowReel.wmv\">Windows Media</a> (.wmv, 7.6MB)</li>";
				download += "</ul>";
				download += "<ul class=\"no-list-margin\">";
				download += "<li class=\"bold\">Docu-Drama</li>";
				download += "<li><img src=\"img/icon-quicktime.gif\" class=\"icon\"> <a href=\"lib/video/DocuDramaShowReel.mov\">Quicktime</a> (.mov, 9.9MB) | <img src=\"img/icon-windows.gif\" class=\"icon\"> <a href=\"lib/video/DocuDramaShowReel.wmv\">Windows Media</a> (.wmv, 9.5MB)</li>";
				download += "</ul>";
				$("#showreel-holder").html(download);
			}

			// set the active class to correct link
			$(".active-showreel").removeClass("active-showreel");
			$(this).addClass("active-showreel");
		});
	});
	
	// form validation
	
	$(document).ready(function(){
		$("#contact-form").validate();
	});
	
});
