function showMap(){
	var theHeight=document.getElementById("map").offsetHeight;
	var theWidth=document.getElementById("map").offsetWidth;
	document.getElementById("shim").style.height=theHeight;
	document.getElementById("shim").style.width=theWidth;
	document.getElementById("shim").style.top = 253;
	document.getElementById("shim").style.left = 20;
	document.getElementById("shim").style.visibility = "visible";
	document.getElementById("map").style.top = 253;
	document.getElementById("map").style.left=20;
	document.getElementById("map").style.visibility = "visible";
	scrollTo(0,253);
}

function hideMap(){
	document.getElementById("map").style.visibility = "hidden";
	document.getElementById("shim").style.visibility = "hidden";
}

function selectLocation(theIndex){
	clearSelected();
	var theId="map_locations_"+theIndex;
	document.getElementById(theId).parentNode.id="highlight";	
}

function clearSelected(){
	if(document.getElementById('highlight')){
		document.getElementById('highlight').id='';
	}
}

function toggleIntersection(whichType)
{
	var intersection = document.getElementById("location_info_intersection");
	var street = document.getElementById("location_info_street");
	
	if(whichType.toLowerCase()=="intersection") 
	{
		street.style.display="none";
		intersection.style.display="inline";
	}
	else 
	{
		intersection.style.display="none";
		street.style.display="inline";
	}
}

function toggleFeedback(whichItem){
	if(whichItem=="sr_create"){
		var theStyle = document.getElementById('sr_create_feedback_table').style.display;		
		if(theStyle == "none"){
			document.getElementById('sr_create_feedback_table').style.display = "block";
		}else{			
			document.getElementById('sr_create_feedback_table').style.display = "none";
		}
	}else if(whichItem=="sr_lookup"){
		var theStyle = document.getElementById('sr_lookup_feedback_table').style.display;
		if(theStyle == "none"){
			document.getElementById('sr_lookup_feedback_table').style.display = "block";
		}else{
			document.getElementById('sr_lookup_feedback_table').style.display = "none";
		}
	}else if(whichItem=="hhs"){
		var theStyle = document.getElementById('hhs_feedback_table').style.display;
		if(theStyle == "none"){
			document.getElementById('hhs_feedback_table').style.display = "block";
		}else{
			document.getElementById('hhs_feedback_table').style.display = "none";	
		}
	} else if(whichItem=="picVidSubmission"){
		var theStyle = document.getElementById('picVidSubmission_feedback_table').style.display;
		if(theStyle == "none"){
			document.getElementById('picVidSubmission_feedback_table').style.display = "block";
		}else{
			document.getElementById('picVidSubmission_feedback_table').style.display = "none";	
		}
	}
}

function showWarning(theText){
	var scrOfY=0;
	if( document.body && document.body.scrollTop) {
	    //DOM compliant
	    scrOfY = document.body.scrollTop;
	} else if( document.documentElement && document.documentElement.scrollTop) {
	    //IE6 standards compliant mode
	    scrOfY = document.documentElement.scrollTop;
	}
	if(scrOfY<165){
		scrOfY=165;
	}
	document.getElementById("warning_text").innerHTML=theText;
	document.getElementById("shim").style.height=document.getElementById("warning_popup").offsetHeight;
	document.getElementById("shim").style.width=document.getElementById("warning_popup").offsetWidth;
	document.getElementById("warning_popup").style.top = scrOfY;
	document.getElementById("warning_popup").style.visibility = "visible";
	document.getElementById("shim").style.top = scrOfY;
	document.getElementById("shim").style.left = document.getElementById("warning_popup").style.left;
	document.getElementById("shim").style.visibility = "visible";
}

function hideWarning(){
	document.getElementById("warning_popup").style.visibility = "hidden";
	document.getElementById("shim").style.visibility = "hidden";
}

