// JavaScript Document

function getStaffPage(storyid)
{
	tmpUrl = "/staff.asp?storyid=" + storyid;
	window.open(tmpUrl,"_blank", "height=620, width=620");
}


var tmpLastElement
function makeActive(tmpElement)
{
	if (window.parent.document.getElementById("editmode").value == "true")
	{
		if (tmpLastElement != undefined || tmpLastElement == "")
		{
			document.getElementById(tmpLastElement).style.borderStyle = "none";
		}
		tmpLastElement = tmpElement;
		document.getElementById(tmpElement).style.border = "1px solid gold";

		window.parent.document.getElementById("hdncurrstoryid").value = document.getElementById(tmpElement).storyid;
		window.parent.document.getElementById("activeIndicator").value = tmpElement;
		//alert(window.parent.document.getElementById("activeIndicator").value);
	}
}


function swapFrame(url,tmpCurrTemplateID)
{
	window.location = url;
}


function reorder()
{
	tmpLoc = document.getElementById("currentpageid").value;
	tmpUrl = "/console/reorder.asp?pageid=" + tmpLoc;
	window.showModalDialog(tmpUrl,null,"dialogHeight:700px;dialogWidth:600px")
	window.location = window.location
}

function openSelector(id)
{
	if(id == "hsaddress")
	{
		document.getElementById("hsselect").style.display = "none";
		if(document.getElementById("hsaddress").style.display == "block")
		{
			document.getElementById("hsaddress").style.display = "none"
		}
		else
		{
			document.getElementById("hsaddress").style.display = "block";
			//document.getElementById("address").focus();
		}
	}
	else
	{
		document.getElementById("hsaddress").style.display = "none";
		if(document.getElementById("hsselect").style.display == "block")
		{
			document.getElementById("hsselect").style.display = "none"
		}
		else
		{
			document.getElementById("hsselect").style.display = "block";
		}
	}
} 

function getAreaPage()
{
	
	tmpUrl = "Neighborhood.asp?pageid=" + document.getElementById("highschoolselect")[document.getElementById("highschoolselect").selectedIndex].value;
	window.location = tmpUrl;
}

function getAreaPageByAddress()
{
	validated = true;
	if(document.getElementById("address").value == "")
	{
		alert("You must enter a street address");
		document.getElementById("address").focus();
		validated = false;
	}
	
	if(document.getElementById("city").value == "")
	{
		alert("You must enter a city");
		document.getElementById("city").focus();
		validated = false;
	}

	if(document.getElementById("zip").value == "" || 
		validateNumber(document.getElementById("zip").value) == false ||
		document.getElementById("zip").value.length < 5)
	{
		alert("You must enter a valid 5 digit zip code"); 
		document.getElementById("zip").focus();
		validated = false;
	}
	
	if(validated == true)
	{
		document.getElementById("useraddress").action = "/neighborhoods/neighborhood.asp"
		document.getElementById("useraddress").submit();
	}
}

function validateNumber(temp_value) 
{ 
   var Chars = "0123456789"; 
   for (var i = 0; i < temp_value.length; i++) 
   { 
       if (Chars.indexOf(temp_value.charAt(i)) == -1) 
       { 
			return false; 
       } 
   } 
} 

function changeAddress()
{
	document.getElementById("state").style.display = "inline";
	document.getElementById("statesub").style.display = "none";
	
	document.getElementById("address").className = "maintext";
	document.getElementById("city").className = "maintext";
	document.getElementById("zip").className = "maintext";
	document.getElementById("getbyaddress").style.display = "inline";
}

function inputAddress()
{
	if(document.getElementById("enteraddressrow").style.display == "none")
	{
		document.getElementById("enteraddressrow").style.display = "inline";
	}
	else
	{
		document.getElementById("enteraddressrow").style.display = "none";
	}
}

function openAreaMap(id)
{
	window.open("areaMap.asp?areaID="+id, "AreaMap", "height=500px, width=500px, menu=no, status=no, address=no, scroll=no")
}


function openMoreTables(id)
{
	document.getElementById("morerow").style.display = "none";
	
	for(i = 5;i < id; i++)
	{	
		document.getElementById("moretables" + i).style.display = "block";
	}
	document.getElementById("moretablesbottom").style.display = "block";
}