var vidblockWidth = 116
var dirMargin = 25
var middleMargin = 1
var selectColor = "#bfdbfe" //better blue color: bfdbfe, safe blue color: 99ccff
var nonSelectColor = "#f2f2f2" //alternative: "white"
var currentlySelected = null

var initalStructureTop = 175
var initialStructureLeft = 50
var initialVidBlockHeight = 263
var initialVidBlockWidth = 166
var initialVidBlockBottom = 0
var initialVidImageWidth = 150
var initialVidImageHeight = 215
var initialMiddleMargin = 5
var initialTitleFontSize = 16
var initialDirMarginBottom = 135

var expandStructureHeight = 263
var expandStructureWidth = 634
var expandStructureTop = 175
var expandStructureLeft = 10
var expandVidBlockHeight = 190
var expandVidBlockWidth = 116
var expandVidBlockBottom = 36
var expandVidImageWidth = 100
var expandVidImageHeight = 142
var expandMiddleMargin = 3
var expandTitleFontSize = 13
var expandDirMarginBottom = 135

var detailsBlockWidth = 300
var windowWidth
var pageWidth
var centerBuffer = 0

var autoPlayMedia = false

var maxBlocks = 5		// max number of blocks possible
var totalBlocks = 5		// total blocks to show (depends on entries in array)

function initialFormat() {

     clearSelection()
     currentlySelected = null
     windowWidth =  document.body.clientWidth
     initialStructureWidth = (dirMargin*2)+((initialMiddleMargin+initialVidBlockWidth)*totalBlocks)-initialMiddleMargin
     pageWidth = (dirMargin*2)+((initialMiddleMargin+initialVidBlockWidth)*maxBlocks)-initialMiddleMargin + (2*expandStructureLeft)

     centerBuffer = 0
     if (windowWidth > pageWidth) {
     centerBuffer = Math.round((windowWidth - pageWidth) / 2)
     }

//alert(centerBuffer + " = " +windowWidth + " - " + pageWidth + " / 2")

     document.getElementById("error").style.display = "none"

     if (totalHours != null) {
     document.getElementById("totalHoursMessage").innerHTML = totalHours + " hours of free quality video available for stream and download."
     }

     document.getElementById("detailsblock").style.display = "none"
     document.getElementById("detailsblock").style.height = initialVidBlockHeight+-2+((navigator.appName=="Microsoft Internet Explorer")?2:0)
     document.getElementById("detailsblock").style.width = detailsBlockWidth+-1+((navigator.appName=="Microsoft Internet Explorer")?1:0)
     document.getElementById("bodyMediaBlock").style.display = "none"

     document.getElementById("structure").style.display = "inline"
     document.getElementById("structure").style.height = initialVidBlockHeight
     document.getElementById("structure").style.width = initialStructureWidth
     document.getElementById("structure").style.top = initalStructureTop
     document.getElementById("structure").style.left = centerBuffer + expandStructureLeft + (maxBlocks - totalBlocks) * ((initialVidBlockWidth + initialMiddleMargin)/2)

     document.getElementById("dirMarginLeft").style.bottom = initialDirMarginBottom
     document.getElementById("dirMarginRight").style.bottom = initialDirMarginBottom

// prevents seeing end of list by removing back button at beginning of list
     if (displayedArray == todayArray) {
     document.getElementById("returnToToday").style.display = "none"
     if (shuffleShift > 0) {
     document.getElementById("backButton").style.display = "inline"
     }
     else {
     document.getElementById("backButton").style.display = "none"
     }
     }
     else {
     document.getElementById("returnToToday").style.display = "inline"
     document.getElementById("backButton").style.display = "inline"
     }

     for (j=0; j<totalBlocks; j++) 
     {
     document.getElementById("vidblock"+j).style.height = initialVidBlockHeight
     document.getElementById("vidblock"+j).style.width = initialVidBlockWidth
     document.getElementById("vidblock"+j).style.bottom = initialVidBlockBottom
     document.getElementById("image"+j).style.width = initialVidImageWidth
     document.getElementById("image"+j).style.height = initialVidImageHeight
     document.getElementById("title"+j).style.fontSize = initialTitleFontSize

     document.getElementById("trc"+j).style.display = "inline"
     document.getElementById("brc"+j).style.display = "inline"

     document.getElementById("vidblock"+j).style.left = dirMargin + j * (initialVidBlockWidth + initialMiddleMargin)
     }

     for (k=0; k<maxBlocks; k++)
     {
     if (k < totalBlocks) {
     document.getElementById("vidblock"+k).style.display = "inline"
     }
     else {
     document.getElementById("vidblock"+k).style.display = "none"
     }

     }

     if (maxBlocks >= displayedArray.length) {
     document.getElementById("dirMarginLeft").style.display = "none"
     document.getElementById("dirMarginRight").style.display = "none"
     }
     else {
     document.getElementById("dirMarginLeft").style.display = "inline"
     document.getElementById("dirMarginRight").style.display = "inline"
     }


//alert(window.screen.availWidth)
//window.resizeTo(800,600)
//alert(windowWidth)
}


