
function focusElement(formName, eleName) {
	var ele = eval("document." + formName + "." + eleName);
	if(ele != null) {
		if (ele.select)
			ele.select();
		ele.focus()
	}
}

/*
Function addReplaceCookie(...) adds/replace, if already exists, a cookie.
Name & value are must params, others are optional.
If 'expiresOn' is given, it must be in milliseconds.
*/
function addReplaceCookie(name, value, expiresOn, path, domain) {
	var cookieValue = name + "=" + (value);
	if ((expiresOn != null) && !isNaN(parseInt(expiresOn))) {
		var dt = new Date(parseInt(expiresOn))
		cookieValue = cookieValue + "; expires=" + dt.toGMTString();
	}
	if (path != null)
		cookieValue = cookieValue + "; path=" + path;
	if (domain != null)
		cookieValue = cookieValue + "; domain=" + domain;
	document.cookie = cookieValue;
}

/*Function to remove the total display area of the portlet if it doesn't render 
  anything on the page, when the ID of a HTML tag rendered from the portlet is passed as a parameter 
*/

function hideTRWithElement(eleID) {
	        var obj = document.getElementById(eleID);
	        var parent = null;
			while(true) {
                        parent = obj.parentNode;
	                    if (parent.tagName.toUpperCase() == "TR" )
                                    break;
                        obj = parent;
            }
            if (parent != null) 
	                    parent.style.display = "none";
}


/**********************************************************

pageHeaderFix.dspp.js by Kalley Powell
This file is for use on the DSPP website to correct a brand
issue on the site, allowing the page title to expand to its
full length when there is no MDA Tagline present.

**********************************************************/
var pageHeaderFix = {}; // creates a new object instance
pageHeaderFix.dspp = (function() {
	function fixHeader() {
		if(document.getElementById('MDATagline') || document.getElementById('memberLogo')) {
			var table = document.getElementsByTagName('tbody')[0].childNodes, x = 0, y = 0, z = 0, target = null;
			for(var i = 0; i < table.length; i++) {
				var a = table[i];
				if(a.nodeName != 'TR') continue;
				if(x == 1){
					var row = a.getElementsByTagName('td')[0].childNodes;
					for(var j = 0; j < row.length; j++) {
						var b = row[j];
						if(b.nodeName != 'TABLE') continue;
						if(y == 2) {
							var titleRow = b.getElementsByTagName('tr')[1].childNodes;
							for(var k = 0; k < titleRow.length; k++) {
								var c = titleRow[k];
								if(c.nodeName != 'TD') continue;
								if(z == 1) target = c;
								if(z == 2) c.style.display = 'none';
								z++;
							}
						}
						y++;
					}
				}
				x++;
			}
			target.colSpan = '2';
			target.style.marginLeft = '10px';
			document.getElementById('pageHeader').style.width = '560px';
		}
	}
	rO = {
		version: 1.2,
		init: function() {
			if(document.getElementById('MDATagline')) {
				if(document.getElementById('MDATagline').innerHTML == '') fixHeader();
			} else if(document.getElementById('memberLogo')) {
				if(document.getElementById('memberLogo').src == 'http://welcome.hp-ww.com/img/s.gif') fixHeader();
			}
		}
  };
  return rO;
})();
function addLoadListener(fn) { //this is a cross-browser function for adding onload events.
  var oldfn = window.onload;
  typeof window.addEventListener != 'undefined' ? window.addEventListener('load', fn, false) : typeof document.addEventListener != 'undefined' ? document.addEventListener('load', fn, false) : typeof window.attachEvent != 'undefined' ? window.attachEvent('onload', fn) : typeof window.onload != 'function' ? window.onload = fn : window.onload = function() { oldfn(); fn(); };
}
addLoadListener(pageHeaderFix.dspp.init);
