function Player(id, baseUrl, flashVars, isAudio, isAd, isPopup, adFrameUrlTop, 
		adFrameUrlSide, width, height, viewMediaURI, clickableThumbInfo, bgcolor, swfName){

	this.exists = true;
	this.isAudio = isAudio;
	//this.isPopup = isPopup == null ? false : isPopup;
	this.isPopup = true;
	this.adFrameUrlTop = adFrameUrlTop;
	this.adFrameUrlSide = adFrameUrlSide;
	this.viewMediaURI = viewMediaURI;
	this.clickableThumbInfo = clickableThumbInfo || null;
	flashVars.isPopup = this.isPopup ? 'true' : 'false';
	if(width == null || height == null) {
		width = 160;
		height = 138;
	}
	if (swfName == null){
		swfName = "scripts/RampPlayerLg.swf";
	} else {
		swfName = "scripts/"+swfName;
	}
	this.enabled = flashVars.enabled == "true";
    this.stkw = eval(flashVars.stkw);
    this.snippets = eval(flashVars.snippets);
    // Modify snippets string for flash parsing
    flashVars.snippets = flashVars.snippets.replace(/new Number\(([^\)])\)/g, "$1");
	UIUtil.CallParentFn(this, FlashObj, id, flashVars, width, height, baseUrl + swfName, "transparent", 
		null, null, null, null, bgcolor, null, null, null, null, baseUrl + "images/");
};

// inherit from FlashObj
UIUtil.Inherit(Player, FlashObj);

function playRemotePlayer(href,index,ev,srpIndex,popup)
{
	
	if (PlayerManager.enabled) {
		var seekTo=0;	
	    if (ev != null)
	    {
			seekTo = Player.snippetHandleMouseEv(ev, index, true,false,srpIndex);
	    }
	    if(popup)
	       showPopupURLTopLeft(href + "&seek=" + seekTo,800,1000);
	    else 
		location = href + "&seek=" + seekTo;
	}
	
}

Player.prototype.showPlayer = function(){

    // a function of the same name is used for the youtube player,
    // when it is embedded into the zing index.  Unlike the podzinger
    // player, its frame is destroyed and rebuilt.
    
	//no nothing
}

Player.prototype.pausePlayer = function(){
   
	if (PlayerManager.enabled) {
			

		Player.getPlayerById(this.attributes['id']).stopPlayer();
	}
}

// TODO Ledbetter this may no longer be of use, replace with Player.prototype.seek method
Player.prototype.playPlayer = function(ev){
   
	if (PlayerManager.enabled) {
		var seekTo;	
	    if (ev != null)
	    {
			var srcEl = PlayerUtil.getSourceElement(ev);
			//get a time index.
	        var seekTo = Number(srcEl.getAttribute("start_offset"));
	    }
		Player.getPlayerById(this.attributes['id']).playPlayer(seekTo);
	}
}

Player.prototype.seek = function(timeMsec){
	if (PlayerManager.enabled) {
        timeMsec = timeMsec || 0;
	    timeMsec;
		Player.getPlayerById(this.attributes['id']).playPlayer(Number(timeMsec));
	}
}

Player.snippetBlockId = "ezSnippetBlock";
Player.snippetMatchId = "ezSnippetMatch";
Player.snippetStyles = {st:{sel:"stHighlight", unsel:""},kw:{sel:"kwHighlight", unsel:""}};
Player.currentSnippetBlock = null;

