/* Declares global variables used by All SiteManagers */

//--------------------------------------
// Global vars
//--------------------------------------

//added for doubleclick bug number 3947
var thumbnailURL = ''; 
var titleDate = ''; 
var albumName = ''; 
var artistFirstName = ''; 
var artistLastName = ''; 
var channelName = ''; 
var channelUrl = ''; 
var recordLabelName = ''; 
var titleAltId = ''; 
var category = ''; 
var titleId = ''; 
var titleName = ''; 
var titleSupplierCode = ''; 
var thumbnailFileName = ''; 
var syndicationPreference = ''; 
var titleBitrate = ''; 
var titleFormat = ''; 
var channelUrl = ''; 
var displayChannel = ''; 
var thumbnailHeight = ''; 
var thumbnailWidth = ''; 
var titleUrl = ''; 
var relatedLink = ''; 
var relatedLinkName = '';
//end of added for doubleclick bug number 3947

var _g6V=1
var _g6CurrChannel='';
var _g6PlayListChannel='';
var _g6CurrClipId='';
var _g6CurrBitrate=300;
var _g6CurrFormat='wmp';
var _g6CurrAdList='';
var _g6CurrClipCount=0;
var _g6XMLResult='';
var _g6AdsArray = new Array(5);
var _g6MediaFormat ='wmp';
var _g6SiteId =''; //GUID
var _g6SiteIdInt = '' //Integer
var _g6SearchCriteria ='';
var _g6LastLoggedClipId='';
var _g6LastLoggedClipIdROO=''; //for roo tracking
var _g6LastLoggedClipIdWT=''; //for wt tracking
var _g6LastLoggedAdId='';
var _g6StartPlayerOnLoad=false;
var _g6PlayerIsLoaded=false;
var _g6ActiveClip = new Object();
	_g6ActiveClip.ClipId='';
	_g6ActiveClip.Title='';
	_g6ActiveClip.Description='';
	_g6ActiveClip.Channel='';
	_g6ActiveClip.Type='video';
	_g6ActiveClip.Category=''; //Added by GM
	//tarun -- MasterIMUAdCall property that will hold the IMUADCall
	_g6ActiveClip.MasterIMUAdCall='';
	
	//Added by Ravi for the issue 1268 start
	_g6ActiveClip.ThumbnailURL=''
	_g6ActiveClip.TitleDate='';
	_g6ActiveClip.AlbumName='';
	_g6ActiveClip.ArtistFirstName='';
	_g6ActiveClip.ArtistLastName	='';
	_g6ActiveClip.ChannelName='';
	_g6ActiveClip.ChannelUrl='';
	_g6ActiveClip.RecordLabelName='';
	_g6ActiveClip.TitleAltId='';
	_g6ActiveClip.Category='';
	_g6ActiveClip.TitleId='';
	_g6ActiveClip.TitleName='';
	_g6ActiveClip.TitleSupplierCode='';
	_g6ActiveClip.ThumbnailFileName='';
	_g6ActiveClip.SyndicationPreference='';
	_g6ActiveClip.TitleBitrate='';
	_g6ActiveClip.TitleFormat='';
	_g6ActiveClip.ChannelUrl='';
	_g6ActiveClip.DisplayChannel='';
	_g6ActiveClip.ThumbnailHeight='';
	_g6ActiveClip.ThumbnailWidth='';
	_g6ActiveClip.TitleUrl='';
	_g6ActiveClip.RelatedLink='';
	_g6ActiveClip.RelatedLinkName='';
	//Added by Ravi for the issue 1268 End


var _g6ChannelSurf = new Object();
	_g6ChannelSurf.Channel='';
	_g6ChannelSurf.Criteria='';
	_g6ChannelSurf.SearchType='';
	_g6ChannelSurf.PlayListType='';
var _g6ClipPublisher;
var _g6Referrer=window.document.referrer;
var _g6ScAr = new Array();
var _g6PrevChannel = '';
var _g6PrevChannelClick = '';
var _g6PrevChannelChanged = false;
//For Bw sniffing
var _g6DetectedBandwidth=0;
var _g6BandwidthDetected=true;

//GENERIC HTTP REQUEST OBJECT
/*
var xmlhttp;
if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest()}
else if (window.ActiveXObject){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}
*/
var _xmlCtrlId;

