function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function go_admin()
{
	var oElem = document.getElementById("admin_section_select");
	switch(oElem.value)
	{
		case "admin_members":
			document.location.href = "admin_members.html";
			break;

		case "admin_events":
			document.location.href = "admin_events.html";
			break;

		case "admin_locations":
			document.location.href = "admin_locations.html";
			break;

		case "admin_content":
			document.location.href = "admin_content.html";
			break;

		case "admin_reports":
			document.location.href = "admin_reports.html";
			break;

		case "admin_location_forums":
			document.location.href = "admin_forums_location.html";
			break;
		case "admin_messages":
			document.location.href = "admin_messages.html";
			break;
		case "admin_banners":
			document.location.href = "admin_banners.html";
			break;

		case "admin_photos":
			document.location.href = "admin_photos.html";
			break;
			
		default:
			break;
	}

}



function go_neighbor_results(sPage, sLetter)
{
	document.forms["continue_post"].action = "site_location_neighbors.html?letter=" +sLetter;
	document.forms["continue_post"].elements.page.value = sPage;
	document.forms["continue_post"].submit();
}

function go_results(sPage)
{
	document.forms["continue_post"].elements.page.value = sPage;
	document.forms["continue_post"].submit();
}


function pub_send_invite(oForm)
{
	if(oForm.elements.name_first.value == "")
	{
		alert("Please enter a name before sending the invitation.");
		return false;
	}
	return true;
}

function admin_member(sId, sAction)
{
	var oForm = document.forms.admin_member_form;
	oForm.elements.action.value = sAction;
	oForm.elements.member_id.value = sId;

	switch(sAction)
	{
		case "delete_member":
			if(confirm("Are you sure you wish to delete this member?"))
			{
				oForm.submit();
			}
			break;

		case "delete_pc":
			if(confirm("Are you sure you wish to delete the primary contact?"))
			{
				oForm.submit();
			}
			break;

		case "promote_pc":
		case "demote_pc":
			oForm.submit();
			break;

		case "reinstate_member":
			if(confirm("Are you sure you wish to reinstate this member?"))
			{
				oForm.submit();
			}
			break;
	}
}


function delete_event()
{
	if(confirm("Are you sure you wish to delete this event?"))
	{
		return true;
	}
	return false;

}


function delete_press()
{
	var x = new string();

	if(confirm("Are you sure you wish to delete this press release?"))
	{
		return true;
	}
	return false;

}


function delete_list()
{
	if(confirm("Are you sure you wish to delete this listing?"))
	{
		return true;
	}
	return false;
}


function close_poll()
{
	if(confirm("Are you sure you wish to close this poll?"))
	{
		return true;
	}
	return false;
}


function delete_poll()
{
	if(confirm("Are you sure you wish to delete this poll?"))
	{
		return true;
	}
	return false;
}


function delete_comment()
{
	if(confirm("Are you sure you wish to delete this comment?"))
	{
		return true;
	}
	return false;
}



function delete_post(sId)
{
	if(confirm("Are you sure you wish to delete this post?"))
	{
		return true;
	}
	return false;
}

function delete_topic()
{
	if(confirm("Are you sure you wish to delete this entire thread?"))
	{
		return true;
	}
	return false;
}

function delete_member()
{
	if(confirm("Are you sure you wish to delete this member?"))
	{
		return true;
	}
	return false;
}

function copy(sText)
{
	clipboardData.setData("TEXT", sText);
}

function toggle_press_release(oElem)
{
	if(oElem.checked)
		document.location.href = "admin_content_news.html";
}

function toggle_faq(oElem)
{
	if(oElem.checked)
		document.location.href = "admin_content_faq.html";
}


//------
//location by radius zip
function set_location_selections(aLoc)
{
	var oElemSelect = document.getElementById("location_ids_select");
	var oElemHidden = document.getElementById("search_fields[location_ids]");
	oElemHidden.value = "";
	oElemSelect.options.length = 0;

	for(var i = 0; i < aLoc.length; i++)
	{
		oElemSelect.options[oElemSelect.options.length] = new Option(aLoc[i][1], aLoc[i][0]);
		oElemHidden.value += aLoc[i][0];
		if(i < aLoc.length-1)
			oElemHidden.value += ",";
	}

}

function get_locations()
{
	var window_width = 720;
	var window_height = 350;
	var window_left = parseInt(screen.width / 2) - parseInt(window_width / 2);
	var window_features = "width="+window_width+", height="+window_height+", left="+window_left+", top=100, location=0, menubar=0, resizable=0, scrollbars=1, status=0, toolbar=0, history=0";
	var sRadius = document.getElementById("radius_input").value;
	var sZip = document.getElementById("zip_radius_input").value;
	if(sRadius == "" || sZip == "")
	{
		alert("Please fill in both a Radius and Zip Code/Postal Code.");
		return;
	}
	window.open("admin_location_select.html?radius="+sRadius+"&zip="+sZip, "_get_locations", window_features);
}

function show_invited_locations(sId)
{
	var window_width = 700;
	var window_height = 350;
	var window_left = parseInt(screen.width / 2) - parseInt(window_width / 2);
	var window_features = "width="+window_width+", height="+window_height+", left="+window_left+", top=100, location=0, menubar=0, resizable=0, scrollbars=1, status=0, toolbar=0, history=0";
	window.open("admin_event_locations.html?event_id="+sId, "_show_locations", window_features);
}


function go_page(url)
{
	document.open(url, '_blank', '');
}

function show_primary_contact()
{
	var window_width = 500;
	var window_height = 350;
	var window_left = parseInt(screen.width / 2) - parseInt(window_width / 2);
	var window_features = "width="+window_width+", height="+window_height+", left="+window_left+", top=100, location=0, menubar=0, resizable=0, scrollbars=1, status=0, toolbar=0, history=0, directories=0";
	window.open('public_location_register_duties.html', '_primary_contact_win', window_features);
}

function delete_location()
{
	var oElemSelect = document.getElementById("location_ids_select");
	var oElemHidden = document.getElementById("location_ids");
	if(oElemHidden.value == "") return;

	var aLoc = new Array();
	for(var i = 0; i < oElemSelect.options.length; i++)
	{
		if(oElemSelect.options[i].selected)
		{
			oElemSelect.options[i] = null;
		}
	}

	for(var i = 0; i < oElemSelect.options.length; i++)
	{
		aLoc[aLoc.length] = new Array(oElemSelect.options[i].value, oElemSelect.options[i].text);
	}
	set_location_selections(aLoc);


}
//--------


function show_flyer(sUrl)
{
	var url = sUrl;
	var window_height = screen.height - 100;
	var window_width = 740;
	var window_left = parseInt(screen.width / 2) - parseInt(window_width / 2) - 1;
	var sFeatures = "height="+window_height+", width="+window_width+", left="+window_left+", top=18, resizable=1, toolbar=0, history=0, locationbar=0, scrollbars=1, status=0";
	window.open(url, "_new", sFeatures);
	return false;
}

function  toggle_publish_to(sId)
{
	var oElem = document.getElementById(sId);
	oElem.checked = true;
}
