function VideoPlayerController(){
    this.enableOmniture = true;
    this.dartOrdinal = null;
    //default config stuff
    this.externalAds = true;
    this.overrideAds = false;
    this.contentReady = false;
    //this.playerDiv = null;
    this.thumbsDiv = null;
    this.defaultChannelKey = "OnBlast";  
    this.defaultSubsectionKey = null;  
    this.defaultShowKey = null;
    this.defaultEpisodeKey = null;
    this.defaultSegmentKey = null;
    this.overrideChannelKey = null;  
    this.overrideSubsectionKey = null;  
    this.overrideShowKey = null;
    this.overrideEpisodeKey = null;
    this.overrideSegmentKey = null;
    this.isMaximized = false;
    this.wantsMaximized = false;
    this.enableOmnitureCalls = true;
    this.currentLineup = null;
    this.currentTitle = null;
    this.autoSkipNext = true;
    this.reloadPagePerTitle = false;
    this.titleListCountMin = 2;	// don't display the list if less than this number
    this.titleListHeaderText = null;	// previously "More BET Honors Video"
    this.addThumbOverlays = false;
}
VideoPlayerController.prototype.initialize = function(playerID, width, height){
    if(width == null){ width = 486; }
    if(height == null){ height = 412; }
    var config = new Array();
    config["flashId"] = "flashObj";
    config["videoId"] = null; //the default video loaded into the player
    config["videoRef"] = null; //the default video loaded into the player by ref id specified in console
    config["lineupId"] = null; //the default lineup loaded into the player
    config["playerTag"] = null; //player tag used for identifying this page in brightcove reporting
    config["autoStart"] = null; //tells the player to start playing video on load
    config["preloadBackColor"] = "#FFFFFF"; //background color while loading the player
    config["externalAds"] = this.externalAds;  // if true, playAd() is called
    config["overrideAds"] = this.overrideAds;  // if true, we handle ad calls in javascript
    config["width"] = width;
    config["height"] = height;
    config["playerId"] = playerID;  
    this.config = config; 
}
VideoPlayerController.prototype.writePlayerHtml = function(){
	if(PC.isEditMode){ 
		document.write("<div><b>(VideoPlayer disabled during Editing.)</b></div>");
		return;
	}else{
		

		document.write("<div class=\"twoThirdsColLeft\">");
        //<!--// begin videoPlayerDiv //-->
		document.write("<div id=\"videoPlayerDiv\"><div id=\"videoPlayerDiv1\">");
        //<!-- Start of Brightcove Player -->
		document.write("<div style=\"display:none\">");
		document.write("<a href=\"http://link.brightcove.com/services/link/bcpid1396550160\">http://link.brightcove.com/services/link/bcpid1396550160</a><a href=\"http://www.brightcove.com/channel.jsp?channel=1321417124\">http://www.brightcove.com/channel.jsp?channel=1321417124</a>");
		document.write("</div>");
		
		createExperience(this.config, 8);
		
        //<!-- End of Brightcove Player -->
		document.write("</div></div>");
        //<!--// end videoPlayerDiv //-->
		document.write("</div>");
		document.write("<div class=\"oneThirdColRight\">");
        //<!--// begin videoCoAdDiv //-->
		document.write("<div id=\"videoCoAdDiv\">");
		document.write("<dl><dt>Advertisement</dt><dd>");
		document.write("</dd></dl>");
		document.write("</div>");
        //<!--// end videoCoAdDiv //-->
        //<!--// begin videoDetailsDiv //-->
		document.write("<div id=\"videoDetailsDiv\">");
		document.write("<dl class=\"title\"><dt>Video Title</dt><dd id=\"videoDetailsTitleValue\"></dd></dl>");
		document.write("<dl class=\"description\"><dt>Video Description</dt><dd id=\"videoDetailsDescriptionValue\"></dd></dl>");
		document.write("</div>");
        //<!--// end videoDetailsDiv //-->
		document.write("</div>");
		document.write("<div id=\"lineupTitlesDiv\"></div>");
		
		
//		$(document).ready(function(){
//			var playerHtml = "";
//			playerHtml += "<div id=\"videoModalScreenDiv\"></div>";
//			playerHtml += "<div id=\"videoPositionerDiv\"><div id=\"videoPositionerDiv1\"><div id=\"videoPositionerDiv2\"><div id=\"videoPlayerDiv\"><div id=\"videoPlayerDiv1\">";
//			playerHtml += VPC.getPlayerHtml();
//			playerHtml += "</div></div></div></div></div>";
//			var div = document.createElement("div");
//			window.document.body.appendChild(div);
//			div.innerHTML = playerHtml;
//			VPC.playerDiv = div;
//		});
		
		this.contentReady = true;
		
		_playerId = this.config.playerId;
        _lineupId = this.config.lineupId;
        _titleId = getParameter("bctid");
        _autoStart = this.config.autoStart;
    }
}
//VideoPlayerController.prototype.getPlayerHtml = function(){
//    this.contentReady = false;
//    return getExperienceHtml(this.config, 8);
//}
//VideoPlayerController.prototype.writeThumbsHtml = function(){
//    var html = "";  
//    document.write(html);
//}
VideoPlayerController.prototype.onPlayTitle = function(title){
	if(this.enableOmnitureCalls){
		if(title == null){ return; }
		var lineup = getLineupById(title.lineupId);
		if(lineup == null){ return; }
		// call the omniture
		// we need 4 peices of information for omniture:  subsectionKey, showKey, episodeKey, segmentKey
		var channelKey, subsectionKey, showKey, episodeKey, segmentKey;
		
		// first, get the values from any default values associated with the current object (VPC)
		channelKey = this.defaultChannelKey;
		subsectionKey = this.defaultSubsectionKey;
		showKey = this.defaultShowKey;
		episodeKey = this.defaultEpisodeKey;
		segmentKey = this.defaultSegmentKey;
		
		// next, get values from the current lineup and title.  These values are encoded into the referenceId properties.
		// syntax is something like "subsection: [SomeSubsection]; showKey: [SomeShow];" or "episodeKey: [some episode]; segmentKey: [some segment]; "
		// basically, a series of parm and values of the form "parmName: [value];"
		// first we look at the lineup level, and then the title level.
		var value = null;
		
		// check at the lineup level
		if(lineup.referenceId != null && lineup.referenceId != ""){
			
			value = this.parseParmValue(lineup.referenceId, "channel");
			if(value != null){ channelKey = value; }
			
			value = this.parseParmValue(lineup.referenceId, "subsection");
			if(value != null){ subsectionKey = value; }
			
			value = this.parseParmValue(lineup.referenceId, "show");
			if(value != null){ showKey = value; }
			
			value = this.parseParmValue(lineup.referenceId, "episode");
			if(value != null){ episodeKey = value; }
			
			value = this.parseParmValue(lineup.referenceId, "segment");
			if(value != null){ segmentKey = value; }
		}
		// check at the title level
		if(title.referenceId != null && title.referenceId != ""){
		
			value = this.parseParmValue(title.referenceId, "channel");
			if(value != null){ channelKey = value; }
			
			value = this.parseParmValue(title.referenceId, "subsection");
			if(value != null){ subsectionKey = value; }
			
			value = this.parseParmValue(title.referenceId, "show");
			if(value != null){ showKey = value; }
			
			value = this.parseParmValue(title.referenceId, "episode");
			if(value != null){ episodeKey = value; }
			
			value = this.parseParmValue(title.referenceId, "segment");
			if(value != null){ segmentKey = value; }
		}
		
		// now allow this object (VPC) to override values if apropriate
		if(this.overrideChannelKey != null){ channelKey = this.overrideChannelKey; }
		if(this.overrideSubsectionKey != null){ subsectionKey = this.overrideSubsectionKey; }
		if(this.overrideShowKey != null){ showKey = this.overrideShowKey; }
		if(this.overrideEpisodeKey != null){ episodeKey = this.overrideEpisodeKey; }
		if(this.overrideSegmentKey != null){ segmentKey = this.overrideSegmentKey; }
		//alert(channelKey + " - " + subsectionKey + " - " + showKey + " - " + episodeKey + " - " + segmentKey);
		
		PC.callOmnitureForVideoPlay(channelKey, subsectionKey, showKey, episodeKey, segmentKey);
    } 
}
VideoPlayerController.prototype.parseParmValue = function(text, parmName){
	if(text == null || text == ""){ return null; }
	if(parmName == null || parmName == ""){ return null; }
	var parmIndex = text.indexOf(parmName);
	if(parmIndex == -1){ return null; }
	var valueBeginIndex = text.indexOf(":", parmIndex) + 1;
	if(valueBeginIndex <= parmIndex){ return null; }
	var valueEndIndex = text.indexOf(";", valueBeginIndex);
	if(valueEndIndex <= valueBeginIndex){ return null; }
	var value = text.substr(valueBeginIndex, (valueEndIndex - valueBeginIndex));
	value = Util.trim(value);
	return value;
}
//VideoPlayerController.prototype.attachThumbsDiv = function(div){
//    this.thumbsDiv = div;
//    if(this.contentReady){
//        this.updateThumbsDiv();
//    }
//}
//VideoPlayerController.prototype.onContentLoad = function(evt){
//    this.contentReady = true;
////    if(this.thumbsDiv){
////        this.updateThumbsDiv();
////    }
//}
//VideoPlayerController.prototype.updateThumbsDiv = function(){
//    //alert("update thumbs div");
//}
//VideoPlayerController.prototype.onMinimize = function(){
//    // jquery isn't working for this in ie6.  so do the following:
//    
//    var screenDiv = document.getElementById("videoModalScreenDiv");
//    screenDiv.style.display = "none";
//    
//    var playerDiv1 = document.getElementById("videoPlayerDiv1");
//    playerDiv1.style.width = this.config.width + "px";
//    playerDiv1.style.height = this.config.height + "px";
//    
//    var positioner2 = document.getElementById("videoPositionerDiv2");
//    positioner2.style.left = "187px";
//    positioner2.style.top = "232px";
//    positioner2.style.width = "768px";
//    
//    this.isMaximized = false;
//    this.wantsMaximized = false;
//}
//VideoPlayerController.prototype.onMaximize = function(){
//    // jquery isn't working for this in ie6.  so do the following:
//    
//    var screenDiv = document.getElementById("videoModalScreenDiv");
//    screenDiv.style.display = "block";
//    
//    var playerDiv1 = document.getElementById("videoPlayerDiv1");
//    playerDiv1.style.width = "786px";
//    playerDiv1.style.height = "571px";
//   
//    var positioner2 = document.getElementById("videoPositionerDiv2");
//    positioner2.style.left = parseInt((965 - 786) / 2, 10) + "px";
//    positioner2.style.top = "180px";
//    positioner2.style.width = "965px";
//    
//    this.isMaximized = true;
//    this.wantsMaximized = true;
//}
/*
VideoPlayerController.prototype.callTracking = function(url){
    if(url == null || url == ""){ return; }
    var imageHtml = "<img src=\"" + url + "\" />";
	var div = document.createElement("div");
	window.document.body.appendChild(div);
	div.innerHTML = imageHtml;
}
*/
//VideoPlayerController.prototype.onAdStart = function(){
//	//alert("Ad Start");
//}
//VideoPlayerController.prototype.onAdStop = function(){
//	//alert("Ad Stop");
//}
//VideoPlayerController.prototype.showMiddleBoxAd = function(){
//	if(this.middleBoxAdDiv == null){
//		
//	}
//}
//VideoPlayerController.prototype.hideMiddleBoxAd = function(){