//PUBLISHERS
function publisher(aValue){this.mValue = aValue;inheritFrom(this, new CSimpleObservable());}
publisher.prototype.get = function(){  return this.mValue;}
publisher.prototype.set = function(aValue){  this.mValue = aValue;  this.notify(this);}
_g6ClipPublisher = new publisher(_g6ActiveClip);
_g6ChannelSurfPublisher = new publisher(_g6ChannelSurf);


//SET ACTIVE CHANNEL
function G6_SetActiveChannel(value){
if(typeof(value)!='undefined'){
_g6ActiveClip.Channel=value;
_g6CurrChannel=value;}
}

//SET ACTIVE CLIPID
function G6_SetActiveClipId(value){
	if(typeof(value)!='undefined'){
		
		_g6ActiveClip.ClipId=value;

/*
		//Quick hack fix added kdw in some cases here _g6ActiveClip.Type is undefined
		//need to find out why
		if(typeof(_g6ActiveClip.Type)=='undefined')
		{
			_g6ActiveClip.Type='video'	
		}
		// Fixed RY
*/
		_g6CurrClipId=value;
		
		//testing changed video event logging
		//if (_g6ActiveClip.Type != "Ad")
		if (_g6PrevChannelChanged == false) {
			if (_g6ActiveClip.ClipId != "undefined") if (_g6ActiveClip.ClipId != "") if (_g6ActiveClip.ClipId != null) {
				G6_CallTracker('view_' + _g6ActiveClip.Type.toLowerCase() + '_changed');
				if (_g6ActiveClip.Type.toLowerCase() == "video")
					_g6PrevChannelChanged = true;
			}
		}
		
		else if (_g6PrevChannelChanged == true)
		{
			_g6PrevChannelChanged = false
			//alert("reseting: " + _g6PrevChannelChanged);
		}
		
	}
}

//SET ACTIVECLIP OBJECT
//function G6_SetActiveClip(clipId,clipTitle,clipDescr,clipType,clipCategory){
function G6_SetActiveClip(clipId,clipTitle,clipDescr,clipType,clipCategory){
_g6ActiveClip.ClipId=clipId;
_g6ActiveClip.Title=clipTitle;
_g6ActiveClip.Description=clipDescr;
_g6ActiveClip.Type=clipType;
_g6ActiveClip.Category=clipCategory;
}
//tarun -- added a new clipMasterAdCall
function G6_SetActiveClip(clipId,clipTitle,clipDescr,clipType,clipCategory,clipMasterAdCall){
_g6ActiveClip.ClipId=clipId;
_g6ActiveClip.Title=clipTitle;
_g6ActiveClip.Description=clipDescr;
_g6ActiveClip.Type=clipType;
_g6ActiveClip.Category=clipCategory;
}
//tarun -- added a new clipMasterAdCall
function G6_SetActiveClip(clipId,clipTitle,clipDescr,clipType,clipCategory,clipMasterAdCall){
_g6ActiveClip.ClipId=clipId;
_g6ActiveClip.Title=clipTitle;
_g6ActiveClip.Description=clipDescr;
_g6ActiveClip.Type=clipType;
_g6ActiveClip.Category=clipCategory;
_g6ActiveClip.MasterIMUAdCall=clipMasterAdCall;

}

//Added by Ravi for the issue 1268...

function G6_SetActiveClip(clipId,clipTitle,clipDescr,clipType,clipCategory,clipMasterAdCall,thumbnailURL,titleDate,albumName,artistFirstName,artistLastName,channelName,channelUrl,recordLabelName,titleAltId,category,titleId,titleName,titleSupplierCode,thumbnailFileName,syndicationPreference,titleBitrate,titleFormat,channelUrl,displayChannel,thumbnailHeight,thumbnailWidth,titleUrl,relatedLink,relatedLinkName){
_g6ActiveClip.ClipId=clipId;
_g6ActiveClip.Title=clipTitle;
_g6ActiveClip.Description=clipDescr;
_g6ActiveClip.Type=clipType;
_g6ActiveClip.Category=clipCategory;
_g6ActiveClip.MasterIMUAdCall=clipMasterAdCall;
//Ravi added
_g6ActiveClip.ThumbnailURL=thumbnailURL;
_g6ActiveClip.TitleDate=titleDate;
_g6ActiveClip.AlbumName=albumName;
_g6ActiveClip.ArtistFirstName=artistFirstName;
_g6ActiveClip.ArtistLastName =artistLastName;
_g6ActiveClip.ChannelName=channelName;
_g6ActiveClip.ChannelUrl=channelUrl;
_g6ActiveClip.RecordLabelName=recordLabelName;
_g6ActiveClip.TitleAltId=titleAltId;
_g6ActiveClip.Category=category;
_g6ActiveClip.TitleId=titleId;
_g6ActiveClip.TitleName=titleName;
_g6ActiveClip.TitleSupplierCode=titleSupplierCode;
_g6ActiveClip.ThumbnailFileName=thumbnailFileName;
_g6ActiveClip.SyndicationPreference=syndicationPreference;
_g6ActiveClip.TitleBitrate=titleBitrate;
_g6ActiveClip.TitleFormat=titleFormat;
_g6ActiveClip.ChannelUrl=channelUrl;
_g6ActiveClip.DisplayChannel=displayChannel;
_g6ActiveClip.ThumbnailHeight=thumbnailHeight;
_g6ActiveClip.ThumbnailWidth=thumbnailWidth;
_g6ActiveClip.TitleUrl=titleUrl;
_g6ActiveClip.RelatedLink=relatedLink;
_g6ActiveClip.RelatedLinkName=relatedLinkName;
}

