//-----------------------------------------------------------------------------
//IMAGE ROLLOVERS

// code for rollovers start
function newRollover(imgName,imgFiles) {
  if (document.images) {
    imgFiles=imgFiles+",";
    imgNo=1;
    while(imgFiles.indexOf(',')!=-1) {
      imgFile=imgFiles.substring(0,imgFiles.indexOf(','));
      imgFiles=imgFiles.substring(imgFiles.indexOf(',')+1,imgFiles.length);
      eval(imgName+"_urc_"+imgNo+"=new Image();");
      eval(imgName+"_urc_"+imgNo+".src='"+imgFile+"'");
      imgNo++;
    }
  }
}

function roll(img,on,type) {
  type=type?type:img;
  if (document.images)
  	if(navigator.appName.indexOf('Netscape')!=-1 && navigator.appVersion.substr(0,1)<=4)
		
		setTimeout("",100);
		else{
		alert("document.images['"+img+"'].src="+type+"_urc_"+on+".src");
    	eval("document.images['"+img+"'].src="+type+"_urc_"+on+".src");
    	
	}
}

// GALLERY PHOTOS
var selectedphoto=null;

function selectGalleryPhoto(obj,photo){
	if(selectedphoto!=null)selectedphoto.style.backgroundColor="#E5E5E5";
	selectedphoto=obj;
	selectedphoto.style.backgroundColor="#575757";
	flashLoadImage(photo);
}

var strRootPath = "/MCPE/_Global/img/nav/"	// root path for the navigation images 
var strBtnPath = "/MCPE/_Global/img/"		// root path for the button images 

// Button Rollover
newRollover("button_top_left",strBtnPath + "btnbox_topleft.gif," + strBtnPath + "btnbox_topleft_drkgrey.gif");
newRollover("button_top_right",strBtnPath + "btnbox_topright.gif," + strBtnPath + "btnbox_topright_drkgrey.gif");
newRollover("button_btm_left",strBtnPath + "btnbox_bottomleft.gif," + strBtnPath + "btnbox_bottomleft_drkgrey.gif");
newRollover("button_btm_right",strBtnPath + "btnbox_bottomright.gif," + strBtnPath + "btnbox_bottomright_drkgrey.gif");

