 //
// NavButton class
//
function NavButton (parent, _data, _format )
{
	var no = _data.no;
	var onScale = "1.25";
	var offScale = "1.0";
	var onOpacity = "1.0";
	var offOpacity = "0.7";
	var animDur = "0:0:0.05";
	var dotAnimDur = "0:0:0.3";
	var approxH = Number (_format.fontSize ) *.7;
	// create the label
	var xaml = "<Canvas xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' x:Name='nav_" + no + "' Canvas.Left='" + _data.x + "' Canvas.Top='" + _data.y + "' Width='100' Height='" + approxH + "' RenderTransformOrigin='0,0.5' Opacity='" + offOpacity + "'>";
	xaml += "<Canvas.RenderTransform>";
	xaml += "<ScaleTransform x:Name='nav_" + no + "_trns' ScaleX='1.0' ScaleY='1.0' />";
	xaml += "</Canvas.RenderTransform>";
	xaml += "<Canvas.Resources>";
	xaml += "<Storyboard x:Name='dot_nav_" + no + "_sb'>";
	xaml += "<DoubleAnimationUsingKeyFrames Storyboard.TargetName='nav_dot_y' Storyboard.TargetProperty='Y'>";
	xaml += "<SplineDoubleKeyFrame KeySpline='0.5,0.5,0.5,1' KeyTime='" + dotAnimDur + "' Value='" + _data.y + "' />";
	xaml += "</DoubleAnimationUsingKeyFrames>";
	xaml += "</Storyboard>";
	xaml += "<Storyboard x:Name='nav_" + no + "_overO_sb'>";
	xaml += "<DoubleAnimationUsingKeyFrames Storyboard.TargetName='nav_" + no + "' Storyboard.TargetProperty='(UIElement.Opacity)'>";
	xaml += "<SplineDoubleKeyFrame KeySpline='0.5,0.5,0.5,1' KeyTime='" + animDur + "' Value='" + onOpacity + "' />";
	xaml += "</DoubleAnimationUsingKeyFrames>";
	xaml += "</Storyboard>";
	xaml += "<Storyboard x:Name='nav_" + no + "_outO_sb'>";
	xaml += "<DoubleAnimationUsingKeyFrames Storyboard.TargetName='nav_" + no + "' Storyboard.TargetProperty='(UIElement.Opacity)'>";
	xaml += "<SplineDoubleKeyFrame KeySpline='0.5,0.5,0.5,1' KeyTime='" + animDur + "' Value='" + offOpacity + "' />";
	xaml += "</DoubleAnimationUsingKeyFrames>";
	xaml += "</Storyboard>";
	xaml += "<Storyboard x:Name='nav_" + no + "_outX_sb'>";
	xaml += "<DoubleAnimationUsingKeyFrames Storyboard.TargetName='nav_" + no + "_trns' Storyboard.TargetProperty='ScaleX'>";
	xaml += "<SplineDoubleKeyFrame KeySpline='0.5,0.5,0.5,1' KeyTime='" + animDur + "' Value='" + offScale + "' />";
	xaml += "</DoubleAnimationUsingKeyFrames>";
	xaml += "</Storyboard>";
	xaml += "<Storyboard x:Name='nav_" + no + "_outY_sb'>";
	xaml += "<DoubleAnimationUsingKeyFrames Storyboard.TargetName='nav_" + no + "_trns' Storyboard.TargetProperty='ScaleY'>";
	xaml += "<SplineDoubleKeyFrame KeySpline='0.5,0.5,0.5,1' KeyTime='" + animDur + "' Value='" + offScale + "' />";
	xaml += "</DoubleAnimationUsingKeyFrames>";
	xaml += "</Storyboard>";
	xaml += "<Storyboard x:Name='nav_" + no + "_releaseX_sb'>";
	xaml += "<DoubleAnimationUsingKeyFrames Storyboard.TargetName='nav_" + no + "_trns' Storyboard.TargetProperty='ScaleX'>";
	xaml += "<SplineDoubleKeyFrame KeySpline='0.5,0.5,0.5,1' KeyTime='" + animDur + "' Value='" + onScale + "' />";
	xaml += "</DoubleAnimationUsingKeyFrames>";
	xaml += "</Storyboard>";
	xaml += "<Storyboard x:Name='nav_" + no + "_releaseY_sb'>";
	xaml += "<DoubleAnimationUsingKeyFrames Storyboard.TargetName='nav_" + no + "_trns' Storyboard.TargetProperty='ScaleY'>";
	xaml += "<SplineDoubleKeyFrame KeySpline='0.5,0.5,0.5,1' KeyTime='" + animDur + "' Value='" + onScale + "' />";
	xaml += "</DoubleAnimationUsingKeyFrames>";
	xaml += "</Storyboard>";
	xaml += "</Canvas.Resources>";
	xaml += "<Glyphs x:Name='nav_label_" + no + "' Canvas.Left='0' Canvas.Top='0' Fill='" + _format.fontColor + "' FontUri='assets/fonts/" + _format.fontName + "' FontRenderingEmSize='" + _format.fontSize + "' UnicodeString='" + _data.label + "' />";
	xaml += "</Canvas>";
	var inst = agControl.content.createFromXaml (xaml );
	parent.children.add (inst );
	inst.addEventListener ("mouseEnter", this.over );
	inst.addEventListener ("mouseLeave", this.out );
	inst.addEventListener ("mouseLeftButtonUp", this.release );
}
// rollover
NavButton.prototype.over = NavButtonOver = function (sender )
{
	var no = sender.name.split ("nav_" ).join ("");
	agControl.content.findName ("nav_" + no + "_overO_sb" ).begin ();
}
// rollout
NavButton.prototype.out = NavButtonOut = function (sender )
{
	var tempNo = sender.name.split ("_");
	var no = Number (tempNo [1]);
	if (SECTION_NO != no )
	{
		agControl.content.findName ("nav_" + no + "_outO_sb" ).begin ();
		agControl.content.findName ("nav_" + no + "_outX_sb" ).begin ();
		agControl.content.findName ("nav_" + no + "_outY_sb" ).begin ();
	}
}
// press
NavButton.prototype.down = NavButtonDown = function (sender, args )
{
}
// release
NavButton.prototype.release = NavButtonRelease = function (sender, args )
{
	var tempNo = sender.name.split ("_");
	var no = Number (tempNo [1]);
	if (SECTION_NO != no)
	{
		var prev = SECTION_NO;
		SECTION_NO = no;
		if (prev)
		{
			var prevBtn = agControl.content.findName ("nav_" + prev );
			// rollout prev btn
			NavButtonOut (prevBtn );
		}
		// activate this btn
		agControl.content.findName ("nav_" + no + "_overO_sb" ).begin ();
		agControl.content.findName ("nav_" + no + "_releaseX_sb" ).begin ();
		agControl.content.findName ("nav_" + no + "_releaseY_sb" ).begin ();
		agControl.content.findName ("dot_nav_" + no + "_sb" ).begin ();
		
		// check to see if a sub nav should be visible
		if(checkSubNav(prev, SECTION_NO)){
		
		    PAGE_NO = 0;
		    SubNavButtonRelease(agControl.content.findName("subnavbtn_" + SECTION_NO + "_1"));
		
		}else{
		    PAGE_NO = 1;
		    appNavigator.setHTMLFile(SECTION_NO + "_1");
		    // notify the navigator
		   // appNavigator.setLocation (no + "_1" );
		
		}
			
	}
}
