
var onecount;
onecount = 0;

subcat = new Array();
subcat[0] = new Array("1","","Art & Recreation","0"); 
subcat[1] = new Array("22","","Art & Recreation / Art","1"); 
subcat[2] = new Array("23","","Art & Recreation / Entertainment & Media","1"); 
subcat[3] = new Array("24","","Art & Recreation / Libraries & Museums","1"); 
subcat[4] = new Array("25","","Art & Recreation / Music","1"); 
subcat[5] = new Array("30","","Art & Recreation / Parades & Festivals","1"); 
subcat[6] = new Array("31","","Art & Recreation / Sports Recreation & Parks","1"); 
subcat[7] = new Array("32","","Art & Recreation / Theater & Movies","1"); 
subcat[8] = new Array("2","","Economy","0"); 
subcat[9] = new Array("33","","Economy / Economic Climate","2"); 
subcat[10] = new Array("34","","Economy / Employment","2"); 
subcat[11] = new Array("35","","Economy / Government Assistance Programs","2"); 
subcat[12] = new Array("36","","Economy / Homelessness","2"); 
subcat[13] = new Array("27","","Economy / Homeownership","2"); 
subcat[14] = new Array("37","","Economy / Housing Affordability & Supply","2"); 
subcat[15] = new Array("28","","Economy / Housing Vacancies","2"); 
subcat[16] = new Array("38","","Economy / Income","2"); 
subcat[17] = new Array("39","","Economy / Investment & Personal Finance","2"); 
subcat[18] = new Array("26","","Economy / Poverty","2"); 
subcat[19] = new Array("3","","Education","0"); 
subcat[20] = new Array("40","","Education / Childcare & Early Childhood Education","3"); 
subcat[21] = new Array("41","","Education / Educational Attainment in Adult Population","3"); 
subcat[22] = new Array("29","","Education / Higher Education","3"); 
subcat[23] = new Array("43","","Education / Literacy","3"); 
subcat[24] = new Array("44","","Education / School Environment","3"); 
subcat[25] = new Array("45","","Education / School Resources","3"); 
subcat[26] = new Array("46","","Education / Student Performance K-12","3"); 
subcat[27] = new Array("47","","Education / Vocational & Adult Education","3"); 
subcat[28] = new Array("4","","Government & Politics","0"); 
subcat[29] = new Array("48","","Government & Politics / Elected Officials","4"); 
subcat[30] = new Array("49","","Government & Politics / Elections & Voting","4"); 
subcat[31] = new Array("50","","Government & Politics / Government Responsiveness","4"); 
subcat[32] = new Array("51","","Government & Politics / Judicial System","4"); 
subcat[33] = new Array("52","","Government & Politics / Programs, Policies, & Laws","4"); 
subcat[34] = new Array("53","","Government & Politics / Social Services","4"); 
subcat[35] = new Array("5","","Health","0"); 
subcat[36] = new Array("55","","Health / Alternative Medicine","5"); 
subcat[37] = new Array("65","","Health / An Overview of Mortality Data","5"); 
subcat[38] = new Array("21","","Health / Children's Health","5"); 
subcat[39] = new Array("56","","Health / Chronic Disease","5"); 
subcat[40] = new Array("57","","Health / Communicable Diseases","5"); 
subcat[41] = new Array("58","","Health / Disabilities","5"); 
subcat[42] = new Array("59","","Health / Environmental & Occupational Health","5"); 
subcat[43] = new Array("60","","Health / Exercise, Nutrition, & Weight","5"); 
subcat[44] = new Array("61","","Health / Fetal & Infant Health","5"); 
subcat[45] = new Array("62","","Health / Food Safety","5"); 
subcat[46] = new Array("63","","Health / Health Care Delivery","5"); 
subcat[47] = new Array("64","","Health / Health Insurance","5"); 
subcat[48] = new Array("67","","Health / Medicine, Drugs, & Medical Technology","5"); 
subcat[49] = new Array("11","","Health / Men's Health","5"); 
subcat[50] = new Array("68","","Health / Mental Health","5"); 
subcat[51] = new Array("69","","Health / Oral Health","5"); 
subcat[52] = new Array("73","","Health / Other Conditions","5"); 
subcat[53] = new Array("66","","Health / Prevention & Safety","5"); 
subcat[54] = new Array("70","","Health / Senior Health","5"); 
subcat[55] = new Array("71","","Health / Substance Abuse & Addiction","5"); 
subcat[56] = new Array("54","","Health / Teen & Adolescent Health","5"); 
subcat[57] = new Array("72","","Health / Wellness & Lifestyle","5"); 
subcat[58] = new Array("10","","Health / Women's Health","5"); 
subcat[59] = new Array("6","","Natural Environment","0"); 
subcat[60] = new Array("74","","Natural Environment / Air","6"); 
subcat[61] = new Array("75","","Natural Environment / Energy & Sustainability","6"); 
subcat[62] = new Array("76","","Natural Environment / Environmental Justice","6"); 
subcat[63] = new Array("77","","Natural Environment / Land Contaminants","6"); 
subcat[64] = new Array("78","","Natural Environment / Land Use/Green Space","6"); 
subcat[65] = new Array("79","","Natural Environment / Toxic Chemicals","6"); 
subcat[66] = new Array("80","","Natural Environment / Water","6"); 
subcat[67] = new Array("81","","Natural Environment / Weather & Global Warming","6"); 
subcat[68] = new Array("82","","Natural Environment / Wildlife","6"); 
subcat[69] = new Array("7","","Public Safety","0"); 
subcat[70] = new Array("83","","Public Safety / Corrections","7"); 
subcat[71] = new Array("84","","Public Safety / Crime & Crime Prevention","7"); 
subcat[72] = new Array("85","","Public Safety / Domestic Violence","7"); 
subcat[73] = new Array("86","","Public Safety / Emergency Planning & Response","7"); 
subcat[74] = new Array("87","","Public Safety / Expenditure On Public Safety","7"); 
subcat[75] = new Array("88","","Public Safety / Hate Crimes","7"); 
subcat[76] = new Array("89","","Public Safety / Police & Fire Services","7"); 
subcat[77] = new Array("107","","Public Safety / Recalls, Warnings & Alerts","7"); 
subcat[78] = new Array("90","","Public Safety / Transportation Safety","7"); 
subcat[79] = new Array("8","","Social Environment","0"); 
subcat[80] = new Array("91","","Social Environment / Children's Social Environment","8"); 
subcat[81] = new Array("93","","Social Environment / Community & Business Resources","8"); 
subcat[82] = new Array("108","","Social Environment / Demographics","8"); 
subcat[83] = new Array("94","","Social Environment / Family Structure","8"); 
subcat[84] = new Array("92","","Social Environment / Neighborhood/Community Attachment","8"); 
subcat[85] = new Array("98","","Social Environment / Religion & Spirituality","8"); 
subcat[86] = new Array("95","","Social Environment / Social & Civic Involvement","8"); 
subcat[87] = new Array("96","","Social Environment / Social Activism","8"); 
subcat[88] = new Array("97","","Social Environment / Social Tolerance","8"); 
subcat[89] = new Array("99","","Social Environment / Volunteerism & Charitable Donations","8"); 
subcat[90] = new Array("9","","Transportation","0"); 
subcat[91] = new Array("100","","Transportation / Air Travel","9"); 
subcat[92] = new Array("101","","Transportation / Alternative Travel","9"); 
subcat[93] = new Array("102","","Transportation / Commute To Work","9"); 
subcat[94] = new Array("103","","Transportation / Personal Vehicle Travel","9"); 
subcat[95] = new Array("104","","Transportation / Public Transportation","9"); 
subcat[96] = new Array("105","","Transportation / Roadway Congestion","9"); 
subcat[97] = new Array("106","","Transportation / Train Travel","9"); 
onecount=98;

