/*
*	CRM Video Templates
*	Version 1.0.1
*	11-01-2007 
*/

if (typeof crm == "undefined") { var crm = {}; }
if (typeof crm.util == "undefined") { crm.util = {}; }
if (typeof crm.util.VidUtil == "undefined") {
	crm.util.VidUtil = {
		openPlayer: function(src, caption, w, h, a) {
			//	prevent Safari pre-3
			if (typeof navigator.vendor != "undefined" && navigator.vendor.indexOf("Apple") > -1) {
				var strVersion = navigator.appVersion;
				var strVersion = strVersion.match(/AppleWebKit\/([0-9]{3}(\.[0-9]{1,2})*)/gi);
				var numVersion = parseInt(strVersion[0].substr(12, 3), 10);
				if (typeof numVersion == "number" && numVersion < 500) {
					alert("We're sorry but Safari 3 or higher is required to view this content.");
					return;
				}
			}
			//	create crm_flv_layer if !exist
			if (!document.getElementById("crm_flv_layer")) {
				//	add iframe hack to cover form elements -- IE 6
				/*@cc_on @*/
				/*@if (@_jscript_version < 5.7)
					flv_modal_hide_select = document.body.appendChild(document.createElement("iframe"));
					flv_modal_hide_select.id = "flv_modal_hide_select";
				/*@end @*/
				//	set flash player to correct size (based on video size)
				var playerBgW = w + 40;
				var playerBgH = h + 90;
				//	get browser dimensions for IE 6 hack
				var browserDim = {};
				/*@cc_on @*/
				/*@if (@_jscript_version < 5.7)
					browserDim = this.getBrowserDim();
				/*@end @*/
				//	add wrapper
				var crm_flv_layer = document.body.appendChild(document.createElement("div"));
				crm_flv_layer.id = "crm_flv_layer";
				var script_elem = document.body.appendChild(document.createElement("script"));
				script_elem.type = "text/javascript";
				script_elem.id = "script_elem";
				//	set bg alpha
				var playerBgAlpha = a;
				// CHANGE THIS TO CORRECT URL ON SEAGATE SITE
				script_elem.text = 'var so = new SWFObject("video_template.swf", "crm_video_player", "100%", "100%", "8"); so.addParam("wmode", "transparent"); so.addVariable("lang", "en-US"); so.addVariable("flv_src", "' + src + '"); so.addVariable("caption", "' + caption + '"); so.addVariable("ie6StageWidth", "' + browserDim.width + '"); so.addVariable("ie6StageHeight", "' + browserDim.height + '"); so.addVariable("flv_width", "' + w + '"); so.addVariable("flv_height", "' + h + '"); so.addVariable("player_width", "' + playerBgW + '"); so.addVariable("player_height", "' + playerBgH + '"); so.addVariable("bg_alpha", "' + playerBgAlpha + '"); so.write("crm_flv_layer")';
				document.getElementById("crm_video_player").focus();
			}
		},
		getBrowserDim: function() {
			var w = 0, h = 0;
			if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				//IE 6+ in 'standards compliant mode'
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				//IE 4 compatible
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			}
			return { width:w, height:h };
		},
		closePlayer: function() {
			document.getElementById("crm_flv_layer").style.display = "none";
			setTimeout(function() {
				document.body.removeChild(document.getElementById("crm_flv_layer"));
				document.body.removeChild(document.getElementById("script_elem"));
				/*@cc_on @*/
				/*@if (@_jscript_version < 5.7)
					document.body.removeChild(document.getElementById("flv_modal_hide_select"));
				/*@end @*/
			}, 100);
		}
	};
}