//}

VideoPlayerController.prototype.playVideoCoAd = function(adUrl, adClickUrl){
    var html = null;
    var adUrlLower = adUrl.toLowerCase();
    var width = 180;
    var height = 150;
    if(adUrlLower.indexOf(".swf") >= 0){
		// this is a flash ad
		html = PC.getFlashHtml(width, height, adUrl, 8, null, FlashWMode.Transparent);    // must be transparent otherwise it will mess up menus
		html = "<div style=\"z-index:0;\">" + html + "</div>";
    }else{
		if(adUrlLower.indexOf(".jpg") >= 0 || adUrlLower.indexOf(".gif") >= 0 || adUrlLower.indexOf(".png") >= 0){
			// this is an image ad
			html = "<img src=\"" + adUrl + "\" />";
			if(adClickUrl != null && adClickUrl != ""){
				html = "<a href=\"" + adClickUrl + "\">" + html + "</a>";
			}
		}
    }
    var videoCoAdDiv = document.getElementById("videoCoAdDiv");
    if(videoCoAdDiv != null){
		videoCoAdDiv.style.display = "block";
		//$("#videoCoAdDiv").attr("style.display", "block");
		$("#videoCoAdDiv dd").empty();
		$("#videoCoAdDiv dd").append(html);
    }
}





