//Main navigation for ie
function navItems() {
  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+=" mouseover";
      }
	}
    node.onmouseout=function() {
    this.className=this.className.replace(" mouseover", "");
    }
  }  
}

function onclickFunction() {
  var arrow_left = document.getElementById("gweb-fadetour-arrow-left");
	var arrow_right = document.getElementById("gweb-fadetour-arrow-right");	
	var bread_crumbs = document.getElementById("breadcrumbs");	
	
	arrow_left.onclick=function(){fade_tour_arrows_highlight()};
	arrow_right.onclick=function(){fade_tour_arrows_highlight()};
	bread_crumbs.onclick=function(){fade_tour_arrows_highlight()};
}

 /*fade tour arrow highlight*/
function fade_tour_arrows() {
	var first = document.getElementById("first");
	var display_first = document.getElementById("first").style.display;
	var last = document.getElementById("last");
	var display_last = document.getElementById("last").style.display;
	var left_arrow =document.getElementById('gweb-fadetour-arrow-left');
	var right_arrow = document.getElementById('gweb-fadetour-arrow-right');

  if((display_first == '') || (display_first == 'none')){
    left_arrow.className = 'gweb-fadetour-arrow gweb-fadetour-arrow-left';
		right_arrow.className = 'gweb-fadetour-arrow gweb-fadetour-arrow-right gweb-fadetour-arrow-right-over';
		}
	  if(display_last == ''){
      right_arrow.className = 'gweb-fadetour-arrow gweb-fadetour-arrow-right';
		  left_arrow.className = 'gweb-fadetour-arrow gweb-fadetour-arrow-left gweb-fadetour-arrow-over';
		}
		if((display_first == 'none') && (display_last == 'none')){
		  left_arrow.className = 'gweb-fadetour-arrow gweb-fadetour-arrow-left gweb-fadetour-arrow-over';
  		right_arrow.className = 'gweb-fadetour-arrow gweb-fadetour-arrow-right gweb-fadetour-arrow-right-over';
		}
}

function fade_tour_arrows_highlight(){
  setTimeout("fade_tour_arrows()", 500);
}

//select Product for product landing pages.(Publlisher, Advertisers)
function select_product(obj){
  var selectedProduct = obj.options[obj.selectedIndex];
  if (obj.selectedIndex != 0)
     {
        window.location = selectedProduct.value;
     }
	}

//selct product box for Customer Support and Insights page.
var previousDiv = "dart_enterprise";
function selectShow(divName) {
	if(divName != "select_product")
	{
	  if (previousDiv) {
		document.getElementById(previousDiv).style.display = "none";
	  }
	  if (divName) {
		document.getElementById(divName).style.display = "block";
		previousDiv = divName;
	  }
	}
	else
	{
	  document.getElementById(previousDiv).style.display = "none";
	}
}

/*select Locale*/
function selectLocale(obj){
  var selectedlocale = obj.options[obj.selectedIndex];
  if (selectedlocale.value != "nothing")
     {
        window.location = selectedlocale.value;
     }
}
//Script for Gallery Filter
function buildsubmenus_horizontal(id){
  var menuids=[id];
  for (var i=0; i<menuids.length; i++){
    var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
      ultags[t].parentNode.onmouseover=function(){
        this.getElementsByTagName("ul")[0].style.display="block"
      }
      ultags[t].parentNode.onmouseout=function(){
        this.getElementsByTagName("ul")[0].style.display="none"
      }
    }
  }
}

//onload function for all required on load scripts in this js
function onLoad(){
  navItems();
}
window.onload=onLoad;
