//-----------------------------------------------------------------------------------------
//	Written by Trevor Hutt @ digiINK 11-2004
//	Website www.digiink.net
//
//	This module contains the script for creating and process a client side shopping cart
//	Each product selection is stored in a cookie.  Each product entry contains price, unit
//	and quantity information.  The quantity information is updated back into the cookie
//	and the result set of the cookie is passed back to the server as HTML
//
//
//  Updated: Nov-2005
//	Reason: Added XMLOrder function to output order as XML to a control on the order form
//  This change has been required to over come security changes in IE 6.0 that came out
//  with XP SP2
//
//	Updated: Oct-2006
//	Reason: Added Pound and Euro display option
//
//----------------------------------------------------------------------------------------

/*===========================================================================================
Function: processItem
Puyrpose: This function adds an item to the shopping cart and updates the carts item count
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
function processItem(oCheckBox, sCartName){
	var sItem = "processItem";

	if (oCheckBox){
		sItem = oCheckBox.id;
		//Items with a negative ID are not from the catalogue system
		if (oCheckBox.checked){
			addToCart(sCartName,sItem);
			}
		else {
			removeFromCart(sCartName,getID(sItem));
			}
		DisplayItemCount(sCartName);
		ReCalculate(sCartName,sItem);
		
		}
}
/*===========================================================================================*/
/*===========================================================================================
Function: ReCalculate
Purpose: Recalculating the total Duration 
Date: 2007-10
Author: Trevor Hutt
===========================================================================================*/
function ReCalculate(sCartName,oCheckBox){
	var oDiv = document.getElementById("total_duration");
	if (oDiv){
		oDiv.innerHTML = CartItemDuration(sCartName);
	}
}
/*===========================================================================================*/

/*===========================================================================================
Function: PlayListDuration
Puyrpose: Calculate duration time
Date: 2007-10
Author: Trevor Hutt
===========================================================================================*/

function Duration(duration){
var hh;
hh=Math.floor(duration/3600);
var mm;
mm=Math.floor(((duration/3600)-hh)*60);
var ss;
ss=Math.floor(((((duration/3600)-hh)*60)-mm)*60);
return (PadDigits(hh,2) + ":"+ PadDigits(mm,2) + ":" + PadDigits(ss,2)); 
}
/*===========================================================================================*/
/*===========================================================================================
Function: PadDigits
Puyrpose: To pad the Digits to format Duration
Date: 2007-10
Author: Trevor Hutt
===========================================================================================*/
function PadDigits(n, totalDigits) 
    { 
        n = n.toString(); 
        var pd = ''; 
        if (totalDigits > n.length) 
        { 
            for (i=0; i < (totalDigits-n.length); i++) 
            { 
                pd += '0'; 
            } 
        } 
        return pd + n.toString(); 
    }


/*===========================================================================================*/

/*===========================================================================================
Function: format
Purpose:generic positive number decimal formatting function
Date: 2007-10
Author: Trevor Hutt
===========================================================================================*/

function format (expr, decplaces) {
// raise incoming value by power of 10 times the
// number of decimal places; round to an integer; convert to string
var str = "" + Math.round (eval(expr) * Math.pow(10,decplaces))
// pad small value strings with zeros to the left of rounded number
while (str.length <= decplaces) {
str = "0" + str
}
// establish location of decimal point
var decpoint = str.length - decplaces
// assemble final result from: (a) the string up to the position of
// the decimal point; (b) the decimal point; and (c) the balance
// of the string. Return finished product.
return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}
/*===========================================================================================*/
/*===========================================================================================
Function: addSingleEntry
Puyrpose: Function that adds items to an existing cookie
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
function addSingleEntry(sCartName, oItem){
		DeleteCookie(sCartName);
		SetCookie(sCartName, oItem);
}

/*===========================================================================================
Function: addToCart
Puyrpose: Function that adds items to an existing cookie
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/

function addToCart(sCartName, oItem){
//Copy the value from the cook
var oCartItems = GetCookie(sCartName);

//If not cart cookie then create one
if (!oCartItems){
	SetCookie (sCartName, oItem);
	}
else {
	//If no match has been found then add new item
	if (!oCartItems.match(oItem)){
		//If so then add it, otherwise leave cookie as is
		//oCartItems += "|" + oItem

		//Added to make the Cookie a 'ort In' collection
		var arItems = oCartItems.split("|");

		var sResult = ""
		var bInserted = false;
		
		for (var i = 0; i < arItems.length; i++){
				if (getID(oItem) > getID(arItems[i])){
					sResult += arItems[i] + "|";
				}
				else {
					if (bInserted == false){
						sResult += oItem + "|" + arItems[i] + "|";	
						bInserted = true;
						}
					else {
						sResult += arItems[i] + "|" ; 
					}
				}
		}
		if (!bInserted){
			sResult += oItem;
		}
		
		sResult = TrimCookie(sResult)
	
		SetCookie(sCartName, sResult);
		}
	}
}
/*===========================================================================================*/

