// Master JavaScript Document

var strVideoImage;
var strCloseButton;

$(document).ready(function(){
	// Cufon replacement
	Cufon.replace('h1', { fontSize: '22px' });
	Cufon.replace('.home h2', { fontSize: '16px' });
	Cufon.replace('.home h3', { fontSize: '16px' });
	Cufon.replace('#main #content #col3 h5', { fontSize: '16px' });
	Cufon.replace('#main #content #col2 dl dt', { fontSize: '16px' });
	Cufon.replace('#main #content #col2 div.eaep h2', { fontSize: '16px' });
	Cufon.replace('#main #content #col2 div.downloads h2', { fontSize: '16px' });
	Cufon.replace('#main .invest  #col2 ul li a', { fontSize: '15px' });
	
	//external links
	$("a[rel=external]").attr('target', '_blank');
	
	//video
	var strFlashMessage = "<div id=\"theVideo\"></div>";
	
	$("a.play").click(function() {
		strVideoImage = $("#videoHolder").html();
		strCloseButton = "<img class=\"close\" src=\"images/global/btn-close.gif\" alt=\"Close video\" title=\"Close video\" width=\"20\" height=\"19\" />";
		$("#video").html(strCloseButton + $("#video").html());	
		fncVideoClose();
		$("#videoHolder").html(strFlashMessage);
		$("#video").addClass("playing");
		$(this).parents().find("a.play").show();
		$("p.video").hide();
		var flashvars = {
			//file: "test.flv"
		}; 
		var params = { 
			wmode: "transparent",
			allowfullscreen: true,
			bgcolor: "#000000"
		};
		var attributes = { }; 
		
		swfobject.embedSWF("video.swf?" + $(this).attr("href").replace("fusion-video.php?", ""), "theVideo", "495", "278", "9.0.0", "", flashvars, params, attributes);												 

		return false;	
	});
});

function fncVideoClose() {
	$("#video img.close").click(function() {
		$("#video").removeClass('playing');
		$(".close").replaceWith("");
		$("p.video").show();
		$("#videoHolder").html(strVideoImage);
		return false;	
	});
}

function fncVideoAutoClose() {
	$("#video img.close").click(); //auto close player
}
