/* Thanks to Scott Andrew */
function addEvent(obj, evType, fn) {
    if (obj.addEventListener) {
        obj.addEventListener(evType, fn, false);
        return true;
    } else if (obj.attachEvent) {
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    } else {
        return false;
    }
}

var clean=1;
var pageName;
var imageName;
var lang = "fr"

if (document.images) {

  newsovr 			= new Image(113,24); newsovr.src = "/shared/wow-com/images/menu/mainmenu/" + lang + "/header-news-on.jpg";
  newsoff 			= new Image(113,24); newsoff.src = "/shared/wow-com/images/menu/mainmenu/" + lang + "/header-news.jpg";

  gameguideovr 			= new Image(113,24); gameguideovr.src = "/shared/wow-com/images/menu/mainmenu/" + lang + "/header-gameguide-on.jpg";
  gameguideoff 			= new Image(113,24); gameguideoff.src = "/shared/wow-com/images/menu/mainmenu/" + lang + "/header-gameguide.jpg";

  interactiveovr 			= new Image(113,24); interactiveovr.src = "/shared/wow-com/images/menu/mainmenu/" + lang + "/header-interactive-on.jpg";
  interactiveoff 			= new Image(113,24); interactiveoff.src = "/shared/wow-com/images/menu/mainmenu/" + lang + "/header-interactive.jpg";

  accountovr 			= new Image(113,24); accountovr.src = "/shared/wow-com/images/menu/mainmenu/" + lang + "/header-account-on.jpg";
  accountoff 			= new Image(113,24); accountoff.src = "/shared/wow-com/images/menu/mainmenu/" + lang + "/header-account.jpg";

  communityovr 			= new Image(113,24); communityovr.src = "/shared/wow-com/images/menu/mainmenu/" + lang + "/header-community-on.jpg";
  communityoff 			= new Image(113,24); communityoff.src = "/shared/wow-com/images/menu/mainmenu/" + lang + "/header-community.jpg";

  supportovr 			= new Image(113,24); supportovr.src = "/shared/wow-com/images/menu/mainmenu/" + lang + "/header-support-on.jpg";
  supportoff 			= new Image(113,24); supportoff.src = "/shared/wow-com/images/menu/mainmenu/" + lang + "/header-support.jpg";

  mediaovr 			= new Image(113,24); mediaovr.src = "/shared/wow-com/images/menu/mainmenu/" + lang + "/header-media-on.jpg";
  mediaoff 			= new Image(113,24); mediaoff.src = "/shared/wow-com/images/menu/mainmenu/" + lang + "/header-media.jpg";
  
// not used --------------------------------------------------------------------------------------------------------------------
  infoovr 		= new Image(113,24); infoovr.src = "/shared/wow-com/images/menu/mainmenu/info-header-on.gif";
  infooff 		= new Image(113,24); infooff.src = "/shared/wow-com/images/menu/mainmenu/info-header.gif";
  linksovr 	= new Image(113,24); linksovr.src = "/shared/wow-com/images/menu/mainmenu/links-header-on.gif";
  linksoff 	= new Image(113,24); linksoff.src = "/shared/wow-com/images/menu/mainmenu/links-header.gif";
// --------------------------------------------------------------------------------------------------------------------

  news_iconovr 			= new Image(41,24); news_iconovr.src = "/shared/wow-com/images/menu/mainmenu/news-icon-on.gif";
  news_iconoff 			= new Image(41,24); news_iconoff.src = "/shared/wow-com/images/menu/mainmenu/news-icon-off.gif";

  gameguide_iconovr 			= new Image(41,24); gameguide_iconovr.src = "/shared/wow-com/images/menu/mainmenu/info-icon-on.gif";
  gameguide_iconoff 			= new Image(41,24); gameguide_iconoff.src = "/shared/wow-com/images/menu/mainmenu/info-icon-off.gif";

  interactive_iconovr 			= new Image(41,24); interactive_iconovr.src = "/shared/wow-com/images/menu/mainmenu/interactive-icon-on.gif";
  interactive_iconoff 			= new Image(41,24); interactive_iconoff.src = "/shared/wow-com/images/menu/mainmenu/interactive-icon-off.gif";

  account_iconovr 			= new Image(41,24); account_iconovr.src = "/shared/wow-com/images/menu/mainmenu/account-icon-on.gif";
  account_iconoff 			= new Image(41,24); account_iconoff.src = "/shared/wow-com/images/menu/mainmenu/account-icon-off.gif";

  community_iconovr 		= new Image(41,24); community_iconovr.src = "/shared/wow-com/images/menu/mainmenu/forums-icon-on.gif";
  community_iconoff 		= new Image(41,24); community_iconoff.src = "/shared/wow-com/images/menu/mainmenu/forums-icon-off.gif";

  support_iconovr 		= new Image(41,24); support_iconovr.src = "/shared/wow-com/images/menu/mainmenu/support-icon-on.gif";
  support_iconoff 		= new Image(41,24); support_iconoff.src = "/shared/wow-com/images/menu/mainmenu/support-icon-off.gif"; 

  media_iconovr 		= new Image(41,24); media_iconovr.src = "/shared/wow-com/images/menu/mainmenu/media-icon-on.gif";
  media_iconoff 		= new Image(41,24); media_iconoff.src = "/shared/wow-com/images/menu/mainmenu/media-icon-off.gif"; 
  
  
// not used --------------------------------------------------------------------------------------------------------------------
  links_iconovr 	= new Image(41,24); links_iconovr.src = "/shared/wow-com/images/menu/mainmenu/links-icon-on.gif";
  links_iconoff 	= new Image(41,24); links_iconoff.src = "/shared/wow-com/images/menu/mainmenu/links-icon-off.gif";
// --------------------------------------------------------------------------------------------------------------------


}
function ovrImg( imageName ) {
  if ( document.images ) {
    document[ imageName ].src = eval(imageName + "ovr.src");
  }
}