function vidFormat() {

     clearSelection()

     expandStructureWidth = (dirMargin*2)+((expandMiddleMargin+expandVidBlockWidth)*(totalBlocks-1))+initialVidBlockWidth+detailsBlockWidth

     document.getElementById('structure').style.height = expandStructureHeight
     document.getElementById('structure').style.width = expandStructureWidth
     document.getElementById("structure").style.top = expandStructureTop

if (centerBuffer + expandStructureLeft < initialStructureLeft) {
     document.getElementById("structure").style.left = expandStructureLeft
}
else {
     document.getElementById("structure").style.left = centerBuffer + expandStructureLeft - initialStructureLeft// + (maxBlocks - totalBlocks) * ((expandVidBlockWidth + expandMiddleMargin)/2)
}

     document.getElementById("dirMarginLeft").style.bottom = expandDirMarginBottom
     document.getElementById("dirMarginRight").style.bottom = expandDirMarginBottom

     for (j=0; j<totalBlocks; j++) 
     {

     if (j != clickedVidBlock) {
     document.getElementById("vidblock"+j).style.height = expandVidBlockHeight
     document.getElementById("vidblock"+j).style.width = expandVidBlockWidth
     document.getElementById("vidblock"+j).style.bottom = expandVidBlockBottom
     document.getElementById("image"+j).style.width = expandVidImageWidth
     document.getElementById("image"+j).style.height = expandVidImageHeight
     document.getElementById("title"+j).style.fontSize = expandTitleFontSize

     document.getElementById("trc"+j).style.display = "inline"
     document.getElementById("brc"+j).style.display = "inline"
     }
     else {
     document.getElementById("vidblock"+j).style.height = initialVidBlockHeight
     document.getElementById("vidblock"+j).style.width = initialVidBlockWidth
     document.getElementById("vidblock"+j).style.bottom = initialVidBlockBottom
     document.getElementById("image"+j).style.width = initialVidImageWidth
     document.getElementById("image"+j).style.height = initialVidImageHeight
     document.getElementById("title"+j).style.fontSize = initialTitleFontSize

     document.getElementById("trc"+j).style.display = "none"
     document.getElementById("brc"+j).style.display = "none"
     }

     if (j <= clickedVidBlock) {
     document.getElementById("vidblock"+j).style.left = dirMargin + j * (expandVidBlockWidth + expandMiddleMargin) + (maxBlocks - totalBlocks) * ((expandVidBlockWidth + expandMiddleMargin)/2)
     }
     else {
     document.getElementById("vidblock"+j).style.left = dirMargin + j * (expandVidBlockWidth + expandMiddleMargin) + (maxBlocks - totalBlocks) * ((expandVidBlockWidth + expandMiddleMargin)/2) + (initialVidBlockWidth - expandVidBlockWidth) + detailsBlockWidth
     }
     }

     document.getElementById("detailsblock").style.left = dirMargin + (clickedVidBlock) * (expandVidBlockWidth + expandMiddleMargin) + (maxBlocks - totalBlocks) * ((expandVidBlockWidth + expandMiddleMargin)/2) + initialVidBlockWidth

     document.getElementById("vidblock"+clickedVidBlock).style.backgroundColor = selectColor
     document.getElementById("ltc"+clickedVidBlock).style.backgroundColor = selectColor
     document.getElementById("rtc"+clickedVidBlock).style.backgroundColor = selectColor

     document.getElementById("detailsblock").style.display = "inline"

     for (k=0; k<maxBlocks; k++)
     {
     if (k < totalBlocks) {
     document.getElementById("vidblock"+k).style.display = "inline"
     }
     else {
     document.getElementById("vidblock"+k).style.display = "none"
     }

     }


     currentlySelected = clickedVidBlock
}