function getSecondlevel(toptopicid)
{
    GetElement('topic2').length = 0;
    GetElement('topic').value = toptopicid;

    var topid=toptopicid;
    var i;
    GetElement('topic2').options[0] = new Option('==select subtopic==','');
    for (i=0;i < onecount; i++)
    {
        if (subcat[i][3] == topid)
        {
        	GetElement('topic2').options[GetElement('topic2').length] = new Option(subcat[i][2], subcat[i][0]);
        }
    }
}

function getSecondlevel1(toptopicid)
{
       return getSecondlevel(toptopicid);
}

function getSelection(secondtid)
{
	GetElement('topic').value = secondtid;
}

// There is an internal javascript function 'window.getSelection()' so having a user defined function
// with the same name causes an error in some browsers (Firefox) but not others (IE) so we'll 
// duplicate our implementation of getSelection and rename it.
function getSelection1(secondtid)
{
	GetElement('topic').value = secondtid;
}

function getSecondlevel2(toptopicid)
{
    GetElement('topic22').length = 0;
	GetElement('topicOpt2').value = toptopicid;

    var topid=toptopicid;
    var i;
    GetElement('topic22').options[0] = new Option('==select subtopic==','');
    for (i=0;i < onecount; i++)
    {
        if (subcat[i][3] == topid)
        {
        	GetElement('topic22').options[GetElement('topic22').length] = new Option(subcat[i][2], subcat[i][0]);
        }
    }
}

