/** 
 * Author: Richard Bongiorno (rbongior@us.ibm.com)
 * UC-PRICONT-016 View Main Navigation
 * UC-USER-003 Register using Registration Form
 * UC-USER-004 Sign In - Forgot Password
 */
// used by hidden CEP portlet to set the number of items in the shopping cart
function setCartItems(numItems) {
	var cartItemsSpan = $('#cartItems');
	if (cartItemsSpan.length > 0)
		cartItemsSpan[0].innerHTML='('+numItems+') Items'; 
}

function setDisplayName(displayName) { 
	var displayNameSpan = $('#userDisplayName');
	if (displayNameSpan.length > 0)
		displayNameSpan[0].innerHTML=displayName; 
}

// user by Registration link to submit form which will have info for returning to current page.
function setFormAction(action){
	document.regSubmit.action = action; 
	document.regSubmit.submit();
}

// used by CEP LOGOFF portlet to invoke portal logoff
function doLogout(url) {
	var newwin = window.open(url,'logout', 'width=3,height=3');
	
	this.window.focus();
	setTimeout('changeLogoutUrl()', 250);
}
function changeLogoutUrl(){
	var url = window.location.href;
	url = url.replace(/\/myportal\//, '/portal/');
	//logic to remove the # operation aborted err.
	var isPound = url.substr(url.length-1);
	if ( isPound == '#' ){
	   url = url.substr(0,url.length-1);
	}
	window.location.href = url;
}