/*===========================================================================================
Function: TrimCookie
Puyrpose: Remove empty cookie entries
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
function TrimCookie(sCookie){
	var sResult = "";
	var arItems = sCookie.split("|");

	for (var i = 0; i < arItems.length; i++){
		if (arItems[i] !=""){
			sResult += arItems[i] + "|";
		}
	}
		
	return sResult.slice(0, -1)
}



/*===========================================================================================
Function: 
Puyrpose:
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
//Function to remove items from a cook
function removeFromCart(sCartName, oItem){

	//Check if this item is required 
	if (isRequired(oItem)){
		return false;	
	}
//Copy the value from the cook
var oCartItems = GetCookie(sCartName);
 
//Remove to matching item
if (oCartItems){
	var arItems = oCartItems.split("|");

	if (arItems.length!=0){
		var newCart = "";
		for (var i=0; i < arItems.length; i++){
			//If the ID of the cart item is not the one being removed
			//then add the item back into the cart
			if (getID(arItems[i])!=oItem){
				newCart += arItems[i] + "|"
				}
		}
		newCart = newCart.substring(0,newCart.length-1);
		//Delete the cart and then recreate it
		DeleteCookie(sCartName);
		//Load the value back into the cookie
		if (newCart==null){
			SetCookie(sCartName, "");
			return true;
			}
		else {
			SetCookie(sCartName, newCart)
			return true;
			}
		}
	}
}

/*===========================================================================================*/

/*===========================================================================================
Function: 
Puyrpose:
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
function getByID(sCartName, lID){
	
	var oCartItems = GetCookie(sCartName);
 	if (oCartItems){
		var arItems = oCartItems.split("|");

		if (arItems.length!=0){
			var newCart = "";
			for (var i=0; i < arItems.length; i++){
			//If the ID of the cart item is not the one being removed
			//then add the item back into the cart
				if (getID(arItems[i]) == lID){
				return arItems[i];
			}
		}
		return "";
		}
	}
}
/*===========================================================================================
Function: 
Puyrpose:
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
function CreateCart(sCart){

if (!GetCookie(sCart)){
	SetCookie (sCart, ""); //Cart is only for current session
	}

}
/*===========================================================================================*/

/*===========================================================================================
Function: 
Puyrpose:
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
function ShowCart(sCartName){

//Copy the value from the cook
var oCartItems = GetCookie(sCartName);
if (oCartItems){
	var arItems = oCartItems.split("|");
	var sResult = "";

	for (var i=0;i<arItems.length;i++){
		sResult += arItems[i] + "<br>";
		}

	return sResult;
	}
else {
	return "";
	}
	

}

/*===========================================================================================*/

/*===========================================================================================
Function: 
Puyrpose:
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/

//This function updates the price in the cookie string
//This is mainly used for late currency conversion on the page
//where items will not have originates from the database where
//their price is converted before being presented to the browser
function setPrice(sItem, dPrice){

	if (sItem){
		var arItem = sItem.split("price='$" + format(getPrice(sItem),2));
		return arItem[0] + "price='$" + format(dPrice,2) + arItem[1];
		}

}

/*===========================================================================================*/


function getImage(sCookieEntry){

var regExp = /\image=\'[a-z A-Z 0-9 ._\-\/]+\'/
var m = regExp.exec(sCookieEntry);

regExp = /\'[a-z A-Z 0-9 ._\/]+\'/
m = regExp.exec(m);

if (m){
	return m;
	}
else {
	return "";
	}

}