function scrollExpand(currentHeight) {

     for (i = currentHeight; i <= expandHeight; i++) {
     document.getElementById("structure").style.height = currentHeight + i
     }

}

function clearSelection() {
     for (i=0; i<totalBlocks; i++) {
     document.getElementById("vidblock"+i).style.backgroundColor = nonSelectColor
     document.getElementById("ltc"+i).style.backgroundColor = nonSelectColor
     document.getElementById("rtc"+i).style.backgroundColor = nonSelectColor
     }
}


function displayArray(vidArray) {

     displayedArray = vidArray

     if (vidArray.length <= maxBlocks) {
     totalBlocks = vidArray.length
     }
     else {
     totalBlocks = maxBlocks
     }

     for (i=0; i<totalBlocks; i++) 
     {
     document.getElementById("title"+i).innerHTML = vidArray[i].title
     document.getElementById("image"+i).src = vidArray[i].image
     }

     initialFormat()

}


function displayDetails() {
     var ratingWidth
     var ratingInset = 4

// fill in details in detailsBlock on page
     document.getElementById("detailsTitle").innerHTML = displayedArray[clickedVidBlock].title+((navigator.appName=="Microsoft Internet Explorer")?" ":"")
     document.getElementById("detailsAuthor").innerHTML = displayedArray[clickedVidBlock].author
     document.getElementById("genre").innerHTML = displayedArray[clickedVidBlock].genre
     document.getElementById("runtime").innerHTML = displayedArray[clickedVidBlock].runtime

// clear mediablock
     document.getElementById("mediablock").innerHTML = ""

     if (displayedArray[clickedVidBlock].language.toLowerCase() != "english" && displayedArray[clickedVidBlock].language.toLowerCase() != "eng" && displayedArray[clickedVidBlock].language.toLowerCase() != "en") {
     document.getElementById("language").innerHTML = ', ' + displayedArray[clickedVidBlock].language
     document.getElementById("language").style.display = "inline"
     }
     else {
     document.getElementById("language").style.display = "none"
     }

     document.getElementById("reviewsLink").href = displayedArray[clickedVidBlock].review
     document.getElementById("websiteLink").href = displayedArray[clickedVidBlock].website

     if (displayedArray[clickedVidBlock].rating >= 0) {
     document.getElementById("notRated").style.display = "none"

     ratingWidth = 5+11*(displayedArray[clickedVidBlock].rating)
     }
     else {
     document.getElementById("notRated").style.display = "inline"
     ratingWidth = 0
     }

     document.getElementById("rating").style.right = ratingInset + (64-ratingWidth)
     document.getElementById("rating").style.width = ratingWidth

     if (autoPlayMedia == false) {
     displayDescription()
     }
     else {
     displayPreview()
     }
}


function displayDescription() {

     document.getElementById("descriptionText").innerHTML = '<b>Description:</b><br />' + displayedArray[clickedVidBlock].description

     document.getElementById("bodyDescription").style.display = "block"
     document.getElementById("bodyMediaBlock").style.display = "none"

}


