// JavaScript Document

// -- Placeholder Function
function activatePlaceholders() {
var detect = navigator.userAgent.toLowerCase();
if (detect.indexOf("safari") > 0) return false;
var inputs = document.getElementsByTagName("input");
for (var i=0;i<inputs.length;i++) {
    var placeholderText = inputs[i].getAttribute("placeholder");
	if (placeholderText)
	{
		inputs[i].value = placeholderText;
		inputs[i].style.color = "#999999";
		inputs[i].onclick = function() {
		 if (this.value == this.getAttribute("placeholder")) {
			this.value = "";
		 }
		 return false;
		}
		inputs[i].onkeyup = function()
		{
			if ((this.value != this.getAttribute("placeholder")) && (this.value != ""))
			{
				this.style.color = "#000000";
			}
			else
			{
				this.style.color = "#999999";
			}
		}
		inputs[i].onblur = function() {
		 if (this.value.length < 1) {
		  this.value = this.getAttribute("placeholder");
		 }
	}		
    }
   }
  }
  

// -- Dropdown Nav
function startList()
{   
    //if (document.all&&document.getElementById)
    //{
	    navRoot = document.getElementById("nav");
        //crawlLIs(navRoot);
        
        navRootLIs = navRoot.getElementsByTagName("li");
        //alert(navRootLIs.length);
        
        for (var k=0; k<navRootLIs.length; k++)
        {
            navRootLIs[k].className += " out";
            makeDropDown(navRootLIs[k]);
            //alert(navRootLIs[k].className);
        }
        
        //breadcrumb = document.getElementById("breadcrumb");
        //breadcrumb.className="out";
        //alert(breadcrumb.className);
    //}
}

function makeDropDown(node)
{
    node.onmouseover=function()
    {
        //alert("pre-over [" + this.className + "]");
        this.className=this.className.replace(" out", "");
        this.className=this.className.replace("out", "");
        this.className+=" over";
        //alert("over [" + this.className + "]");
    }
    node.onmouseout=function()
    {
        //alert("pre-out [" + this.className + "]");
        this.className=this.className.replace(" over", "");
        this.className=this.className.replace("over", "");
        this.className+=" out";
        //alert("out [" + this.className + "]");
    }
}

function retract(node)
{
    //node.className=node.className.replace(" over", "");
    //node.className+=" out";
    //alert("!");
}

function crawlLIs(myUL)
{
    //alert(myUL.childNodes.length);
    for (var i=0; i<myUL.childNodes.length; i++)
    {
        node = myUL.childNodes[i];
        //alert(i + " / " + node.nodeName);
        if (node.nodeName=="LI")
        {
            //alert('encountered li:'+i);
            makeDropDown(node);
            //alert('getnavchildren:'+i);
            getNavChildren(node);
            retract(node);
        }
        //alert("!");
    }
}

function getNavChildren(myLI)
{
    //alert("#" + myLI.childNodes.length + "#");
    for (var j=0;j<myLI.childNodes.length;j++)
    {
        //alert(j + " / " + node.nodeName);
        node = myLI.childNodes[j];
        if (node.nodeName=="UL")
        {
            crawlLIs(node);
        }
        //alert(myLI.childNodes[i].innerHTML);
    }
}

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}


initRollovers();
startList();
activatePlaceholders();