function _BrightCoveTools(){ 
    this.tempVideoIndex;
    this.tempLineup;
    this.tempCallback;
}
_BrightCoveTools.prototype.loadLineupTitles = function(lineup, callback){
    if(lineup == null){ return; }
    lineup.titles = new Array();
    this.tempVideoIndex = -1;
    this.tempLineup = lineup;
    this.tempCallback = callback;
    this.getNextLineupTitle();
}
_BrightCoveTools.prototype.getNextLineupTitle = function(){
    if(this.tempLineup == null || this.tempLineup.videoIds == null || this.tempLineup.videoIds.length == null || this.tempVideoIndex >= this.tempLineup.videoIds.length - 1){ return; }
    this.tempVideoIndex++;
    var titleId = this.tempLineup.videoIds[this.tempVideoIndex];
    callFlash("getTitleById", titleId);
}
_BrightCoveTools.prototype.getTitleById_Result = function(title){
    if(title == null){ return; }
    if(this.tempLineup == null || this.tempLineup.videoIds == null || this.tempLineup.videoIds.length == null || this.tempVideoIndex > this.tempLineup.videoIds.length - 1){ return; }
    if(this.tempLineup.titles == null){ return; }
    this.tempLineup.titles[this.tempVideoIndex] = title;
    if(this.tempLineup.videoIds.length == this.tempVideoIndex + 1){
        this.onLineupTitlesLoaded();
    }else{
        this.getNextLineupTitle();
    }
}
// the following function is needed for brightcove
function getTitleById_Result(title){
    BrightCoveTools.getTitleById_Result(title);
}

_BrightCoveTools.prototype.onLineupTitlesLoaded = function(){
    if(this.tempCallback != null){
        this.tempCallback(this.tempLineup);
    }
}
var BrightCoveTools = new _BrightCoveTools();




// Brightcove looks for this method to call.  
function onTemplateLoaded(message){
    callFlash("addEventListener", "contentLoad", "onContentLoad");
    callFlash("addEventListener", "streamStart", "onStreamStart");
    callFlash("addEventListener", "mediaComplete", "onMediaComplete");
//    callFlash("addEventListener", "minimize", "onMinimize");
//    callFlash("addEventListener", "maximize", "onMaximize");
//    callFlash("addEventListener", "adStart", "onAdStart");
//    callFlash("addEventListener", "adStop", "onAdStop");
}
// handle events
function onContentLoad(evt){
    //VPC.onContentLoad(evt);
    //callFlash("getFeaturedLineup");
    callFlash("getFeaturedLineup");
    //callFlash("setVolume", 0);
}
function onStreamStart(evt){
    if(VPC.enableOmniture){
        callFlash("getCurrentTitle");
    }
}
function onMediaComplete(evt){

}
//function onMinimize(){
//    VPC.onMinimize();
//}
//function onMaximize(){
//    VPC.onMaximize();
//}
function onAdStart(){
    VPC.onAdStart();
}
function onAdStop(){
    VPC.onAdStop();
}


function pausecomp(millis){
	var date = new Date();
	var curDate = null;
	do { curDate = new Date(); } 
	while(curDate - date < millis);
} 



var getLineupById_processingId = -1;
var getLineupById_resultObject = null;
function getLineupById(lineupId){
	if(lineupId == null || lineupId == -1){ return null; }
	if(getLineupById_processingId != -1 || getLineupById_resultObject != null){ return null; }
	getLineupById_processingId = lineupId;
	getLineupById_resultObject = null;
	callFlash("getLineupById", lineupId);
	// wait up to 2 seconds for the result
	var attempt = 0;
	while(attempt < 20 && getLineupById_resultObject == null){
		attempt++;
		pausecomp(100);
	}
	var lineup = getLineupById_resultObject;
	if(lineup.id + "" != lineupId + ""){ return null; }	// make sure we have the right lineup
	getLineupById_resultObject = null;
	getLineupById_processingId = -1;
	return lineup
}
function getLineupById_Result(lineup){
	if(getLineupById_processingId == -1 || getLineupById_resultObject != null){ return; }
    getLineupById_resultObject = lineup;
}