/*===========================================================================================
Function: isRequired
Puyrpose: Returns true if the item is required to be in the cart
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
function isRequired(sCookieEntry){
var regExp = /\required=[0-9\-]+/
var m = regExp.exec(sCookieEntry);

regExp = /[0-9\-]+/
m = regExp.exec(m);

if (m){
	if(parseInt(m) == 1){
		return true;
	}
	else {
		return false;	
	}
		
					   
	}
else {
	return false;
	}	
}

/*===========================================================================================
Function: getID
Puyrpose:
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
function getID(sCookieEntry){

var regExp = /\ID=[0-9\-]+/
var m = regExp.exec(sCookieEntry);

regExp = /[0-9\-]+/
m = regExp.exec(m);
if (m){
	return parseInt(m);
	}
else {
	return "";
	}

}
/*===========================================================================================*/

/*===========================================================================================
Function: 
Puyrpose:
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
function getPlayStatus(sCookieEntry){
	
	var regExp = /played=\'[A-Z]+\'/
	var m = regExp.exec(sCookieEntry);

	regExp = /[A-Z\-]+/
	m = regExp.exec(m);
	if (m){
		return m;
		}
	else {
		return "";
		}
}

/*===========================================================================================
Function: 
Purpose:
Date: 2007-10
Author: Trevor Hutt
===========================================================================================*/
function setMovieStatus(sCart, sID, sStatus){
	//Remove it from the cart
	removeFromCart(sCart, getID(sID));
	//Add back into the cart with played status
	sID += " played='" + sStatus + "'";
	addToCart(sCart, sID);
}
/*===========================================================================================*/
/*===========================================================================================
Function: 
Puyrpose:
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/

function getLinkID(sCookieEntry){

var regExp = /\linkID=\'[0-9]+\'/
var m = regExp.exec(sCookieEntry);

regExp = /[0-9]+/
m = regExp.exec(m);

if (m){
	return parseInt(m);
	}
else {
	return "0";
	}

}

/*===========================================================================================*/


/*===========================================================================================
Function: 
Puyrpose:
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
//Country Selected from order form
function SelectedCountry(){

var oCountrySelector = document.getElementById("txtCountry");

if (oCountrySelector){
	return oCountrySelector.options[oCountrySelector.selectedIndex].text;
	}

}
/*===========================================================================================*/
/*===========================================================================================
Function: 
Puyrpose:
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
//Delivery method selected from order form
function SelectedDeliveryMethod(){

	if (SelectedCountry() == "Australia"){
		return "none";
		}
	else {

		oDeliveryMethod = document.forms["frmOrder"].txtDeliveryMethod;
		for (var i = 0; i < oDeliveryMethod.length; i++) {
			if (oDeliveryMethod[i].checked) {
				return oDeliveryMethod[i].value;	
				}
			}
	
		}


}

/*===========================================================================================*/

/*===========================================================================================
Function: CalculateTotals
Puyrpose:This function updates the totals for the order.  It is important
		 that there be a cell or span tag with a matching name to those
		 used in this function.
Date	: 2007-10
Author	: Trevor Hutt
===========================================================================================*/

