//===============================================================================
//	Copyright © The NewsMarket Inc. All rights reserved.
//===============================================================================
//	Player Detection and Play
//===============================================================================


// initialize global variables
//var detectableWithVB = true;	// Do we need VBScript
var QT = 2;
var WMP = 1;


function isValidPlayerType(playerType)
{
	return WMP == playerType || QT == playerType;
}

/////////////////////////////////////////////////

function embedQT(src,shouldAutoPlay,width,height)
{
	return ('<EMBED SRC="'+ src + '" WIDTH="' + width + '" HEIGHT="' + height + '" SCALE="TOFIT" SHOWSTATUSBAR="1" SHOWCONTROLS="1" AUTOPLAY="' + shouldAutoPlay + '" CACHE="false" LOOP="false" transparentatStart="false"/>');
}

function embedWMP(src,shouldAutoPlay,width,height)
{
	return '<embed name="player" id="player" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/" type="application/x-mplayer2"  width="' + width + '" height="' + height + '" ShowControls="1" ShowDisplay="0" ShowStatusBar="0" autostart="' + shouldAutoPlay  + ' autorewind="0" ShowPositionControls="0" ShowTracker="1" src="' + src + '" transparentatStart="false">  </embed>'

}

//TODO: Show error message
function embedImage(width,height,src,title, clicklinksrc)
{
	
	var bShowLink = isValid(clicklinksrc);
	if (bShowLink)
	{
		retString = '<a href="' + clicklinksrc + '" title="' + title + '">';
	}	
	
	retString = retString + '<img id="flasherrorimg" border="0" title"' + title + '" src="' + src + '" WIDTH="' + width + '" HEIGHT="' + height + '">' + (bShowLink ? '</a>' : '');
	
	
	return retString; 

}



function embedNonFlash(srcWMV,srcQT,shouldAutoPlay,width,height,playerType,largeRep)
{
	var retVal = null;
	if (null != playerType && isValidPlayerType(playerType))
	{
		var isValidQTsrc = isValid(srcQT);
		var isValidWMVsrc = isValid(srcWMV);
		
		var finalPlayerType = null;
		if (WMP == playerType) 
		{
			if(isValidWMVsrc)
			{
				finalPlayerType = WMP;
			}
		}
		else if (QT == playerType) 
		{
			if(isValidQTsrc)
			{
				finalPlayerType = QT;
			}
		}
		
		if(QT == finalPlayerType)
		{
			retVal = embedQT(srcQT,shouldAutoPlay,width,height);
				
		}
		else if (WMP == finalPlayerType)
		{
			retVal = embedWMP(srcWMV,shouldAutoPlay,width,height);
				
		}
		else // preview file missing
		{
			retVal = embedImage(width,height,strjsImagePath + "missingFile.gif","Preview file is temporarily unavailable."," ");
		}
	}
	else //plugin missing
	{
		retVal = embedImage(width,height,strjsImagePath + "missingPlugin.jpg","Please click here to install the latest Adobe Flash player","http://www.adobe.com/go/getflashplayer");
	}
	
	return retVal;
}

function embedFlash()
{
	{
		document.write('<DIV id="divGatewayMPP" style="visibility: visible; z-index:1; fixMozillaZIndex=false;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="545" height="335" id="most_popular" align="middle" valign="top">' + 
					   '<param name="allowScriptAccess" value="sameDomain" />' + 
					   '<param name="movie" value="' + strSWFPath + 'most_popular.swf?xmlLoc=' + url + '" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent"/><embed src="' + strSWFPath + 'most_popular.swf?xmlLoc=' + url + '" quality="high" bgcolor="#ffffff" width="545" height="335" name="most_popular" align="middle" valign="top" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" wmode="transparent" />' + 
					   '</object></DIV>');
	}
}