Player.snippetAdjust = function(selectedIndex,type,snip,initialCall,srpindex,sClassNames, sLinkClassNames){
    sLinkClassNames = sLinkClassNames || sClassNames;
	initialCall = initialCall || false;
    
    // showSnippet in flash
	if( (typeof playerInst0 != 'undefined' ) && !initialCall) {
		
		playerInst0.showHideSnippetArrow(true, snip);
    
	    var stkw = playerInst0.stkw;
	    for (var i = 0; i < stkw.length; i++)
	    {
	      
	       if(stkw[i].type == Player.SNIPPET_TYPE_ST)
	       {	
				var triggerItem = document.getElementById("stLink" + i);
				var triggerSnippetMarker = document.getElementById("stLinkSnippetMarker" + i);
				if(triggerItem != null){
					if(selectedIndex == i || type == Player.SNIPPET_SELECT_TYPE_AST){
						if (triggerSnippetMarker != null)
							triggerSnippetMarker.style.display = "inline";
						triggerItem.className = sLinkClassNames.st.sel;
					} else {
						if (triggerSnippetMarker != null)
							triggerSnippetMarker.style.display = "none";
						triggerItem.className = sLinkClassNames.st.unsel;
					}
				}
	       }
	       else
	       {
				var triggerItem = document.getElementById("kwLink" + i);
				var triggerSnippetMarker = document.getElementById("kwLinkSnippetMarker" + i);
				if(triggerItem != null){
					if (selectedIndex == i){
						if (triggerSnippetMarker != null)
							triggerSnippetMarker.style.display = "inline";
						triggerItem.className = sLinkClassNames.kw.sel;
					} else {
						if (triggerSnippetMarker != null)
							triggerSnippetMarker.style.display = "none";
						triggerItem.className = sLinkClassNames.kw.unsel;
					}
				}
	       }
	    }
    
	    if (type == Player.SNIPPET_SELECT_TYPE_AST){
	        // determine snip value
	        // contains all the search terms
	        snip = null;
	        for (var i = 0; i < stkw.length; i++){
	           
	            if(stkw[i].type == Player.SNIPPET_TYPE_ST){
	                
	                if(snip == null)
	                    snip = "";
	                else
	                    snip += "_";
	                snip += stkw[i].value.toLowerCase().replace(/ /g, "_").replace(/(^")|("$)/g, "");
	            }
	           
	        }
	    }
	    
	    var snippets = playerInst0.snippets;
	    var currentMatchIndex = 0;
		var foundMatches = false;
	   
	    for (var i = 0; i < ezSnippetTimesAry[srpindex].length; i++){
	        var stkwInBlock = false;
	        var snippetBlock = document.getElementById(Player.snippetBlockId + "_" + i + "_" + srpindex);
	        if (snip != null && type != Player.SNIPPET_SELECT_TYPE_FT || type == Player.SNIPPET_SELECT_TYPE_FT){
	            // Loop through all the matches in this block and see if they "match" with the snippet
	            for (var j = 0; j < ezSnippetTimesAry[srpindex][i].matches; j++){
	                var matchElem = document.getElementById(Player.snippetMatchId + currentMatchIndex);
	                var matchRegExp = new RegExp("(^|\_)" + matchElem.innerHTML.toLowerCase() + "($|\_)", "im");
	                if(snip != null && matchRegExp.exec(snip) != null || type == Player.SNIPPET_SELECT_TYPE_FT){
	                //if(snip != null && matchElem.indexOf(snip) != -1 || type == Player.SNIPPET_SELECT_TYPE_FT){
	                    stkwInBlock = true;
	                    matchElem.className = (matchElem.getAttribute("eztype") == "st" ? sClassNames.st.unsel : sClassNames.kw.unsel);
						foundMatches = true;
	                } else {
	                    matchElem.className = null;
	                }
	                currentMatchIndex++;
	            }
	        }
	        
	        if (stkwInBlock || type == Player.SNIPPET_SELECT_TYPE_FT){
	            snippetBlock.style.display = "block";
	        } else {
	            snippetBlock.style.display = "none";
	        }
	    }
   	}
    
	/* ** COMMENTED OUT 1/7/08 TRP. Handled via jquery.playerSetup.js
	 * 
	// modify full text link
	// null snip represents full text link click
	var fullTextArea = document.getElementById("fullTranscript");
	var partialTextArea = document.getElementById("snippetsTranscript");
	var fullTextLinkElem = document.getElementById("ftLink");
	var fullTextTextElem = document.getElementById("ftText");
	var notFoundTextElem = document.getElementById("notFoundTranscript");
	
	if(type != Player.SNIPPET_SELECT_TYPE_FT) {
		fullTextLinkElem.style.display = "block";
		fullTextTextElem.style.display = "none";
		if(fullTextArea != null)
			fullTextArea.style.display = "none";
		if(partialTextArea != null)
		   partialTextArea.style.display = "block";
		if(notFoundTextElem != null)
		   notFoundTextElem.style.display = !foundMatches ? "block" : "none";
	} else {
		if(notFoundTextElem != null)
		   notFoundTextElem.style.display = !foundMatches ? "block" : "none";
		if(partialTextArea != null)
	    	partialTextArea.style.display = "none";
	    if(fullTextArea != null)
	    	fullTextArea.style.display = "block";
		fullTextLinkElem.style.display = "none";
		fullTextTextElem.style.display = "block";
	}
	*/ 		
}

Player.snippetGetHighlightId = function(index) {
    return "currentHighlightWord";
}

Player.snippetGetPlayHereElem = function(index) {
    return document.getElementById("sbph" + index);
}


