$().ready(function() {

			function findValueCallback(event, data, formatted) {
				$("<li>").html( !data ? "No match!" : "Selected: " + formatted).appendTo("#result");
			}
	
			function formatItem(row) {
				return row[0] + " (<strong>id: " + row[1] + "</strong>)";
			}
	
			function formatResult(row) {
				return row[0].replace(/(<.+?>)/gi, '');
			}
		
			$("#movie_title").autocomplete("movie_list.php", {
				width: 260,
				selectFirst: false
			});
			
			$("#edit_movie_title").autocomplete("../movie_list.php", {
				width: 260,
				selectFirst: false
			});
		
		});
		
		
 $(document).ready(function(){
			makeSublist('book','chapter',true);
			makeSublistSearch('book_search','chapter_search',true);	
		});
		
		
function makeSublist(parent,child,isSubselectOptional)
	{
		$("body").append("<select style='display:none' id='"+parent+child+"'></select>");
		$('#'+parent+child).html($("#"+child+" option"));
		$('#'+child).html("<option selected> -- Select -- </option>");		
		$('#'+parent).change(
			function()
			{
				var parentValue = $('#'+parent).attr('value');
				$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());
				if(isSubselectOptional) $('#'+child).prepend("<option selected> -- Select -- </option>");
			}
		);
	} 
	
function makeSublistSearch(parent,child,isSubselectOptional)
	{
		$("body").append("<select style='display:none' id='"+parent+child+"'></select>");
		$('#'+parent+child).html($("#"+child+" option"));
		$('#'+child).html("<option selected> -- ALL -- </option>");		
		$('#'+parent).change(
			function()
			{
				var parentValue = $('#'+parent).attr('value');
				$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());
				if(isSubselectOptional) $('#'+child).prepend("<option selected> -- ALL -- </option>");
			}
		);
	} 
	
	
	
	
function validateFormClipMovie(form) { //This is the name of the function

if (form.edit_movie_title.value == "") {
   alert("Please enter a validated movie name."); 
   form.edit_movie_title.focus( ); 
   return false; 
   }

}

function validateFormClipBook(form) { //This is the name of the function

if (form.book.value == "") {
   alert("Please select a book."); 
   form.book.focus( ); 
   return false; 
   }
   
if (form.chapter.value == "") {
   alert("Please select a chapter."); 
   form.chapter.focus( ); 
   return false; 
   }

}

function validateFormClipInfo(form) { //This is the name of the function

if (form.subject_desc.value == "") {
   alert("Please provide a subject description."); 
   form.subject_desc.focus( ); 
   return false; 
   }
   
if (form.clip_title.value == "") {
   alert("Please provide a clip title."); 
   form.clip_title.focus( ); 
   return false; 
   }
   
if (form.clip_desc.value == "") {
   alert("Please provide a clip description."); 
   form.clip_desc.focus( ); 
   return false; 
   }

   
if (form.dvd_chapter.value == "") {
   alert("Please provide a DVD chapter."); 
   form.dvd_chapter.focus( ); 
   return false; 
   }
   
if (form.expletive_indicator.value == "") {
   alert("Please select an expletive indicator."); 
   form.expletive_indicator.focus( ); 
   return false; 
   }
   
if (form.clip_setup.value == "") {
   alert("Please provide clip setup information."); 
   form.clip_setup.focus( ); 
   return false; 
   }
   
if (form.clip_unpack.value == "") {
   alert("Please provide clip unpack information."); 
   form.clip_unpack.focus( ); 
   return false; 
   }
   
}

function validateFormClipContribute(form) { //This is the name of the function

if (form.book.value == "") {
   alert("Please select a book."); 
   form.book.focus( ); 
   return false; 
   }
   
if (form.chapter.value == "") {
   alert("Please select a chapter."); 
   form.chapter.focus( ); 
   return false; 
   }

if (form.subject_desc.value == "") {
   alert("Please provide a subject description."); 
   form.subject_desc.focus( ); 
   return false; 
   }
   
if (form.clip_title.value == "") {
   alert("Please provide a clip title."); 
   form.clip_title.focus( ); 
   return false; 
   }
   
if (form.clip_desc.value == "") {
   alert("Please provide a clip description."); 
   form.clip_desc.focus( ); 
   return false; 
   }
   
if (form.movie_title.value == "") {
   alert("Please enter a movie name."); 
   form.movie_title.focus( ); 
   return false; 
   }
   
if (form.start_hour.value == "") {
   alert("Start time must be specified, please select a start hour."); 
   form.start_hour.focus( ); 
   return false; 
   }
   
if (form.start_minute.value == "") {
   alert("Start time must be specified, please select a start minute."); 
   form.start_minute.focus( ); 
   return false; 
   }
   
if (form.start_second.value == "") {
   alert("Start time must be specified, please select a start second."); 
   form.start_second.focus( ); 
   return false; 
   }
   
if (form.end_hour.value == "") {
   alert("End time must be specified, please select an end hour."); 
   form.end_hour.focus( ); 
   return false; 
   }
   
if (form.end_minute.value == "") {
   alert("End time must be specified, please select an end minute."); 
   form.end_minute.focus( ); 
   return false; 
   }
   
if (form.end_second.value == "") {
   alert("End time must be specified, please select an end second."); 
   form.end_second.focus( ); 
   return false; 
   }
   
if (form.dvd_chapter.value == "") {
   alert("Please provide a DVD chapter."); 
   form.dvd_chapter.focus( ); 
   return false; 
   }
   
if (form.expletive_indicator.value == "") {
   alert("Please select an expletive indicator."); 
   form.expletive_indicator.focus( ); 
   return false; 
   }
   
if (form.clip_setup.value == "") {
   alert("Please provide clip setup information."); 
   form.clip_setup.focus( ); 
   return false; 
   }
   
if (form.clip_unpack.value == "") {
   alert("Please provide clip unpack information."); 
   form.clip_unpack.focus( ); 
   return false; 
   }
   
}

function validateFormComment(form) { //This is the name of the function

if (form.comment.value == "") {
   alert("Please provide a comment."); 
   form.comment.focus( ); 
   return false; 
   }
   
}