var theSubs = new Array();

window.onload = init;

function showCurrentSection(showID)
{
	var objCurrentSection = document.getElementById(showID);		
	if (objCurrentSection != null) {
		objCurrentSection.style.display = "block";
		objCurrentSection.parentNode.style.listStyle= "url(images/arrow.gif)";		
		if (objCurrentSection.parentNode.parentNode.nodeName == "UL")
			showSection(objCurrentSection.parentNode.parentNode);
	}
}

function showSection(objSection)
{
	objSection.style.display = "block";
		objSection.parentNode.style.listStyle= "url(images/arrow.gif)";
	if (objSection.parentNode.parentNode != null && objSection.parentNode.parentNode.nodeName == "UL")
		showSection(objSection.parentNode.parentNode);
}

function init() {
	if (document.getElementById && document.getElementsByTagName) {
		catchSubMenus();
  	showCurrentSection("navcurrentsection")
	}
}

function catchSubMenus() {
	if (!document.getElementById("menu")) { return; }
	var subCounter = 0;
	var myMenu = document.getElementById("menu").getElementsByTagName("A");
	if (document.getElementById("currentPage") != null) {
    if (document.getElementById("currentPage").parentNode.id != "menu") {
      document.getElementById("currentPage").parentNode.id = "navcurrentsection";
    }
  }
    for (var i=0;i<myMenu.length;i++) {
		  if (myMenu[i].nextSibling) {
		    if (myMenu[i].nextSibling.nodeName == "UL") {
				  myMenu[i].parentNode.style.listStyle= "url(images/arrowdwn.gif)";
  				myMenu[i].onclick = clickNav;
          myMenu[i].onkeypress = clickNav;
          myMenu[i].nextSibling.style.display = "none";
          theSubs[subCounter] = myMenu[i].nextSibling;
          subCounter++;
        }
      }
    }
	document.getElementById("menu").style.display = "block";
}

function closeNav() {
	for (var i=0;i<theSubs.length;i++) {
		theSubs[i].style.display = "none";
		theSubs[i].id = ""
		theSubs[i].parentNode.style.listStyle= "url(images/arrowdwn.gif)";
	}
	if (document.getElementById("currentPage") != null) {
    if (document.getElementById("currentPage").parentNode.id != "menu") {
      document.getElementById("currentPage").parentNode.id = "navcurrentsection";
    }
  }
  showCurrentSection("navcurrentsection")
}

function clickNav(e) {
	if (!e) var e = window.event;
	if (e.target) var tg = e.target;
	else if (e.srcElement) var tg = e.srcElement;
	while (tg.nodeName != 'A') 
		tg = tg.parentNode;
  if (tg.nextSibling.style.display == "none") {
    var currentSection = tg.nextSibling;
  }	else if ( tg.parentNode.parentNode.id != "menu" ){
  	var currentSection = tg.parentNode.parentNode;
  }
  closeNav();
  if (currentSection != null) {
    currentSection.id= "clicknav";}
  showCurrentSection("clicknav")
	return false;
}

function emailMe() {
        var em1 = "info";
        var em2 = "dragflicking";
	var em3 = "com";
	var sub = "Email from dragflicking";
	var title = "Email me for questions or remarks";
        document.write("<\A HREF='" + "mail" + "to:" + em1 + "&#64;" + em2 + "." + em3 + "?subject=" + sub + "' TITLE='" + title + "'>" + em1 + "&#64;" + em2 + "." + em3 + "<\/A>");
}

function OneStat_Pageview()
{
    var d=document;
    var sid="389834";
    var CONTENTSECTION="";
    var osp_URL=d.URL;
    var osp_Title=d.title;
    var t=new Date();
    var p="http"+(d.URL.indexOf('https:')==0?'s':'')+"://stat.onestat.com/stat.aspx?tagver=2&sid="+sid;
    p+="&url="+escape(osp_URL);
    p+="&ti="+escape(osp_Title);
    p+="&section="+escape(CONTENTSECTION);
    p+="&rf="+escape(parent==self?document.referrer:top.document.referrer);
    p+="&tz="+escape(t.getTimezoneOffset());
    p+="&ch="+escape(t.getHours());
    p+="&js=1";
    p+="&ul="+escape(navigator.appName=="Netscape"?navigator.language:navigator.userLanguage);
    if(typeof(screen)=="object"){
       p+="&sr="+screen.width+"x"+screen.height;p+="&cd="+screen.colorDepth;
       p+="&jo="+(navigator.javaEnabled()?"Yes":"No");
    }
    d.write("<\div id='counter'><\a href='http://www.onestat.com/aspx/login.aspx?sid="+sid+"' target='_blank'><\img id='onestat_tag' border='0' src='"+p+"' alt='This site tracked by OneStat.com. Get your own free website counter.'><\/a><\/div>");
}