Player.snippetMouseOut = function(ev, index) {
    var blah = ev.currentTarget;
    // unhighlight last selected word
    Player.snippetUnhighlightWord(index, document.getElementById(Player.snippetGetHighlightId(index)));
}

Player.snippetUnhighlightWord = function(index, span){
    if(span != null){
        var spanTextNode = span.firstChild.cloneNode(false);
        span.parentNode.replaceChild(spanTextNode, span);
    }
}

Player.snippetIsChildOf = function(child, parent, stopId){
	if(child == null || child.parentNode == null){ return false; }
    if(child.parentNode.id == parent.id)
        return true;
    else if (stopId == child.parentNode.id )
        return false;
    else
        return Player.snippetIsChildOf(child.parentNode, parent, stopId);
}

Player.snippetGetWordObj = function(strPtns, startRngStr, endRngStr){
    
    // obtains word that user has clicked on or moused over
    var word = {end:null, start:null, complete:""};
    word.end = endRngStr.match(strPtns.end);
    word.start = startRngStr.match(strPtns.start);
    word.complete = word.end != null && word.start != null ? word.start + word.end : "";
    return word;
}

Player.snippetPrevSpanRevert = function(prevSpan){
    if(prevSpan != null){
        
        var prevSpanTextNode = prevSpan.firstChild.cloneNode(false);
        prevSpan.parentNode.replaceChild(prevSpanTextNode, prevSpan);
    }
}

