﻿InfoDisplayModule.prototype.startInfoDisplay = function(){
	this.infoDisplayDiv = document.getElementById("infodisplay");
	this.infoDisplayFrame = document.getElementById("infodisplayframe");
	this.infoDisplayDiv.style.display = "none";
	
	var topDiv = document.createElement("div");
	topDiv.style.width = this.width + "px";
	topDiv.style.height = "22px";
	topDiv.style.backgroundColor = "#EDEDED";
	this.infoDisplayDiv.insertBefore(topDiv, this.infoDisplayFrame);
	
	var closeButtonLink = document.createElement("a");
	closeButtonLink.href = "#";
	closeButtonLink.setAttribute("onclick", "infodisplay.close();return false;");
	closeButtonLink.style.position = "relative";
	closeButtonLink.style.cssFloat = "right";

	// Thank you IE!
	closeButtonLink.style.styleFloat = "right";
	
	closeButtonLink.style.top = "2px";
	closeButtonLink.style.width = "60px";
	closeButtonLink.style.height = "18px";
	closeButtonLink.style.textDecoration = "none";
	closeButtonLink.style.color = "#878787";
	closeButtonLink.style.backgroundImage = "url('img/infodisplay/closebutton.gif')";
	closeButtonLink.style.fontFamily = "Arial, sans-serif";
	closeButtonLink.style.fontSize = "8pt";
	closeButtonLink.style.marginRight = "4px";
	topDiv.appendChild(closeButtonLink);
	
	var closeText = document.createElement("span");
	closeText.style.position = "relative";
	closeText.style.left = "5px";
	closeText.style.top = "2px";
	closeText.style.marginLeft = "5px";
	
	
	closeText.innerHTML = "Close";
	closeButtonLink.appendChild(closeText);
	
	// Crazy hack for IE
	topDiv.innerHTML = topDiv.innerHTML;
}

InfoDisplayModule.prototype.showSettings = function(){
	this.infoDisplayFrame.src = "Settings.aspx?currentquality=" + quality + "&playerkey=" + playerkey;
	this.infoDisplayDiv.style.display = "block";
}



InfoDisplayModule.prototype.showArchive = function(){
	this.infoDisplayFrame.src = "Archive.aspx?playerkey="+ playerkey;
	this.infoDisplayDiv.style.display = "block";
}


InfoDisplayModule.prototype.showTip = function(){
	var mediaDetails;
	if(playingType == "live"){
		mediaDetails = "liveid=" + playingId;
	}
	else{
		mediaDetails = "ondemandid=" + playingId;
	}
	
	this.infoDisplayFrame.src = "Tip.aspx?playerkey=" + playerkey + "&tiptextkey=" + tiptextkey + "&" + mediaDetails;
	
	this.infoDisplayDiv.style.display = "block";
}

InfoDisplayModule.prototype.showSearchResult = function(){

}

InfoDisplayModule.prototype.close = function(){
	this.infoDisplayDiv.style.display = "none";
	this.infoDisplayFrame.src = "";
}

if(infodisplay){
	dojo.event.connect('before', window, 'onload', infodisplay, 'startInfoDisplay');
	dojo.event.connect(player, 'SettingsShowEvent', infodisplay, 'showSettings');
	//dojo.event.connect(player, 'HelpShowEvent', infodisplay, 'showHelp');
	dojo.event.connect(player, 'TipShowEvent', infodisplay, 'showTip');
	dojo.event.connect(player, 'ArchiveShowEvent', infodisplay, 'showArchive');
	dojo.event.connect(player, 'SearchResultShowEvent', infodisplay, 'showSearchResult');
	dojo.event.connect(player, 'SetQualityEvent', infodisplay, 'close');
	dojo.event.connect(player, 'SendTipEvent', infodisplay, 'close');
	dojo.event.connect(player, 'EpglistClickEvent', infodisplay, 'close');
	dojo.event.connect(player, 'EpginfoPlayEvent', infodisplay, 'close');
	dojo.event.connect(player, 'PushPlayEvent', infodisplay, 'close');
}