function displayPreview() {
     var mediaBlock = ""
     var mediaType = "Quicktime"	// can be "Windows Media" or "Quicktime"
     var mediaWidth = 220
     var mediaHeight = 165
     var mediaDomain = clickedVidURL.slice(0,22).toLowerCase()
     var mediaExtension = clickedVidURL.slice(clickedVidURL.length - 4).toLowerCase()
     var showControls = false
     var autoPlay

     if (!showControls) {
     autoPlay = true
     }

     document.getElementById("bodyDescription").style.display = "none"
     document.getElementById("bodyMediaBlock").style.display = "block"

     if (clickedVidURL.toLowerCase() == "" || clickedVidURL.toLowerCase() == "no" || clickedVidURL.toLowerCase() == "none" || clickedVidURL.toLowerCase() == "http://") {
     mediaBlock = '<br /><br /><br /><br /><br /><b>Sorry, no preview is available at this time.</b>'
     }
     else {

     if (mediaDomain == "http://video.google.co") {
     mediaType = "Google"
     }
     else if (mediaDomain == "http://www.youtube.com") {
     mediaType = "YouTube"
     }
     else if (mediaExtension == ".mov" || mediaExtension == ".mp4" || mediaExtension == ".mpg" || mediaExtension == ".mpeg") {
     mediaType = "Quicktime"
     }
     else if (mediaExtension == ".wmv" || mediaExtension == ".avi" || mediaExtension == ".divx") {
     mediaType = "Windows Media"
     }

     if (mediaType == "Google") {

/* template for embedding Google Video file
<embed style="width:400px; height:326px;" id="VideoPlayback" align="middle" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DnQAAAIcyXEv06hofL0etBzD5uIGPcC_BcgUX08A8n3jiONWBaBUmlnTteY6fXYlkj-0_pu4KUY6NyRAAlOBZiNXS2hstGWGYjBUWRE-RXNjpyNyaCSyrqE-SzBVctbTk-2fLYy85HucRu0L9J46TNlJg-JNDYvscCVJTBy2XJhg0fiFxddhgy7hwEBrYNk8OjaeyCF3nfLcbCHg4gp8UcNRh6F0%26sigh%3Dz3GY1H_WM_nYEIveSXYNU20FHU0%26begin%3D0%26len%3D442999%26docid%3D-3168939844864107798&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer%3Fcontentid%3Ddbd692653aeae7db%26second%3D5%26itag%3Dw320%26urlcreated%3D1142717248%26sigh%3DD0sLr8FW2oUElnEXh01UoHG5EiM&playerId=-3168939844864107798" allowScriptAccess="sameDomain" quality="best" bgcolor="#ffffff" scale="noScale" wmode="window" salign="TL"  FlashVars="playerMode=embedded"> </embed>
*/
     mediaBlock = '<embed style="width:'+mediaWidth+'px; height:'+mediaHeight+'px;" id="VideoPlayback" align="middle" type="application/x-shockwave-flash" src="'+clickedVidURL+'" allowScriptAccess="sameDomain" quality="best" bgcolor="#ffffff" scale="noScale" wmode="window" salign="TL" FlashVars="playerMode=embedded"> </embed>'
     }

     if (mediaType == "YouTube") {

/* template for embedding YouTube file
<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/VeW1UOAeLvM"></param><embed src="http://www.youtube.com/v/VeW1UOAeLvM" type="application/x-shockwave-flash" width="425" height="350"></embed></object>
*/
     mediaBlock = '<object width="'+mediaWidth+'" height="'+mediaHeight+'"><param name="movie" value="'+clickedVidURL+'"></param><embed src="'+clickedVidURL+'" type="application/x-shockwave-flash" width="'+mediaWidth+'" height="'+mediaHeight+'"></embed></object>'
     }


     if (mediaType == "Windows Media") {

/* template for embedding Windows file
<object id="MediaPlayer" width="320" height="240" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
standby="Loading Windows Media Player components..." type="application/x-oleobject">
<param name="FileName" value="videofilename.wmv">
<param name="ShowControls" value="true">
<param name="ShowStatusBar" value="false">
<param name="ShowDisplay" value="false">
<param name="autostart" value="false">
<embed type="application/x-mplayer2" src="videofilename.wmv" name="MediaPlayer" width="320" height="240" ShowControls="1" ShowStatusBar="0" ShowDisplay="0" autostart="0"> </embed>
</object>
*/

     mediaBlock += '<object id="MediaPlayer" width="'+mediaWidth+'" height="'+(mediaHeight+((showControls==true)?30:0))+'" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject">'
     mediaBlock += '<param name="FileName" value="'+clickedVidURL+'" />'
     mediaBlock += '<param name="ShowControls" value="'+((showControls==true)?'true':'false')+'" />'
     mediaBlock += '<param name="ShowStatusBar" value="false" />'
     mediaBlock += '<param name="ShowDisplay" value="false" />'
     mediaBlock += '<param name="autostart" value="'+((autoPlay==true)?'true':'false')+'" />'
     mediaBlock += '<embed type="application/x-mplayer2" src="'+clickedVidURL+'" name="MediaPlayer" width="'+mediaWidth+'" height="'+(mediaHeight+((showControls==true)?30:0))+'" ShowControls="'+((showControls==true)?'1':'0')+'" ShowStatusBar="0" ShowDisplay="0" autostart="'+((autoPlay==true)?'1':'0')+'"> </embed>'
     mediaBlock += '</object>'
     }

     if (mediaType == "Quicktime") {

/* template for embedding Quicktime file
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="320" height="180" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
<param name="src" value="videofilename.mov">
<param name="autoplay" value="false">
<param name="controller" value="true">
<embed src="videofilename.mov" width="320" height="180" autoplay="false" controller="true" pluginspage="http://www.apple.com/quicktime/download/"> </embed>
</object>
*/

     mediaBlock += '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="'+mediaWidth+'" height="'+(mediaHeight+((showControls==true)?10:0))+'" codebase="http://www.apple.com/qtactivex/qtplugin.cab">'
     mediaBlock += '<param name="src" value="'+clickedVidURL+'">'
     mediaBlock += '<param name="autoplay" value="'+((autoPlay==true)?'true':'false')+'">'
     mediaBlock += '<param name="controller" value="'+((showControls==true)?'true':'false')+'">'
     mediaBlock += '<embed src="'+clickedVidURL+'" width="'+mediaWidth+'" height="'+(mediaHeight+((showControls==true)?10:0))+'" autoplay="'+((autoPlay==true)?'true':'false')+'" controller="'+((showControls==true)?'true':'false')+'" pluginspage="http://www.apple.com/quicktime/download/"> </embed>'
     mediaBlock += '</object>'

     }
     }

     document.getElementById("mediablock").innerHTML = mediaBlock

}


