/*
getSummerVideo
*/

function getVideoParams(strParam) {

//get the params of the url		

	//var paramsBrut = strParam.search.substring(1).split('&');
	var params = strParam.split('?');
	var paramsDeta = new Object();	
	
	if(params.length>1) {
		var paramsBrut = params[1].split('&');

		paramsBrut.each(

			function(i, a) {

				var _a = a.split('=');

				paramsDeta[_a[0]] = _a[1];

			}

		);
		paramsDeta.video = params[0];
		return paramsDeta;
	}


}

function summerVideo() {
	var id = 'videoBox';
	var file = E('vidFile').href;
	var userParams = getVideoParams(file);
	var params = {
		wmode	: 'transparent',
		bgcolor	: '#FFF',
		menu	: "false",
		scale	: "noScale",
		align	: "tl"
	};

	var vars = {
		//videoWidth: userParams.width || null,
		//videoHeight: userParams.height || null,
		video: userParams.video || file,
		autoSize: userParams.autoSize || true,
		ratio: userParams.ratio || '16/9',
		autoStart: true
	}
	
	//~ var swf = /^http:\/\/www\.youtube\.com/.test(file) ? file : './--swf--/VideoPlugin.swf';
	//~ swf = /^http:\/\/www\.dailymotion/.test(file) ? file : swf;
	//~ swf = /^http:\/\/www\.vimeo/.test(file) ? file : swf;
	
	var swf = /^http:\/\/(www\.)?(youtube|dailymotion|vimeo)/.test(file) ? file : './--swf--/VideoPlugin.swf';
	
	var w = userParams.width  || '100%';
	var h = userParams.height || '100%';
	swfobject.embedSWF(swf, id, w, h, "9.0.0", "expressInstall.swf", vars, params);
	if(h!='100%')
		E('videoBox').style.height = h;
	//~ swfobject.embedSWF(swf, id, '100%', '100%', "9.0.0", "expressInstall.swf", vars, params);
	//~ swfobject.embedSWF(swf, id, 640, 480+15, "9.0.0", "expressInstall.swf", vars, params);
	
}


	
Event.add(window, 'load', summerVideo);