///Added by Ravi for the issue 1268 end...






//SET VIDEO TITLE INFO
function G6_SetVideoTitleInfo(clipTitle,clipDescr){
_g6ActiveClip.Title=clipTitle;
_g6ActiveClip.Description=clipDescr;
_g6ClipPublisher.set(_g6ActiveClip);
}

//SET VIDEO TITLE TO CHANNEL
function G6_SetVideoTitleInfoToChannel(clipId,channel){
_g6ActiveClip.ClipId=clipId; _g6ActiveClip.Channel=channel; _g6ActiveClip.Title='You are now watching'; _g6ActiveClip.Description=channel;
_g6ActiveClip.Type='Video';
_g6ClipPublisher.set(_g6ActiveClip);
}

//G6_CHANNELSURF FOR SURFING CHANNELS
function G6_ChannelSurf(channel,criteria,searchType,playListType){
if(typeof(channel)!='undefined' && channel!='') {

	// trigger G6_CallTracker for tracking	
	if (_g6ChannelSurf.Channel != channel) // TODO: find out a way to prevent logging when a channel menu item is clicked and a top10 is clicked in the same channel
		G6_CallTracker("surf_channel", channel); //tracking -- added criteria for the channel being viewed	
	
	//-- Set the channel now
	_g6ChannelSurf.Channel=channel;
}
if(typeof(criteria)!='undefined') {_g6ChannelSurf.Criteria=criteria;} else{ _g6ChannelSurf.Criteria='';}
if(typeof(searchType)!='undefined'){ _g6ChannelSurf.SearchType=searchType;} else{ _g6ChannelSurf.SearchType='';}
if(typeof(playListType)!='undefined'){ _g6ChannelSurf.PlayListType=playListType;} else {_g6ChannelSurf.PlayListType='';}
_g6ChannelSurfPublisher.set(_g6ChannelSurf);
//log the previous channel so we don't keep logging a channel change when in the same channel
_g6PrevChannel = _g6CurrChannel;
_g6PrevChannelClick = channel;
}

//G6_CHANNELSURFMUSIC FOR SURFING MUSIC CHANNELS
function G6_ChannelSurfMusic(){G6_ChannelSurf('','','','Music');}
function G6_LoadPlayList(channel,criteria, searchType){
G6_ChannelSurf(channel,criteria,searchType,'Standard');
}

//G6_LOADMUSICPLAYLIST FOR LOADING MUSIC PLAYLIST
function G6_LoadMusicPlayList(channel,criteria, searchType){
G6_ChannelSurf(channel,criteria,searchType,'Music');
}


//G6_ONSTARTPLAYEREVENT
function G6_OnStartPlayerEvent(queryString){
	if(_g6PlayerIsLoaded)
	{
		try
		{			
			G6_StartPlayer(queryString); 
			_g6StartPlayerOnLoad=false;
		}
		catch(e)
		{
			_g6StartPlayerOnLoad=true;
		}
	}	
	else 
	{
	_g6StartPlayerOnLoad=true;
	}
}

//G6_ONPLAYERLOADEDEVENT
function G6_OnPlayerLoadedEvent(){
	if(!_g6BandwidthDetected){
		_g6PlayerIsLoaded=false;
	}
	else{
		_g6PlayerIsLoaded=true;
	}
	if((typeof(G6_ReloadAds)=='undefined') || (_g6StartPlayerOnLoad))
		G6_ThumbClick(_g6CurrClipId,_g6CurrChannel);
}


