/* Timber Valley JavaScript */

pageSetup = function()
{
	/* no 'var' to declare as global variable */
	navRoot = document.getElementById("Nav");

	addOverClass();

	externalLinks();
}


function addOverClass()
{
	if (document.all && document.getElementById)
	{
		for (var i=0; i<navRoot.childNodes.length; i++)
		{
			var node = navRoot.childNodes[i];
			if (node.tagName == "A")
			{
				node.onmouseover = function()
				  		   {
							this.className += " Over";	
						   }
				node.onmouseout = function()
						  {
							this.className = this.className.replace(" Over","");
						  }
			}
			else if (node.tagName == "DIV")
			{
				node.onmouseover = function()
				  		   {
							this.className += " Over";	
						   }
				node.onmouseout = function()
						  {
							this.className = this.className.replace(" Over","");
						  }
				for (var j=0; j<node.childNodes.length; j++)
				{
					var child = node.childNodes[j];
					if (child.tagName == "DIV")
					{
						for (var k=0; k<child.childNodes.length; k++)
						{
							var grandChild = child.childNodes[k];
							if (grandChild.tagName == "A")
							{
								grandChild.onmouseover = function()
						   					 {
												this.className += " Over";
						   					 }
								grandChild.onmouseout = function()
						  					{
												this.className = this.className.replace(" Over","");
						  					}
							}
						}
					}
				}
			}
		}
	}		
}


function externalLinks()
{
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++)
	{
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "External")
			anchor.target = "_blank";
 	}
}


window.onload = pageSetup;

/* ----------------------------------------------------------------------------------- */

function bookmark()
{
	url = "http://tvfreshscent.com/";
	title = "Timber Valley Fresh Scent";
	if (document.all)
	{
		window.external.addFavorite(url,title);
	}
	else if (window.sidebar)
	{
		window.sidebar.addPanel(title,url,"");
	}
}


function blinkSetup()
{
	text = document.getElementById("Blink");
	times = 0;
	setTimeout("blinkText()",0);
}


function blinkText()
{
	if (text.style.visibility == "visible")
		text.style.visibility = "hidden";
	else
		text.style.visibility = "visible";
	if (times < 8)
	{
		times++;
		setTimeout("blinkText()", 500);
	}
}


function newWindow(File)
{
	window.open(File, "", "scrollbars=yes, menubar=no,  height=500, width=660, resizable=yes, location=no, statusbar=no, left=0, top=0");
}
