function showMap() {
	$('#rssDisplay')[0].innerHTML = '';
	$('#usmapsmall').hide();
	$('#action_items').hide();
	$('#usmap').show();
	$("#usmap img").animate({ width: "550px",height: "367px",marginTop:"0px"}, 500);
}

function onCompleteShrink() {
	var state = passedstate;
	$('#usmap').hide();
	$('#usmapsmall').show();
	$('#action_items')[0].innerHTML = '';
	statename = "California";
	$('#content-ai h1')[0].innerHTML = State[state];
	//var html = "<h3>"+State[state]+"</h3>";
	var html = '';
	html += "<ul>";
	html += "<li class='showstate rc'><a href='javascript:void(0)' onclick='showRC(\""+state+"\",this)'><h3>Regional Coordinators</h3></a><div id='rssRC' class='rssDisplay'></div>";
	html += "<li class='showstate lco'><a href='javascript:void(0)' onclick='showLCO(\""+state+"\",this)'><h3>Local Climbing Organizations</h3></a><div id='rssLCO' class='rssDisplay'></div>";
	html += "<li class='showstate'><a href='javascript:void(0)' onclick='showAlerts(\""+state+"\",this)'><h3>Action Alerts</h3></a><div id='rssAA' class='rssDisplay'></div>";
	html += "<li class='showstate'><a href='javascript:void(0)' onclick='showAccessIssues(\""+state+"\",this)'><h3>Restrictions &amp; Closures</h3></a><div id='rssAccessIssues' class='rssDisplay'></div>";
	html += "<li class='showstate'><a href='javascript:void(0)' onclick='showNews(\""+state+"\",this)'><h3>News</h3></a><div id='rssNews' class='rssDisplay'></div>";
	html += "<li class='showstate'><a href='javascript:void(0)' onclick='showEvents(\""+state+"\",this)'><h3>Events</h3></a><div id='rssEv' class='rssDisplay'><div id='rssEvents'></div><div id='rssEventsAdopt'></div><div id='rssEventsTeamWorks'></div></div>";
	html += "<li class='showstate'><a href='javascript:void(0)' onclick='filelist(\""+state+"\",this)'><h3>Position Statements</h3></a><div id='rssLPS' class='rssDisplay'></div>";
	html += "<li class='showstate'><a href='javascript:void(0)' onclick='showGrants(\""+state+"\",this)'><h3>Grants Awarded</h3></a><div id='rssGrants' class='rssDisplay'></div>";
	html += "</ul>";
	$('#action_items')[0].innerHTML = html;
	$('#action_items').fadeIn();
	showRC(state,$('li.rc a')[0]);
	showLCO(state,$('li.lco a')[0]);
}

function showState(state) {
	passedstate = state;
	$("#usmap img").animate({ width: "145px",height: "97px",marginTop:"-20px"}, 500, onCompleteShrink);
	$('#rssDisplay')[0].innerHTML = '';
}

function getEl(id)
{
	return document.getElementById(id);
}

function toggle(id)
{
	el = document.getElementById(id);
	var d = 'block';
	var a='arrowDown.gif';
	if (el.style.display=='block')
	{
		d = 'none';
		a = 'arrowRight.gif';
	}
	el.style.display = d;
	document.getElementById('arrow_'+id).src="http://mountainproject.com/img/"+a;
}

function showAccessIssues(state, href)
{
	href.onclick = function() {
		if ($('#rssAccessIssues')[0].style.display=="none")
			$('#rssAccessIssues').slideDown();
		else
			$('#rssAccessIssues').slideUp();
	}

	if (getEl('rssAccessIssues').innerHTML.length)
		return;

	getEl('rssAccessIssues').innerHTML = "Loading data for "+state+". <img src='/atf/cf/{1F5726D5-6646-4050-AA6E-C275DF6CA8E3}/loading.gif' />";

	var pJson = document.createElement("script")
	pJson.type="text/javascript";
	pJson.src = "http://status.accessfund.org/?format=json&state="+state;
	document.getElementsByTagName("head")[0].appendChild(pJson);
}

