//////////////////////////////////////////////////////////////////////////////////////////
// Name
//	 Menu.js
//
// Description
//	 JavaScript functions used by menus
//
// Functions
//   Rollover
//   IndicateCurrentPage
//
//////////////////////////////////////////////////////////////////////////////////////////

// added for ticket 5099 - ability for menu items to have a popup property

function openWin(w,h,page,s) 
	{
		var thisPlatform
		var thisBrowser
		var win
		
			
		//sniffing for browser and platform
		thisBrowser = navigator.userAgent
		thisPlatform = navigator.platform;
		
		if (thisPlatform == "MacPPC") {
			if (thisBrowser.indexOf("MSIE") != -1) {
				win=window.open(page , "POP", "width=" + w + ",height=" + h + ",left=0,top=0,toolbar=no,scrollbars=" + s)
			} else {
				win=window.open(page , "POP", "width=" + w + ",height=" + h + ",left=0,top=0,toolbar=no,scrollbars=" + s)
			}
		} else {
			win=window.open(page , "POP", "width=" + w + ",height=" + h + ",left=0,top=0,toolbar=no,scrollbars=" + s)
		}
		 
		win.focus();
	}

function Rollover(srcElm, bOn) {
    if (bOn) {
		srcElm.src = srcElm.src.replace(/\.gif/i, '_on.gif');
		srcElm.src = srcElm.src.replace(/\.jpg/i, '_on.jpg');
    } else {
		srcElm.src = srcElm.src.replace(/_on\.gif/i, '.gif');
		srcElm.src = srcElm.src.replace(/_on\.jpg/i, '.jpg');
    }
}

function IndicateCurrentPage(LinkName) {
 
	if (LinkName.length == 0) { return; }
 
	var PageURL;
	var pos = 0;
	var objTag, objParent;
	var numLinks = document.links.length;

	if (window.location == null) {
		if (document.URL == null) {
			return;
		} else {
			PageURL = document.URL.toLowerCase();
		}
	} else {
		PageURL = window.location.href.toLowerCase();
	}
	  
	while (pos < numLinks) {
	  
		objTag = document.links[pos++];
		 
		if (objTag != null) {
		
			if (objTag.className == LinkName || objTag.name == LinkName) {
				if (objTag.href.toLowerCase() == PageURL) {
					objParent = objTag.parentElement;
					
					// Change image to "on"
					objParent.innerHTML = objTag.innerHTML.replace(/\.gif/i, '_on.gif');
					// Remove onmouseover and onmouseout events
					objParent.innerHTML = objParent.innerHTML.replace(/onmouse(over|out)=[^ ]+/gi, '');

					break;
				} 
			}
		}
	}
}

function getObjById(id) {
    var obj = null;
    if (document.getElementById) {
        obj = document.getElementById(id);
    } else if(document.all) {
          obj = document.all[id];
    } else if(document.layers) {
          obj = document.layers[id];
    }        
    return obj;
}

function cancelEvent(e)
{
  if(!e)
    e = window.event;
  if(e.stopPropagation)
    e.stopPropagation();
  if(e.preventDefault)
    e.preventDefault();
  e.cancelBubble = true;
  e.cancel = true;
  e.returnValue = false;
  return false;
}
function cancelBubble(e)
{
 if (!e) 
    e = window.event;
 e.cancelBubble = true;
 if (e.stopPropagation) e.stopPropagation();
}

function getEventTarget(e)
{
  if(!e)
    e = window.event;
  if(e.target)
    return e.target;
  return e.srcElement;
}

function canClick(e)
{
    var target = getEventTarget(e)
    
    alert(target.parentElement);
    
    alert(target.id + ' ' + target);
}