//-------------------------------------------------------------------------------
//create authentication function to authenticate channels on channel change -kdw
//-------------------------------------------------------------------------------
AuthorizeChannel_onChange=function(aValue){G6_AuthorizeChannel(aValue.get().Channel);}
var AuthorizeChannel_Observer={observe: AuthorizeChannel_onChange };
_g6ChannelSurfPublisher.addObserver(AuthorizeChannel_Observer);

function G6_AuthorizeChannel(channel, clipIdParam){

	var CKNAME; //defined below
	
	//If authorization array does not exist, return.
	if(typeof(channel)=='undefined' || typeof(_g6SCAuthArray)=='undefined' || typeof(_g6SCAuthArray)=='null' || typeof(_g6SCAuthArray[channel])=='undefined')
		return true;
	
	var clipId = "";  //TODO
	
	if(typeof(clipIdParam)!='undefined'){
		clipId=clipIdParam;
	}
	
	//Split value from array into two components channelid and authcode
	var valArray	= _g6SCAuthArray[channel].split(':');
	var channelId	= valArray[0];
	var authCode	= valArray[1];
	//remaining vars
	var channelName	= escape(channel);
	var format		= _g6CurrFormat;
	var bitrate		= _g6CurrBitrate;
	var cVal;
	var vc			= false;
	var rBase; 
	
	//NN bug Fix 1306
	//if (_g6FrameType == "roo")
	//	rBase = top.location.href;
	//else
		rBase = window.location.href;
	
	//strip off anything from ? on in rBase  (base return url)
	//and escape the url

	var qLoc = rBase.indexOf("?");
	if(qLoc > -1)
		rBase=escape(rBase.substring(0,qLoc));


	//setting cookie name to the authschema guid
	CKNAME = authCode; 
	
	//VALIDATE COOKIE
	cVal = G6_GetCookie(CKNAME);  //read the cookie
	vc = (cVal != null)
		
	//are we authorized?
	if(cVal == "true")
		vc = true;
		
	// REDIRECT TO SSO MANAGER FOR VALIDATION if vc=false;
	if(!vc)
	{
		//NN Bug Fix 1306
		//if (_g6FrameType == "roo")
		//	top.location.href = "/g6publish/common/security/ssomanager.aspx?chi=" + channelId + "&c=" + channelName + "&cli=" + clipId + "&format="+format+"&bitrate="+bitrate+"&rBase="+rBase;
		//else
			window.location.href = "/g6publish/common/security/ssomanager.aspx?chi=" + channelId + "&c=" + channelName + "&cli=" + clipId + "&format="+format+"&bitrate="+bitrate+"&rBase="+rBase;
	}
	else
	{
		return true;
	}
}

//--------------------------------------------
// Buffer Function - eleminates some 
// browser-specific js related errors
//--------------------------------------------
var cbuffer = "";
function cdebug(str){
	cbuffer += str + "\n";
}

