ns4 = (document.layers) ? true:false 
ie4 = (document.all) ? true:false 
ng5 = (document.getElementById) ? true:false 

//Custom code cuz embedded JS submits form twice
boolPressed = false;
boolReturn = false;

function open_url(url) {
	opener.location.href = url;
}

function popupNormal(link, windowname, dimensions) {
	var settings =dimensions+',';
		settings +='scrollbars=yes,';
		settings +='resizable=no';
	win=window.open(link, windowname, settings)
}

function doConfirm(msg) {
	return confirm(msg);
}

function showDesc(id) {
	if (ie4) {
		if (document.all["reg1_" + id].style.display != "none") {
			document.all["reg1_" + id].style.display = "none";
			document.all["reg2_" + id].style.display = "none";
			document.all["arrow_" + id].src = "images/arrowLeft.gif";
			return;
		} else {
			document.all["reg1_" + id].style.display = "inline";
			document.all["reg2_" + id].style.display = "inline";
			document.all["arrow_" + id].src = "images/arrowDown.gif";
			return;
		}
	}
	if (ng5) {
		if (document.getElementById(["reg1_" + id]).style.display != "none") {
			document.getElementById(["reg1_" + id]).style.display = "none";
			document.getElementById(["reg2_" + id]).style.display = "none";
			document["arrow_" + id].src = "images/arrowLeft.gif";
			return;
		} else {
			document.getElementById(["reg1_" + id]).style.display = "inline";
			document.getElementById(["reg2_" + id]).style.display = "inline";
			document["arrow_" + id].src = "images/arrowDown.gif";
			return;
		}
	}
	return false;
}

function filterResults(page) {

	if (theForm1.sort_by1[3].selected) {
		theForm1.search1.value = "";
	}

	var url = "profiles.php";
	url += "?sort_by="+theForm1.sort_by1[theForm1.sort_by1.selectedIndex].value;
	url += "&sort_group="+theForm1.sort_group1[theForm1.sort_group1.selectedIndex].value;
	url += "&per_page="+theForm1.per_page1[theForm1.per_page1.selectedIndex].value;
	url += "&search="+theForm1.search1.value;
	if (page) {
		url += "&page="+page;
	} else {
		url += "&page=1";
	}

	window.location.href = url
}

function filterName() {

	theForm1.sort_by1[0].selected = true;
	theForm2.sort_by2[0].selected = true;
	theForm1.sort_group1[0].selected = true;
	theForm2.sort_group2[0].selected = true;
	theForm1.per_page1[0].selected = true;
	theForm2.per_page2[0].selected = true;

	filterResults();
}

function setFilter() {

	theForm1.sort_by1[theForm2.sort_by2.selectedIndex].selected = true;
	theForm1.sort_group1[theForm2.sort_group2.selectedIndex].selected = true;
	theForm1.per_page1[theForm2.per_page2.selectedIndex].selected = true;

	filterResults();
}

function submit_OnClick()
{
	//button pressed
	boolPressed = true;
}

function validateForm()
{
	if (boolPressed)
	{
		//Validate Form Was Called
		boolPressed = false;
		
		intErrors = 0;
	
		var myName = theForm.author;
		var myEmail = theForm.email;
		var myComment = theForm.text;
	
		strAlertMessage = "Please fill in the following fields:\n";
		
		if (!myName.value)
		{
			strAlertMessage += " - Please provide your name.\n";
			myName.focus();
			intErrors++;
		}
	
		if (myEmail.value.indexOf ('@',0) == -1 || myEmail.value.indexOf ('.',0) == -1 || myEmail.value == "")
		{
			strAlertMessage += " - Please provide a valid email address.\n";
			myEmail.focus();
			intErrors++;
		}
	
		if (!myComment.value)
		{
			strAlertMessage += " - Please provide some content for your comment.\n";
			myComment.focus();
			intErrors++;
		}
	
		if(intErrors > 0)
		{
			alert(strAlertMessage);
			intErrors = 0;
			return false;
		}
		else
		{
			//this should be submitted
			boolReturn = true;
		}
	}

	if(!boolReturn)
		return false;
}