function getCurrentTitle_Result(title){
    if(title != null){
        VPC.onPlayTitle(title);
    }
}
function playAd(adString, callback){
	/*var adXML = XmlTools.getXmlObject(adString);
	if(adXML == null){ return; }
	if(adXML.firstChild && adXML.firstChild.nodeName == "externalAd"){ 
		//alert("time to make custom ad call");
		callbackFlash(callback)
	}else{	
	    if(!parseAndPlay(adXML)){
			callbackFlash(callback)
	    }
	}
	return;*/
	if(adString.indexOf("</synchedVideoPageAds>") == -1 || !parseAndPlay2(adString)){
	    callbackFlash(callback);
	}
}
function parseAndPlay(adXML){	
    var root = XmlTools.getFirstElement(adXML, "synchedVideoPageAds");
    if(root == null){ return false; }
    // attributes
    var duration = root.getAttribute("duration");
    var trackStartURLs = root.getAttribute("trackStartURLs");
    if(trackStartURLs != null){ trackStartURLs = trackStartURLs.split(","); }	// split to an array
    // sub elements
    var videoAdURL = XmlTools.getTagInnerValue(root, "videoAdURL");
    var videoAdClickURL = XmlTools.getTagInnerValue(root, "videoAdClickURL");
    var leaderboardAdURL = XmlTools.getTagInnerValue(root, "leaderboardAdURL");
    var leaderboardAdClickURL = XmlTools.getTagInnerValue(root, "leaderboardAdClickURL");
    var mediumBoxAdURL = XmlTools.getTagInnerValue(root, "mediumBoxAdURL");
    var mediumBoxAdClickURL = XmlTools.getTagInnerValue(root, "mediumBoxAdClickURL");
    var hasAds = false;
    
    // tracking
	//VPC.callTracking(trackStartURLs);
	
	// videoAds and mediumBoxAds must be passed back into the player
	var trackStartURLsSet = false;
	if(videoAdURL != ""){
	    var ad = new Object(); //sets up our ad object for passing to the player later
	    ad.type = "videoAd";
	    ad.duration = duration;
	    if(trackStartURLsSet == false){
			ad.trackStartURLs = trackStartURLs;
			trackStartURLsSet = true;
	    }
	    ad.videoURL = videoAdURL;
	    ad.videoClickURL = videoAdClickURL;
	    callFlash("playAd", ad); //send the ad object to the player
	    hasAds = true;
	}
	
	
	if(mediumBoxAdURL != ""){
	    /*
	    var ad = new Object(); //sets up our ad object for passing to the player later
	    ad.type = "synchedBanner";
	    ad.duration = duration;
	    if(trackStartURLsSet == false){
			ad.trackStartURLs = trackStartURLs;
			trackStartURLsSet = true;
		}
	    ad.expandedBannerURL = mediumBoxAdURL;
	    ad.expandedBannerClickURL = mediumBoxAdClickURL;
	    callFlash("playAd", ad); //send the ad object to the player
	    */
	    
	    
	    VPC.playVideoCoAd(mediumBoxAdURL, mediumBoxAdClickURL);
	    hasAds = true;
	}

	
	// handle external ads
	if(leaderboardAdURL != ""){
	    PC.playLeaderboardAd(leaderboardAdURL, leaderboardAdClickURL);
	    hasAds = true;
	}
	return hasAds;
}
function getFirstAttribute(xmlString, attributeName){
    var indexBegin = xmlString.indexOf(attributeName + "=\"");
    if(indexBegin == -1) return null;
    indexBegin += attributeName.length + 2;
    var indexEnd = xmlString.indexOf("\"", indexBegin);
    if(indexEnd == -1) return null;
    return xmlString.substring(indexBegin, indexEnd);
}
function getFirstElementValue(xmlString, elementName){
    var indexBegin = xmlString.indexOf("<" + elementName + ">");
    if(indexBegin == -1) return null;
    indexBegin += elementName.length + 2;
    var indexEnd = xmlString.indexOf("</" + elementName + ">", indexBegin);
    if(indexEnd == -1) return null;
    return xmlString.substring(indexBegin, indexEnd);
}
function parseAndPlay2(xmlString){	
    var duration = getFirstAttribute(xmlString, "duration");
    var trackStartURLs = getFirstAttribute(xmlString, "trackStartURLs");
    if(trackStartURLs != null){ trackStartURLs = trackStartURLs.split(","); }	// split to an array
    // sub elements
    var videoAdURL = getFirstElementValue(xmlString, "videoAdURL");
    var videoAdClickURL = getFirstElementValue(xmlString, "videoAdClickURL");
    var leaderboardAdURL = getFirstElementValue(xmlString, "leaderboardAdURL");
    var leaderboardAdClickURL = getFirstElementValue(xmlString, "leaderboardAdClickURL");
    var mediumBoxAdURL = getFirstElementValue(xmlString, "mediumBoxAdURL");
    var mediumBoxAdClickURL = getFirstElementValue(xmlString, "mediumBoxAdClickURL");
    
    var hasAds = false;

    // tracking
	//VPC.callTracking(trackStartURLs);
	
	// videoAds and mediumBoxAds must be passed back into the player
	var trackStartURLsSet = false;
	if(videoAdURL != ""){
	    var ad = new Object(); //sets up our ad object for passing to the player later
	    ad.type = "videoAd";
	    ad.duration = duration;
	    if(trackStartURLsSet == false){
			ad.trackStartURLs = trackStartURLs;
			trackStartURLsSet = true;
	    }
	    ad.videoURL = videoAdURL;
	    ad.videoClickURL = videoAdClickURL;
	    callFlash("playAd", ad); //send the ad object to the player
	    hasAds = true;
	}
	
	if(mediumBoxAdURL != ""){
	    VPC.playVideoCoAd(mediumBoxAdURL, mediumBoxAdClickURL);
	    hasAds = true;
	}

	// handle external ads
	if(leaderboardAdURL != ""){
	    PC.playLeaderboardAd(leaderboardAdURL, leaderboardAdClickURL);
	    hasAds = true;
	}
	return hasAds;
}


function getConfigValues() {
    var init = new Object();
	init["flashId"] = VPC.config.flashId;
    init["videoId"] = VPC.config.videoId; //the default video loaded into the player
    init["videoRef"] = VPC.config.videoRef; //the default video loaded into the player by ref id specified in console
    init["lineupId"] = VPC.config.lineupId; //the default lineup loaded into the player
    init["playerTag"] = VPC.config.playerTag; //player tag used for identifying this page in brightcove reporting
    init["autoStart"] = VPC.config.autoStart; //tells the player to start playing video on load
    init["preloadBackColor"] = VPC.config.preloadBackColor; //background color while loading the player
    init["externalAds"] = VPC.config.externalAds;  // if true, playAd() is called
    init["overrideAds"] = VPC.config.overrideAds;  // if true, we handle ad calls in javascript
    init["width"] = VPC.config.width;
    init["height"] = VPC.config.height;
    init["playerId"] = VPC.config.playerId;
	return init;
}







function getFeaturedLineup_Result(lineup){
    if(lineup == null) return;
    // load the titles
    BrightCoveTools.loadLineupTitles(lineup, onTitlesLoaded);
}
 
function onTitlesLoaded(lineup){
    if(lineup == null) return;
    
    // link up the lineup
    lineup.titleLookup = new Array();
    for(var i=0; i<lineup.titles.length; i++){
        var title = lineup.titles[i];
        lineup.titleLookup[title.id] = title;
        title._index = i;
        if(i > 0){
            var prevTitle = lineup.titles[i-1];
            prevTitle._nextTitle = title;
            title._prevTitle = prevTitle;
        }else{
            title._prevTitle = null;
        }
    }
    // make it global
    _lineup = lineup;
    
    updateTitleThumbs(lineup);
}
 