// ================================
// Tracking Function - RJJ 5/12/06
// ================================
var g6TrackingImgName = "g6TrackingImg";
document.write("<img id='" + g6TrackingImgName + "' width='0' height='0' border='0' src='/g6publish/common/images/transparent.gif'>");
function G6_Tracker(siteId, siteIdInt, clipId, clipPos, clipDur, channel, format, bitrate, action, subscriberId, criteria)
{
	var versionNo		= "1-20060524"; // version of this tracker (date ex: May 24, 2005)
	
    siteId          = ((siteId)       ? (siteId)			: "");
    clipId          = ((clipId)       ? (clipId)			: "");
    clipPos         = ((clipPos)      ? (clipPos)			: "");
    clipDur         = ((clipDur)      ? (clipDur)			: "");
    channel         = ((channel)      ? escape(channel)		: "");
    format          = ((format)       ? (format)			: "");
    bitrate         = ((bitrate)      ? (bitrate)			: "");
    action          = ((action)       ? escape(action)		: "");
    subscriberId    = ((subscriberId) ? escape(subscriberId): "");
    criteria        = ((criteria)     ? escape(criteria)	: "");
    
	document.getElementById(g6TrackingImgName).width    = 1;
	document.getElementById(g6TrackingImgName).height   = 1;
    
    //document.getElementById(g6TrackingImgName).src      = "/g6publish/common/images/rts.gif?siteId=" + siteId + "&action=" + action + "&criteria=" + criteria + "&clipId=" + clipId + "&clipPos=" + clipPos + "&clipDur=" + clipDur + "&channel=" + channel + "&format=" + format + "&bitrate=" + bitrate + "&subscriberId=" + subscriberId + "&v=" + versionNo; //test code
    document.getElementById(g6TrackingImgName).src      = "http://tracking.vx.roo.com/rts.gif?siteId=" + siteId + "&sidint=" + siteIdInt + "&action=" + action + "&criteria=" + criteria + "&clipId=" + clipId + "&clipPos=" + clipPos + "&clipDur=" + clipDur + "&channel=" + channel + "&format=" + format + "&bitrate=" + bitrate + "&subscriberId=" + subscriberId + "&v=" + versionNo; //production code
}
function G6_CallTracker(action, criteria)
{
	var position = "0";
	var duration = "0";
	
    criteria = ((criteria) ? (criteria) : "");
	
	if (typeof(G6_GetPlayerCurrentDuration) != "undefined") {
		try {
			duration = G6_GetPlayerCurrentDuration();
		}
		catch (e) {
			duration = "-1";
		}
	}
	
	if (typeof(G6_GetPlayerCurrentPosition) != "undefined") {
		try {
			// set to the total duration of the of the clip if the cip has indeed played all the way through
			if(action == "view_ad_completed" || action == "view_video_completed") 
				position = duration;
			else 
				position = G6_GetPlayerCurrentPosition();
		}
		catch (e) {
			position = "-1";
		}
	}
	
	//for some reason position and duration becomes 'undefined'
	if(typeof(duration)=='undefined'){duration="0";}
	if(typeof(position)=='undefined'){position="0";}
	
    G6_Tracker(_g6SiteId, _g6SiteIdInt, _g6ActiveClip.ClipId, position.toString(), duration.toString(), _g6CurrChannel, _g6CurrFormat, _g6CurrBitrate, action, G6_GetCookie("subscriberId"), criteria); //production code
    //alert("_g6SiteId=" + _g6SiteId + " | _g6CurrClipId=" + _g6ActiveClip.ClipId + " | _g6CurrChannel=" + _g6CurrChannel + " | _g6CurrFormat=" + _g6CurrFormat + " | _g6CurrBitrate=" + _g6CurrBitrate + " | action=" + action + " | G6_GetCookie(\'subscriberid\')=" + G6_GetCookie('subscriberid') + " | criteria=" + criteria); //for debugging -- note flash format uid does not always work with this turned on but works with production code
    //alert(action); // testing
}

// ================================
// Querystring parser
// ================================
function G6_PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; }	
}
function G6_QueryString(key){
var page = new PageQuery(window.location.search); 
return unescape(page.getValue(key)); 
}

//-------------------------------------------------------------------------------
//Issue 1304 KK
//Detect function to check if the user has installed the player software.
//Will be called only if DetectPlugin property is true for the VideoPlayerControl
//-------------------------------------------------------------------------------

var agt=navigator.userAgent.toLowerCase();
var ie=false, ff=false,ns=false,sf=false,op=false,cwin=false,mac=false;
ns = (agt.indexOf('navigator') != -1);
if (!ns) {
 ie  = (agt.indexOf('msie') != -1);
 ff  = (agt.indexOf('firefox') != -1);
 sf  = (agt.indexOf('safari') != -1);
 op  = (agt.indexOf('opera') != -1);
}
var platform=navigator.platform.toLowerCase();

var cwin = (platform.indexOf('win')!=-1);
var cmac = (platform.indexOf('mac')!=-1);
var clinux = (platform.indexOf('linux')!=-1);

var nse = '';
//All download urls
var flashdwn = 'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash/';
var realdwn = 'http://www.real.com';
var wmpdwn = 'http://mediaplayer-download.org/';

if(cmac) {
//MAC
flashdwn = 'http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash&P2_Platform=MacOSX';
realdwn='http://forms.real.com/real/realone/mac.html';
wmpdwn=	'http://www.apple.com/downloads/macosx/video/windowsmediaplayerformacosx.html';
} else if(clinux) {
//Linux
flashdwn = 'http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash&P2_Platform=Linux';
realdwn='http://www.real.com/linux/';
}

var wmpmsg='You do not have Windows Media Player Installed. Do you want to Install it?';


// initialize global variables
var detectableWithVB = false;
var pluginFound = false;


