var mName;
var mSub;
var name;
var matchTo="left_menu";
var parentTop=0;
var openMenu=false;
var mLink;
var subMen="";

function isMenu(linkRef)
{
	if(linkRef.parentNode.parentNode.parentNode.id==matchTo)
	{
		showMenu();
		openMenu=true;
	}
	else
	{		
		openMenu=false;
		return false;
	}
}

function blinky(blinkMe)
{
	var bMe = document.getElementById ? document.getElementById(blinkMe) : document.all[blinkMe];
	if(bMe)
	{
		if(bMe.style.color=="#aa0000")
		{
			bMe.style.color="#ffffff";
		}
		else
		{
			bMe.style.color="#aa0000";
		}
		setTimeout("blinky("+blinkMe+")",3000);
	}
}

function focusSetNames(linkRef,action)
{
	mLink=linkRef;

	if(mLink.parentNode.parentNode.id==matchTo)
	{
	if(action==1)
	{		
		openMenu=true;
		mStyler("#aa0000","#000000","#ddeeff","#000000");
	}
	else
	{
		
		mStyler("#000000","#ccddee","#003366","#ffffff")
	}
	}
	else
	{
		return;
	}
}


function setNames(linkRef)
{
	mLink=linkRef;
	if(mLink.parentNode.parentNode.id==matchTo)
	{
		openMenu=true;
		parentTop=mLink.parentNode.parentNode.id;
		name=linkRef.parentNode.id;			
		parentTop=document.getElementById ? document.getElementById(parentTop) : document.all[parentTop];	
		mName=document.getElementById ? document.getElementById(name) : document.all[name];
		mSub=document.getElementById ? document.getElementById(name+"Sub") : document.all[name+"Sub"];
		showMenu();
	}
	else
	{
		openMenu=false;
		return openMenu;
	}
}

/*function showStyle(){mStyler("#aa0000","#000000","#ddeeff","#000000")}
function hideStyle(){mStyler("#000000","#ccddee","#003366","#ffffff")}

function showMenu()
{
	showStyle();	
	if(mSub)
	{
		mSub.style.display="block";
		mSub.style.top= mSub.offsetHeight > 180  && mName.offsetTop > 120 && 
		(mSub.offsetHeight >=(mName.offsetTop+mName.offsetHeight)) ? 
			"0px" : mName.offsetTop+"px";
		mSub.style.left=(mName.offsetWidth-1)+"px";	
	}
	return true;
}

function hideMenu()
{
	if(openMenu)
	{
		hideStyle();
		if(mSub)
		{
			mSub.style.display="none";
		}
		return true;
	}
	else
	{
		return false;
	}
}

function mStyler(v1,v2,v3,v4)
{
	if(openMenu)
	{
		styleSet(mLink,"borderLeftColor",v1,0);
		styleSet(mLink,"borderTopColor",v2,0);
		styleSet(mLink,"backgroundColor",v3,0);
		styleSet(mLink,"color",v4,0);
	}
	else
	{	
		return false;
	}
}

function styleSet(styleObject,styleName,styleValue,tagDepth)
{
	
	if(tagDepth > 1)
	{
		for(var i=1; i<tagDepth; i++)
		{
			styleObject=styleObject.parentNode;
		}
	}

	eval("styleObject.style."+styleName+"=styleValue");

}*/
function mailSender(emailAddress)
{
	location.href="mailto:"+emailAddress+"@azroc.gov";
}

function eHide(part1,part2,part3)
{
	location.href="mailto:"+part1+"@"+part2+"."+part3+"?subject=Feedback from azroc.gov Website";
}

function setEHide()
{
	var l=document.getElementsByTagName("a");
	
	for(var i=0; i<l.length; i++)
	{
		if(!l[i].href)
		{
			l[i].innerHTML=" [email] ";
			l[i].href="#";
		}
	}
}



function narrateLink(storyTitle,storyID)
{
	var st=storyTitle;
	var si=storyID;
	var theLink="<a class='inline' style='color: #ffffff; background-color: #ffffff' "+
	"href='javascript: void(0)' "+
	"onclick='narrateThis(\""+st+"\",\""+si+"\"); return false' tabindex='100'>"+
	st+"</a><br /><br />";
	return theLink;
}

function narrateThis(storyTitle,storyID)
{
	var narrateDiv=itemValue(storyID);
	var narrateContent=
		narrateDiv.innerHTML.replace(/<BR><BR>/g,"</a><br /><br /><a href='#'>");
		narrateContent="<a href='#' accesskey='w'>"+narrateContent+"</a>";
		
		if(top.consoleRef){top.consoleRef.close()}

	//SET WINDOW PROPERTIES HERE. WIDTH AND HEIGHT REFER TO INNER WIDTH AND INNER HEIGHT
	windowProps=' top=10,left=10,width=680,height=400,status=0,'+
		'menubar=0,resizable=1,scrollbars=1,toolbar=0 ';

		top.consoleRef=window.open('','narratorWindow',windowProps);
		if(top.consoleRef)
		{	
			narrateContent='<html><head><title>'+storyTitle+'</title>'+
				'<style type="text/css">'+
				'body {'+
				'font-family: verdana, arial, helvetica,sans-serif; font-size: 90%}'+
				'a {text-decoration: none; color: #0000aa;}'+
				'a:active,a:hover {text-decoration: underline; color: #0000ff;}'+
				'a:visited {color: #666699;}'+
				'</style>'+
				'</head><body onload="self.focus()">'+
				narrateContent+'</body></html>';
				top.consoleRef.document.writeln(narrateContent);
				top.consoleRef.document.close();		
		}
	
}

