var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;

getViewportWidth = function() {
  var width = 0;
  if( document.documentElement && document.documentElement.clientWidth ) {
	width = document.documentElement.clientWidth;
  }
  else if( document.body && document.body.clientWidth ) {
	width = document.body.clientWidth;
  }
  else if( window.innerWidth ) {
	width = window.innerWidth - 18;
  }
  return width;
}

getViewportHeight = function() {
  var height = 0;
  if( document.documentElement && document.documentElement.clientHeight ) {
	height = document.documentElement.clientHeight;
  }
  else if( document.body && document.body.clientHeight ) {
	height = document.body.clientHeight;
  }
  else if( window.innerHeight ) {
	height = window.innerHeight - 18;
  }
  return height;
}

getViewportScrollY = function() {
  var scrollY = 0;
  if( document.documentElement && document.documentElement.scrollTop ) {
	scrollY = document.documentElement.scrollTop;
  }
  else if( document.body && document.body.scrollTop ) {
	scrollY = document.body.scrollTop;
  }
  else if( window.pageYOffset ) {
	scrollY = window.pageYOffset;
  }
  else if( window.scrollY ) {
	scrollY = window.scrollY;
  }
  return scrollY;
}


var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;
function hideDropDowns() {
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	var i = 1;
	var NewImage = '';
	for (i=1; i<13; i++)
	{
		if (document.getElementById('tab' + i))
		{
			if (document.getElementById('tab12'))
			{
				newImage = "url(../images/TG/bg_nav_li_a.png)";
			} else {
				newImage = "url(../images/GO/cat_downarrow.gif)";
			}
			document.getElementById('tab' + i).style.backgroundImage = newImage;
		}
	}
}
function showDropDown(tab) {
	mcancelclosetime();
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	ddmenuitem = document.getElementById('dropdown' + tab);
	ddmenuitem.style.visibility = 'visible';
	if (document.getElementById('newslett')) {
		var newImage = "url(../images/TG/bg_emailblock_off.jpg)";
		document.getElementById('newslett').style.backgroundImage = newImage;
	}
	var newImage = "url()";
	document.getElementById('tab' + tab).style.backgroundImage = newImage;
}
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}




function showDiv(divID) {
  var item = document.getElementById(divID);
  if (item) {
    item.className='unhidden';
  }
}

function hideDiv(divID) {
  var item = document.getElementById(divID);
  if (item) {
    item.className='hidden'
  }
}


function checkDomain(confirmationPage) {
    var currentURL = location.href;

    protocolIndex = currentURL.indexOf("://");
    serverIndex = currentURL.indexOf("/", protocolIndex + 4);
    urlResult = currentURL.substring(protocolIndex + 3, serverIndex);

    alert(urlResult);
}

// background override
function bgOverRide(evt)
{
	var node = (evt.target) ? evt.target : ((evt.srcElement) ?evt.srcElement : null );
	evt = (evt) ? evt : ((event) ? event : null);
	if (node.id == "wrap") {
		window.location ='/Category/WrestleMania/ViewAll'
	}
}


// background override
function bgMouseOver(evt)
{
	var node = (evt.target) ? evt.target : ((evt.srcElement) ?evt.srcElement : null );
	evt = (evt) ? evt : ((event) ? event : null);
	switch (node.id)
	{
		case "wrap": 
			ddrivetip('WrestleMania XXVI','white', 130);
		//	 alert('a')
			node.style.cursor='pointer'
			break;
		case "csmNav_1": case "csmH2_1": case "csmP_1": 
		case "csmNav_2": case "csmH2_2": case "csmP_2": 
		case "csmNav_3": case "csmH2_3": case "csmP_3": 
		case "csmNav_4": case "csmH2_4": case "csmP_4": 
			hideddrivetip()
			node.style.cursor='pointer'
			break;
		default:
			hideddrivetip()
			if (node.tagName == "A")
			{
					node.style.cursor='pointer'
			} else
			{
				if (node.tagName == "IMG")
				{
					if (node.parentNode.href)
					{
						node.style.cursor='pointer'
					} else
					{
						node.style.cursor='auto'
					}

				} else
				{
					node.style.cursor='auto'
				}
			}
			break;
	}

}

function resetPointer() { 

} 


// TOOL TIPS
var offsetxpoint=10 //Customize x offset of tooltip
var offsetypoint=22 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
var tipobj

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
	if (ns6||ie){
		if (document.getElementById("texttooltip")) {
			tipobj = document.getElementById("texttooltip") 
			if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
			if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
			tipobj.innerHTML=thetext
			enabletip=true
			return false
		}
	}
}

function positiontip(e){
	if (enabletip){
		if (document.getElementById("texttooltip")) {
			var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
			var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
			//Find out how close the mouse is to the corner of the window
			var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
			var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

			var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

			//if the horizontal distance isn't enough to accomodate the width of the context menu
			if (rightedge<tipobj.offsetWidth)
			//move the horizontal position of the menu to the left by it's width
			tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
			else if (curX<leftedge)
			tipobj.style.left="5px"
			else
			//position the horizontal position of the menu where the mouse is positioned
			tipobj.style.left=curX+offsetxpoint+"px"

			//same concept with the vertical position
			if (bottomedge<tipobj.offsetHeight)
			tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
			else
			tipobj.style.top=curY+offsetypoint+"px"
			tipobj.style.visibility="visible"
		}
	}
}

function hideddrivetip(){
	if (ns6||ie){
		if (document.getElementById("texttooltip")) {
			tipobj = document.getElementById("texttooltip") 
			enabletip=false
			tipobj.style.visibility="hidden"
			tipobj.style.left="-1000px"
			tipobj.style.backgroundColor=''
			tipobj.style.width=''
		}
	}
}

document.onmousemove=positiontip