//News – news will be displayed by state and date. We can do that with the SQL file you sent.
//Action Alerts – I see they are in CMS but will need to update to identify which state the action alert is for
//Events – I see that a calendar is going to be used to plan events. Are you wanting a way to display these events by state? Or is the calendar what you were looking for?
//Local Climbing Organizations – this content is already in Sphere, organized by state, so no import is needed … but it’s currently in CMS as a single html page. If the plan is to display them by state then we will need to
//separate each of these organizations into their own content item.
//Regional Coordinators – this content is already in Sphere, organized by state, so no import is needed … but it’s currently in CMS as a html page. If the plan is to display them by state then we will need to separate each of
//these coordinators into their own content item. These coordinators could probably added to sphere as contact records with a segment of Regional Coordinator then use the contact lookup tool to filter the list by state.
//Grants Awarded – grants will be displayed by state and date.

function showGrants(state, href) {
	rsscall = new RSSDisplay({
	   linktitletag : "title",
	   linkurltag : "link",
	   showtitle : false,
	   title : "Grants for " + State[state],
	   sitepath : "/atf/cf/{1F5726D5-6646-4050-AA6E-C275DF6CA8E3}/",
	   itemsToDisplay : 999,
	   fieldsToDisplay : {"title":"true", "k:subtitle":"true", "description":"true"},
	   dataArea : "rssGrants",
	   datekey : "k:pubDate",
	   filter : { "k:byline" : [state, "National"]},
	   loadingImage : "loading.gif",
	   showlabels : false,
	   labeltags : {
			  "title" : ""
	   },
	   labeltypes : {},
	   showsort : false,
	   labelsort : {},
	   feed : "/site/apps/nl/rss2.asp?c=tmL5KhNWLrH&b=5051883"
	});
	href.onclick = function() {
		if ($('#rssGrants')[0].style.display=="none")
			$('#rssGrants').slideDown();
		else
			$('#rssGrants').slideUp();
	}
}

function showNews(state, href) {
	rsscall = new RSSDisplay({
	   linktitletag : "title",
	   linkurltag : "link",
	   showtitle : false,
	   title : "News for " + State[state],
	   sitepath : "/atf/cf/{1F5726D5-6646-4050-AA6E-C275DF6CA8E3}/",
	   itemsToDisplay : 999,
	   fieldsToDisplay : {"title":"true", "k:subtitle":"true", "description":"true"},
	   dataArea : "rssNews",
	   datekey : "k:pubDate",
	   filter : { "k:byline" : [state, "National"]},
	   loadingImage : "loading.gif",
	   showlabels : false,
	   labeltags : {
			  "title" : ""
	   },
	   labeltypes : {},
	   showsort : false,
	   labelsort : {},
	   feed : "/site/apps/nl/rss2.asp?c=tmL5KhNWLrH&b=5051885"
	});
	href.onclick = function() {
		if ($('#rssNews')[0].style.display=="none")
			$('#rssNews').slideDown();
		else
			$('#rssNews').slideUp();
	}
}

function showAlerts(state,href) {
	rsscall = new RSSDisplay({
	   linktitletag : "title",
	   linkurltag : "link",
	   showtitle : false,
	   title : "Action Alerts for " + State[state],
	   sitepath : "/atf/cf/{1F5726D5-6646-4050-AA6E-C275DF6CA8E3}/",
	   itemsToDisplay : 999,
	   fieldsToDisplay : {"title":"true", "k:subtitle":"true", "description":"true"},
	   dataArea : "rssAA",
	   datekey : "k:pubDate",
	   filter : { "k:byline" : [state, "National"]},
	   loadingImage : "loading.gif",
	   showlabels : false,
	   labeltags : {
			  "title" : ""
	   },
	   labeltypes : {},
	   showsort : false,
	   labelsort : {},
	   feed : "/site/apps/nl/rss2.asp?c=tmL5KhNWLrH&b=5052331"
	});
	href.onclick = function() {
		if ($('#rssAA')[0].style.display=="none")
			$('#rssAA').slideDown();
		else
			$('#rssAA').slideUp();
	}
}

