// Flash detection
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;

if (plugin) {
	plugin = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 6;
} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))\n');
	document.write('</SCRIPT\> \n');
}

function ShowFlash(url, w, h, id, notWrite, noWmode) {
	html =  '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' +
		'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ';

	if(id != undefined) {
		html += 'id="'+id+'" ';
	}

	html += 'width="' + w + '" height="' + h + '">' +

		'<param name="movie"             value="'+url+'" />'+
		'<param name="allowScriptAccess" value="sameDomain" />'+
		'<param name="movie"             value="' + url + '">' +
		'<param name="menu"              value="false">' +
		'<param name="quality"           value="high">';

	if(noWmode == undefined) {
		html += '<param name="wmode"             value="transparent" />';
	}

	html += '<embed src="' + url + '" quality="high" menu="false" ' +
		'pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ' +
		'width="' + w + '" height="' + h + '"';

	if(noWmode == undefined) {
		html += ' wmode="transparent"';
	}

	html += '></embed>' +
		'</object>';

	if(notWrite === true)  {
		return html;
	}

	document.write(html);
}

function mainPromoVideoStart(path, title) {
	document.body.className = 'root veil video-banner';
	try {
		title = decodeURIComponent(escape(title))
	} catch (e) {
	}
	title = encodeURIComponent(title);
	document.getElementById('veil').innerHTML += ShowFlash('/i/video.swf?autoplay=true&videopath='+path+'&videotitle='+title, 410, 400, 'videoBanner', true);
}

function mainPromoVideoHide() {
	var veil = document.getElementById('veil');
	var object = veil.getElementsByTagName('object')[0];
	veil.removeChild(object);

	document.body.className = 'root';

	var imgs = veil.getElementsByTagName('img');
	for(var i =0; i <imgs.length; i++) {
		var element = imgs[i];

		if(element.parentNode.parentNode !== veil) {
			return;
		}

		element.src = '/i/v.gif';
		element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + element.realSrc + "', sizingMethod='scale')";
	}

}