function updateTitleThumbs(lineup){
    var lineupTitlesDiv = document.getElementById("lineupTitlesDiv");
    if(lineupTitlesDiv == null) return;
    var html = getTitlesHtml(lineup);
    lineupTitlesDiv.innerHTML = html;
    // add the behaviors
    PC.makeBlockAnchors("#lineupTitlesDiv .barkerList dl:not(.disabled)", "mouseover");	// pass in jquery selector and hover css class
    if(VPC.addThumbOverlays){
		$('#lineupTitlesDiv .barkerList img').after('<div class="barkerThumbOverlayVideo"></div>');
    }
}
function getTitlesHtml(lineup){
    if(lineup == null || lineup.titles == null || lineup.titles.length == null || lineup.titles.length == 0) return "";
    
    
    
    var urlBase = removeParameter("bctid");
    if(urlBase.indexOf("?") == -1){ 
        urlBase += "?"; 
    }else{
        if(urlBase.substring(urlBase.length-1, 1) != "&"){ 
            urlBase += "&"; 
        }
    }
    urlBase += "bctid=";
    
    var titleId = _titleId;  
    if(titleId == ""){ titleId = null; }    //title will become the first title
    
    var inner = "";
    var selectedTitle = null;
    for(var i=0; i<lineup.titles.length; i++){
        var title = lineup.titles[i];
        var id = title.id;
        var thumbUrl = title.thumbnailURL;
        var altText = title.displayName;
        var displayName = title.displayName;
        var description = title.shortDescription;
        
        if(titleId == null){ titleId = id; }
        
        var isSelected = (titleId == null && i == 0) || (titleId + "" == id + "");


        var className = "";
        if(lineup.titles.length > 1){
            if(i == 0){ 
                className += " first"; 
            }else{
                if(i == lineup.titles.length - 1){ 
                    className += " last"; 
                }
            }
        }
        if(isSelected){
            className += " selected";
            selectedTitle = title;
        }
        // set the index into a classname
        className += " i" + i;
        if(className != ""){
            className = Util.trim(className);
            className = " class=\"" + className + "\"";
        }
        
        
        //var linkUrl = urlBase + id;   
        var linkUrl = "java" + "script:playTitle(" + id + ");" 
        
        inner += "<dl" + className + "><dt>Item</dt><dd>\r\n";
        if(thumbUrl != null && thumbUrl != ""){
            inner += "<img src=\"" + thumbUrl + "\" title=\"" + altText + "\" />\r\n";
        }
        inner += "<h3 class=\"title\">" + displayName + "</h3>\r\n";
        inner += "<p class=\"description\">" + description + "</p>\r\n";
        //if(!isSelected){
            inner += "<p class=\"action\"><a href=\"" + linkUrl + "\" class=\"actionLink\">Watch ></a></p>\r\n";
        //}
        inner += "</dd></dl>\r\n";
    }
    // build the header
    var head = "<div class=\"twoThirdsColLeft barkerBlockListDiv\"><div class=\"barkerBlockListDiv1\"><div class=\"barkerBlockListDiv2\">\r\n";
    if(this.titleListHeaderText == null){
	head += "<dl class=\"barkerList barkerBlockList\"><dd>\r\n";
    }else{
    	head += "<dl class=\"barkerList barkerBlockList\"><dt>" + this.titleListHeaderText + "</dt><dd>\r\n";
    }
    // build the footer
    var foot = "<div class=\"clearFloats\"></div>\r\n";
    foot += "</dd></dl>\r\n";
    foot += "</div></div></div>\r\n";
    
    // set the global titleId in case it was changed
    _titleId = titleId;
    
    // update the details
    updateTitleDetails(selectedTitle);
    
    if(lineup.titles.length < VPC.titleListCountMin){ 
		return ""; 
	}else{
		// return result
		return head + inner + foot;
    }
}

 
 
 function onMediaComplete(){
    // goto the next title
    if(_lineup == null){ return; }
    if(VPC.autoSkipNext){
		var title = _lineup.titleLookup[_titleId];
		if(title._nextTitle != null){
			playTitle(title._nextTitle.id);
		}
    }
 }
 
 
 function playTitle(titleId){
    if(_lineup == null){ return; }
    var title = _lineup.titleLookup[titleId];
    
    if(VPC.reloadPagePerTitle){
		var urlBase = removeParameter("bctid");
		if(urlBase.indexOf("?") == -1){ 
			urlBase += "?"; 
		}else{
			if(urlBase.substring(urlBase.length-1, 1) != "&"){ 
				urlBase += "&"; 
			}
		}
		urlBase += "bctid=";
		document.location = urlBase + titleId;
    }else{
		if(title != null){
			_titleId = title.id;
		}
		callFlash("loadTitleById", title.id);  
    }
 }
 
 function loadTitleById_Result(){
    var title = _lineup.titleLookup[_titleId];
    var videoPlayerDiv = document.getElementById("videoPlayerDiv");
    if(videoPlayerDiv != null){
        //videoPlayerDiv.focus();
        window.scrollTo(0, 0);
    }
    updateTitleDetails(title);
    selectThumbByIndex(title._index);
 }
 
 function selectThumbByIndex(index){
    if(_lineup == null || _lineup.titles == null){ return; }
    if(index < 0 || index >= _lineup.titles.length){ return; }
    unSelectAll();
    $("#lineupTitlesDiv .barkerList dl.i" + index).addClass("selected");
 }
 
 function unSelectAll(){
    $("#lineupTitlesDiv .barkerList dl.selected").removeClass("selected");
 }
 
 function updateTitleDetails(title){
    if(title == null){ return; }
    
    var displayName = title.displayName;
    var nameElement = document.getElementById("videoDetailsTitleValue");
    if(nameElement != null) nameElement.innerHTML = displayName;
    
    var description = title.longDescription;
    if(description == null || description == ""){ description = title.shortDescription; }
    var descriptionElement = document.getElementById("videoDetailsDescriptionValue");
    if(descriptionElement != null) descriptionElement.innerHTML = description;
    
 }
 
 

 
function removeParameter(name, url) {
    if(url == null){ url = document.location.href; }
    if(url == null){ return; }
    var urlToLower = url.toLowerCase();
    var nameToLower = name.toLowerCase();
    var parmStartIndex = urlToLower.indexOf(nameToLower + "=");    // case insensitive
    if (parmStartIndex == -1) {
        return url;
    }else{
        if(url.substring(parmStartIndex - 1, 1) == "&"){ parmStartIndex--; }
        var i = url.indexOf("&", parmStartIndex);
        if (i == -1) {
            return url.substring(0, parmStartIndex);
        }else{
            return url.substring(0, parmStartIndex) + url.substring(i, url.length);
        }
    }
}