function displayDownloads() {
     var printDownloads = '<b>Available Downloads:</b><br />'
     var fileNo = 1

     for (i = 0; i < fileListArray.length; i++) {
     if (fileListArray[i].type.toLowerCase() != "stream") {
     printDownloads += '<span style="white-space: nowrap; text-transform: capitalize"><a href="' + fileListArray[i].fileURL + '">File ' + fileNo + '</a> - ' + fileListArray[i].quality + ' quality (' + fileListArray[i].size + ' mb), ' + fileListArray[i].type + '</span><br />'
     fileNo++
     }
     }

     if (fileNo == 1) {
     printDownloads += '<i>No file downloads available.</i><br />'
     }

     printDownloads += '<br /><b>Available Streams:</b><br />'
     fileNo = 1

     for (i = 0; i < fileListArray.length; i++) {
     if (fileListArray[i].type.toLowerCase() == "stream") {
     printDownloads += '<span style="white-space: nowrap; text-transform: capitalize"><a href="' + fileListArray[i].fileURL + '" target="_blank">Stream ' + fileNo + '</a> - ' + fileListArray[i].quality + ' quality</span><br />'
     fileNo++
     }
     }

     if (fileNo == 1) {
     printDownloads += '<i>No streams available.</i><br />'
     }

     printDownloads += '<br /><div style="font-size: 10px; text-align: left">To download a file, right-click or control-click on the "File" link and choose "Save ' + ((navigator.appName=="Microsoft Internet Explorer")?'Target':'Link') + ' As..."<br />To stream a file, simply click on the link and a new window will open.</div>'

     document.getElementById("descriptionText").innerHTML = printDownloads
     document.getElementById("bodyDescription").style.display = "block"
     document.getElementById("bodyMediaBlock").style.display = "none"

}


