// JavaScript Document

// get all links that are inside div#clips
var links1 = document.getElementById("clips1").getElementsByTagName("a");
// get all links that are inside div#clips
var links2 = document.getElementById("clips2").getElementsByTagName("a");
// get all links that are inside div#clips
var links3 = document.getElementById("clips3").getElementsByTagName("a");


// Flowplayer installation with Flashembed parameters
$f("player", {

	// our Flash component
	src: "/wp-content/flowplayer/flowplayer-3.1.5.swf",

	// we need at least this version
	version: [9, 115],
	
	// older versions will see a custom message
	onFail: function()  {
		document.getElementById("noFlashContent").style.display = "block";
		document.getElementById("noFlashContent").innerHTML =
			"You need the latest Flash version to view our videos. " +
			"Your version is " + this.getVersion()
		;
	}

	// here is our third argument which is the Flowplayer configuration
}, {
	clip:{ 
	
	//set initial video here
		url:links1[0].getAttribute("href", 2),
        autoPlay: false,
        autoBuffering: true

	}
	
});



// loop those links and alter their click behaviour
for (var i = 0; i < links1.length; i++) {
	links1[i].onclick = function() {
		
		// play the clip specified in href- attribute with Flowplayer
		$f().play(this.getAttribute("href", 2));
		
		// by returning false normal link behaviour is skipped
		return false;
	}
}


// loop those links and alter their click behaviour
for (var i = 0; i < links2.length; i++) {
	links2[i].onclick = function() {
		
		// play the clip specified in href- attribute with Flowplayer
		$f().play(this.getAttribute("href", 2));
		
		// by returning false normal link behaviour is skipped
		return false;
	}
}


// loop those links and alter their click behaviour
for (var i = 0; i < links3.length; i++) {
	links3[i].onclick = function() {
		
		// play the clip specified in href- attribute with Flowplayer
		$f().play(this.getAttribute("href", 2));
		
		// by returning false normal link behaviour is skipped
		return false;
	}
}

var $j = jQuery.noConflict();

	



$j(document).ready(function(){
						
	$j("#clips1 a").click(function(){
	
		var largePath = $j(this).attr("href");
		var largeAlt = $j(this).attr("title");
		
		$j("#video_caption").attr({ src: largePath, alt: largeAlt });
		
		$j("#video_caption p").html(largeAlt); return false;
	});
	
	$j("#clips2 a").click(function(){
	
		var largePath = $j(this).attr("href");
		var largeAlt = $j(this).attr("title");
		
		$j("#video_caption").attr({ src: largePath, alt: largeAlt });
		
		$j("#video_caption p").html(largeAlt); return false;
	});
	
	$j("#clips3 a").click(function(){
	
		var largePath = $j(this).attr("href");
		var largeAlt = $j(this).attr("title");
		
		$j("#video_caption").attr({ src: largePath, alt: largeAlt });
		
		$j("#video_caption p").html(largeAlt); return false;
	});
	
});
