// the dimensions of the videos
var width = 475
var height = 282

function playVimeo( url ) {
    
	var arrayURL= url.split("vimeo.com/");
	if (arrayURL)
	{
		var id = arrayURL[1];
	}			

	var html  = '';
	html += '<object width="'+width+'" height="'+height+'">';
    html += '<param name="allowfullscreen" value="true" />';
    html += '<param name="allowscriptaccess" value="always" />';
    html += '<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+id+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" />';
    html += '<embed src="http://vimeo.com/moogaloop.swf?clip_id='+id+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+width+'" height="'+height+'">';
    html += '</embed>';
    html += '</object>';
    
	$("#videoHolder").html(html);
	$(".imageHolder").hide();
	$("#videoHolder").show();
	
}

function playYouTubeVideo( url ) {

	var width = 475
	var height = 282	
	
	var arrayURL= url.split("=");
	if (arrayURL)
	{
		var id = arrayURL[1];
	}				

	var html  = '';
	html += '<object>';
	html += '<param name="movie" value="http://www.youtube.com/v/'+id+'"></param>';
	html += '<param name="height" value="'+height+'">';
	html += '<param name="width" value="'+width+'">';
	html += '<param name="autoplay" value="1">';
	html += '<param name="egm" value="0">';
	html += '<param name="wmode" value="transparent"></param>';
	html += '<embed height="'+height+'" width="'+width+'" src="http://www.youtube.com/v/'+id+'&autoplay=1&egm=0" type="application/x-shockwave-flash" wmode="transparent" ></embed>';
	html += '</object>';
	$("#videoHolder").html(html);
	$(".imageHolder").hide();
	$("#videoHolder").show();
	
}

function playFLVVideo( url ) {
	var html  = '';
	html += '<embed height="'+height+'" width="'+width+'" allowfullscreen="true" src="/flash/player.swf" flashvars="file='+url+'&autostart=true" type="application/x-shockwave-flash" wmode="transparent" ></embed>';
	$("#videoHolder").html(html);
	$(".imageHolder").hide();
	$("#videoHolder").show();
	
}

$(function()
{
	$(".videos a.vimeo").click(function() {
		playVimeo( $(this).attr("href") );
		return(false);
	});
	$(".videos a.youtube").click(function() {
		playYouTubeVideo( $(this).attr("href") );
		return(false);
	});
	$(".videos a.flv").click(function() {
		playFLVVideo( $(this).attr("href") );
		return(false);
	});
}
);
