$(document).ready(function(){ 
     $("#footer_nav li:first").addClass("first");
    	 $('#handle').click(function(){
       $('#item-wrap').slideToggle("medium");
       return false;
     });

        $("#get_connected ul").each(function(){$(this).find("li:first").addClass("first");});
 		 $("#resources_nav li:last").addClass("last").find("a").wrapInner("<strong></strong>");
        

	 //function to generate new player with video & preview image selected
	 function loadFlash(obj){ 
		$this = obj;
		
           $('#home_features_hero').fadeOut(function(){
              
              $("#flash").html("").append("<div id='swf'></div>");
		   //$("#flash").html(""); 
		    var flashvars = {};
      		    flashvars.file = $this.data('video');
      		    flashvars.image = $this.data('image');
      		    flashvars.width = 333;
          		flashvars.height = 189;
          		flashvars.fullscreen = "true";
          		flashvars.controlbar = "over";
          		flashvars.stretching = "uniform";
          		flashvars.skin = "/flash/default.swf";
          		flashvars.fullscreen = "false";
          		var params = {};
          		params.base = ".";
          		params.bgcolor = "#000000";
          		params.wmode = "transparent";
          		params.allowfullscreen = "true";

          		swfobject.embedSWF("/flash/player.swf", "swf", "333", "189", "9.0.0", false, flashvars, params); 
          		
          		//$("#flash").load("/includes/html5video.php",{name:$this.data('title'),url:$this.data('video'),image:$this.data('image')}); 
		 
		    $(this).show();
		});  
	   }     
		
	 $(".col_b ul").load("/includes/home-videos.php",function(){
	      $("#videos ul li").each(function(){
			  $this = $(this);
			  $this.data({video: $this.attr("id"), image:$this.find("img").attr("src"), title:$this.find("strong").text()});
		});

		//click event to load video clicked
		$("#videos ul li").click(function(){ 
			   $this = $(this);
			   $("#videos ul li.off").removeClass("off").fadeIn();  
			   $this.addClass("off").hide();
			   loadFlash($this);
			   //$('#home_features_hero').fadeOut(function(){loadFlash($this);});
			   $("#videos .subtitle").text($this.data('title'));
			});

		//randomly selects one of the videos to be displayed as video if default is not specified
		if($("#videos ul li.default").length < 1){
		    //var initVid =  $("#videos ul li").eq(rand); 
			var rand=Math.floor(Math.random()*3);
		    $("#videos ul li").eq(rand).addClass("default");
		}
		//removes video that will show in player as default and fades side videos up
		$("#videos ul li:not('.default')").hide().removeClass("off").fadeIn("normal");
		//loads initial videos  
		loadFlash($("#videos ul li.default"));
		$("#videos .subtitle").text($("#videos ul li.default").data('title'));
	     
	     
	 });   
		
	 //sets data variables for video image & video url
	  
	
   }); 