function showHelp(helpIndex,theId){
	var theField=document.getElementById(theId);
	var posy = theField.offsetTop;
	var posx = theField.offsetLeft;
	tempEl = theField.offsetParent;
	while (tempEl != null){
		posy += tempEl.offsetTop;
		posx += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}
	var theHelpIndex=-1;
	for(var i=0;i<helpText.length;i++){
		if(helpText[i][0].toLowerCase()==helpIndex.toLowerCase()){
			theHelpIndex=i;
		}
	}
	if(theHelpIndex>-1){
		document.getElementById("help_title").innerHTML=helpText[theHelpIndex][0];
		document.getElementById("help_text").innerHTML=helpText[theHelpIndex][1];
	}else{
		document.getElementById("help_title").innerHTML="Help Text Missing";
		document.getElementById("help_text").innerHTML="The specified help index ("+helpIndex+") was not found";
	}
	var theHeight=document.getElementById("help_popup").offsetHeight;
	var theWidth=document.getElementById("help_popup").offsetWidth;
	posy=posy+28;
	posx=posx-330;
	document.getElementById("shim").style.height=theHeight;
	document.getElementById("shim").style.width=theWidth;
	document.getElementById("shim").style.top = posy;
	document.getElementById("shim").style.left = posx;
	document.getElementById("shim").style.visibility = "visible";
	document.getElementById("help_popup").style.top = posy;
	document.getElementById("help_popup").style.left=posx;
	document.getElementById("help_popup").style.visibility = "visible";
}
function showHelpLabel(theId,helpIndex){
	var theField=document.getElementById(theId);
	var posy = theField.offsetTop;
	var posx = theField.offsetLeft;
	tempEl = theField.offsetParent;
	while (tempEl != null){
		posy += tempEl.offsetTop;
		posx += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}
	var theHelpIndex=-1;
	for(var i=0;i<helpText.length;i++){
		if(helpText[i][0].toLowerCase()==helpIndex.toLowerCase()){
			theHelpIndex=i;
		}
	}
	if(theHelpIndex>-1){
		document.getElementById("help_title").innerHTML=helpText[theHelpIndex][0];
		document.getElementById("help_text").innerHTML=helpText[theHelpIndex][1];
	}else{
		document.getElementById("help_title").innerHTML="Help Text Missing";
		document.getElementById("help_text").innerHTML="The specified help index ("+helpIndex+") was not found";
	}
	var theHeight=document.getElementById("help_popup").offsetHeight;
	var theWidth=document.getElementById("help_popup").offsetWidth;
	posy=posy+35;
	document.getElementById("shim").style.height=theHeight;
	document.getElementById("shim").style.width=theWidth;
	document.getElementById("shim").style.top = posy;
	document.getElementById("shim").style.left = posx;
	document.getElementById("shim").style.visibility = "visible";
	document.getElementById("help_popup").style.top = posy;
	document.getElementById("help_popup").style.left=posx;
	document.getElementById("help_popup").style.visibility = "visible";
}
function hideHelp(){
	document.getElementById("help_popup").style.visibility = "hidden";
	document.getElementById("shim").style.visibility = "hidden";
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function showElements(){
	var arr=showElements.arguments;
	for(i=0;i<arr.length;i++){
		show(arr[i]);
	}
}

function showDetails(theIndex){
	var theLink="show_hide_link_"+theIndex;
	var theDetails="show_hide_"+theIndex;
	var textContent=document.getElementById(theLink).firstChild.firstChild.nodeValue;
	show(theDetails);
	var theNewLink='<a href="javascript:hideDetails(\''+theIndex+'\')">'+textContent+'</a>';
	document.getElementById(theLink).innerHTML=theNewLink;
}

function hideDetails(theIndex){
	var theLink="show_hide_link_"+theIndex;
	var theDetails="show_hide_"+theIndex;
	var textContent=document.getElementById(theLink).firstChild.firstChild.nodeValue;
	hide(theDetails);
	var theNewLink='<a href="javascript:showDetails(\''+theIndex+'\')">'+textContent+'</a>';
	document.getElementById(theLink).innerHTML=theNewLink;
}


function hideElements(){
	var arr=hideElements.arguments;
	for(i=0;i<arr.length;i++){
		hide(arr[i]);
	}
}

function toggleElements(){
	var arr=toggleElements.arguments;
	for(i=0;i<arr.length;i++){
		toggle(arr[i]);
	}
}

function show(whichElement){
	document.getElementById(whichElement).style.display="";
}

function hide(whichElement){
	document.getElementById(whichElement).style.display="none";
}

function toggle(whichElement){
	var theStyle=document.getElementById(whichElement).style;
	theStyle.display = theStyle.display? "":"none";
}

function showResidency(isLocal){
	if(isLocal){
		hide("non-local_resident");
		show("local_resident");
	}else{
		show("non-local_resident");
		hide("local_resident");
	}
}