// Here we write out the VBScript block for MSIE Windows
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('<script language="VBscript">');

    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('</scr' + 'ipt>');
}

function detectFlashActiveXObject(activeObjectName,minMajVersion)
{
	pluginFound =false;
	try{
	var obj=new ActiveXObject(activeObjectName);
	if ( typeof(obj) != 'undefined') {
		var ver= obj.GetVariable("$version");
		if (ver.length>0) {
		var majVerFound=parseInt(ver.split(" ")[1].split(",")[0]);
		if (majVerFound >= minMajVersion)
		pluginFound=true;
		}
	}
	}
	catch(e) {}
	return pluginFound;
}

function detectFlash() {
	//Minimum Flash version for player to play clips is 8
    pluginFound = detectPlugin('Shockwave Flash','application/x-shockwave-flash',8); 
    // if not found, try to detect with VisualBasic
    if(!pluginFound) 
		pluginFound=detectFlashActiveXObject('ShockwaveFlash.ShockwaveFlash.8',8);
   return pluginFound;
}


function detectReal() {
    pluginFound = detectPlugin('RealPlayer','audio/x-pn-realaudio-plugin');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = (detectActiveXControl('rmocx.RealPlayer G2 Control') ||
		       detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
		       detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)'));
    }	
   return pluginFound;
}

function detectWindowsMedia() {
	if (cwin && (ff||sf)) {
		pluginFound = detectPlugin('np-mswmp','application/x-ms-wmp');
		wmpdwn ='http://port25.technet.com/pages/windows-media-player-firefox-plugin-download.aspx';
		wmpmsg='You do not have Windows Media Player for Firefox Installed. The player or player controls may not work. Do you want to Install it?';
		}
	else {
		pluginFound = detectPlugin('Windows Media Player','application/x-mplayer2');
		// if not found, try to detect with VisualBasic
		if(!pluginFound && detectableWithVB) {
		pluginFound = (detectActiveXControl('MediaPlayer.MediaPlayer.1')||
		detectActiveXControl('wmplayer.ocx'));
		}
    }
   return pluginFound;
}

function detectPlugin(daPlugins,strmimeType,minVersion) {
    var pluginFound = false;
    if (navigator.plugins && navigator.plugins.length > 0) {
	var pluginsArrayLength = navigator.plugins.length;
	for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
		if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins) >= 0) || 
		    (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins) >= 0) ) {
		    if (minVersion && minVersion.length>0) {
				var chkIndex=navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins);
				var substrItem=navigator.plugins[pluginsArrayCounter].description.substring(chkIndex+16,chkIndex+18);
				if (substrItem.indexOf('.') == 1 ) 
					substrItem = substrItem.substring(0,1);
				if (parseInt(substrItem) >= parseInt(minVersion)){ 
					pluginFound = true;
					break;
					}
		    }
		    else
		    {
				pluginFound = true;
				break;
		    }
	    }//
	}//for
    }//if
    
    //if plugin not found by plugins array -try to look up mimetypes
    if (!pluginFound)
    {
    if (navigator.mimeTypes && navigator.mimeTypes.length > 0) {
	var mimeTypeArrayLength = navigator.mimeTypes.length;
	for (mimeTypesArrayCounter=0; mimeTypesArrayCounter < mimeTypeArrayLength; mimeTypesArrayCounter++ ) {
	    var numFound = 0;
		if( navigator.mimeTypes[pluginsArrayCounter].type == strmimeType ) {
		    pluginFound = true;
		    break;
	    }//if
	}//for
    }//if
    }
    return pluginFound;
} // detectPlugin

function detectplayerplugin(){

	if(_g6CurrFormat == 'wmp'){
	if (!detectWindowsMedia()){
	var dwnWmp= confirm(wmpmsg);
	if (dwnWmp== true)
	window.location.replace(wmpdwn);
	else return;}}

	if(_g6CurrFormat == 'real'){
	if (!detectReal()){
	var dwnReal= confirm('You do not have Real Player Installed. Do you want to Install it?');
	if (dwnReal== true)
	window.location.replace(realdwn);
	else return;}}

	if(_g6CurrFormat == 'flash'){
	if (!detectFlash()){
	var dwnFlash= confirm('You do not have Flash Player Installed. Do you want to Install it?');
	if (dwnFlash== true)
	window.location.replace(flashdwn);
	else return;}}
}

//-------------------------------------------------------------------------------
//End of Issue 1304
//-------------------------------------------------------------------------------