Player.snippetHandleMouseEv = function(ev, index, isClick,isViewMedia,srpindex) {
	var seekTo;	
	
    if (ev != null) {
		var srcEl = ev.srcElement || ev.currentTarget;
		
		// obtain range offset
		var rangeOffset = 0;
        var strPtns = {end:/^\S+/, start:/\S+$/};
        if (window.getSelection){
           
           // Firefox & Safari
            var parentNode;
            var selRng;
            if(UIUtil.isSafari()){
                // Safari's range and selection is broken for onmousemove events, just ignore them.
                if(!isClick)
                    return;
                selRng = window.getSelection();
			    rangeOffset = selRng.focusOffset;
                parentNode = selRng.focusNode;
				
				var playHereElem = Player.snippetGetPlayHereElem(index);
	            var isChild = Player.snippetIsChildOf(srcEl, playHereElem, Player.snippetBlockId + "_" + index + "_" + srpindex);
	            if (isChild) {
	                seekTime = ezSnippetTimesAry[srpindex][index].times[0];
	                if (isViewMedia) {
	                    if (typeof playerInst0 != 'undefined') 
	                        playerInst0.seek(seekTime);
	                    
	                    if (window.callFlash) {
	                        callFlash("seek", seekTime);
	                    }
	                    
	                }
	                return seekTime;
	            }
            } else {
                // Firefox
                rangeOffset = ev.rangeOffset;
                parentNode = ev.rangeParent;
                selRng = document.createRange();
                selRng.setStart(ev.rangeParent, ev.rangeOffset);
            }
            var parentNodeStr = parentNode.nodeValue != null ? parentNode.nodeValue : "";
            var endRngStr = parentNodeStr.substring(rangeOffset);
            var startRngStr = parentNodeStr.substring(0, rangeOffset);
            var word = Player.snippetGetWordObj(strPtns, startRngStr, endRngStr);
			
            if(word.complete.length > 0){
                if(!isClick){
                     // Create a range that contains the word
                    // use range to replace word with word wrapped in a span
                    var prevSpan = document.getElementById(Player.snippetGetHighlightId(index));
                    if(prevSpan != parentNode.parentNode){
                    	
                        var mOvrRng = document.createRange();
                        var rngStart = startRngStr.length - new String(word.start).length;
                        var rngEnd = rngStart + new String(word.end).length + new String(word.start).length;
                        mOvrRng.setStart(parentNode, rngStart);
                        mOvrRng.setEnd(parentNode, rngEnd);
                        // if previous span is not the same element as the new span
                        Player.snippetPrevSpanRevert(prevSpan);
                        mOvrRng.deleteContents();
                        var spanElem = document.createElement("span");
                        spanElem.className = "snippetLnk";
                        spanElem.id = Player.snippetGetHighlightId(index);
                        // Determine whether to add spaces to the start and end of the word.
                        // We should not add spaces if the mouseed over word is inside another
                        // html element.
                        // We should not add spaces if the mouseed word occurs right after the play here text.
                        var parentIsBlockRegExp = new RegExp(Player.snippetBlockId);
                        var startStr = "";
                        var endStr = "";
                        if(parentNode.parentNode.id.search(parentIsBlockRegExp) != -1){
                            // mouseed over word is not inside another element
                            endStr = " ";
                            // Don't add a space if the word occurs right after the play here text.
                            var thelength = parentNodeStr.split(/\s/)[0].length;
                            if(rngEnd != parentNodeStr.split(/\s/)[0].length)
                                startStr = " ";
                        }
                        spanElem.innerHTML = startStr + word.complete + endStr;
                        mOvrRng.insertNode(spanElem);
                    }
                   
                } else {
                    // on click case
                    var playHereElem = Player.snippetGetPlayHereElem(index);
                    var isChildOfPlayHere = Player.snippetIsChildOf(parentNode, playHereElem, Player.snippetBlockId + "_" + index + "_" + srpindex);
                    var seekTime = 0;
                    if(isChildOfPlayHere){
	                     alert("seektime in if main="+ seekTime);
                        seekTime = ezSnippetTimesAry[srpindex][index].times[0];
                    } else {
                        var snippetBlock = document.getElementById(Player.snippetBlockId + "_" + index + "_" + srpindex);
                        // create range up to where user clicked, this will be used to index into the array that stores
                        // snippet times
                        var textContentRng = document.createRange();
                        textContentRng.setStart(snippetBlock, 0);
                        textContentRng.setEnd(parentNode, rangeOffset);
                        // trim whitespace
                        var textContent = textContentRng.toString().replace(/^\s+/, "").replace(/\s+$/, "");
                        // remove play here element text from string
                        var playHereRng = document.createRange();
                        playHereRng.selectNode(playHereElem);
                        
                        textContent = textContent.replace(playHereRng.toString(), "").replace(/^\s+/, "");
                        var timeIndex = textContent.split(/\s+/).length;
						// TODO Ledbetter this changes based upon view, it should not be hardcoded
                        // subtract 4 from timeIndex, this is because textContent includes the text "Player here 00:34:00"
						// subtract 1 for bcom
                        seekTime = ezSnippetTimesAry[srpindex][index].times[timeIndex - 1];
                    }
                    if(isViewMedia)
                    {
                    	if(typeof playerInst0 != 'undefined') playerInst0.seek(seekTime);

                    	if(window.callFlash) {
                    		callFlash("seek", seekTime);
                    	}
                    	
                    }
                    else
                        return seekTime;
                }
            } else if(!isClick){
                Player.snippetPrevSpanRevert(document.getElementById(Player.snippetGetHighlightId(index)));
				
            } else if( (word.complete.length == 0 || word.complete.length == null) && parentNode.parentNode.id != Player.snippetBlockId + "_" + index + "_" + srpindex){
				// TODO Ledbetter this is hack it should be handled in the above on click case
                // User has clicked in play here area
                seekTime = ezSnippetTimesAry[srpindex][index].times[0];
                if (isViewMedia) {
					if (typeof playerInst0 != 'undefined') 
						playerInst0.seek(seekTime);
					
					if (window.callFlash) {
						callFlash("seek", seekTime);
					}
					
				} else {
					return seekTime;
				}
            }
		} else {
			
			// IE has no methods to directly obtain the offset index
			// have to use ranges to get this information
			// Get selection range
			var selRng = document.selection.createRange();
			if (!isClick)
				selRng.moveToPoint(ev.clientX, ev.clientY);
            // Create a range that just contains the contents of the snippet block, by default IE will have the range
            // include all the snippet blocks
            // The block range will then be used to set the start and end points of startRng and endRng
            var blockRng = selRng.duplicate();
            blockRng.moveToElementText(document.getElementById(Player.snippetBlockId + "_" + index + "_" + srpindex));
            // Duplicate selection range and expand to entire text
		    // We'll then set it's end point to the selRng start and the length will be the offset.
		    var startRng = selRng.duplicate();
		    startRng.expand("textedit");
			startRng.setEndPoint("EndToStart", selRng);
            startRng.setEndPoint("StartToStart", blockRng);
            var endRng = selRng.duplicate();
		    endRng.expand("textedit");
			endRng.setEndPoint("StartToEnd", selRng);
            endRng.setEndPoint("EndToEnd", blockRng);
            var endRngStr = endRng.text;
            var startRngStr = startRng.text;
            
            var word = Player.snippetGetWordObj(strPtns, startRngStr, endRngStr);
            
            if(word.complete.length > 0){
                if(!isClick){
                    // mouse over case
                    // Create a range that contains the word
                    // use range to replace word with word wrapped in a span
                    var mOvrRng = selRng.duplicate();
					// only highlight elements outside of the "play here" element
					if(mOvrRng.parentElement().id == Player.snippetBlockId + "_" + index + "_" + srpindex){
	                    mOvrRng.moveEnd("character", new String(word.end).length);
	                    mOvrRng.moveStart("character", -1 * new String(word.start).length);
	                    var prevSpan = document.getElementById(Player.snippetGetHighlightId(index));
	                    if(prevSpan != selRng.parentElement()){
	                        // if previous span is not the same element as the new span
	                        Player.snippetPrevSpanRevert(prevSpan);
	                        mOvrRng.pasteHTML('<span id="' + Player.snippetGetHighlightId(index) + '" class="' + "snippetLnk" + '">' +
	                                word.complete + '</span>');
	                    }
					}
                } else {
                    // on click case
                    var seekTime = 0;
                    var playHereElem = Player.snippetGetPlayHereElem(index);
                    var isChildOfPlayHere = Player.snippetIsChildOf(selRng.parentElement(), playHereElem, Player.snippetBlockId + "_" + index + "_" + srpindex);
                    if(isChildOfPlayHere){
	                    alert("seektime in if main="+ seekTime);
                        seekTime = ezSnippetTimesAry[srpindex][index].times[0];
                    } else {
                        // remove play here element from string
                        var playHereStr = playHereElem.innerText;
                        startRngStr = startRngStr.replace(playHereStr, "");
                        // trim whitespace
                        startRngStr = startRngStr.replace(/^\s+/, "").replace(/\s+$/, "");
                        var timeIndex = startRngStr.split(/\s+/).length;
                        seekTime = ezSnippetTimesAry[srpindex][index].times[timeIndex - 1];
                        alert("seektime in else="+ seekTime);
                    }
                   
                    if(isViewMedia)
                    {
                    	if(typeof playerInst0 != 'undefined') playerInst0.seek(seekTime);
                    	
                    	if(window.callFlash) {
                    		callFlash("seek", seekTime);
                    	}

                    }
                    else
                        return seekTime;
                }
            } else if(!isClick){
                
                var prevSpan = document.getElementById(Player.snippetGetHighlightId(index));
                // if previous span is not the same element as the new span
                if(prevSpan != null){
                    var prevSpanTextNode = prevSpan.firstChild.cloneNode(false);
                    prevSpan.parentNode.replaceChild(prevSpanTextNode, prevSpan);
                }
            } else if(word.complete.length == 0 && selRng.parentElement().parentNode.id != Player.snippetBlockId + "_" + index + "_" + srpindex){
				// TODO Ledbetter this is hack it should be handled in the above on click case
				// User has clicked in play here area
				seekTime = ezSnippetTimesAry[srpindex][index].times[0];
				if(isViewMedia){
                  	if(typeof playerInst0 != 'undefined') playerInst0.seek(seekTime);

                	if(window.callFlash) {
                		callFlash("seek", seekTime);
                	}

                } else
					return seekTime;
			}
           
		} 
    }
    return 0;
}