function CalculateTotals(){
var oSpan;
var oCtrl;

//Get weight of order
oSpan = document.getElementById("totalWeight");
oCtrl = document.getElementById("txtWeight");
var dWeight =  (OrderWeight('myCart')/1000);
oSpan.innerHTML = dWeight;
if (isNaN(dWeight)){
	oCtrl.value = 0;
	setInnerHTML(oSpan,0);
	}
else {
	oCtrl.value = dWeight;
	setInnerHTML(oSpan,dWeight);
	}

//Get total price of items on order
oSpan = document.getElementById("totalPrice");
oCtrl = document.getElementById("txtTotal");
var dTotalCost = OrderPrice('myCart');
if (isNaN(dTotalCost)){
	oCtrl.value = CurrencySymbol() + "0.00"
	setInnerHTML(oSpan,CurrencySymbol() + "0.00");
	}
else {
	oCtrl.value = CurrencySymbol(CurrencyCode) + dTotalCost;
	setInnerHTML(oSpan,CurrencySymbol() + format(dTotalCost + "",2));
	}


//Get the selected state
var oState = document.getElementById("txtState");
var sState = oState.options[oState.selectedIndex].text;
//Get Postage
oSpan = document.getElementById("postageCost");
oCtrl = document.getElementById("txtPostage");
var dPostage = format(DeliveryCost(sState,"",OrderWeight('myCart'), SelectedCountry(), SelectedDeliveryMethod(),OrderPrice('myCart')),2);
if (isNaN(dPostage)){
	setInnerHTML(oSpan, CurrencySymbol() + "0.00");
	oCtrl.value = CurrencySymbol() + "0.00";
	}
else {
	oCtrl.value = CurrencySymbol() +  + dPostage;
	setInnerHTML(oSpan, CurrencySymbol() +  + dPostage); 
	}

//Get total price + postage
oSpan = document.getElementById("totalPriceAndPost");
oCtrl = document.getElementById("txtTotalPlusPostage");
var dTotalPlusPost = format(DeliveryCost(sState,"",OrderWeight('myCart'), SelectedCountry(), SelectedDeliveryMethod(),OrderPrice('myCart')) + OrderPrice('myCart'),2);
if (isNaN(dTotalPlusPost)){
	oCtrl.value = CurrencySymbol() + "0.00";
	setInnerHTML(oSpan,CurrencySymbol() + "0.00");
	}
else {
	oCtrl.value = CurrencySymbol() + dTotalPlusPost;
	setInnerHTML(oSpan,CurrencySymbol() + dTotalPlusPost);
	} 

}

/*===========================================================================================*/


/*===========================================================================================
Function: saveQTY
Puyrpose:This function stores the quantity entered into the order form in the cookie
		 so the next time the page is displayed the previous quantity entries will be
		 remembered.
Date	: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
//-------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------
function saveQTY(sCartName, sCookieID){

//Get the value from the control
var oQTY = document.getElementById("txt" + sCookieID)

if (oQTY.value.NaN){
	oQTY.value=0;
	}
else {
	var oCartItems = GetCookie(sCartName);

	if (oCartItems){
		var arItems = oCartItems.split("|");

		for (var i=0; i < arItems.length; i++){
			if (getID(arItems[i])==sCookieID){
				//Replace the QTY field value
				var oldQTY = "qty='" + getQTY(arItems[i]) + "'";
				var newQTY = "qty='" + oQTY.value + "'";
				arItems[i] = replaceString(arItems[i],oldQTY,newQTY);
				}
			}
		//Create new Cookie string from array
		var newItems="";
		for (var i=0; i < arItems.length; i++){
			newItems += arItems[i] + "|"
			}
			newItems = newItems.substring(0,newItems.length-1);
		//Delete the cart and then recreate it
		DeleteCookie(sCartName);
		//Load the value back into the cookie
		if (newItems==null){
			SetCookie(sCartName, "");
			}
		else {

			SetCookie(sCartName,newItems)
			}
		CalculateTotals();
		}
	}
}
/*===========================================================================================*/

/*===========================================================================================
Function: ShowOrder
Puyrpose:
Date	: 2007-10
Author	: Trevor Hutt
===========================================================================================*/