//SIDE NAV POPUPS
alphapngdirectx=navigator.userAgent.toLowerCase().indexOf("win")>-1&&document.all&&document.getElementById;
sidenav_popup_itemscount=0;
function htmlSideNavPopupHeader(name) {
	sidenav_popup_itemscount=0;
	document.write(
		'<div style="position:relative;"><div id="obj_sidenav_popup_'+name+'" style="position:absolute; left:-1000px; top:-17px; width:148px; z-index:99; visibility:visible;" onmouseover="clearTimeout(sidenav_popup_timer);return false;" onmouseout="mouseOutSideNavPopup();return false;">'+
		'<div style="position:absolute; left:0px; top:0px; width:148px; height:50px;'+(alphapngdirectx?' filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+strRootPath+'sidenav_popupbox_top.png\',sizingMethod=\'image\');':'')+'">'+(!alphapngdirectx?'<img src="'+strRootPath+'sidenav_popupbox_top.png" width="148" height="50">':'')+'</div>'+
		'<div style="position:relative; left:0px; top:0px; width:148px; clip:rect(0px, 148px, 100%, 0px); overflow:hidden; z-index:99;">'+
		'<div style="position:absolute; left:0px; top:50px; width:148px; height:1000px;'+(alphapngdirectx?' filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+strRootPath+'sidenav_popupbox_bkgrnd.png\',sizingMethod=\'scale\');':'')+'">'+(!alphapngdirectx?'<img src="'+strRootPath+'sidenav_popupbox_bkgrnd.png" width="148" height="1000">':'')+'</div>'+
		'<div style="position:relative; left:14px; top:0px; width:134px; padding-left:5px; padding-top:10px; z-index:100;">'+
		'<table cellpadding="0" cellspacing="0" width="120" border="0">'
	);
}
function htmlSideNavPopupItem(name,href) {
	if(sidenav_popup_itemscount>0)
		document.write(
			'<tr><td class="hdottedLine"></td></tr>'
		);
	document.write(
		'<tr><td class="indentTdPopup"><a href="'+href+'" class="subNavPopup">'+name+'</a></td></tr>'
	);
	sidenav_popup_itemscount+=1;
}
function htmlSideNavPopupFooter() {
	document.write(
		'</table>'+
		'</div>'+
		'</div>'+
		'<div style="position:relative; width:148px; height:20px;'+(alphapngdirectx?' filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+strRootPath+'sidenav_popupbox_btm.png\',sizingMethod=\'image\');':'')+'">'+(!alphapngdirectx?'<img src="'+strRootPath+'sidenav_popupbox_btm.png" width="148" height="20">':'')+'</div>'+
		'</div></div>'
	);
}
sidenav_popup=null;
sidenav_popup_parentitem=null;
sidenav_popup_timer=null;
function showSideNavPopup(parentitem,name) {
	selectSideNavItem(parentitem);
	sidenav_popup=document.getElementById("obj_sidenav_popup_"+name);
	sidenav_popup.style.left="148px";
}
function hideSideNavPopup(show) {
	if(sidenav_popup!=null){
		unselectSideNavItem(show);
		sidenav_popup.style.left="-1000px";
		sidenav_popup=null;
	}
}
function mouseOverSideNavPopup(parentitem,name,show) {
	clearTimeout(sidenav_popup_timer);
	if(sidenav_popup!=document.getElementById("obj_sidenav_popup_"+name)){
		hideSideNavPopup(show);
		showSideNavPopup(parentitem,name);
	}
}
function mouseOutSideNavPopup(show) {
	sidenav_popup_timer=setTimeout("hideSideNavPopup('" + show + "')",300);
}
function mouseOverSideNavItem(parentitem,show) {
	clearTimeout(sidenav_popup_timer);
	hideSideNavPopup(show);
	
	if( show.toLowerCase() == "false" )
	    selectSideNavItem(parentitem);
}
function mouseOutSideNavItem(show) {
	if(sidenav_popup_parentitem!=null && show.toLowerCase() == "false")unselectSideNavItem(show);
}
function selectSideNavItem(parentitem) {
	sidenav_popup_parentitem=parentitem;
	sidenav_popup_parentitem.style.backgroundColor="#F0F0F0";
}
function unselectSideNavItem(show) {
	if( show.toLowerCase() == "false" )
        sidenav_popup_parentitem.style.backgroundColor="#FFFFFF";
	
	sidenav_popup_parentitem=null;
}


// FAQ open / close menu
//-----------------------------
function getStyleObject(name){
	return document.getElementById ? document.getElementById(name).style : document.all ? document.all[name].style : null;
}
function getObject(name){
	return document.getElementById ? document.getElementById(name) : document.all ? document.all[name] : null;
}

function changeObjectDisplay(objectId, newVisibility) {
   return getStyleObject(objectId).display =getStyleObject(objectId)?newVisibility:null;
} 
function showNewAnswer (targetObjectId) {
	return window.currentVisibleAnswer = changeObjectDisplay(targetObjectId, 'block')?targetObjectId:null;
}
function hideQuestion (targetObjectId) {
	return window.currentHiddenQuestion = changeObjectDisplay(targetObjectId, 'none')?targetObjectId:null;
}
function hideCurrentAnswer() {
	if(window.currentVisibleAnswer) {
	getObject(window.currentVisibleAnswer).className='questionAnswerDiv';
	window.currentVisibleAnswer = false;
    }
}
function showAnswer(targetObjectId,eventObj){
	if(eventObj) {
		eventObj.cancelBubble = true;
		hideCurrentAnswer();
		getObject(targetObjectId).className='questionAnswerDivOpen';//hideQuestion('q'+questionID);
		showNewAnswer(targetObjectId);
		
	} else {
		return false;
    }
}	


// ***********************
// hacks and workarounds *
// ***********************

// initialize hacks whenever the page loads
window.onload = createFakeEventObj;
function createFakeEventObj() {
    // create a fake event object for older browsers to avoid errors in function call
    // when we need to pass the event object to functions
    if (!window.event) {
	window.event = false;
    }
} 

function goToChart(s)
{
	url=s.options[s.selectedIndex].value;
	document.location.href=url;
}

function newWindow(url,name,features){
   var newWin = window.open(url,name,features);
}