// method to hide and show snippet arrows based on search terms or keyterms
Player.prototype.showHideSnippetArrow = function(show, snippetToShow, initialLoad){
	show = show || true;
	snippetToShow = snippetToShow || null;
	initialLoad = initialLoad || false;
	if (PlayerManager.enabled) {
		Player.getPlayerById(this.attributes['id']).showHideSnippetArrow(show, snippetToShow, initialLoad);
	}
}

Player.popupPlayer = function(id, position, adPlayed, refreshPage){
	eval("var playerRef = playerInst" + id);
	var params = FlashObj.GenFlashVars(playerRef.flashVars);
	// Bug/Feature in firefox prevents popups from being called from flash player
	// call popupHelper from timeout to fix this
	if (playerRef.flashVars.popupUpUrl != null) {
		window.setTimeout("Player.popupHelper('" + playerRef.flashVars.popupUpUrl + "', 'popupPlayerWin', Player.popupWin, {height:617, width:748}, " + refreshPage + ")", 200);
	} else {
		window.location = playerRef.viewMediaURI;
		/*window.setTimeout("Player.popupHelper('" + "PopupPlayer.jsp?" + 
					params + 
					"&pos=" + encodeURIComponent(position) + 
					"&adPlayed=" + adPlayed + 
					"&hostid=" + hostid + 
					"&reqtime=" + reqtime + 
					"&querystring=" + encodeURIComponent(querystring) + 
					"&pzSessionId=" + pzSessionId + 
				"', 'popupPlayerWin', Player.popupWin, {height:320, width:360}, " + refreshPage + ")", 200);*/
	}
}

