// JavaScript Document
function moreItems($items, $max) {
	obj = document.getElementsByName($items);
	for (i=0; i<$max; i++) {
		if (obj[i].style.display == 'none') {
			obj[i].style.display = '';
			return;
		}
	}
}

function check_length(sale) {
maxLen = 120; // max number of characters allowed
if (sale.shortdesc.value.length >= maxLen) {
// Alert message if maximum limit is reached. 
// If required Alert can be removed. 
var msg = "You have reached your maximum limit of characters allowed";
alert(msg);
// Reached the Maximum length so trim the textarea
sale.shortdesc.value = sale.shortdesc.value.substring(0, maxLen);
}
else{ // Maximum length not reached so update the value of my_text counter
sale.text_num.value = maxLen - sale.shortdesc.value.length;}
}
//-->


function confirmDelete() {
var agree=confirm("Are you sure you want to delete?");
if (agree)
return true ;
else
return false ;
}

function changeImage(txt, w, h, title, caption) {
	var img = document.getElementById("change");
	img.src = txt;
	img.width = w;
	img.height = h;
	document.getElementById('changeTitle').innerHTML = title;
	document.getElementById('changeCaption').innerHTML = caption;
}

function changeVideo(movie, title, caption) {
	var newMovie = '<OBJECT classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="500"';
	newMovie += 'height="300" codebase="http://www.apple.com/qtactivex/qtplugin.cab">';
	newMovie += '<param name="src" value="' + movie + '">';
	newMovie += '<param name="autoplay" value="true">';
	newMovie += '<param name="controller" value="true">';
	newMovie += '<param name="loop" value="false">';
	newMovie += '<EMBED src="' + movie + '" width="500" height="300" autoplay="true" ';
	newMovie += 'controller="true" loop="false" pluginspage="http://www.apple.com/quicktime/download/">';
	newMovie += '</EMBED>';
	newMovie += '</OBJECT>';
	document.getElementById('changeMovie').innerHTML = newMovie;
	document.getElementById('changeTitle').innerHTML = title;
	document.getElementById('changeCaption').innerHTML = caption;
}

function submitSearch(state){
	window.location='director.php?page=mapResults&state=' + state;
}


function checkrequired(which) {
	var pass = true;
	if (document.images) {
		for (i=0;i<which.length;i++) {
			var tempobj=which.elements[i];
			if (tempobj.name.substring(0,8)=="required") {
				if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||
					(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)) {
					pass=false;
					break;
				}
			}
		}
	}
	if (!pass) {
		alert("One or more of the required elements are not completed. Please complete them, then submit again!");
		return false;
	} else return true;
}