function offImg( imageName ) {
  if ( document.images ) {
    document[ imageName ].src = eval(imageName + "off.src");
  }
}



window.name= "mainPage";


//Show layer//
function showLayer(layerName){

	obj = document.getElementById(layerName);
	obj.style.visibility="visible";

}

//Hide layer//
function hideLayer(layerName){

	obj = document.getElementById(layerName);
	obj.style.visibility="hidden";

}

function popUp (url, width, height, name) {


		widthHeight = "width=" + width + ",height=" + height;

		winFeatures = "width=" + width + ",height=" + height + ",menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,location=no"


			spawn = window.open(url,name,winFeatures);


}

function popUp_noscroll (url, width, height, name) {


		widthHeight = "width=" + width + ",height=" + height;

		winFeatures = "width=" + width + ",height=" + height + ",menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,location=no"


			spawn = window.open(url,name,winFeatures);


}


	var styleSheet;

	var agt    = navigator.userAgent.toLowerCase();
	var appVer = navigator.appVersion.toLowerCase();

	var verInt = parseInt(appVer);

	var ie     = (appVer.indexOf('msie') != -1);

	var opera  = (agt.indexOf('opera') != -1);

    var mozilla = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('opera')==-1)
					&& (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1)
	                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));

	var ns4     = (mozilla && (verInt == 4));

	if (ie && !opera) {

		styleSheet = document.styleSheets["pageStyle"];


		styleSheet.addRule ("b", "font-size: x-small");
		styleSheet.addRule ("span", "font-size: x-small");
		styleSheet.addRule (".postBody", "font-size: x-small");

	} else if ( mozilla && !ns4 ) {
		styleSheet = document.styleSheets[0];

		styleSheet.insertRule('b { font-size: small; }',styleSheet.cssRules.length);
		styleSheet.insertRule('span { font-size: small; }',styleSheet.cssRules.length);
		styleSheet.insertRule('.postBody { font-size: small; }',styleSheet.cssRules.length);

	}


