//$CVS: homepage/homepage_public/src/main/webapp/home/js/utilities.js,v 1.12 2008/03/03 01:32:40 justinw Exp $
// JavaScript Document for lp.com Homepage 2008
startList = function() {
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("nav");
			for (i=0; i<navRoot.childNodes.length; i++) {
  				node = navRoot.childNodes[i];
  					if (node.nodeName=="LI") {
  						node.onmouseover=function() {
  						this.className+=" overnav";
    					}
  						node.onmouseout=function() {
  						this.className=this.className.replace
      					(" overnav", "");
   						}
   					}
  			}
 		}
}

buttonHover = function() {
	var theElements = document.getElementsByTagName("input");
	for (var i=0; i<theElements.length; i++) {
		theElements[i].onmouseover=function(){
			this.className+=" over";
		}
		
		theElements[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" over\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", buttonHover);

function focusForm() {
	var theElements = document.getElementsByTagName("input");
	for (var i=0; i<theElements.length; i++) {
		
		if(theElements[i].className == 'text'){
		
			theElements[i].onfocus = function() {
			if(this.value == this.defaultValue)
			{this.value = ''}
			}
	
			theElements[i].onblur = function() {
			if(this.value.replace(' ','') == '')
			{this.value = this.defaultValue}
			}
		}
	}
}

function cancelEvent(e)
{
 if (!e) var e = window.event;
 
 //e.cancelBubble is supported by IE - this will kill the bubbling process.
 e.cancelBubble = true;
 e.returnValue = false;
 
 //e.stopPropagation works only in Firefox.
 if (e.stopPropagation) {
  e.stopPropagation();
  e.preventDefault();
 }
}

/* HP flash map omniture capture and URL jump */
function omnitureFlashClick(omnitureAccount,vendorName,podName, url)
{
    // try and log to omniture, if omniture library available/loaded
    if (typeof s_gi!="undefined") {
        var s=s_gi(omnitureAccount);
        s.linkTrackVars='prop26,prop27,eVar31,eVar32';
        s.linkTrackEvents='None';
        s.prop26=podName;
        s.prop27=vendorName;
        s.eVar31=podName;
        s.eVar32=vendorName;
        s.tl(this,'o', 'homepage: flash map : '+podName+' : '+vendorName);
    }
    document.location.href=url;
}

/* Finds all a href's that have class="gl_external" and makes them open content in a popup */
function externalLinksPopUp()
{
 var classToFind = "gl_external";
 var classToFindWg = "gl_wg_gallery";
 var classToFindFeature = "gl_feature_gallery";
 
 var links = document.getElementsByTagName("a");
 
 for(i=0;i<links.length;i++)
 {
  if(links.item(i).className == classToFind)
  {
   links.item(i).onclick = function(e){window.open(this.href); cancelEvent(e);};
  }
  
   if(links.item(i).className == classToFindWg)
  	{
   	links.item(i).onclick = function(e){window.open(this.href,'ph','width=885,height=605,toolbar=no,personalbar=no,location=no,directories=no,statusbar=no,menubar=no,status=no,resizable=no,left=60,screenX=60,top=100,screenY=100');
	cancelEvent(e);};
  }
  
  if(links.item(i).className == classToFindFeature)
  	{
   	links.item(i).onclick = function(e){window.open(this.href,'ph','width=680,height=595,toolbar=no,personalbar=no,location=no,directories=no,statusbar=no,menubar=no,status=no,resizable=no,left=60,screenX=60,top=100,screenY=100');
	cancelEvent(e);};
  }
  
 }
}

function validateForm(e)
{
	var theForm = document.getElementById("search_form");
	if(theForm.Ntt.value == theForm.Ntt.defaultValue || theForm.Ntt.value.replace(' ','') == "") {
		alert("Please enter a search term");
		theForm.Ntt.focus();
    	if (e && e.preventDefault) {
    		e.preventDefault(); // DOM style
        }
        return false; // IE style
	}
    else
        return true;
}

function validateJumpTo(e)
{
    var theForm = document.getElementById("DestinationJump");
    if(theForm.destination.value == theForm.destination.defaultValue || theForm.destination.value.replace(' ','') == "") {
        alert("Please enter a destination");
        theForm.destination.focus();
        if (e && e.preventDefault) {
            e.preventDefault(); // DOM style
        }
        return false; // IE style
    }
    else
        return true;
}
	
//addLoadListener(externalLinksPopUp);
//addLoadListener(focusForm);
//addLoadListener(buttonHover);