Player.displayFullScreenPlayer = function(id, position, adPlayed, refreshPage){
	eval("var playerRef = playerInst" + id);
	refreshPage = refreshPage || false;
	var fsUrl = new String(window.location);
	var seekParamMatch = fsUrl.match(/[&]seek=[^&]*/);
	if (seekParamMatch  != null) {
		fsUrl = fsUrl.replace(seekParamMatch, "&seek=" + position);
	} else {
		fsUrl += "&seek=" + position;
	}
	window.setTimeout("Player.popupHelper('" + fsUrl + "&fs=true" + "', " + "'fullscreenPlayerWin', Player.fullscreenWin, {height:" + window.screen.height + ", width:" + window.screen.width + "}, " + refreshPage + ")", 200);
}

Player.popupHelper = function(url, id, refObj, params, refreshPage) {
	refObj = window.open(url, id, "height=" + params.height + ",width=" + params.width + ",left=0,top=0,screenX=0,screenY=0,toolbar=0,location=0,menubar=0,statusbar=1,resizable=1,scrollbars=1", true);
	PlayerManager.playing('popup');
	// Refresh/reload page, this is a hack in place to cause
	// the popup player to work for youtube content
	if (refreshPage){
		// set cookie to notify action to not autoPlay upon refresh
		document.cookie = "vmr=true"
		window.location.reload(false); // false indicates the page should be reloaded from browser cache
	}
}