function getSelection2(secondtid)
{
	GetElement('topicOpt2').value = secondtid;
}

function getSecondlevel3(toptopicid)
{
    GetElement('topic32').length = 0;
	GetElement('topicOpt3').value = toptopicid;

    var topid=toptopicid;
    var i;
    GetElement('topic32').options[0] = new Option('==select subtopic==','');
    for (i=0;i < onecount; i++)
    {
        if (subcat[i][3] == topid)
        {
        	GetElement('topic32').options[GetElement('topic32').length] = new Option(subcat[i][2], subcat[i][0]);
        }
    }
}

function getSelection3(secondtid)
{
	GetElement('topicOpt3').value = secondtid;
}

var indCrossTabChild = new Array();
indCrossTabChild["101"] = new Array(); 
indCrossTabChild["101"][indCrossTabChild["101"].length] = new Option("Infant", "123"); 
indCrossTabChild["101"][indCrossTabChild["101"].length] = new Option("Child", "124"); 
indCrossTabChild["101"][indCrossTabChild["101"].length] = new Option("Adult", "125"); 
indCrossTabChild["102"] = new Array(); 
indCrossTabChild["102"][indCrossTabChild["102"].length] = new Option("Male", "126"); 
indCrossTabChild["102"][indCrossTabChild["102"].length] = new Option("Female", "127"); 
indCrossTabChild["100"] = new Array(); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("White", "122"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Black", "170"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Hispanic", "121"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Am Indian/ Alask Nat", "177"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("American Indian", "199"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Asian", "154"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Asian/ Pac Islander", "178"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Asian/Hawaiian/Pac Islander", "197"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Black or African American", "195"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Filipino", "188"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Hispanic or Latino", "196"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Latino", "198"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Multiple or No Response", "189"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Native American", "153"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Other", "169"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Pacific Islander", "200"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Two or more races", "187"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("African American", "120"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Overall County", "128"); 
indCrossTabChild["100"][indCrossTabChild["100"].length] = new Option("Healthy People 2010 Goal", "129"); 

function setDropDownOptions(ddlName, arrOptions)
{
	var objDDL = GetElement(ddlName);
	if(objDDL == null || objDDL.type != 'select-one')
	{
		return;
	}
	// Delete all but the first option items
	for(i=objDDL.options.length-1; i>0; i--)
	{
		objDDL.options[i] = null;
	}

	if(arrOptions == null || arrOptions.length <= 0)
	{
		return;
	}
	for(i=0; i<arrOptions.length; i++)
	{
		// Create a new option element and add it to the list element.  If we were to
		// assign the original option element to the list it assigns by reference which
		// is problematic if you try to assign the same options to a different list later on.
		objDDL.options[i+1] = new Option(arrOptions[i].text, arrOptions[i].value);
	}
	objDDL.options[0].selected = true;
}

function autoSelectDropDown(objDDL, selectedValue)
{
	if(typeof(objDDL) != 'object' || objDDL.type != 'select-one')
	{
		return;
	}

	for(i=0; i<objDDL.options.length; i++)
	{
		if(objDDL.options[i].value == selectedValue || objDDL.options[i].innerHTML == selectedValue)
		{
			objDDL.options[i].selected = true;
			return;
		}
	}
}

