function Trim(trimStr)
{
	trimStr = trimStr.replace( /^\s*/, "" )
	trimStr = trimStr.replace( /\s*$/, "" );
	return trimStr;
}
function clearBorrower()
{
	document.getElementById("out").value = "";
}
function changeSearchString()
{
	var title = Trim(document.getElementById("title").value)

	title = title.toLowerCase()

	title = title.replace( /^the\s/, "" );
	title = title.replace( /^a\s/, "" );

	for (var i=0, output='', valid="0123456789abcdefghijklmnopqrstuvwxyz"; i<title.length; i++)
       if (valid.indexOf(title.charAt(i)) != -1)
          output += title.charAt(i)
   newTitle = output;

	document.getElementById("search").value = newTitle;
}
function confirmDelete()
{
	var dialogText = "Are you sure you want to delete this Movie?\n\n";
	var yes=confirm(dialogText);
	if (yes) {
		return true;
	} else {
		return false;
	}
}
function CheckForm()
{
	var theInput = document.getElementById("title").value
	if (!theInput) {
		document.getElementById("title").focus();
		alert("Please enter the title.");
		return false;
	}
	var theInput = document.getElementById("rating").value
	if (!theInput) {
		document.getElementById("rating").focus();
		alert("Please enter the rating.");
		return false;
	}
	var theInput = document.getElementById("minutes").value
	if (!theInput) {
		document.getElementById("minutes").focus();
		alert("Please enter the running time.");
		return false;
	}
	var theInput = document.getElementById("year").value
	if (!theInput) {
		document.getElementById("year").focus();
		alert("Please enter the year.");
		return false;
	}

	if (document.getElementById("search").value == "") {
		changeSearchString()
	}

	return true;
}
function checkClick(url,ref) {
	if (!window.ActiveXObject) return false;
	var e = window.event;
	var ok=0;
	switch (ref)
		{
		case 1: if (e.ctrlKey) ok=1; break;
		case 2: if (e.ctrlKey && e.altKey) ok=1; break;
		case 3: if (e.altKey) ok=1; break;
		case 4: if (e.shiftKey) ok=1; break;
		case 5: if (e.shiftKey && e.altKey) ok=1; break;
		case 6: if (e.shiftKey && e.ctrlKey) ok=1; break;
		case 7: if (e.ctrlKey && e.altKey && e.shiftKey) ok=1; break;
		}
	if (ok) location.href = url;
	return false;
}