function ShowOrder(sCartName){

//Copy the value from the cook
var oCartItems = GetCookie(sCartName);
if (oCartItems){
	var arItems = oCartItems.split("|");
	var sResult = "";
	var iWeight = 0;
	var dPrice = 0.0;

	for (var i=0;i<arItems.length;i++){
		sResult += "<tr><td>"

		if (getLinkID(arItems[i])!="0"){
				sResult += "<a href='productDetail.aspx?prodID=" + getLinkID(arItems[i]) + "' ";
				}
		else {
				sResult += "<a href='#'";
				}

		
			sResult += "OnMouseOver=\"showProductImage(" + getImage(arItems[i]) + ", " + getLinkID(arItems[i]) + ")\">" + getItem(arItems[i]) + "</a></td>" +						
							"<td><div  style=\"display:none;\">" + getUnit(arItems[i]) + "</div>.</td>" +
							"<td>" + CurrencyCode + " " + getPriceAsCurrency(arItems[i]) + "</td>" +
							"<td align='center'><input type='text' style='width:20px;' id='txt" + getID(arItems[i]) +
							"' class='text-field' value='" + getQTY(arItems[i]) + "' " +
							"onBlur=\"saveQTY('myCart'," + getID(arItems[i]) + ")\">" +
							"</td>" +
						"<td><a href='#' onClick=\"removeItem('" + getID(arItems[i]) + "');\">remove</a></td><td></td></tr>";
		}

	sResult = "<table width='100%' border=0>" + 
						"<tr><td align='left'><b>Item</b></td>" +
						"<td><b style=\"display:none;\"></b>.</td>" + 
						"<td><b>Price</b></td>" + 
						"<td align='center'><b>Qty</b></td><td></td></tr>" +
						sResult + 
						"</table>"

	return sResult;
	}
else {
	return "";
	}
	

}

/*===========================================================================================*/

/*===========================================================================================
Function: XMLOrder
Puyrpose:
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/

function XMLOrder(sCartName, oForm){

var sResult = "<productOrder>";
var sTag = "";
var iStartPos = 0;
var sFldName = "";

//Get Input Values from form
for (var i = 0; i < oForm.elements.length; i++) {
	sFldName = oForm.elements[i].name
	iStartPos = sFldName.indexOf("txt");
	if (iStartPos != -1) {
		sTag = sFldName.substring(3,sFldName.length); 

		if(oForm.elements[i].checked){
			sResult = sResult + "<" + sTag + " checked=\"true\">" + oForm.elements[i].value + "</" + sTag + ">"
			}
		else {
			sResult = sResult + "<" + sTag + ">" + oForm.elements[i].value + "</" + sTag + ">"
			}
		}
	}

	sResult = sResult + "<order>"

//Copy the value from the cook
var oCartItems = GetCookie(sCartName);
if (oCartItems){
	var arItems = oCartItems.split("|");
	var iWeight = 0;
	var dPrice = 0.0;

	for (var i=0;i<arItems.length;i++){
		//iWeight = getWeight(arItems[i],1);
		//dPrice = getPrice(arItems[i],1);
		sResult +="<lineItem>" +
							"<product>" + getItem(arItems[i]) + "</product>" +
							"<unit>" + getUnit(arItems[i]) + "</unit>" +
							"<price>" + getPriceAsCurrency(arItems[i]) + "</price>" +
							"<quantity>" + getQTY(arItems[i]) + "</quantity>" +
							"</lineItem>"
		}
	}

	sResult = sResult + "</order></productOrder>"


	return sResult;
}

/*===========================================================================================*/


/*===========================================================================================
Function: CartItemCount
Puyrpose: To display the number of items in the cart
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
function CartItemCount(sCartName){
	//Copy the value from the cook
	var oCartItems = GetCookie(sCartName);

	if (oCartItems){
		var arItems = oCartItems.split("|");

		return arItems.length;
		}
	else {
		return 0;
		}
}
/*===========================================================================================*/

/*===========================================================================================
Function: CartItemDuration
Puyrpose: To display the number of items in the cart
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
function CartItemDuration(sCartName){
	//Copy the value from the cook
	var oMovies = PlayList(sCartName);
	var dDuration = 0.0;
	for (var i = 0; i < oMovies.length; i++){
		dDuration += MovieDuration(oMovies[i]) * 1;
	}
	return Duration(dDuration);
		
} 

/*===========================================================================================*/

/*===========================================================================================
Function: replaceString
Puyrpose: replace searchString with replaceString
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
function replaceString(mainStr,searchStr,replaceStr) {
var front = getFront(mainStr,searchStr)
var end = getEnd(mainStr,searchStr)
if (front != null && end != null) {
return front + replaceStr + end
}
return null
}
/*===========================================================================================*/