Player.sendEmail = function(recip, sendName, sendAddress, message, isAudio) {
	// HACK ALERT
	// for some strange reason flash will not allow certain js to be called from the same thread
	// as a js method called from flash.  The solution is to call this method from another thread.
	window.setTimeout("Player.sendEmailHelper('" + recip + "','" + 
			sendName.replace(/\'/g, "\\'") + "','" + 
			sendAddress.replace(/\'/g, "\\'") + "','" + 
			message.replace(/\'/g, "\\'") + "'," + 
			isAudio + ",'" + 
			playerId.replace(/\'/g, "\\'") + "')", 200);
}

Player.sendEmailHelper = function(recip, sendName, sendAddr, message, isAudio, playerId) {
	var req = new XmlHttpReq(Player.handleEmailResponse);
	/*
	sendMail - REQUIRED.  When present, tells the ViewMediaAction servlet to treat this as an email request.  Its value does not matter as long as it is non-null

	recip - (Neccessary for email to get sent). Email address of the recipient.  Returns EMAIL_RECIPIENT_MISSING if null or empty.
	
	sendName - (Neccessary for email to get sent). Name of the sender.  Returns EMAIL_SEND_NAME_MISSING if null or empty.
	
	sendAddr - (Necessary for email to get sent).  Address of the sender.  Returns EMAIL_SEND_ADDRESS_MISSING if null or empty
	
	url - (Neccessary for email to get sent).  URL of the media content being shared.  Returns EMAIL_MEDIA_URL_MISSING if null or empty.
	
	media - when value = "au", subject informs the recipient of incoming audio.  Otherwise informs incoming video.
	
	checkAddr - when true, enforces the formatting of the sendAddr and recip email addresses.  If this parameter is true, and either address is malformed, a EMAIL_RECIPIENT_INVALID or EMAIL_SEND_ADDRESS_INVALID status is returned and the email is not sent.
	
	message - User-specified message to embed into the email body. (if null or empty, that section of the email is simply omitted, but the mail is still sent)
	*/
	req.open("GET", EZBaseUrl + "sendEmail.htm?recip=" + encodeURIComponent(recip) + 
			"&sendName=" + encodeURIComponent(sendName) + 
			"&sendAddr=" + encodeURIComponent(sendAddr) + 
			"&message=" + encodeURIComponent(message) +
			"&url=" + encodeURIComponent(Player.getSeriesLink()) +
			"&media=" + (isAudio ? "au" : "vid") + 
			"&description=" + encodeURIComponent(Player.getDescription())+
			"&playerId=" + playerId +
			"&checkAddr=true");
	req.send();
}

Player.handleEmailResponse = function(data) {
	var playerI = Player.getPlayerById("player0");
	playerI.formResponseHandler(data, "email");
}

Player.setSeriesLink = function(seriesLink) {
	// seriesLink does not begin with ?
	seriesLink = seriesLink.replace(/([&]|^)seek=[^&]*/, "");
	seriesLink = seriesLink.replace(/([&]|^)fs=[^&]*/, "");
	seriesLink = seriesLink.replace(/([&]|^)action=embeddedPlayer/, "");
	Player.seriesLink = window.location.protocol + "//" + window.location.hostname + 
			(window.location.port == "80" ? "" : ":" + window.location.port) + 
			window.location.pathname + "?" + seriesLink;
	// remove episode
	var moreLikeThisLink = seriesLink.replace(/([&]|^)e=[^&]*/, "");
	// remove index
	moreLikeThisLink = moreLikeThisLink.replace(/([&]|^)index=[^&]*/, "");
	// remove any leading & characters
	moreLikeThisLink = moreLikeThisLink.replace(/^[&]/, "");
	
	Player.moreLikeThisLink = window.location.protocol + "//" + window.location.hostname + 
			(window.location.port == "80" ? "" : ":" + window.location.port) + 
			"/results.jsp" + "?" + moreLikeThisLink;
}

Player.getSeriesLink = function() {
	return Player.seriesLink;
}

Player.setQ = function(q){
	Player.Q = q;
}

Player.getQ = function(){
	return Player.Q;
}

Player.setURL = function(url) {
	var urlStr = new String(url);
	urlStr = urlStr.replace(/([&]|[?])fs=[^&]*/, "");
	urlStr = urlStr.replace(/([&]|[?])action=embeddedPlayer/, "");
	urlStr = urlStr.replace(/([&]|[?])seek=[^&]*/, "");
	Player.URL = urlStr;
}
Player.getURL = function() {
	return Player.URL;
}

Player.setHTML = function(q, thumbnailSrc) {
	// q does not begin with ?
	q = q.replace(/([&]|^)seek=[^&]*/, "");
	q = q.replace(/([&]|^)fs=[^&]*/, "");
	q = q.replace(/([&]|^)action=embeddedPlayer/, "");
	q = "?" + q;
	var hostname = window.location.hostname + (window.location.port == "80" ? "" : ":" + window.location.port);
	/*var botStr = Player.Q + '&nbsp;' + Player.getDescription().replace(/\<[^>]*\>/g, "");
	var htmlStr = '<scr' + 'ipt type="text/javascript"><!--\n' +
	'// Player needs to be at least 480 pixels wide and \n' +
	'// at least 424 pixels high, otherwise there will be some layout issues\n' +
	'pz_params = {width:480,' +
	' height:424,' +
	' q:"' + q + '"' +
	'};\n' +
	'//--></scr' + 'ipt>\n' +
	'<scr' + 'ipt type="text/javascript" src="http://' + hostname + '/scripts/UIUtil.js"></script>\n' +
	'<scr' + 'ipt type="text/javascript" src="http://' + hostname + '/scripts/Embed.js"></script>\n' + 
	'<a href="' + Player.getSeriesLink() + '" style="display:none;">' + botStr + '</a>';*/
	var page = "viewMedia.jsp" + q + "&fs=true&action=embeddedPlayer";
	var embedWidth = 480;
	var embedHeight = 424;
	var controlsHeight = 64;
	var thumbHeight = 180;
	var thumbWidth = 240;
	var botStr = Player.Q + '&nbsp;' + Player.getDescription().replace(/\<[^>]*\>/g, "");
	htmlStr = '<iframe frameborder="0" scrolling="no" src="http://' + hostname + '/' + page + '" width="' + embedWidth + '" height="' + embedHeight + '"></iframe>' +
	'<br>\n<a href="' + Player.getSeriesLink() + '" style="display:none;">' + botStr + '</a>';
	var htmlStr2 = '<div class="fooIsThisClass">';
	htmlStr2 += '<a href="' + Player.getSeriesLink() + '"><div class="thisIsSonOfFoo"><center><div></div><img style="border:none;" src="' + thumbnailSrc + '" width="' + thumbWidth + '" height="' + thumbHeight + '"/></center></div><img style="border:none;" src="http://' + hostname + '/images/player-controls.gif"/></a>';
	htmlStr2 += '</div>';
	Player.embedHtmlStr = htmlStr;
	Player.embedHtmlStr2 = htmlStr2;
}

Player.getHTML = function(type) {
	if(type == null || type == "bHtml" || type == "bBlogger")
		return Player.embedHtmlStr;
	else
		return Player.embedHtmlStr2;
}

Player.setDescription = function(description) {
	Player.description = description;
}

Player.getDescription = function() {
	return Player.description;
}

Player.MoreLikeThisClick = function() {
	window.setTimeout("window.top.location = '" + Player.moreLikeThisLink + "'", 200);
}

Player.embeddedLogoClick = function() {
	window.setTimeout("window.top.location = 'http://www.everyzing.com'", 200);
}

Player.unselectSnippetBgs = function(ev, force)
{
    if(typeof ev != "undefined" && Player.currentSnippetBlock != null)
    {
        var el=PlayerUtil.getSourceElement(ev);
        if(!force && el.id != null && el.id.search(new RegExp("(" + Player.snippetGetHighlightId() + ")|(" + Player.snippetBlockId + ")|(" + Player.snippetMatchId + ")")) != -1){
            return;
        } else {
            // document.getElementById(Player.currentSnippetBlock).style.background = "transparent";
            // Rather than styling inline, we need to add/remove a class on the fly.
            jscss('remove',document.getElementById(Player.currentSnippetBlock), 'snippetHighlight');
        }
    }
}

Player.selectUnselectSnippet = function(select, playerIndex,fromSnippets,snipTabInstance) {
    var oldSnippetBlock = null;
    var fullTextArea = document.getElementById("fullTranscript");
    snipTabInstance = snipTabInstance || (fullTextArea.style.display == "none" ? 0 : 1 );
    if(fromSnippets)
    {
	    if(Player.currentSnippetBlock != "snippetHighlight_" + playerIndex + "_" + snipTabInstance){
	        oldSnippetBlock = document.getElementById(Player.currentSnippetBlock);
	        Player.currentSnippetBlock = "snippetHighlight_" + playerIndex + "_" + snipTabInstance;
	    }
	}
    
	var snippetBlock = document.getElementById("snippetHighlight_" + playerIndex + "_" + snipTabInstance);
	if (snippetBlock != null){
        // snippetBlock.style.background = (fromSnippets || select) ? "#EEF9FE" : "transparent";
        (fromSnippets || select) ? jscss('add',snippetBlock, 'snippetHighlight') : jscss('remove',snippetBlock, 'snippetHighlight');
		// called from js not flash
		if (fromSnippets){
		
		    if(oldSnippetBlock != null)
            	// oldSnippetBlock.style.background = "transparent";
		        jscss('remove', oldSnippetBlock, 'snippetHighlight');
			var playerI = Player.getPlayerById("player0");
			if(playerI != null){
				playerI.highlightSnippetArrow(select,playerIndex);
			}
		}
	}
    return false;
}

Player.thumbClick = function(id) {
	eval("var playerRef = playerInst" + id);
	if(playerRef.clickableThumbInfo.target != null)
		window.setTimeout("window.top.location = '" + playerRef.clickableThumbInfo.href + "'", 200);
	else
		window.setTimeout("window.location = '" + playerRef.clickableThumbInfo.href + "'", 200);
}

Player.getPlayerById = function(id){
	return UIUtil.isIE() ? window[id] : document[id];
}

Player.resourceBundle = null;

Player.getResourceBundle = function() {
	if (Player.resourceBundle == null)
		Player.resourceBundle = ResourceBundle.getStringsFromBundle('player');
	return Player.resourceBundle;
}

Player.writeYouTubePlayer = function(width, height, vidId) {
	document.writeln("<object width=\"" + width + "\" height=\"" + height + "\">" +
				"<param name=\"movie\" value=\"http://www.youtube.com/v/" + vidId + "\"></param>" +
				"<param name=\"wmode\" value=\"transparent\"></param>" +
				"<embed src=\"http://www.youtube.com/v/" + vidId + "\" " +
				"type=\"application/x-shockwave-flash\" " + 
				"wmode=\"transparent\" " +
				"width=\""+ width + "\" " +
				"height=\""+ height + "\"></embed></object>");
}


Player.SNIPPET_TYPE_ST = 0;
Player.SNIPPET_TYPE_KW = 1;

// Selection types single, all search terms, and full text
Player.SNIPPET_SELECT_TYPE_S = 0;
Player.SNIPPET_SELECT_TYPE_AST = 1;
Player.SNIPPET_SELECT_TYPE_FT = 2;

// Flash 9 contains a bug when using IE and mulitple instances of flash.
// If the page in this case is reloaded IE goes into an infinite loop.
// To fix this we need to overwrite the functions set up by flash
// see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
Player.overrideFlashFunctions = function() {
	__flash_unloadHandler = function(){};
	__flash_savedUnloadHandler = function(){};
}

UIUtil.addToBodyOnBeforeUnload(Player.overrideFlashFunctions);

