function listByMovie(parentElement, repElement) {
	//Grab the year from the local form
	var staYear=document.getElementById('curyear').value;
	if(!staYear){//if it isn't set, use todays date
		var staDate=new Date();
	} else {
		var staMonth=document.getElementById('curmonth').value;
		var staDay=document.getElementById('curday').value;
		var staDate=new Date(staYear,staMonth-1,staDay);
	}
	var rightNow=new Date();//So we can only have links on movies that are still coming up
	var endDate=new Date(staDate.getFullYear(),staDate.getMonth(),staDate.getDate());
	var matineeEnd=new Date(staDate.getFullYear(),staDate.getMonth(),staDate.getDate(), matEndHour, matEndMin);
	//alert( matineeEnd.format("EE NNN d, yyyy hh:mma"));
	endDate.setDate(staDate.getDate()+1);//Show a days worth of movies
	var staDay=staDate.format("yyyyMMdd")+"035900";//Earliest movie is midnight the day it shows
	var endDay=endDate.format("yyyyMMdd")+"040000";//Latest movie is 1am the following day
	var newEl = document.createElement('DIV');
	newEl.id=repElement.id; 
	daRow=document.createElement('P');
	daRow.className=curDateClass;
	daData=document.createTextNode("Showing For " + staDate.format("EE NNN d, yyyy") + " - It is now " + rightNow.format("EE NNN d h:mma"));
	daRow.appendChild(daData);
	newEl.appendChild(daRow);
	//var imgPath=new Array();
	var TID=new Array();
	tlById=new Array();
	var movies=new Array();
	for(x=0;x<scheduleList.length;x++) {
		xmlDoc=scheduleList[x];
		TID[x]=retText(xmlDoc.getElementsByTagName('Cinema_ID')[0]);
		tlById[TID[x]]=theaterList[x];
		if (x == 0 ) {
			var firstMovies=scheduleList[0].getElementsByTagName("Movie");
			for(y=0;y<firstMovies.length;y++){
				movies[y]=firstMovies[y];
			}
			for(y=0;y<movies.length;y++) {
				//imgPath[y]="assets/" + theaterList[x] + "/images/";
			}
		} else {
			var newMovies=xmlDoc.getElementsByTagName("Movie");
			for(var y=0;y<newMovies.length;y++) {
				mFound=false;
				for(var z=0;z<movies.length;z++) {
					if(retText(newMovies[y].getElementsByTagName('Movie_ID')[0])==retText(movies[z].getElementsByTagName('Movie_ID')[0])) {
						mFound=true;
						break;
					}
				}
				if(mFound==false) {
					movies[movies.length]=newMovies[y];
					//imgPath[movies.length-1]="assets/" + theaterList[x] + "/images/";
				}
			}
		}
	}
	movies.sort(moviesort);
	var showArr=new Array();
	var tickets=new Array();
	for(x=0;x<scheduleList.length;x++) {
		xmlDoc=scheduleList[x];
		var showings=xmlDoc.getElementsByTagName("Session");//Grab all the sessions
		for(var showing=0;showing<showings.length;showing++){//Fill showArr with only relevent Sessions
			showDate=retText(showings[showing].getElementsByTagName('Date_time')[0]);
			if(showDate > staDay && showDate < endDay){
				mi=String(retText(showings[showing].getElementsByTagName('Movie_ID')[0]));
				si=String(retText(showings[showing].getElementsByTagName('Session_ID')[0]));
				pg=String(retText(showings[showing].getElementsByTagName('Price_group_code')[0]));
				if(!showArr[mi]) showArr[mi]=new Array();
				if(!showArr[mi][x]) showArr[mi][x]=new Array();
				showArr[mi][x][si]=[showDate,pg];
			}
		}
		var tickTypes=xmlDoc.getElementsByTagName("Price");
		for(var tickType=0;tickType<tickTypes.length;tickType++){
			gc=String(retText(tickTypes[tickType].getElementsByTagName('Price_group_code')[0]));
			tn=String(retText(tickTypes[tickType].getElementsByTagName('Ticket_type_description')[0]));
			tp=retText(tickTypes[tickType].getElementsByTagName('Ticket_Price')[0])/100;
			if(!tickets[x]) tickets[x]=new Array();
			if(!tickets[x][gc]) tickets[x][gc]="";
			tickets[x][gc]+=tn + "...$"+tp.toFixed(2)+"\n";
		}
	}
	
	for(var i=0;i<movies.length;i++){//step through each movie
		var moDiv= document.createElement('DIV');
		moDiv.className="split";
		var moRow = document.createElement('H3');
		moRow.className="hdr floatcontainer";
		//var clkContainer=document.createElement('SPAN');
		//clkContainer.className='clickToShow';
		//clkContainer.appendChild(document.createTextNode("Show Schedule"));
		//moRow.appendChild(clkContainer);
		var raContainer=document.createElement('SPAN');
		var moRating=retText(movies[i].getElementsByTagName('Rating')[0]);
		if(moRating=="R"){
			raContainer.className=movieRatingRSpan;
		} else {
			raContainer.className=movieRatingSpan;
		}
		var moI=String(retText(movies[i].getElementsByTagName('Movie_ID')[0]));
		moDiv.id=moI;

		var moA=document.createElement('A');
		var moWS=retText(movies[i].getElementsByTagName('Movie_WebSite')[0]);
		moA.href=moWS;//movieInfoURL.replace('<movieID>',moI);
		//moA.className="thickbox byMovieLink";
		moA.target="_movieWebSite";
		var mi=retText(movies[i].getElementsByTagName('Movie_Image')[0]);
		if(mi!='') {
			var moImg=document.createElement('IMG');
			moImg.src= tlById[retText(movies[i].getElementsByTagName('Cinema_ID')[0])] + "images/" + mi;
			moImg.width=movieImageWidth;
			moImg.height=movieImageHeight;
			moImg.className="movieImage";
			moA.appendChild(moImg);
		}
		var moN= document.createTextNode(retText(movies[i].getElementsByTagName('Movie_Name')[0]));
		moA.appendChild(moN);
		moA.title=retText(movies[i].getElementsByTagName('Movie_Name')[0]);
		var moR=document.createTextNode("(" + moRating + ")");
		moRow.appendChild(moA);
		raContainer.appendChild(moR);
		moRow.appendChild(raContainer);
		var moD=document.createElement('DIV');
		moD.className=movieDescriptionCell;
		moD.id="long_des_" + moI;
		var de=retText(movies[i].getElementsByTagName('Movie_Description')[0]);
		if(de.length > shortDescLength) {//If the description is more than 60 characters long create a secondary short one
			sdeContainer=document.createElement('DIV');
			sdeContainer.className=movieDescriptionCell;
			sdeContainer.name=moI;
			sdeContainer.id="short_des_" + moI;
			var sde=document.createTextNode(de.substr(0,shortDescLength));
			var lde=document.createElement('A');
			lde.onclick=function () {this.parentNode.previousSibling.style.display="";this.parentNode.style.display="none";};
			lde.appendChild(document.createTextNode(" More..."));
			sdeContainer.appendChild(sde);
			sdeContainer.appendChild(lde);
		}
		if(de!=''){
			deN=document.createTextNode(de);
			moD.appendChild(deN);
			moRow.appendChild(moD);
			if(de.length > shortDescLength){//add the short description to the DOM
				moD.style.display='none';
				moD.name=moI;
				var lode=document.createElement('A');
				lode.onclick=function () {this.parentNode.nextSibling.style.display="";this.parentNode.style.display="none";};
				lode.appendChild(document.createTextNode(" Hide..."));
				moD.appendChild(lode);
				moRow.appendChild(sdeContainer);
			}
		} else {
			deN=null;
		}
		var oldDate=new Date(0);
		shRow=document.createElement('DIV');
		shRow.className="content";
		shRow.id=moI + "times";
		var opArr=new Array();
		var timeTR, timeNameTD, timeTD;
		if(showArr[moI]){//if the Movie is showing on this day
			var timeTbl=document.createElement("TABLE");
			var timeBody=document.createElement("TBODY");
			for(x in showArr[moI]){
				timeTbl.appendChild(timeBody);
				for(var si in showArr[moI][x]){
					var showDate=new Date.parseString(showArr[moI][x][si][0], "yyyyMMddHHmmss");
					if(showDate.isBefore(matineeEnd)){
						opData=document.createTextNode("(" + showDate.format("h:mma") + ")");
					} else {
						opData=document.createTextNode(showDate.format("h:mma"));
					}
					opDiv=document.createTextNode(" ");
					if(!showDate.isBefore(rightNow) && remotePurchaseURL!=""){
						opContainer=document.createElement('A');
						opContainer.className=movieTimeLink;
						opContainer.href=remotePurchaseURL + "?" + tidVar + "=" +TID[x] + "&" + sidVar + "="+si ;
						opContainer.title=tickets[x][showArr[moI][x][si][1]];
						opContainer.target="_blank";
						opContainer.appendChild(opData);
						opArr[opArr.length++]=new addShow(showArr[moI][x][si][0],opContainer);
					} else {
						opContainer=document.createElement('SPAN');
						opContainer.className=movePastTime;
						opContainer.appendChild(opData);
						opArr[opArr.length++]=new addShow(showArr[moI][x][si][0],opContainer);
					}
				}
				opArr.sort(timeSort);
				timeTR=document.createElement("TR");
				timeNameTD=document.createElement("TD");
				timeNameTD.className=movieCellClass;
				opDiv=document.createTextNode(theaterLabel[x]);
				timeNameTD.appendChild(opDiv);
				timeTR.appendChild(timeNameTD);
				timeTD=document.createElement("TD");
				timeTD.className=movieTimesCell;
				for(ti=0;ti<opArr.length;ti++){
					timeTD.appendChild(opArr[ti].item);
					opDiv=document.createTextNode(" ");
					timeTD.appendChild(opDiv);
				}
				timeTR.appendChild(timeTD);
				timeBody.appendChild(timeTR);
				opArr=new Array();
			}
			shRow.appendChild(timeTbl);
			moDiv.appendChild(moRow);
			moDiv.appendChild(shRow);
			newEl.appendChild(moDiv);
		}
	}
	parentElement.replaceChild(newEl, repElement);//Replace the existing table with the new one
	
	for(var i=0;i<movies.length;i++){
		moI=String(retText(movies[i].getElementsByTagName('Movie_ID')[0]));
		if(showArr[moI]){
			//setDrawerClick(moI, moI + "times");
		}
	}
	//tb_init('a.thickbox, area.thickbox, input.thickbox');
	//imgLoader = new Image();// preload image
	//imgLoader.src = tb_pathToImage;
}