/*===========================================================================================
Function: getFront
Puyrpose: extract front part of string prior to searchString
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
function getFront(mainStr,searchStr){
foundOffset = mainStr.indexOf(searchStr)
if (foundOffset == -1) {
return null
}
return mainStr.substring(0,foundOffset)
}

/*===========================================================================================
Function: getEnd
Puyrpose: extract back end of string after searchString
Date: 2007-10
Author	: Trevor Hutt
===========================================================================================*/
function getEnd(mainStr,searchStr) {
foundOffset = mainStr.indexOf(searchStr)
if (foundOffset == -1) {
return null
}
return mainStr.substring(foundOffset+searchStr.length,mainStr.length)
}


/* ====================== PLAYLIST CODE ===================================================*/
// JavaScript Document
// Movie Attribute List
// 0. Movie Name
// 1. Required = Must be watched
// 2. Duration in seconds
// 3. Filepath
// 4. Thumbnail

function MovieName(sMovieString){
	try{
		return sMovieString.split("|")[0];
		}
	catch (err){
		return "";
	}
}

function MovieRequired(sMovieString){
	try{
		return (sMovieString.split("|")[1] == "required");
		}
	catch (err){
		return false;
	}
}

function MovieDuration(sMovieString){
	try{
		if (sMovieString != ""){
			return sMovieString.split("|")[2];
		}
		else {
			return 0;
		}
		}
	catch (err){
		return 0;
	}
}

function MovieFilePath(sMovieString){
	try{
		return sMovieString.split("|")[3];
		}
	catch (err){
		return "";
	}
}

function MovieThumbnail(sMovieString){
	try{
		return sMovieString.split("|")[4];
		}
	catch (err){
		return "";
	}
}


/*===========================================================================================
Function: PlayList
Puyrpose: Gets the list of selected movies
Date: 2007-10
Author: Trevor Hutt
===========================================================================================*/
function PlayList(sCartName){
	//Get the array of selected movies
	var sMovies = GetCookie(sCartName);

	if (sMovies){
		var oMovies = sMovies.split("|");
		if (oMovies.length != 0){
			var sSelectedMovies = "";
			for (var i = 0;i < oMovies.length; i++){
				//Get the movies ID
				lMovieID = getID(oMovies[i]);
				sSelectedMovies +=  oMovieLibrary[lMovieID-1] + "^" ;
			}
			sSelectedMovies = sSelectedMovies.slice(0,-1);
			return sSelectedMovies.split("^");	
		}
	}
	else {
		return "";
	}
		
}


/*===========================================================================================
Function: PlayListHTML
Purpose:
Date: 2007-10
Author: Trevor Hutt
===========================================================================================*/

function PlayListHTML(oMovies, sCart, oCookieArray){
	var sHTML = "";

	if (oMovies.length == 0){
		return "No movies have been selected.";
	}
	
	var oCookies = oCookieArray.split("|");
	//For each movie
	for (var i = 0; i < oMovies.length; i++){

		if (oMovies[i]){
			sHTML += "<ul>";
			sHTML += "<li class='movie_image'>";
			sHTML += "<a href='javascript:playMovie(\"" + sCart + "\",\"ID="+ getID(oCookies[i]) + "\");'>";
			sHTML += "<img id='movie_" + getID(oCookies[i]) + "' src='" +  MovieThumbnail(oMovies[i]) + "' border='0'/>";
			sHTML += "</a>";
			sHTML += "</li>";
			sHTML += "<li class='movie_name'>";
			sHTML += "<h2>" + MovieName(oMovies[i]) + "</h2>";
			sHTML += "<input id='ID=" + getID(oCookies[i]) + "' ";
			sHTML += "onclick='processItem(this, MOVIES);' ";
			sHTML += "type='checkbox' checked='checked'/><br clear='all'/>";
			sHTML += "</li>";
			sHTML += "<li class='movie_duration'>" + Duration(MovieDuration(oMovies[i])) + " duration</li>";
			sHTML += "</ul>";
		}
	}
	sHTML += "<br clear='all'/>"
	return sHTML;
	
}

/*===========================================================================================*/


/*===========================================================================================
Function: playMovie
Purpose:
Date: 2007-10
Author: Trevor Hutt
===========================================================================================*/
function playMovie(sCart, sID){
		setMovieStatus(sCart, sID, "PLAYED")
}
/*========================== PLAYLIST CODE END ============================================*/