function showEvents(state,href) {
	rsscall = new RSSDisplay({
	   linktitletag : "title",
	   linkurltag : "link",
	   showtitle : true,
	   title : "General Events",
	   sitepath : "/atf/cf/{1F5726D5-6646-4050-AA6E-C275DF6CA8E3}/",
	   itemsToDisplay : 999,
	   fieldsToDisplay : {"title":"true", "pubDate":"true", "description":"true"},
	   dataArea : "rssEvents",
	   datekey : "k:pubDate",
	   filter : { "k:byline" : [state, "National"]},
	   uniqueid : 0,
	   loadingImage : "loading.gif",
	   showlabels : false,
	   labeltags : {
			  "title" : ""
	   },
	   labeltypes : {},
	   showsort : false,
	   labelsort : {},
	   feed : "/site/apps/nl/rss2.asp?c=tmL5KhNWLrH&b=5053289"
	});
	rsscall2 = new RSSDisplay({
	   linktitletag : "title",
	   linkurltag : "link",
	   showtitle : true,
	   title : "Adopt a Crag Events",
	   sitepath : "/atf/cf/{1F5726D5-6646-4050-AA6E-C275DF6CA8E3}/",
	   itemsToDisplay : 999,
	   fieldsToDisplay : {"title":"true", "pubDate":"true", "description":"true"},
	   dataArea : "rssEventsAdopt",
	   datekey : "k:pubDate",
	   filter : { "k:byline" : [state, "National"]},
	   uniqueid : 0,
	   loadingImage : "loading.gif",
	   showlabels : false,
	   labeltags : {
			  "title" : ""
	   },
	   labeltypes : {},
	   showsort : false,
	   labelsort : {},
	   feed : "/site/apps/nl/rss2.asp?c=tmL5KhNWLrH&b=5063883"
	});
	rsscall3 = new RSSDisplay({
	   linktitletag : "title",
	   linkurltag : "link",
	   showtitle : true,
	   title : "TeamWorks Events",
	   sitepath : "/atf/cf/{1F5726D5-6646-4050-AA6E-C275DF6CA8E3}/",
	   itemsToDisplay : 999,
	   fieldsToDisplay : {"title":"true", "pubDate":"true", "description":"true"},
	   dataArea : "rssEventsTeamWorks",
	   datekey : "k:pubDate",
	   filter : { "k:byline" : [state, "National"]},
	   uniqueid : 0,
	   loadingImage : "loading.gif",
	   showlabels : false,
	   labeltags : {
			  "title" : ""
	   },
	   labeltypes : {},
	   showsort : false,
	   labelsort : {},
	   feed : "/site/apps/nl/rss2.asp?c=tmL5KhNWLrH&b=5063885"
	});
	href.onclick = function() {
		if ($('#rssEv')[0].style.display=="none")
			$('#rssEv').slideDown();
		else
			$('#rssEv').slideUp();
	}
}

function showLCO(state,href) {
	rsscall = new RSSDisplay({
	   showtitle : false,
	   title : "Local Climbing Organizations for " + State[state],
	   sitepath : "/atf/cf/{1F5726D5-6646-4050-AA6E-C275DF6CA8E3}/",
	   itemsToDisplay : 999,
	   fieldsToDisplay : {"description":"true"},
	   dataArea : "rssLCO",
	   datekey : "k:pubDate",
	   filter : { "k:byline" : [state, "National"]},
	   uniqueid : 0,
	   loadingImage : "loading.gif",
	   showlabels : false,
	   labeltags : {
			  "title" : ""
	   },
	   labeltypes : {},
	   showsort : false,
	   labelsort : {},
	   feed : "/site/apps/nl/rss2.asp?c=tmL5KhNWLrH&b=5056539"
	});
	href.onclick = function() {
		if ($('#rssLCO')[0].style.display=="none")
			$('#rssLCO').slideDown();
		else
			$('#rssLCO').slideUp();
	}
}

function showLCO_contactlookup(state) {
	rsscall = new RSSContentSearch({
	   linktitletag : "title",
	   linkurltag : "link",
	   sitepath : "/atf/cf/{1F5726D5-6646-4050-AA6E-C275DF6CA8E3}/",
	   itemsToDisplay : 999,
	   dataArea : "rssDisplay",
	   filter : { "state" : state},
	   loadingImage : "loading.gif",
	   showlabels : false,
  	   templatedata : {
		   line1 : "[1]"
	   },
	   usetemplate : true,
	   feed : "/site/c.tmL5KhNWLrH/b.5053389/k.CFE8/Local_Climbing_Organizations/apps/kb/cs/contactsearch.asp"
	});
}

function showRC(state,href) {
	rsscall = new RSSDisplay({
	   showtitle : false,
	   title : "Regional Coordinators for " + State[state],
	   sitepath : "/atf/cf/{1F5726D5-6646-4050-AA6E-C275DF6CA8E3}/",
	   itemsToDisplay : 999,
	   fieldsToDisplay : {"description":"true"},
	   dataArea : "rssRC",
	   datekey : "k:pubDate",
	   filter : { "k:byline" : [state, "National"]},
	   uniqueid : 0,
	   loadingImage : "loading.gif",
	   showlabels : false,
	   labeltags : {
			  "title" : ""
	   },
	   labeltypes : {},
	   showsort : false,
	   labelsort : {},
	   feed : "/site/apps/nl/rss2.asp?c=tmL5KhNWLrH&b=5057821"
	});
	href.onclick = function() {
		if ($('#rssRC')[0].style.display=="none")
			$('#rssRC').slideDown();
		else
			$('#rssRC').slideUp();
	}
}