var _playerId;
var _lineupId;
var _titleId = getParameter("bctid");
var _autoStart;
var _lineup = null;

var flashObj = null;




var VPC = new VideoPlayerController();

// turn off the normal page ads
//PC.enableAds = false;




//      NOTE: code below is copied from BrightCove's http://admin.brightcove.com/js/experience_util.js on 2008-02-10
//      Then the code was modified to point to our swf wrapper instead of the brightcove player explicitly


var playerIndex;
var flashId;
function createExperience(config, flashVersion) {
   // default version to 7 for backwards compatability
   if (flashVersion == undefined) var flashVersion = 7;
   // Config parameters to pass into the SWF file.
   var servicesURL = "http://services.brightcove.com/services";
   var viewerSecureGatewayURL = "https://services.brightcove.com/services/amfgateway";
   var cdnURL = "http://admin.brightcove.com";

   var bgcolor = config["preloadBackColor"];
   var externalAds = (typeof(playAd) != "undefined");
   var sendReports = (typeof(reportEvent) != "undefined");
   
   var width = config["width"];
   var height = config["height"];
   if (width == null) {
    width = "100%";    
   }
   if (height == null) {
    height = "100%";    
   }
  //specify version required Flash version
  if (config["requireFlash8"] || flashVersion == 8){
    requiredMajorVersion = 8;
  } else{
	//mac requires flash 8
	requiredMajorVersion = 7;
	var isMac = navigator.appVersion.toLowerCase().indexOf("mac") > 0;
	if (isMac) requiredMajorVersion = 8;
  }
  var requiredMinorVersion = 0;
  var requiredRevision = 0;
  
  var hasRightVersion = DetectFlashVer(requiredMajorVersion,requiredMinorVersion,requiredRevision);
  if(hasRightVersion) { 
  
	var pid = getParameter("bcpid");
	if(pid.length < 1  || (pid == config["playerId"]))  {
		var titleParam = getParameter("bctid");
		if (titleParam.length > 0) {
		  config["videoId"] = titleParam;
		  config["autoStart"] = true;
		  config["fromLink"] = true;
		}
		var lineupParam = getParameter("bclid");
		if (lineupParam.length > 0) {
		  config["lineupId"] = lineupParam;
		}
	}
  
    if (playerIndex == undefined){
		playerIndex = 0;
	}else{
		playerIndex++;
	}	

/*
    if (config["flashId"] == undefined) {
      flashId = "flashObj" + playerIndex;
    } else {
      flashId = escapeValue(config["flashId"]) + playerIndex;
    }
    */
    flashId = "flashObj"

    var configItems = "";
    for (var i in config) {
       if (i == "flashId") continue;
       if (typeof(config[i]) == "function" || typeof(config[i]) == "object") continue;
       
       configItems += "&" + i + "=" + escapeValue(config[i]);
    }

    // Hook for Internet Explorer.
    if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub ' + flashId + '_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call onFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
    }

    var swfFile = "federated.swf";
    if (flashVersion == 8) {
      swfFile = "federated_f8.swf";
    }

    var file = cdnURL + "/viewer/" + swfFile + "?flashId="+flashId+
         "&servicesURL="+escapeValue(servicesURL)+
         "&viewerSecureGatewayURL="+escapeValue(viewerSecureGatewayURL)+
         "&cdnURL="+escapeValue(cdnURL)+
         configItems+
         "&externalAds="+escapeValue(externalAds)+
         "&sendReports="+escapeValue(sendReports)+
         "&buildNumber=" + 852 +
         "&ranNum=" + Math.floor(Math.random()*1000000);   

    if (!DetectFlashVer(8,0,0)) {
      file += "&domain=" + getDomain();
    }
    
    wmode = config["wmode"];
	if (wmode == null) wmode = "window";
	
    //version = "7,0,0,0"; // why write 7 always??
    version = "8,0,0,0";
    quality = "high";
    document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + version + "\" id=\""+flashId+"\" width=\""+width+"\" height=\""+height+"\">");
    document.write("  <param name=\"allowScriptAccess\" value=\"always\"/>");
    document.write("  <param name=\"allowFullScreen\" value=\"true\"/>");
    document.write("  <param name=\"movie\" value=\""+file+"\"/>");
    document.write("  <param name=\"wmode\" value=\""+wmode+"\"/>");
    document.write("  <param name=\"quality\" value=\""+quality+"\"/>");
    document.write("  <param name=\"bgcolor\" value=\"" + bgcolor + "\"/>");
    document.write("  <param name=\"base\" value=\""+cdnURL+"/viewer/\"/>");
    document.write("  <param name=\"SeamlessTabbing\" value=\"false\"/>");
    document.write("  <embed src=\""+file+"\" base=\""+cdnURL+"/viewer/\" quality=\""+quality+"\" bgcolor=\""+bgcolor+"\" allowScriptAccess=\"always\" name=\""+flashId+"\" width=\""+width+"\" height=\""+height+"\" wmode=\""+wmode+"\" seamlesstabbing=\"false\" type=\"application/x-shockwave-flash\" swLiveConnect=\"true\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>");
    document.write("</object>"); 
    
    flashObj = document.getElementById(flashId);
    
  } else {  // flash is too old or we can't detect the plugin 
    document.write("<table width='" + width + "' height='" + height + "' border='0' bgcolor='"+bgcolor+"'>");
    document.write("<tr><td align='center' valign='middle'>");
    document.write("<a href='http://www.macromedia.com/go/getflashplayer/' target='_blank'><img src='"+cdnURL+"/viewer/upgrade_flash_player.gif' alt='Get Flash Player' width='314' height='200' border='0'></a>");
    document.write("</td></tr></table>");      
   }

   return flashId;
}

function escapeValue(str) {
  return encodeURIComponent(str);
}

function getDomain() {
  var domain = window.location.href;
  if (domain.substring(0, 7) == "http://") {
    domain = domain.substring(7, domain.length);
  }
  var i = domain.indexOf("/");
  if (i != -1) {
    domain = domain.substring(0, i);
  }
  i = domain.indexOf(":");
  if (i != -1) {
    domain = domain.substring(0, i);
  }
  return domain;
}
var ID_DELIM = "|||";

