$(document).ready(function(){ 
	if ($('#player').length >0){
		flowplayer("player", "flowplayer-3.2.0.swf");
	}
	if ($('#videolist').length >0){
		
		$.ajax({ type: "POST",  
		 url: "widgets/gallery/remote.asmx/GetInformationMultipleByPathXml",  
		 dataType: "xml",  
		 data: "Path=/files/Videos/"+$("#pagename").text(),  
		 processData: false,  
		 error: function(XMLHttpRequest, textStatus, errorThrown) { ajaxError(XMLHttpRequest,textStatus, errorThrown); },  
		 success: function(xml) { ajaxFinish(xml); }  
		}); 
		
		function ajaxFinish(xml)  
		{  
		   $("#videolist").append("<div id='videos'>");
		 
		   $("File", xml).each(function()  
   			 {  
				 name = $("Name", this).text();  
				 //description = $("Description", this).text();  
				 size = $("Size", this).text();  
				 path = $("Path", this).text();
				 
				 newName=name.split(".flv");
				 
				 $("#videos").append("<a href='"+path+"'>"+newName[0]+"</a>");

		     });  
			 $("#videos").append("</div>");
			 
			 initVid();
		   	
		 }  
   
		 function ajaxError(xmlObj,textStatus,errorThrown)  
		 {  
			 // Comment this out for live environments, and put a friendly error message  
			 alert("(Ajax error: "+txt+")");  
			 alert(request.responseText);  
		 }
		
		
		function initVid(){
			$('#videos a:last-child').addClass("lastchild");
			
			$f("player2", "flowplayer-3.2.0.swf").playlist("#videos", {loop:false});
		}

	}
	
	if ($('#player3').length >0){
		flowplayer("player3", "flowplayer-3.2.0.swf");
	}
	
	
	$('#utilities li:last-child').addClass("lastchild");
	
	
	 $("#header h2 a").click(function (event) {
		 $("#quicklinks-area").slideToggle("slow");
		 event.preventDefault();
	 });
}); 