function showRC_contactlookup(state) {
	rsscall = new RSSContentSearch({
	   showtitle : false,
	   linktitletag : "title",
	   linkurltag : "link",
	   sitepath : "/atf/cf/{1F5726D5-6646-4050-AA6E-C275DF6CA8E3}/",
	   itemsToDisplay : 999,
	   dataArea : "rssDisplay",
	   filter : { "state" : state},
	   loadingImage : "loading.gif",
  	   templatedata : {
		   line1 : "<span class='name'>[1] [2]</span><br />",
		   line2 : "<span class='add1'>[4], [5]  [6]</span><br />",
		   line3 : "<span class='email'>[3]</span><br />"
	   },
	   usetemplate : true,
	   feed : "/site/apps/kb/cs/contactsearch.asp?c=tmL5KhNWLrH&b=5054307"
	});
}

function filelist(state,href) {
	$('#rssLPS')[0].innerHTML = "Loading... <img src='/atf/cf/{1F5726D5-6646-4050-AA6E-C275DF6CA8E3}/loading.gif' />";
	$.post("/site/apps/fs/filesearch.asp?c=tmL5KhNWLrH&b=5052203","searchtext="+state+"--&submit=Search",function(data){
		$(data).find('#content table td:eq(0)').each(function(index, item) {
			$(item).find('form').remove();
			$('#rssLPS')[0].innerHTML = item.innerHTML;
		});
	});
	href.onclick = function() {
		if ($('#rssLPS')[0].style.display=="none")
			$('#rssLPS').slideDown();
		else
			$('#rssLPS').slideUp();
	}
}

function eventList(state) {
	$('#rssDisplay')[0].innerHTML = "Loading... <img src='/atf/cf/{1F5726D5-6646-4050-AA6E-C275DF6CA8E3}/loading.gif' />";
	$.get("/site/c.tmL5KhNWLrH/b.5059417/k.338C/Calendar_Item_Content_Listing/apps/cd/calendarindex.asp",function(data){
		$(data).find('#content table td:eq(0)').each(function(index, item) {
			$(item).find('form').remove();
			$('#rssDisplay')[0].innerHTML = item.innerHTML;
		});
	});
}

function BuildArrays()
{
 State = {};
 State["AL"] = "Alabama";
 State["AK"] = "Alaska";
 State["AZ"] = "Arizona";
 State["AR"] = "Arkansas";
 State["CA"] = "California";
 State["CO"] = "Colorado";
 State["CT"] = "Connecticut";
 State["DE"] = "Delaware";
 State["FL"] = "Florida";
 State["GA"] = "Georgia";
State["HI"] = "Hawaii";
State["ID"] = "Idaho";
State["IL"] = "Illinois";
State["IN"] = "Indiana";
State["IA"] = "Iowa";
State["KS"] = "Kansas";
State["KY"] = "Kentucky";
State["LA"] = "Louisiana";
State["ME"] = "Maine";
State["MD"] = "Maryland";
State["MA"] = "Massachusetts";
State["MI"] = "Michigan";
State["MN"] = "Minnesota";
State["MS"] = "Mississippi";
State["MO"] = "Missouri";
State["MT"] = "Montana";
State["NE"] = "Nebraska";
State["NV"] = "Nevada";
State["NH"] = "New Hampshire";
State["NJ"] = "New Jersey";
State["NM"] = "New Mexico";
State["NY"] = "New York";
State["NC"] = "North Carolina";
State["ND"] = "North Dakota";
State["OH"] = "Ohio";
State["OK"] = "Oklahoma";
State["OR"] = "Oregon";
State["PA"] = "Pennsylvania";
State["RI"] = "Rhode Island";
State["SC"] = "South Carolina";
State["SD"] = "South Dakota";
State["TN"] = "Tennessee";
State["TX"] = "Texas";
State["UT"] = "Utah";
State["VT"] = "Vermont";
State["VA"] = "Virginia";
State["WA"] = "Washington";
State["WV"] = "West Virginia";
State["WI"] = "Wisconsin";
State["WY"] = "Wyoming";
}
BuildArrays();