/// <reference path="http://code.jquery.com/jquery-1.4.1-vsdoc.js" />

// Functions for the home page.

function OpenSubject(SubjectID) {
	GoToLibrary(SubjectID);
}

function GoToLibrary(SubjectID, Media) {
	if (typeof SubjectID == 'undefined')
		SubjectID = -1;
	if (typeof Media == 'undefined')
		Media = 3;
	window.location = '/player.html#!SubjectPlay=' + SubjectID + '&Media=' + Media;
}

function Play(ItemID) {
	window.location = '/player.html#!Item=' + ItemID;
}

function Search() {
	var str = $("#txtHeaderSearch").val();
	if (str.length > 0 && str != strBaseSearch)
		window.location = '/player.html#!Search=' + str;
	else {
		//$.modal("Please enter a search term before searching", { overlayClose: true });
		//var tModal = setTimeout("$.modal.close()", 2000);
	}
}

function PlayAudio(loc, AudioID) {
	$("#title_" + AudioID).text("change to player. ");
	var aText = "x";
	var aClose = aText.link("javascript:ClosePlayer(" + loc + ", " + AudioID + ")");
	$("#title_" + AudioID).append(aClose);
}

function ClosePlayer(loc, AudioID) {
	var aText = "Audio";
	var aPlayer;
	if (loc == 0) {
		aText = "Today's Audio";
		aPlayer = aText.link("javascript:PlayAudio(" + loc + ", " + AudioID + ")");
		$("#title_" + AudioID).html(aPlayer);
	}
	else {
		$.post("/dynamic/ProductTitle.php", { "Product": AudioID }, function (data) {
			if (data) {
				var pro = eval("(" + data + ")");
				aText = pro.title;
			}
			aPlayer = aText.link("javascript:PlayAudio(" + loc + ", " + AudioID + ")");
			$("#title_" + AudioID).html(aPlayer);
		});
	}
}
