/*
	allows for multiple actions to be added to the window.onload event
	without overwriting the existing event contents

	called as
	addOnLoadAct(functionName);
	NOTE: do not include () in the function name 
*/
var isIE=(document.all && navigator.userAgent.toLowerCase().indexOf('msie')!=-1? true : false);
var isOpera=(document.all && navigator.userAgent.toLowerCase().indexOf('opera')!=-1? true : false);
var isSafari=(document.getElementById && !isIE && !isOpera && navigator.userAgent.toLowerCase().indexOf('safari')!=-1? true :false)
var isFF=(document.getElementById && !isIE && !isOpera && !isSafari && navigator.userAgent.toLowerCase().indexOf('firefox')!=-1? true :false)
var isNS=isFF;



var isWin=(navigator.platform.toLowerCase().indexOf('win')!=-1? true: false);
var isMac=(navigator.platform.toLowerCase().indexOf('mac')!=-1? true: false);

var iVers=parseInt((isIE ? navigator.appVersion.split('MSIE')[1].split(';')[0] :0));

var sTemp;

function addOnLoadAct(fNewOnLoad){	
	// save the existing onload event(s)
	var fCurrentOnLoad = window.onload;
	// if the existing onload does not have a function ...
	if (typeof window.onload != 'function'){
		// give it this function
		window.onload = fNewOnLoad;
	}else{
		// else add the new function to the existing function
		window.onload = function(){
			fCurrentOnLoad();
			fNewOnLoad();
		}
	}
}



function getTop(obj){
	yPos = eval(obj).offsetTop;
	tempEl = eval(obj).offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
	}
return yPos;
}

function getLeft(obj){
	xPos = eval(obj).offsetLeft;
	tempEl = eval(obj).offsetParent;
	while (tempEl != null) {
		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}
return xPos;
}


var arrGlobalSettings = new Array('divGlobal','divFax', 'divFaxIn');
var arrGlobalHeadings = new Array('tdGlobal','tdFax','tdFaxIn');

var arrUserSettings = new Array('divUser','divSchedule', 'divVoicemail', 'divVoicemailIn');
var arrUserHeadings = new Array('tdUser','tdSchedule', 'tdVoicemail', 'tdVoicemailIn');

function hideAll(arrBodyName, arrHeaderName){
	for(x=0; x<arrBodyName.length;x++){
		document.getElementById(arrBodyName[x]).style.display='none';
		document.getElementById(arrHeaderName[x]).className='clsSectionHeaderOff';
	}

}

function showHideContent(arrBodyName, arrHeaderName,objClassChange, objShow){
	hideAll(arrBodyName, arrHeaderName);
	document.getElementById(objShow).style.display='block';
	document.getElementById(objClassChange).className='clsSectionHeaderOn';
	

}


function getSource(sSource, eTarget){
	var xmlHttp;
	try	{  // Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	}catch (e) {  // Internet Explorer  
		try{    
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
		}catch (e){    
			try{      
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
			}catch (e){      
				alert("Your browser does not support AJAX!");      
				return false;      
			}    
		}  
	}
  	xmlHttp.onreadystatechange=function(){
   		 if(xmlHttp.readyState==4){
      		document.getElementById(eTarget).innerHTML=xmlHttp.responseText;
			document.getElementById(eTarget).parentNode.style.display='block';
			
      	}
    }
  	xmlHttp.open("GET",sRoot+"/AJAXContent/p_AJAXContent.cfm?friendlyName="+sSource,true);
  	xmlHttp.send(null);  
}

// supported by all IE7 Opera, FF and Safari (Win/Mac)
function setClass(lstParentID, objOn, sCls){
	for (x=0; x<document.getElementById(lstParentID).childNodes.length;x++){
		document.getElementById(lstParentID).childNodes[x].className=sCls+'Off';
	}
	objOn.className=sCls+'On';
}

function setImage(lstParentID, objOn){
	var y=1;
	var iStep=2;
	//change indexing for IE - Opera also supports document.all, so check that it is not opera!! 
	if(document.all && navigator.appName.toLowerCase().indexOf('opera')==-1){
		y=0;
		iStep=1;
	}	
	for (x=y; x<document.getElementById(lstParentID).childNodes.length;x+=iStep){
		document.getElementById(lstParentID).childNodes[x].firstChild.src=document.getElementById(lstParentID).childNodes[x].firstChild.src.replace(/_on|_hv/i,'_nm');
	}
	objOn.src=objOn.src.replace(/_on|_hv|_nm/i,'_on');
	sTemp=objOn.src
}

var iPosY;
var bNewDiv=0
function popImage(strImg){
var str='';
var iHeight=parseInt(document.body.scrollHeight)+(isIE || isFF || isNS? 100 :0);
iPosY=(isIE ? document.documentElement.scrollTop : window.pageYOffset);
	str+='<div style="width:100%; height:' + iHeight+'px; top:0px; left:0px;color:black;background:gray;filter:alpha(opacity=80);-moz-opacity:.80;opacity:.80;"></div>';
	str+='<div style="position:absolute; top:0px; left:0px; width:100%; height:100%; text-align:center;">';
	str+='<div style="width:100%; height:100%; text-align:center;">';
	str+='<table align="center" style="height:' + (isIE && iVers ==6 ? screen.availHeight :'100%;' ) +'" border="0"><tr><td valign="middle">';
	str+='<img src="'+strImg.replace(/_tn/i,'') +'">';	
	str+='</td></tr></table>';
	str+='</div>';
	str+='</div>';
	window.scrollTo(0,0);
	if(!bNewDiv){
	var newDiv = document.createElement('div');
	newDiv.id='divPopImage';
	newDiv.style.width='100%'; 
	newDiv.style.height='100%'; 
	newDiv.style.position='absolute'; 
	newDiv.style.left='0px'; 
	newDiv.style.zIndex='10000';
	newDiv.onclick=hidePortImage;
	document.getElementsByTagName('body').item(0).appendChild(newDiv);
	bNewDiv=1;
	}
	divSet=document.getElementById('divPopImage');
	divSet.style.top=getScrollXY()[1] +'px'; 
	divSet.innerHTML='';
	divSet.innerHTML=str;
	divSet.style.display='block';
}

function hidePortImage(){
document.getElementById('divPopImage').style.display='none';
window.scrollTo(0,iPosY);
}

function getScrollXY() {
    var x = 0, y = 0;
    if( typeof( window.pageYOffset ) == 'number' ) {
        // Netscape
        x = window.pageXOffset;
        y = window.pageYOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        // DOM
        x = document.body.scrollLeft;
        y = document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        // IE6 standards compliant mode
        x = document.documentElement.scrollLeft;
        y = document.documentElement.scrollTop;
    }
    return [x, y];
}




	
	