function displayEmail() {

     var locationStart = "http://www.engio.com/home.htm"
     var printEmail = '<form name="emailForm" action="http://www.audienceoftwo.com/stage/engio_mail.php" method="get" target="_blank">'
     printEmail += '<div  style="position: absolute; top: 2px; left: 6px;">'
     printEmail += '<b>Link to this film:</b>'
     printEmail += '<form name="emailForm" action="" method="get">'
     printEmail += '<div class="inputField">'
     printEmail += 'Film URL (e-mail or link it):<br />'
     printEmail += '<input class="inputBox" name="fURL" id="fURL" onClick="javascript:document.emailForm.fURL.focus();document.emailForm.fURL.select();" readonly="true" type="text" value="'+locationStart+'?id='+clickedVidId+'">'
     printEmail += '<input name="fTitle" id="fTitle" type="hidden" value="'+clickedVidTitle+'">'
     printEmail += '</div><br />'

     printEmail += '<b>E-mail this link to a friend:</b>'
     printEmail += '<div class="inputField">'
     printEmail += 'Your e-mail address:<br />'
     printEmail += '<input class="inputBox" name="sender" id="sender" type="text">'
     printEmail += '</div>'

     printEmail += '<div class="inputField">'
     printEmail += 'Recipient\'s e-mail address:<br />'
     printEmail += '<input class="inputBox" name="recipient" id="recipient" type="text"><br />'
     printEmail += '</div>'
     printEmail += '<div style="position: absolute; top: 200px; left: 80px;">'
     printEmail += '<input class="buttonLink" name="submitButton" id="submitButton" type="submit" value="Send Link" style="width: 100px; height: 26px; font-family: arial,sans-serif; font-size: 13px; text-decoration: underline; color: #0000CC; cursor: pointer;"><br /><br /> '
//     printEmail += '<a class="buttonLink" onclick="document.getElementById(\'submitForm\').submit()" id="submitButton">Send Link</a>'
     printEmail += '</div>'
     printEmail += '</form>'
     printEmail += '</div>'

     document.getElementById("descriptionText").innerHTML = printEmail
     document.getElementById("bodyDescription").style.display = "block"
     document.getElementById("bodyMediaBlock").style.display = "none"
}


function changeView(view, inOrOut) {

     if (view == "favorites") {
     if (inOrOut == true) {
     document.getElementById("addFavorite").style.display = "none"
     document.getElementById("removeFavorite").style.display = "inline"
     }
     else {
     document.getElementById("addFavorite").style.display = "inline"
     document.getElementById("removeFavorite").style.display = "none"
     }
     }

/*
     if (view == "series") {
     if (inOrOut == true) {
     document.getElementById("detailsSeries").style.display = "none"
     document.getElementById("detailsDate").style.display = "inline"
     document.getElementById("detailsSeriesTitle").innerHTML = seriesTitle+((navigator.appName=="Microsoft Internet Explorer")?" ":"")
     }
     else {
     document.getElementById("detailsSeries").style.display = "inline"
     document.getElementById("detailsDate").style.display = "none"
     document.getElementById("detailsSeriesTitle").innerHTML = ""
     }
     }
*/
}


function selectBlock(block, inOrOut) {
     var makeColor

     if (currentlySelected != block) {
//alert(currentlySelected)
     if (inOrOut == true) {
     makeColor = selectColor
     }
     else {
     makeColor = nonSelectColor
     }

     document.getElementById("vidblock"+block).style.backgroundColor = makeColor
     document.getElementById("ltc"+block).style.backgroundColor = makeColor
     document.getElementById("rtc"+block).style.backgroundColor = makeColor

     }
}


function displayFavoritesNumber() {

     var favoritesNumber
     var favoriteIdArray = new Array()
     var tempFavoriteList = getCookie("favorites")

     if (tempFavoriteList == null || tempFavoriteList == "") {
     favoritesNumber = 0
     document.getElementById("myFavorites").style.fontWeight = "normal"
     }

     else {
     favoriteIdArray = tempFavoriteList.split(",")
     favoritesNumber = favoriteIdArray.length
     document.getElementById("myFavorites").style.fontWeight = "bold"
     }

     document.getElementById("favoritesNumber").innerHTML = favoritesNumber

}