function getDropDownSelectedValue(objDDL)
{
	if(typeof(objDDL) != 'object' || objDDL.type != 'select-one')
	{
		return;
	}

	for(i=0; i<objDDL.options.length; i++)
	{
		if(objDDL.options[i].selected)
		{
			return objDDL.options[i].value;
		}
	}
    return;
}

function DoDisplay(regionLevel, editValues) {
	// If editValues is explicitly set to false then we only set the disabled property of the controls
	// and don't modify their vales.  Else we set the disabled property of the controls and modify 
	// their values.
	if(editValues != false) {
		editValues = true;
	}
	
	if (regionLevel == 'Local'){
		document.contents.local.disabled = false;
		document.contents.place.disabled = false;
		if(editValues) {
			if (document.contents.local.value == 'County'){
				document.contents.place.value = 'Whatcom';
			}else{
				document.contents.place.value = '';
			}
		}
	}
	if (regionLevel == 'State'){
		document.contents.local.disabled = true;
		document.contents.place.disabled = false;
		if(editValues) {
			document.contents.place.value = 'Washington';
		}
	}
	if (regionLevel == 'Nation'){
		document.contents.local.disabled = true;
		document.contents.place.disabled = false;
		if(editValues) {
			document.contents.place.value = 'USA';
		}
	}
	if (regionLevel == 'Null') {
		document.contents.local.disabled = true;
		document.contents.place.disabled = true;
		if(editValues) {
			document.contents.place.value = '';
		}
	}
}

function DoLocation(regionLevel) {
	document.contents.local.disabled = '';
	document.contents.place.disabled = '';
	//document.contents.place.value = 'County';
	if (regionLevel == 'County'){
		document.contents.place.value = 'Whatcom';
	}else{
		document.contents.place.value = '';
	}
}

function TopicSelected(topicElemId, subtopicElemId, hiddenElemId) {
	var topicElem = GetElement(topicElemId);
	var topicId = topicElem.options[topicElem.selectedIndex].value;

	var hiddenElem = GetElement(hiddenElemId);
	if(hiddenElem != null) {
		hiddenElem.value = topicId;
	}

	var subtopicElem = GetElement(subtopicElemId);
	if(subtopicElem != null) {
		subtopicElem.length = 0;
		subtopicElem.options[0] = new Option('==select subtopic==',topicId);
		for (var i=0;i < onecount && topicId > 0; i++) {
			if (subcat[i][3] == topicId) {
				subtopicElem.options[subtopicElem.length] = new Option(subcat[i][2], subcat[i][0]);
			}
		}
    }

}

function SubtopicSelected(subtopicElemId, hiddenElemId) {
	var subtopicElem = GetElement(subtopicElemId);
	var subtopicId = subtopicElem.options[subtopicElem.selectedIndex].value;

	var hiddenElem = GetElement(hiddenElemId);
	if(hiddenElem != null) {
		hiddenElem.value = subtopicId;
	}
}

function GetElement(elemId) {
	var elem = (document.getElementById) ? document.getElementById(elemId) : document.all[elemId];
	if(elem != null) {
		return elem;
	}

	elem = document.getElementsByName(elemId);
	return (elem.length > 0) ? elem[0] : null;
}

function IsUrlValid(url) {
    // an empty url is valid
    if(url == null || url == "")
        return true;

    var re = new RegExp("^http(s)?:\/\/", "i");
    url = trim(url);
    return url.match(re);
}

function InvalidUrlMessage() {
    return "The URL must begin with http:// or https://";
}

function trim(str)
{
    return str.replace(/^\s*|\s*$/g,"");
}

function loadCSS(cssfile) { 
    var link = document.createElement('link'); 
    link.href = cssfile; 
    link.rel = 'stylesheet'; 
    link.type = 'text/css'; 
    document.getElementsByTagName('head')[0].appendChild(link); 
}

// From openwindow.js:
function openwindow(hlpfile)
{
	if(typeof(hlpfile)=="undefined"){
		alert('Help file does not exist');
		return;
	}
	window.open (hlpfile,"Help","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=600,height=400");
}

// From showimages.js:
function showimage()
{
  //if (!document.images)
  if (document.images['avatar'].src)
	 return document.images.avatar.src= 'images/avatar/' + document.Register.user_avatar.options[document.Register.user_avatar.selectedIndex].value
}

// Script created: Wed, 10 Mar 2010 12:57:12 GMT