function onFSCommand(command, args) {
  if (command == "eval"){
    eval(args);
    return;
  }
  if (this[command] == null) return;
  var obj = convertToObject(unescape(args));
  if (obj != null) {
    var callback = obj.callback;
    var flashId = obj.flashId;
    if (obj.flashId != null && callback != null) {
      callback = obj.flashId + ID_DELIM + callback;
    }
    if (obj.args == null) {
      eval(command + "(callback);");
    } else {
      eval(command + "(obj.args, callback);");
    }
  } else {
    eval(command + "();");
  }
}

var flashCallback;
var flashCallbacks = [];
function setAPICallback(id, callback) {
  flashCallback = callback;
  flashCallbacks[id] = callback;
}

function callFlash() {
  var method = arguments[0];
  var params = [];
  for (var i = 1; i < arguments.length; i++) {
    params.push(arguments[i]);
  }
  callbackFlash(flashCallback, {method:method, params:params});
}

function callFlashInstance() {
  var flashId = arguments[0];
  var method = arguments[1];
  var params = [];
  for (var i = 2; i < arguments.length; i++) {
    params.push(arguments[i]);
  }
  var callback = flashCallbacks[flashId];
  callbackFlash(callback, {method:method, params:params});
}

function callbackFlash(callback, returnValue) {
  var flashId = "flashObj";

  var arry = callback.split(ID_DELIM);
  
  if (arry.length > 1) {
    if (arry[0].length > 0) {
      flashId = arry[0];
    }
    callback = arry[1];
  }

  var fo = document[flashId];
  if (fo == null) fo = document.embeds[flashId];
  if (fo == null) fo = document.getElementById(flashId);

  if (fo[callback] != null) {
    return fo[callback](convertToXML(returnValue, "js2flash"));
  } else {
    try {
      fo.SetVariable(callback, convertToXML(returnValue, "js2flash"));
    } catch (e) {}
  }
}


function convertToXML(obj, rootName) {
	if (obj instanceof Function) return "";
  	var type = getType(obj);
  	var xml = "<"+type.name+rootName+">";
  
	if(type.sub) {
  		for (var i in obj) {
 		  xml += convertToXML(obj[i], i);
    	}
	}
	else if (type.name == "str") {
		obj = replaceEntities(obj);
		xml += obj;
	} 
	else {
		  xml += obj;
	}
	xml += "</"+type.name+rootName+">";
	return xml;
}

function replaceEntities(obj) {
	obj = obj.replace("&", "&amp;");
	obj = obj.replace("<", "&lt;");
	obj = obj.replace(">", "&gt;");	
	return obj;
}

var s_xml_types = new Array();	
s_xml_types.push({name:"str",type:String,sub:false});
s_xml_types.push({name:"boo",type:Boolean,sub:false});
s_xml_types.push({name:"num", type:Number,sub:false});
//s_xml_types.push({name:"date", type:Date,sub:false});
s_xml_types.push({name:"arr", type:Array,sub:true});
s_xml_types.push({name:"cda", type:CData, sub:false});
s_xml_types.push({name:"obj", type:Object,sub:true});

function getType(obj) {
        switch (typeof(obj)) {
		case "boolean":
			return {name:"boo",type:Boolean,sub:false};
		case "string":
			return {name:"str",type:String,sub:false};
		case "number":
			return {name:"num",type:Number,sub:false};
	}
	for (var i = 0; i < s_xml_types.length; i++) {
	  if (obj instanceof s_xml_types[i].type) {
	    return s_xml_types[i];
	  }
	}
	return {name:"obj", type:Object,sub:true};
}
function getTypeClass(name) {
  if (name == null) return null;

  name = name.toLowerCase();
	for (var i = 0; i < s_xml_types.length; i++) {
	  if (name == s_xml_types[i].name) {
	    return s_xml_types[i].type;
	  }
	}
	return null;
}

function convertToObject(node) {
//  try {
    if (node == null) {
      return;
    }
    
    if (node.substring != null) {
      node = parseXML(node);
    }
	  
	  if (node == null || node.childNodes == null || node.childNodes.length == 0) {
	    return null;
	  }

	  var type = getTypeClass(node.nodeName.substring(0,3));
	  if (type == null) {
	    type = Object;
	  }

		if (node.firstChild.nodeType == 3 || node.firstChild.nodeType == 4) {
			return getObjectForNode(type, node);

		} else {
		
  		var obj = new type();
	  	var children = node.childNodes;
		  for (var i = 0; i < children.length; i++) {
		    var name = children[i].nodeName;
		    name = name.substring(3, name.length);
			  obj[name] = convertToObject(children[i]);
	  	}
		  return obj;
		}
//	} catch (e) {
//    alert("Error creating object:" + e.message);
//	  return null;
//	}
}

function getObjectForNode(type, node) {
	if (type == Boolean) {
		if (node.firstChild.nodeValue == "true") {
			return new Boolean(1);
		}
		else {
			return new Boolean(0);
		}
	}
	else {
		return new type(node.firstChild.nodeValue);
	}
}

function parseXML(str) {
  if (window.ActiveXObject) {
    var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
    try {
      xmldoc.setProperty("SelectionLanguage", "XPath");
    } catch (e) {} // i.e. 5 doesn't like setting the selection language
    xmldoc.async = false;

    xmldoc.loadXML(str);
    return xmldoc.documentElement;  
  } else if (DOMParser) {

    var parser = new DOMParser();
    var doc = parser.parseFromString(str, "text/xml");
    
    return doc.firstChild;
    
  } else {
    return makeXMLNode(str);
  }
}


