function _FixIEController(element)
{
	if(navigator.appName != "Microsoft Internet Explorer")
		return;

	var movieObj = element.lastChild;

	if(!movieObj.GetControllerVisible());
		setTimeout( function() { movieObj.SetControllerVisible(true); }, 100);
}

function _FixOperaOpacity(element)
{
	if(navigator.appName != "Opera")
		return;

	element.style.opacity = "1.0";
}

function QT_ReplaceWithPoster()
{
      var args = Array.prototype.slice.call(arguments);
      var clickText = args.shift();
      var posterSrc = args.shift();
      var element = args.shift();
      var src = args[0];
      var width = args[1];
      var height = args[2];

		if (navigator.platform.indexOf('iPhone') > -1) 
		{
 			QT_ReplaceElementContents(element, 
        posterSrc,
				width, height, '',
				'href', src,
				'target', 'myself',
				'controller', 'false', 
				'autoplay', 'true', 
				'scale', 'aspect');
		}
		else
		{
			element.style.position = 'relative';
			element.style.width = width + 'px';
			element.style.height = height + 'px';
			element.style.textAlign = 'center';
			element.style.backgroundImage = 'url(' + posterSrc + ')';
			element.style.backgroundRepeat = 'no-repeat';
			element.style.backgroundPosition = 'top center';
      element.args = args;

			var play = element.appendChild(document.createElement('span'));
			play.innerHTML = clickText;
			play.className = 'playButton';
			_FixOperaOpacity(play);

			element.onclick = function() { 
        element.onclick = '';
        play.style.display = 'none';
        var playBackground = element.appendChild(document.createElement('div'));
        playBackground.className = 'playBackground';
        playBackground.style.opacity = '0';
        playBackground.style.width = element.style.width;
        playBackground.style.height = element.style.height;

        var intervalId = setInterval(function() {
          var opacity = parseFloat(playBackground.style.opacity);
          opacity = Math.min(1.0, opacity + 0.2);
          playBackground.style.opacity = opacity;
          playBackground.style.filter = 'alpha(opacity='+(opacity*100)+')';
          }, 25);


        setTimeout(function() {
            clearInterval(intervalId); 
            element.style.backgroundImage = '';
            element.style.backgroundColor = 'rgb(0,0,0)';
            playBackground.style.opacity = '1.';
            playBackground.style.filter = 'alpha(opacity=100)';

            var	txt = _QTGenerate("QT_WriteOBJECT_XHTML", true, args);
            if(txt.length > 0)
              element.innerHTML = txt;

              _FixIEController(this);
          }, 250);
      }
		}
}

function QT_WritePoster_XHTML()
{
	var args = Array.prototype.slice.call(arguments);
	var clickText = args.shift();
	var posterSrc = args.shift();
	var src = args[0];
	var width = args[1];
	var height = args[2];

	if (navigator.platform.indexOf('iPhone') > -1) 
	{
		QT_WriteOBJECT_XHTML( posterSrc,
			width, height, '',
			'href', src,
			'target', 'myself',
			'controller', 'false', 
			'autoplay', 'true', 
			'scale', 'aspect');
	}
	else
	{
		var id = 'qtp_poster_div_id_' + Math.random();
		document.writeln('<div id="'+id+'"></div>');
		var element = document.getElementById(id);
		element.id = '';
		element.style.position = 'relative';
		element.style.width = width + 'px';
		element.style.height = height + 'px';
		element.style.textAlign = 'center';
		element.style.backgroundImage = 'url(' + posterSrc + ')';
		element.style.backgroundRepeat = 'no-repeat';
		element.style.backgroundPosition = 'top center';

		var play = element.appendChild(document.createElement('span'));
		play.innerHTML = clickText;
		play.className = 'playButton';
		_FixOperaOpacity(play);

		element.onclick = function() { 
			element.onclick = '';
			play.style.display = 'none';
			var playBackground = element.appendChild(document.createElement('div'));
			playBackground.className = 'playBackground';
			playBackground.style.opacity = '0';
			playBackground.style.width = element.style.width;
			playBackground.style.height = element.style.height;

			var intervalId = setInterval(function() {
			var opacity = parseFloat(playBackground.style.opacity);
			opacity = Math.min(1.0, opacity + 0.2);
			playBackground.style.opacity = opacity;
			playBackground.style.filter = 'alpha(opacity='+(opacity*100)+')';
			}, 25);


			setTimeout(function() {
				clearInterval(intervalId); 
				element.style.backgroundImage = '';
				element.style.backgroundColor = 'rgb(0,0,0)';
				playBackground.style.opacity = '1.';
				playBackground.style.filter = 'alpha(opacity=100)';

				var txt = _QTGenerate("QT_WriteOBJECT_XHTML", true, args);
				if(txt.length > 0)
				element.innerHTML = txt;

				_FixIEController(element);
			}, 250);
		}
	}
}