function turnAutoPlay(onOrOff) {
     if (onOrOff == "on" || onOrOff == true) {
     document.getElementById("autoplayOn").style.fontWeight = "bold"
     document.getElementById("autoplayOn").style.textDecoration = "underline"
     document.getElementById("autoplayOn").style.color = "#0000CC"
     document.getElementById("autoplayOn").style.cursor = "pointer"

     document.getElementById("autoplayOn").style.display = "inline"
     document.getElementById("autoplayOff").style.display = "none"

/*
     document.getElementById("autoplayOn").style.fontWeight = "bold"
     document.getElementById("autoplayOn").style.textDecoration = "none"
     document.getElementById("autoplayOn").style.color = "#000000"
     document.getElementById("autoplayOn").style.cursor = "default"

     document.getElementById("autoplayOff").style.fontWeight = "normal"
     document.getElementById("autoplayOff").style.textDecoration = "underline"
     document.getElementById("autoplayOff").style.color = "#0000CC"
     document.getElementById("autoplayOff").style.cursor = "pointer"
*/

     autoPlayMedia = true
     }
     else {
     document.getElementById("autoplayOff").style.fontWeight = "normal"
     document.getElementById("autoplayOff").style.textDecoration = "underline"
     document.getElementById("autoplayOff").style.color = "#0000CC"
     document.getElementById("autoplayOff").style.cursor = "pointer"

     document.getElementById("autoplayOff").style.display = "inline"
     document.getElementById("autoplayOn").style.display = "none"

/*
     document.getElementById("autoplayOn").style.fontWeight = "normal"
     document.getElementById("autoplayOn").style.textDecoration = "underline"
     document.getElementById("autoplayOn").style.color = "#0000CC"
     document.getElementById("autoplayOn").style.cursor = "pointer"

     document.getElementById("autoplayOff").style.fontWeight = "bold"
     document.getElementById("autoplayOff").style.textDecoration = "none"
     document.getElementById("autoplayOff").style.color = "#000000"
     document.getElementById("autoplayOff").style.cursor = "default"
*/

     autoPlayMedia = false
     }

}


function searchBoxClick() {

     if (document.getElementById("searchbox").value == "Search by title, keyword, etc.") {
     document.getElementById("searchbox").value = ""
     }
}


function searchBy(field) {

     var searchString

     if (field == "title") {
     searchString = displayedArray[clickedVidBlock].title
     }
     else if (field == "author") {
     searchString = displayedArray[clickedVidBlock].author
     }
     else if (field == "genre") {
     searchString = displayedArray[clickedVidBlock].genre
     }

     for (i=0; i<(searchString.length-1); i++) {
     if (searchString.charAt(i) == " ") {
     searchString = searchString.substring(0, i) + "+" + searchString.substring(i+1, searchString.length)
     }
     }

     document.location = "?search=" + searchString

}


function displayError(errMess) {

     document.getElementById("error").style.display = "inline"
     document.getElementById("errorMessage").innerHTML = errMess
     document.getElementById("errorMessage").style.cursor = "pointer"
//     document.getElementById("errorMessage").onclick = returnToToday()

}


function selectButton(direction, inOrOut) {
     var makeColor

     if (inOrOut == true) {
     makeColor = selectColor
     }
     else {
     makeColor = nonSelectColor
     }

     if (direction == "forward") {
     document.getElementById("forwardButton").style.backgroundColor = makeColor
     selectButton('back', false)
     }
     else if (direction == "back") {
     document.getElementById("backButton").style.backgroundColor = makeColor
     }

}

function launchViewer() {
//     var id = unescape(location.search).substring(4)
//     var id = "test.txt"
     var id = clickedVidId + ".txt"
     window.open("asp/viewer.asp?id="+id,"_blank","toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width="+screen.width+", height="+screen.height)
}