function makeXMLNode(str) {
  var node = {};
  var nodeName = node.nodeName = getNodeName(str);
  node.nodeType = 1;
  node.childNodes = [];
  node.firstChild = null;
  var startTagEndIndex = nodeName.length + 2;
  var endTagIndex = str.lastIndexOf("</" + nodeName);
  var nodeData = str.substring(startTagEndIndex, endTagIndex);
  if (nodeData.substring(0, 9) == "<![CDATA[") {
    var child = {};
    child.nodeName = null;
    child.nodeType = 4;
    child.nodeValue = getCDATA(nodeName, str.substring(startTagEndIndex, str.length));
    node.childNodes = [child];
  } else if (nodeData.indexOf("<") > -1) {
    node.childNodes = getChildNodes(nodeData);
  } else if (nodeData.length == 0) {
    //do nothing, we want 0 children here
  } else {
    var child = {};
    child.nodeName = null;
    child.nodeType = 3;
    child.nodeValue = getNodeValue(nodeName, nodeData);
    node.childNodes = [child];
  }
  if (node.childNodes.length > 0) {
    node.firstChild = node.childNodes[0];
  }
  return node;
}

function getNodeName(str) {
  return str.substring(str.indexOf("<")+1, str.indexOf(">"));
}

function getChildNodes(nodeData) {
  var childNodes = [];
  var nodeName;
  var nextIndex;
  var endIndex;
  var dataLength;
  var nameLength;
  var startNodesArray;
  var endNodesArray;
  var startNodesLength;
  var endNodesLength;
  var endNodes;
  var startNodes;
  var endNode;
  var i;
  var j;
  while (nodeData.length > 0) {
    nodeName = getNodeName(nodeData);
    nameLength = nodeName.length;
    nextIndex = nodeData.indexOf("<"+nodeName, nameLength);
    endIndex = nodeData.indexOf("</"+nodeName, nameLength);
    if (endIndex < 0) return childNodes;
    if (nextIndex < 0 || endIndex < nextIndex) {
      dataLength = endIndex+nodeName.length+3;
      childData = nodeData.substr(0, dataLength);
      nodeData = nodeData.substr(dataLength);
      childNodes.push(makeXMLNode(childData));
    } else {
      endNodes = 0;
      startNodes = 0;
      startNodesArray = nodeData.split("<" + nodeName + ">");
      startNodesLength = startNodesArray.length;
      endNode = "</" + nodeName + ">";
      for (i = 0; i < startNodesLength; i++) {
        startNodes++;
        startNodesStr = startNodesArray[i];
        if (startNodesStr.indexOf(endNode) > -1) {
          endNodesArray = startNodesStr.split("</" + nodeName + ">");
          endNodesLength = endNodesArray.length;
          for (j = 0; j < endNodesLength; j++) {
            if (++endNodes == startNodes) {
              childData = startNodesArray.slice(0, startNodes).join("");
              dataLength = childData.length;
              nodeData = nodeData.substr(dataLength);
              childNodes.push(makeXMLNode(childData));
              return childNodes;
            }
          }
        }
      }
      childNodes.push(makeXMLNode(nodeData));
      nodeData = "";
    }
  }
  return childNodes;
}

function getCDATA(nodeName, nodeData) {
  var endCDATA = nodeData.indexOf("]]>", 9);
  if (endCDATA < 0) {
    return null;
  } else {
    return getNodeValue(nodeName, nodeData.substring(9, endCDATA));
  }
}

function getNodeValue(nodeName, nodeValue) {
  switch (nodeName.substr(0, 3)) {
    case "boo":
      return (nodeValue=="true");
    case "num":
      return Number(nodeValue);
    case "str":
      return String(nodeValue);
    default:
      return nodeValue;
  }
}

function CData(str) {
  this.data = str;
}

CData.prototype.toString = function() {
  return "<![CDATA[" + this.data + "]]>";
}

/*
var chunks = {}
function chunkCall(id, total, index, chunk) {
  if (chunks[id] == undefined) chunks[id] = [];
  chunks[id][index] = chunk;
  if (index == total) {
    eval(chunks[id].join(""));
    delete chunks[id];
  }
}
*/
//Flash Detection
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1 && /opera/i.test(navigator.userAgent) == false) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			descArray = flashDescription.split(" ");
			tempArrayMajor = descArray[2].split(".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
      	} else {
			flashVer = -1;
		}
	}
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else {		
		flashVer = -1;
	}
	return flashVer;
} 
// If called with no parameters this function returns a floating point value 
// which should be the version of the Flash Player or 0.0 
// ex: Flash Player 7r14 returns 7.14
// If called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
{
 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
   	for (i=25;i>0;i--) {	
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer(i);		
		}
		if (versionStr == -1 ) { 
			return false;
		} else if (versionStr != 0) {
			if(isIE && isWin && !isOpera) {
				tempArray         = versionStr.split(" ");
				tempString        = tempArray[1];
				versionArray      = tempString .split(",");				
			} else {
				versionArray      = versionStr.split(".");
			}
			versionMajor      = versionArray[0];
			versionMinor      = versionArray[1];
			versionRevision   = versionArray[2];
			
			versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
			versionNum        = parseFloat(versionString);
    		if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
				return true;
			} else {
				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
			}
		}
	}	
	return (reqVer ? false : 0.0);
}

// Visual basic helper required to detect Flash Player ActiveX control version information
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('Function VBGetSwfVer(i)\n');
	document.write('  on error resume next\n');
	document.write('  Dim swControl, swVersion\n');
	document.write('  swVersion = 0  \n');
	document.write('  set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))\n');
	document.write('  if (IsObject(swControl)) then\n');
	document.write('    swVersion = swControl.GetVariable("$version")\n');
	document.write('  end if\n');
	document.write('  VBGetSwfVer = swVersion\n');
	document.write('End Function\n');
	document.write('</script\>\n');
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub flashObj_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call onFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}
// Functions to parse query string parameters
// version: 1.0
// written by Kevin Langdon


// #############################################
// function returns the query string part of url
// everything followed by the '?'
function getQueryString() {
    var urlStr = document.location.href;
    var i = urlStr.indexOf("?");
    if (i != -1) {
        return urlStr.substring(i, urlStr.length - 1);
    }
    return null;
}


// #############################################
// function parses the query string and returns each
// parameter and value seperated by '&'
function getParameter(name, defaultValue) {
    if (defaultValue == null) {
        defaultValue = "";
    }

    var url = document.location.href;
    var i = url.indexOf(name + "=");
    if (i != -1) {
        var valuestart = i+name.length+1;
        var valueend = url.length;

        i = url.indexOf("&", valuestart)
        if (i != -1) {
            valueend = i;
        }

        return unescape(url.substring(valuestart, valueend));
    }
    return defaultValue;
}



