try{
	document.execCommand("BackgroundImageCache",false,true);
}catch(err){
}


//Menu section
/*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);



function getEl(id)
	{
		var ele = document.getElementById(id);
		var elementIndex;
		var nextElementIndex;
		
		for(index = 0; index < ele.childNodes.length; index++)
		{
			if(ele.childNodes[index].tagName == 'H4')
			{
				elementIndex = index;
				break;
			}
		}
		
		for(index = elementIndex + 1; index < ele.childNodes.length; index++)
		{
			if(ele.childNodes[index].tagName == 'P')
			{
				nextElementIndex = index;
				break;
			}
		}
		// On Mouse Over
		ele.childNodes[elementIndex].onmouseover = function(){ 
			ele.childNodes[nextElementIndex].style.display = 'block';
		}
		// On Mouse Out
		ele.childNodes[elementIndex].onmouseout = function(){ 
			ele.childNodes[nextElementIndex].style.display = 'none';
		}
	}






//News Scroller Section

var liElements;
var currentElementIndex;
var totalLIElements;
var scrollSpeed = 4000;
var timerHandle = null;
var hrefLastElement;
var hrefFirstElement;
var swapElement;

initScroll = function()
{

	liElements = document.getElementById('news').getElementsByTagName('LI');
	totalLIElements = liElements.length;
	
	currentElementIndex = 0;
	
	// Display 1st and 2nd element and other elements.
	for(index = 0; index < totalLIElements; index++)
	{
		if(index == 0 || index == 1)
		{
			liElements[index].style.display = 'block';
		}
		else
		{
			liElements[index].style.display = 'none';
		}
	}

	hrefFirstElement = liElements[currentElementIndex].innerHTML;
	hrefLastElement = liElements[(totalLIElements - 1)].innerHTML;
		
	ulElement = document.getElementById('news').getElementsByTagName('UL')[0];
	
	ulElement.onmouseover = function()
	{
		stopScroll();
	}
	
	ulElement.onmouseout = function()
	{
		startScroll();
	}
	
	startScroll();
}

function scrollNews()
{
	if(currentElementIndex != -1)
	{
		// Hide 1st element.
		liElements[currentElementIndex].style.display = 'none';
	}
	
	// Display 2nd and 3rd element.
	currentElementIndex++;
	liElements[currentElementIndex].style.display = 'block';
	
	if(currentElementIndex == (totalLIElements - 1))
	{
		var hrefLast = liElements[currentElementIndex].innerHTML;
		currentElementIndex = 0;
		var hrefFirst = liElements[currentElementIndex].innerHTML;

		liElements[(totalLIElements - 1)].innerHTML = hrefFirst;
		liElements[currentElementIndex].innerHTML = hrefLast;
		
		liElements[currentElementIndex].style.display = 'block';

		swapElement = true;
		currentElementIndex = -1;
	}
	else
	{
		if(swapElement == true)
		{
			// Reset 1st and last element href;
			liElements[0].innerHTML = hrefFirstElement;
			liElements[(totalLIElements - 1)].innerHTML = hrefLastElement;
			swapElement = false;
		}
		
		liElements[(totalLIElements - 1)].style.display = 'none';
		liElements[(currentElementIndex + 1)].style.display = 'block';
	}
}

function startScroll()
{
	timerHandle = setInterval('scrollNews()', scrollSpeed);
}

function stopScroll()
{
	if(timerHandle != null)
	{
		clearInterval(timerHandle);
	}
}

 

//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 == 'Search')
	{
		searchField.value = '';
	}
	
	useSearchKeyword = true;
}

function onSearchLostFocus()
{
	var searchField = document.getElementById('global-search-field');
		
	if(searchField.value == '')
	{
		searchField.style.color = 'gray';
		searchField.value = 'Search';
		useSearchKeyword = false;
	}
}

function setSearchString()
{
	if(useSearchKeyword == false)
	{
		var searchField = document.getElementById('global-search-field');
		searchField.value = '';
	}
}
function hackersafe(){
	
	var firstElement = getElementPosition('hho');
	if(document.getElementById('hacker-safe')){
	document.getElementById('hacker-safe').style.left =  firstElement.left + 888 + 'px';
	document.getElementById('hacker-safe').style.display = 'block'
	}
}
function threatpop(){
	
	var firstElement = getElementPosition('hho');
	if(document.getElementById('legend-learnmore')){
	document.getElementById('legend-learnmore').style.left =  firstElement.left + 33 + 'px';
	}
}

function mastheadposition(itemf){
	var butt1ref = document.getElementById(itemf.substring(0,4));
if(document.getElementById(itemf))
{
	var leftVal = parseInt(document.getElementById(itemf).value) + parseInt(getElementPosition('hho').left) + parseInt('12')
	butt1ref.style.left = leftVal + 'px' ;}
}


function bodyonload(){
	
	var leftVal = parseInt(document.getElementById('but1left').value) + parseInt(getElementPosition('hho').left) + parseInt('12');
	document.getElementById('but1').style.left = leftVal + 'px' ;
	
	hackersafe();
	threatpop();
	document.getElementById('mast_a1').style.color='#aa0828';
	document.getElementById('but1').style.display = 'block';
	
}

function outFunc(item){
item.style.backgroundImage = 'url(/common/media/images/masthead/buttons/masthead_button.gif)';
}

function overFunc(item){
if (document.images){
item.style.backgroundImage = 'url(/common/media/images/masthead/buttons/masthead_button_over.gif)';
}
}

function mastheadbutpos(){
for(var i=1 ;i < 11 ; i++){
	
	if('but'+ i + 'left'){
		mastheadposition('but'+ i + 'left');	
		}
	}

}

function toresize(){
	hackersafe();
	threatpop();
	mastheadbutpos();
}
addLoadEvent(bodyonload);
window.onresize = toresize;

