function selectAll(object) {
	form = object['form'];
	siteType = object.id;
	len = siteType.length;
	bChecked = object.checked;
	for (i = 0; i < form.length; i++) {
		id = (form[i].id).substring(0,len);
		if (id == siteType) {
			form[i].checked = bChecked;
		}
	}
}

function setCheckAll(siteType) {

	var item = document.all(siteType);
	var len = item.length;
	
	if(item[len-1].checked == true){
		for (i = 0; i < len; i++) {
			item[i].checked = true;
		}
	}
}

function setSelectAll(object)
{
	form = object['form'];
	bChecked = true;
	var item = document.all(object.id);
	var len = item.length;
	var i=0;

	for (i = 0; i < len-1; i++) {
		bChecked = (bChecked && item[i].checked)
	}
	item[i].checked = bChecked;
}

function inputOK() {
	if (document.getElementById("search").value == "") {
		alert('Please enter a search keyword!');
		return false;
	}
}

function inputOK(form, bMultipleSources) {
	if (document.getElementById("search").value == "") {
		alert('Please enter a search keyword!');
		return false;
	}
	
	bChecked = false;
	bPat = false;
	bProf = false;
	bSource = false;
	for (i = 0; i < form.length; i++) {
		lenPat = 'patient'.length;
		lenProf = 'professional'.length;
		//lenSource = 'patient'.length;
		idPat = (form[i].id).substring(0,lenPat);
		idProf = (form[i].id).substring(0,lenProf);
		//idSource = (form[i].id).substring(0,lenSource);
		if ('patient' == idPat || 'professional' == idProf ){ //|| 'patient' == idSource) {
			bChecked = (bChecked || form[i].checked);
			bPat = (bPat || form[i].checked);
			bProf = (bProf || form[i].checked);
			//bSource = (bSource || form[i].checked);
		}
	}
	if (!bChecked) {
		if (bMultipleSources) {
			alert('Please select at least one source (patient or professional site)!');
		} else {
			alert('Please select at least one source!');
		}
		return false;
	}
	return true;
}

function inputSaveOK() {
	if (document.getElementById("searchName").value == "") {
		alert('Please enter a name for the search!');
		return false;
	}
}

function inputFindOK() {
	if (document.getElementById("communitySearch").value == "") {
		alert('Please enter a search keyword!');
		return false;
	}
}

function agreedOK() {
	if (document.getElementById("agree").checked == false) {
		alert('You must agree that your email address will be sent to the recipient\'s inbox!');
		return false;
	}
}

function refineQuery() {
	alert('We can\'t guarantee the relevance of the next search results. Please refine your search.');
}

function newAutonomyWindow(url) {
	window.open(url, 'popup', 'width=640, height=480, resizable=yes, scrollbars=yes');
}