// Popup script

function popUpOmega (screenshot, width, height, caption) 
{
	//Browser detection - is the user relying on the one browser where this script does not work?
	var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;

	var name = "Sheenscrot"; 
	widthHeight = "width=" + width + ",height=" + height;
	winFeatures = "width=" + width + ",height=" + height + ",left=50,top=50,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,location=no"
	if (is_safari) spawn = window.open(screenshot,name,winFeatures);
	else
	{
		spawn = window.open("/shared/wow-com/images/layout/pixel.gif",name,winFeatures)
		spawn.document.write("<html> <head> <title>" + caption + "<\/title> <\/head> <body onBlur='self.close()' background= " + screenshot + "><\/body><\/html>"); 
		spawn.document.close();
	}
}

function showComplete(showThis) {
	document.getElementById(showThis).style.display = "inline";
	document.getElementById(showThis).style.visibility = "visible";
}

function hideComplete(showThis) {
	document.getElementById(showThis).style.display = "none";
	document.getElementById(showThis).style.visibility = "visible";
}

//This is needed for our kewl new navigation
function keepStyle (elem) {
liRoot = document.getElementById(elem);
	liRoot.style.backgroundColor = '#344961';
	for (i=0; i<liRoot.childNodes.length; i++) {
		node = liRoot.childNodes[i];
		if (node.nodeName=="A") {
			node.style.color = '#fff';
	   	}
	}
}
function loseStyle (elem) {
liRoot = document.getElementById(elem);
	liRoot.style.backgroundColor = '';
	for (i=0; i<liRoot.childNodes.length; i++) {
		node = liRoot.childNodes[i];
		if (node.nodeName=="A") {
			node.style.color = '#CBA300';
	   	}
	}
}

// Get maxlength of longest linkname in the unordered list and resize the list -->
function resizeList() { 
    var lists = document.getElementsByTagName("ul"); 
    for (x = 0; x < lists.length; x++) { 
        var list = lists[x]; 
		var maxlength = 8;
		if (list.getAttribute("class") == "menulist1" || list.getAttribute("className") == "menulist1" || list.getAttribute("class") == "menulist2" || list.getAttribute("className") == "menulist2") { 
            var listitems = list.childNodes; 
			for (j = 0; j < listitems.length; j++) {
				node = listitems[j];
				if (node.nodeName == "LI") {
					linkitems = node.childNodes;
					for (k = 0; k < linkitems.length; k++) {
						linkitem = linkitems[k];
						if (linkitem.nodeName == "A") {
							var linktext = linkitem.childNodes[1].nodeValue; 
			                if (linktext.length > maxlength) { 
		    	                maxlength = linktext.length; 
		        	        } 
						}
					}
	            }
			}
			list.style.width = ((maxlength/5)*2+1.5) + "em"; 	
			var ulitems = list.getElementsByTagName("ul"); 
	        for (j = 0; j < ulitems.length; j++) { 
				ulitems[j].style.left = ((maxlength/5)*2)+1 + "em"; 
				ulitems[j].style.marginTop = "-20px";
	        }
		}
		// if there is a UL following the 2nd level UL, then position it according to width of 2nd level ul
    } 
} 

var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('safari'))
{
  function Player() 
  {
    window.open("/shared/wow-com/downloads/mp3player/fr/sound-page.htm","_blank","toolbar=no, location=no, directories=no, menubar=no, status=no, scrollbars=no, resizable=no, copyhistory=yes, width=295, height=260")
  }	
}

if (checkIt('msie')) browser = "Internet Explorer"
{
  function Player() 
  {
    window.open("/shared/wow-com/downloads/mp3player/fr/sound-page.htm","_blank","toolbar=no, location=no, directories=no, menubar=no, status=no, scrollbars=no, resizable=no, copyhistory=yes, width=283, height=249")
  }
}

if (!version) version = detect.charAt(place + thestring.length);

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

addEvent(window, 'load', resizeList);