menuHover = function() {
	
	if (!document.getElementsByTagName) return false;
	var menuEls = document.getElementById("segment-navigation").getElementsByTagName("li");
	for (var i=0; i<menuEls.length; i++) {
		menuEls[i].onmouseover=function() {
			this.className+=" menuhover";
		}
		menuEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" menuhover\\b"), "");
		}
	}
}

uHover = function() {
	if (!document.getElementsByTagName) return false;
	var uEls = document.getElementById("utility-navigation").getElementsByTagName("li");
	for (var i=0; i<uEls.length; i++) {
		uEls[i].onmouseover=function() {
			this.className+=" uhover";
		}
		uEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" uhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", menuHover);
if (window.attachEvent) window.attachEvent("onload", uHover);


//Menu flip to avoid the submenus going outside stage

function getElementPosition(elemID){
	var offsetTrail = document.getElementById(elemID);
	var offsetLeft = 0;
	var offsetTop = 0;
	
	while (offsetTrail){
		offsetLeft += offsetTrail.offsetLeft;
		offsetTop += offsetTrail.offsetTop;
		offsetTrail = offsetTrail.offsetParent;
	}
	
	if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined'){
		offsetLeft += document.body.leftMargin;
		offsetTop += document.body.topMargin;
	}
	
	return {left:offsetLeft,top:offsetTop};
}

function FlipSection()
{
	if(getElementPosition('par').left > 735)
	{

		var firstElement = getElementPosition('hho');
		var Pos = document.getElementById('par');
		var extraPixelToReduce = window.screen.availWidth - document.body.clientWidth;
		var newWidth = getElementPosition('par').left + Pos.offsetWidth - 276 - (firstElement.left - extraPixelToReduce) + 'px';
		document.getElementById('segment-par').style.left = newWidth;
	}
} 


var useSearchKeyword = false;

function onSearchSetFocus()
{
	var searchField = document.getElementById('global-search-field');
	searchField.style.color = 'black';
	
	if(searchField.value == '入力してください  ')
	{
		searchField.value = '';
	}
	
	useSearchKeyword = true;
}

function onSearchLostFocus()
{
	var searchField = document.getElementById('global-search-field');
		
	if(searchField.value == '')
	{
		searchField.style.color = 'gray';
		searchField.value = '入力してください  ';
		useSearchKeyword = false;
	}
}

function setSearchString()
{
	if(useSearchKeyword == false)
	{
		var searchField = document.getElementById('global-search-field');
		searchField.value = '';
	}
}

function breadCrumbPos(){
	
	var firstElement = getElementPosition('hho');
	if(document.getElementById('breadcrumb')){
	document.getElementById('breadcrumb').style.left = firstElement.left + 'px';
	document.getElementById('breadcrumb').style.display = 'block'
	}
	if(document.getElementById('rate')){
	document.getElementById('rate').style.left =  firstElement.left + 850 + 'px';
	document.getElementById('rate').style.display = 'block'
	}
}



var check_for_load_complete;
check_for_load_complete = false;
function HighlightNavTab()
{


var BodyIDSplit=new Array();
var bodyTagList = document.getElementsByTagName('body');

for(var bodytag=0; bodytag<bodyTagList.length; bodytag++)
{
 BodyIDSplit=bodyTagList[bodytag].getAttribute('id').replace(/-$/g,'').split('-');
 EntireBodyID=bodyTagList[bodytag].getAttribute('id');
}

/* BodyIDSplit is array with each element of the body id */

// Stores segment ID and match with the body ID
var segment = document.getElementById("segment-navigation");
if (!segment) return;
var segmentLiID = segment.getElementsByTagName('li');
for (var seg=0;seg<segmentLiID.length ;seg++ )
{

  for (var body=0;body<BodyIDSplit.length ;body++ )
   {
    if (segmentLiID[seg].getAttribute('id') == BodyIDSplit[body])				
     {
	segmentLiID[seg].className = "selected";
	//Below if condition is to remove the extra slash from the Segment nav
	//if (seg<(segmentLiID.length-1))
	//{
	//segmentLiID[seg+1].className = "unselected";
	//}
    }
  }
} // Ends segment process

/*//Stores section ID and match with the body ID
var section = document.getElementById("nav-section");
if (!section) return;
var sectionLiID = section.getElementsByTagName('li');
for (var sec=0;sec<sectionLiID.length ;sec++ )
{
  for (var body=0;body<BodyIDSplit.length ;body++ )
   {
    if (sectionLiID[sec].getAttribute('id') == BodyIDSplit[body])
     {
	sectionLiID[sec].className = "selected";
	//Below if condition is to remove the extra slash from the section nav
	if (sec<(sectionLiID.length-1))
	{
	sectionLiID[sec+1].className = "unselected";
	}
     }
   }
} // Ends Section Process*/

 // Start the left nav process

 // First see if we can find the id strightup
 var selectItem = document.getElementById("ln-"+EntireBodyID);
 if (selectItem != null) {
 // the body id found in entirety - highlight it, and expand any parents
	selectItem.className = "selected";
	var currentItems = BodyIDSplit[0];
        for (var body=1;body<BodyIDSplit.length ;body++ ) {
		currentItems = currentItems + "-" +BodyIDSplit[body];
		var expandItem = document.getElementById("ln-"+currentItems+"-index");
		// Modification to highlight categories
		if ((expandItem != null)&&(expandItem.className != null)) {
			  if (expandItem.className=="selected") {
				expandItem.className="selected expanded";
			  }
			  else {
				expandItem.className="expanded";
			  }
		}
		else if (expandItem != null) { 
		// End modifications
				expandItem.className="expanded";
		// closing ifs of modification
		} // end closing ifs
	}
	    
   }

// Do it the old way if the entire ln- id was not found
else {
//Stores Left Nav ID and match with the body ID
var navRoot = document.getElementById("nav-page");
if (!navRoot) return;
var navRootLiID = navRoot.getElementsByTagName('li');
for (var nav=0;nav<navRootLiID.length; nav++ )
{
   for (var body=0;body<BodyIDSplit.length ;body++)
    {
    /* replace method in the below if condition is to reomve _, mcafee and and string from the body ID*/
    if (navRootLiID[nav].getAttribute('id') == BodyIDSplit[body].replace(/^(m+c+a+f+ee)|(and)/g,''))
    {
     if(navRootLiID[nav].childNodes.length>2)
	navRootLiID[nav].className = "expanded";
     else navRootLiID[nav].className = "selected";
    }
  }
}
} // Ends Left Nav Process

//Decalre below boolean var as true as some app pages need it's value as true

check_for_load_complete = true;

} // Function HighlightNavTab ends 

function bodyload(){
	HighlightNavTab();
	breadCrumbPos();
	//FlipSection();
}

/*japan/downloads/updates/d_dat.aspページのみonloadさせない*/
ddaturl = window.location["pathname"]
ddatfile = ddaturl.match("d_dat.asp")

if (ddatfile < 0){
window.onload = bodyload;
}
window.onresize = breadCrumbPos;

