var curPopupWindow = null;

// used for all page layouts to initialize page specific info
function _init(oBody) {
	// don't error out if this function doesn't exist on the layout page
	try {
		init(oBody);
	} catch (e) { }
	
	try {
		statusErrMsg();
	} catch (e) {  }
}
/**
 * Calls through to the openPopupFocus() with closeOnLoseFocus set to true.
 */
function openPopup(url, name, pWidth, pHeight, features, snapToLastMousePosition) {
	openPopupFocus (url, name, pWidth, pHeight, features, false, true);
	//														|-->  never doing snapToLastMousePosition
}

/**
 * Handles popup windows.
 * If snapToLastMousePosition is true, then the popup will open up near the mouse click.
 * If closeOnLoseFocus is true, then it will close when the user clicks back into the browser window that opened it.
 */
function openPopupFocus(url, name, pWidth, pHeight, features, snapToLastMousePosition, closeOnLoseFocus) {
    closePopup();

	// never doing snapToLastMousePosition
    //if (snapToLastMousePosition) {
    	//alert("Last Mouse X--"+lastMouseX);
    	//alert("Last Mouse Y--"+lastMouseY);
    	////alert("pWidth--"+pWidth);
    	//alert("pHeight--"+pHeight);
    	//alert("Screen--"+screen.height);
    	
    	
        //if (lastMouseX - pWidth < 0) {
        //    lastMouseX = pWidth;
        //}
        
        //if (lastMouseY + pHeight > screen.height) {
        //     lastMouseY -= (lastMouseY + pHeight + 50) - screen.height;
        //}
        //lastMouseX -= pWidth;
        //lastMouseY += 10;
        //features += " screenX=" + lastMouseX + ", left=" + lastMouseX + " screenY=" + lastMouseY + ", top=" + lastMouseY;
    //} else {
        features += ", left=" + pWidth + ", top=" + pHeight+", screenX=" + pWidth + ", screenY=" + pHeight;
    //}
    if (closeOnLoseFocus) {
    	curPopupWindow = window.open(url, name, features, false);
        curPopupWindow.focus ();
    } else {
        // assign the open window to a dummy var so when closePopup() is called it won't be assigned to curPopupWindow
        win = window.open(url, name, features, false);
        win.focus ();
    }
}

function closePopup() {

    if (curPopupWindow != null)  {
		var _popUp = curPopupWindow;
		curPopupWindow = null;
		try {
	        if (!_popUp.closed) {
    	        _popUp.close();
        	}
        } catch (e)	{; }
    }
}

function openLookup(baseURL,width,high) {

    var props = "scrollBars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=yes";
    openPopup(baseURL, "lookup", 300, 400, props +",width="+width+",height="+high, false);
}


function deleteAgendaData(val, itemVal, agendaItem, verb, agendaId) {
	if (confirm("Confirm " + verb + " of this "+agendaItem)) {
		url = "Agenda?actionType=d&agendaId="+agendaId+"&itemId="+itemVal+"&agendaDataType="+val;
		gotoURL(url);
	}
}

function showMap(street, city, state, zip, country)
{
	var params;
	var frm = document.Form1;
	if (frm != undefined && frm.streetNameText != undefined) {
		params = frm.streetNameText.value+","+frm.cityText.value+","+frm.stateText.value;
		if (frm.zipText.length > 0)
			params +=","+frm.zipText.value;
		if (frm.countryText.length > 0)
			params +=","+frm.countryText.value;
	} else {
		params = street+","+city+","+state;
		if (zip > 0)
			params +=","+zip;
		if (country > 0)
			params +=","+country;
	}
	
	curPopupWindow = window.open("http://maps.google.com/maps?q=" + escape(params),"directions");
	curPopupWindow.focus ();
}

function moveTo(val, agendaId) {
	url='';
	if(val == 'PreSession')	{
		url = "PreSession.jsp";
	}
	else if(val == 'clientView') {
		url = "clientAgendaView.jsp";
	}
	else if(val == 'PostSession') {
		url = "PostSession.jsp";
	}
	else if(val == 'SendAgenda') {
		url = "SendAgenda.jsp";
	}	
	else if(val == 'SendMinutes') {
		url = "SendMinutes.jsp";
	}
	else if(val == 'Engage') {
		url = "AgendaEngage.jsp";
	}
	else if(val == 'Review') {
		url = "AgendaReview.jsp";
	}
	url+='?agendaId='+agendaId;
	gotoURL(url);
}

function newAgendaData(typeId, itemVal, agendaId, additionalInfo) {

	goURL='';
	params='?itemId='+itemVal+'&agendaId='+agendaId;
	if( typeId == 'handOut') {
		goURL = "newHandout.jsp";
	} 
	else if (typeId == 'logistics') {
		goURL = 'agendaLogisticsEdit.jsp';
	}
	else if( typeId == 'agendaItems') {
		goURL = "AgendaItem.jsp";
		params+='&agendaTrackId='+additionalInfo;
	} 
	else if( typeId == 'agendaInternalObj') {
		goURL = "AgendaObjectives.jsp";
	} 
	else if( typeId == 'participants') {
		goURL = "Participants.jsp";
	}
	else if(typeId == 'preMeetingNotes') {
		goURL = "EditAgendaNotes1.jsp";
	}
	else if(typeId == 'agendaClientQues') {
		goURL = "NewQuestion.jsp";
	}
	else if(typeId == 'lessonLearned')	{
		goURL = "newLesson.jsp";
	}
	else if(typeId == 'postMeetingNotes') {
		goURL = "SessionNotes.jsp";
	}
	else if(typeId == 'actionItems') {
		goURL = "AgendaActionItem.jsp";
	}
	else if(typeId == 'actionItemsView') {
		goURL = "AgendaActionItemView.jsp";
	}
	else if (typeId == 'psTaskEdit') {
		goURL = 'AgendaPSTask.jsp'
	}
	else if (typeId == 'taskView') {
		goURL = 'TaskView.jsp';
	}
	else if (typeId == 'nextAgenda' || typeId == 'editAgenda') {
		goURL = 'EditAgenda.jsp?agendaId='+itemVal;
		goURL+='&agendaType='+typeId;
			
		gotoURL(goURL);
		return;
	}
		
	goURL+=params;
	gotoURL(goURL);
}

function openWindowSelTIM(refId, refType)
{curPopupWindow = window.open("selTIMWin.jsp?referenceId="+refId+"&referenceType="+refType,"selTim","height=400,width=650,left=300,scrollbars=yes,top=100,dependent=yes");curPopupWindow.focus ();
}

function openWindowSelQuest(agendaId, itemId)
{curPopupWindow = window.open("questSelect.jsp?agendaId="+agendaId+'&itemId='+itemId,"selQuest","height=500,width=650,left=300,scrollbars=yes,top=100, dependent=yes");curPopupWindow.focus ();
}

function openWindowReorderQuest(agendaId, itemId, calledFrom)
{curPopupWindow = window.open("reorderItemWin.jsp?calledFrom="+calledFrom+"&jumpTag=Questions&itemType=0&elementId="+agendaId+"&groupId="+itemId,"reorderQuest","height=350,width=650,left=300,scrollbars=yes,top=100, dependent=yes");curPopupWindow.focus ();
}

function openWindowReorderKeyAccounts() { 
	curPopupWindow = window.open("reorderItemWin.jsp?calledFrom=AccountList.jsp&itemType=1","reorderAccts","height=305,width=450,left=300,scrollbars=yes,top=100, dependent=yes");curPopupWindow.focus ();
}

function openWindowReorderTopGoals() { 
	curPopupWindow = window.open("reorderItemWin.jsp?calledFrom=GoalList.jsp&itemType=2","reorderGoals","height=305,width=450,left=300,scrollbars=yes,top=100, dependent=yes");curPopupWindow.focus ();
}

function openWindowReorderUsefulLinks() { 
	curPopupWindow = window.open("reorderItemWin.jsp?calledFrom=UsefulLinks.jsp&itemType=4","reorderUsefulLinks","height=305,width=450,left=300,scrollbars=yes,top=100, dependent=yes");curPopupWindow.focus ();
}

function openWindowReorderTopGroups() { 
	curPopupWindow = window.open("reorderItemWin.jsp?calledFrom=GroupBuilderView.jsp&itemType=3","reorderGroups","height=305,width=450,left=300,scrollbars=yes,top=100, dependent=yes");curPopupWindow.focus ();
}

function openWindowClientQuest(val) {
curPopupWindow = window.open("clientQuestSelect.jsp?agendaId="+val,"reorderAntQuests","height=455,width=640,left=300,scrollbars=yes,top=100, dependent=yes");curPopupWindow.focus ();
}

function openSelAccMbrs(acctId, teamId, pageURL) {
	url = "accountMbrSel.jsp?accountId="+acctId+"&teamId="+teamId+"&refreshAction="+pageURL+"%26jumpTag=Members";
curPopupWindow = window.open(url,"selMbrs","height=375,width=640,left=300,scrollbars=yes,top=100, dependent=yes");curPopupWindow.focus ();
}

function openWindowSelDoc(refId, refType, assocId, assocType, rtnURL) {
	url = "documentSel.jsp?referenceId="+refId+"&referenceTypeId="+refType+"&associatedId="+assocId+"&associatedTypeId="+assocType+"&_fromURL="+rtnURL;
	curPopupWindow = window.open(url,"docSel","height=400,width=650,left=300,scrollbars=yes,top=100,dependent=yes");curPopupWindow.focus ();
}

function openWindowGeneratePDF(url) {
	newUrl = url.replace(/\&/g,'%26');
	newUrl = newUrl.replace(/\?/g, '%3f');
	window.open('generatePDFWin.jsp?htmlPage='+newUrl,"Generate_PDF","height=750,width=750,left=300,scrollbars=yes,top=100, resizable=yes,dependent=yes").focus();
}

function openWindowViewStatement(val)
{ 
	//window.showModelessDialog("viewStatementWin.jsp?sopId="+val+"&refresh="+s,window,"dialogHeight:540px;dialogWidth:650px;scroll:yes;status:no");
    //var curPopupWindow = window.open("viewStatementWin.jsp?sopId="+val, 'Statement of Position', "height=540px,width=650px,left=300px,scrollbars=yes,top=200,dependent=yes");
    openLookup("viewStatementWin.jsp?sopId="+val,'650','440');
    //curPopupWindow.focus (); 
}

function openExampleSOP(type)
{ 
	var height, url;
    if (type == "personal") {
		height = 320;
        url = "sop_personalExample.html";
    }
        //window.showModelessDialog("sop_personalExample.html",window,"dialogHeight:310px;dialogWidth:650px;scrollbars:yes;status:no");
	else {
		height = 510;
        url = "sop_businessExample.html";
    }
        //window.showModelessDialog("sop_businessExample.html",window,"dialogHeight:500px;dialogWidth:650px;scrollbars:yes;,status:no");
    curPopupWindow = window.open(url, 'exmplPosStmt', "height="+height+"px,width=650px,left=300px,scrollbars=yes,top=200,dependent=yes");
    curPopupWindow.focus ();
}

function openWindowGraph(dep, res, pos, inf, count, select, type) {
	curPopupWindow = window.open("Graph.jsp?type="+type+"&dep="+dep+"&res="+res+"&pos="+pos+"&inf="+inf+"&count="+count+"&select="+select,"DRPIGraph","height=565,width=478,left=300, top=100, dependent=yes");
	curPopupWindow.focus();
}


function openOrgLookup(oSearchFld,oRtnFld)
{
	openLookup("orgLookupWin.jsp?SearchStr="+oSearchFld.value+"&rtnName="+oSearchFld.name+"&rtnId="+oRtnFld.name,'425','400');
}

function openAccountLookup(accountId, oParentId, parentNameFld) {
	openLookup("orgLookupWin.jsp?SearchStr=&rtnName="+parentNameFld+"&rtnId="+oParentId,'425','400');
}

function openAgendaLookup(agendaId, oParentId, parentNameFld) {
	openLookup("agendaLookupWin.jsp?rtnId="+oParentId+"&rtnName="+parentNameFld+"&itemId="+agendaId,'425','385');
}

function openGroupLookup(refId, oRtnId, oRtnName) {
	openLookup("groupLookupWin.jsp?rtnId="+oRtnId+"&rtnName="+oRtnName+"&refId="+refId,'425','370');
}

function openGoalLookup(refId, oRtnId, oRtnName) {
	openLookup("goalLookupWin.jsp?rtnId="+oRtnId+"&rtnName="+oRtnName+"&refId="+refId,'425','370');
}

function openUserLookup(refId, oRtnId, oRtnName) {
	openLookup("userLookupWin.jsp?rtnId="+oRtnId+"&rtnName="+oRtnName+"&refId="+refId,'425','370');
}

function openRelatedToAgendaLookup(agendaId, parentNameFld) {
	openLookup("relatedToAgendaSel.jsp?agendaId="+agendaId+"&rtnName="+parentNameFld,'640','450');
}


function openContactLookup(oAccName, rtnAccId, val, showGroups, rtnId, rtnName, rtnTitle, rtnEmail, excludePrivate)
{
	var names = '';
	var val1 = '';
	var rtnAccName = undefined;
	var val2 = '', val3 = '';
	var _showGroups = '';
	
	if (oAccName != undefined) {
		val1= oAccName.value;
		rtnAccName = oAccName.name;
	}
	if (showGroups != undefined)
		_showGroups = showGroups;
	
	
	var priv=0;
	if (excludePrivate != undefined) {
		priv=1;
	}

	openLookup("contactLookupWin.jsp?selAcc="+val1+
		"&SearchStr="+val+
		"&showGroups="+_showGroups+
		"&rtnName="+rtnName+
		"&rtnId="+rtnId+
		"&rtnTitle="+rtnTitle+
		"&rtnEmail="+rtnEmail+
		"&rtnAccName="+rtnAccName+
		"&rtnAccId="+rtnAccId+
		"&exclPriv="+priv
		,'460','425');
}

function pagePrint(URL, params)
{
	completeURL = URL + '?pagePrint=true';
	if (params != undefined && params.length != 0) {
		completeURL += '&' + params;
	}
	var myBars='directories=0, menubar=0, scrollbars=1, width=940, height=600, resizable=1';
	curPopupWindow = window.open(completeURL, 'prntPage', myBars);
	curPopupWindow.focus();
}

function newItemFocus(itemId, inputFld) {
		if (itemId != undefined) {
			if (itemId.value == "0" || itemId.value == "") {
				inputFld.focus();
			}
		}
		else  inputFld.focus();		
}

function changeTo(val) {
	document.Form1.action = val;
	document.Form1.submit();
}

function changeToHref(val)
{
	window.location.href = val;
}

function viewSOP(val)
{ 
    var newVal = '';
    if (val != null) 
        newVal = val;
    //window.showModelessDialog("ViewSOP.jsp?userId="+newVal,window,"dialogHeight:540px;dialogWidth:650px;scroll:yes;status:no");
    curPopupWindow = window.open("ViewSOP.jsp?userId="+newVal, 'viewPosStmt', "height=375px,width=650px,left=300px,scrollbars=yes,top=200,dependent=yes");
    curPopupWindow.focus ();
}


// t i m e o u t    l o g i c
    // scripts in support of session timeout warning

    function startPageTimer() {
        var dt, dtMilli, warnTime, expTime;
        var pg = document.getElementById('initPageLoad');
        if (pg) {
            if (pg.value == '0') {      // first time
                pg.value = '1';
                
                dt = new Date();
                dtMilli = dt.valueOf(); // current time in milliseconds
                warnTime = sessionWarn;         // warning time
                expTime  = sessionTimeout;  // expire time
                                timeOut = dtMilli + sessionTimeout;
                                
                setCookie("sessionTime", timeOut);      // save exp time
  
            }
            else {      // a page-back
                    // get the existing cookie
                    timeOut = getCookie("sessionTime");
                    if (timeOut != null) {
                        dt = new Date();        // get now
                        expTime = timeOut - dt.valueOf();       // time until expire
                        warnTime = expTime - warningInterval;                       
                    } 
                    else {
                        expTime = 0;
                    }
            }

                        if (expTime > 0) {
                setTimeout("expTimeout()",expTime);         // wait this long for expire

                if (warnTime > 0) {
                    setTimeout("warnTimeout()",warnTime); // wait this long for warning
                  }
                  else {
                    warnTimeout();
                  }
              }
              else {
                expTimeout();
              } 
        }
    }

    function warnTimeout() {
                // determine the time of expiration 
                document.getElementById('expTime').innerHTML = formatTime(new Date(parseInt(timeOut)));             
                document.getElementById('expire').style.display  = "none"; 
                document.getElementById('warning').style.display = "inline"; 
                
        showBanner();
    }
    
    function formatTime(oDate) {
		result = "";
		yr = oDate.getFullYear();
		dttm = oDate.toLocaleString();
		pos = dttm.indexOf(yr);
		if (pos != -1)
			result = dttm.substr(pos+5); // 4 digit yr plus space
		else
			result = dttm;
			
		return result;
	}
    
    function expTimeout() {             
                document.getElementById('warning').style.display = "none"; 
        document.getElementById('expire').style.display  = "inline"; 
        
        showBanner()  
    }
    
    function showBanner() {
                showHideSelects('hidden');
                 
        document.getElementById('Banner').style.visibility = "visible"; 
        document.getElementById('Banner').style.left = document.body.clientWidth/2-150; 
            document.getElementById('Banner').style.top = document.body.clientHeight/2 + document.body.scrollTop - 100;   
    }
    
    function showHideSelects(val) {
        // clear out all select tags which will coverup our popup
                var aSel = document.body.getElementsByTagName("SELECT");
                
                for (x = 0; x < aSel.length; x++) {
                    aSel[x].style.visibility = val;
                }
    }
    
    
    function formatPhone (field) {
	    field.value = trim(field.value);
	
	    var orig = field.value;
	    var result = '';
	    var ext = -1;
	    var isNum = new RegExp('[0-9]');
	    var isDelim =  new RegExp('[\-\.\(\) ]');
	    var n = 0;
	
	    if (orig.length > 0) {
	    	if (orig.charAt(0) == '+') { // format international
	    		var fields_n = 0; // count delimeters to use 0 =' (', 1 ='( ', >1 =' '
	    		result = '+';
	    		for (i = 1; i < orig.length; i++) {	// skip '+'
		            var ch = orig.charAt(i);
		
		            // build up formatted number
		            if (isNum.exec(ch) != null) {
		            	result += ch;	// store asis
		            	n++;
		            } else {
		            	if (isDelim.exec(ch) != null) {
			            	// if first delimeter break, enclose area code in parens
			            	if (fields_n == 0)
		            			result += ' (';
		            		else if (fields_n == 1)
		            			result += ') ';
			            	else
			            		result += ' ';	// use blank if any other delimeter is used
			            	fields_n++;
			            	
			            } else { // some foreign char - quit parsing
			            	ext = i;
			            	break;
			            }
		            }
		        }
	
	    	} else {		// us or canadian
		        // count number of digits
		        if (orig.charAt(0) == '1') {  // skip it
		            orig = orig.substring(1, orig.length);
		        }
		
		        for (i = 0; i < orig.length; i++) {
		            var ch = orig.charAt(i);
		
		            // build up formatted number
		            if (isNum.exec(ch) != null) {
		                if (n == 0) result += "(";
		                else if (n == 3) result += ") ";
		                else if (n == 6) result += "-";
		                result += ch;
		                n++;
		            } else if (isDelim.exec(ch) == null) { // throw away delim but stop on non-delim
		                ext = i;
		                break;
		            } else if (n >= 10 && ch != ' ') {
		            	result += ch;			// preserve char after required 10 found
		            }
		        }
		    }
			// add the extension
	        if (ext >= 0) {
	        	result += ' ' + orig.substring(ext, orig.length);
	        }
		
		    if (n >= 8) field.value = result;
		}
	    return true;
	}
    
    <!--

/*
   name - name of the cookie
   value - value of the cookie
   [expires] - expiration date of the cookie
     (defaults to end of current session)
   [path] - path for which the cookie is valid
     (defaults to path of calling document)
   [domain] - domain for which the cookie is valid
     (defaults to domain of calling document)
   [secure] - Boolean value indicating if the cookie transmission requires
     a secure transmission
   * an argument defaults when it is assigned null as a placeholder
   * a null placeholder is not required for trailing omitted arguments
*/

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}


/*
  name - name of the desired cookie
  return string containing value of specified cookie or null
  if cookie does not exist
*/

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}


/*
   name - name of the cookie
   [path] - path of the cookie (must be same as path used to create cookie)
   [domain] - domain of the cookie (must be same as domain used to
     create cookie)
   path and domain default if assigned null or omitted if no explicit
     argument proceeds
*/

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// initialize a field used for input or searching using an embedded label
function fieldInit(field, initContents, label) {
	if (field != undefined) {
		if (initContents == "" || initContents == label) {
			field.className = "bodySmallGrey";
			field.value = label;
		} else {
			field.className = "bodySmall";
			field.value = initContents;
		}
	}
}

// determine if embedded label should be cleared
function fieldFocus(field) {
	if (field.className == "bodySmallGrey") {
		field.className = "bodySmall";
		field.value = "";
	}
}

// convert minutes to hours & minutes 
function makeFriendlyTime(val) {

  var hours = Math.floor(val / 60);
  if (val < 0)
  	hours++;		// somehow hours is off by one when negative

  var minutes = val % 60;
  var sResult = "";
  
  if (hours != 0) {
  	if (hours == 1)
  		sResult = hours + " Hour ";
  	else
  		sResult = hours + " Hours ";
  }
  		
  if (minutes != 0)
  	sResult += " " + minutes + " minutes";	
  	
  if (sResult.length == 0)
  	sResult = "none";

  return sResult;
}

function viewTextData(val)
{
	popupText = window.open("textResume.jsp?contactId="+val,"ViewTextResume");
}

function trim(strText) { 
    // this will get rid of leading spaces 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);

    // this will get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;
}

function gotoURL(url) {
	var submitAction = document.getElementById('submitAction');
	
	if (submitAction != undefined) {
		submitAction._action.value = 0;	// goto actionType
		submitAction._gotoURL.value = escape(url);
		submitAction.submit();
	} else
		changeToHref(url);
}

var collapsed = 'images/hide.gif';
var expanded  = 'images/display.gif';
function twistie(sectionId, referenceId, recordable) {
	var img     = document.getElementById(sectionId+'Img');
	var content = document.getElementById(sectionId+'Section');
	var rule    = document.getElementById(sectionId+'Rule');
	var buttons = document.getElementById(sectionId+'Buttons');
	var isExpanded;
	
	if (img.src.indexOf(collapsed) > 0) {	
		// go to expanded
		img.src = expanded;
		isExpanded = "1";
		content.className	= content.className.replace('collapsed','expanded');
		if (rule != undefined)
			rule.className	= rule.className.replace('expanded', 'collapsed');
		if (buttons != undefined)
			buttons.className= buttons.className.replace('collapsed','expanded');				
	} else {
		img.src = collapsed;
		isExpanded = "0";
		content.className	= content.className.replace('expanded', 'collapsed');
		if (rule != undefined)
			rule.className	= rule.className.replace('collapsed','expanded');
		if (buttons != undefined)
			buttons.className= buttons.className.replace('expanded', 'collapsed');	
	}
	
	// update the system for next refresh
	if (recordable != null && recordable == true) {
		actionIFrame('Twistie?referenceId='+referenceId+'&sectionId='+sectionId+'&isExpanded='+isExpanded);
	} 
}

function actionIFrame(url) {
	var actionIFrame = document.getElementById("actionIFrame");
	if (actionIFrame != undefined) {
		actionIFrame.src=url;
	}
}

function newDialogWin() {
	curPopupWindow = window.open("newFeedbackWin.jsp","nDialg","height=270,width=550,left=300,top=200,scrollbars=yes,dependent=yes");
	curPopupWindow.focus ();
}

// Browser Detect  v2.1.6
// documentation: http://www.dithered.com/javascript/browser_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)


function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}

//  <input type='hidden' name='_gotoURL'>
//  <input type='hidden' name='_action'>
//  <input type='hidden' name='_itemType'>
//  <input type='hidden' name='_subType'>
//  <input type='hidden' name='_itemId'>
//  <input type='hidden' name='_referenceId'>
//  <input type='hidden' name='_referenceType'>
//  <input type='hidden' name='_oParams'>
//  <input type='hidden' name='_gotoURL'>
function deleteAction(itemId, itemType, subType, referenceId, referenceType, oParams, gotoURL) {
	if (confirm("Confirm deletion")) {
		doAction(4, itemId, itemType, subType, referenceId, referenceType, oParams, gotoURL);
	}
}

function doAction(actionType, itemId, itemType, subType, referenceId, referenceType, oParams, gotoURL) {
	var oSubmitAction = document.submitAction;
	if (oSubmitAction != undefined) {
		oSubmitAction._action.value=actionType;
		oSubmitAction._itemId.value = itemId;
		oSubmitAction._itemType.value = itemType;
		oSubmitAction._subType.value = subType;
		oSubmitAction._referenceId.value = referenceId;
		oSubmitAction._referenceType.value = referenceType;
		oSubmitAction._oParams.value = oParams;
		oSubmitAction._gotoURL.value = gotoURL;
		oSubmitAction.submit();
	}
}

// <a href="javascript:sortData(\'a.name\',\''+sortOrder+'\')" title="Agenda Name">Agenda Name</a>&nbsp;<img id="a.name" src="images/s.gif">

var navSearch_fields = new Array();


function bldHdr_navTitle(label, title, sortField, currSortField, currSortOrder) {
	sResult = '<a class="titleLineBorder" href="javascript:sortData(\''+sortField+'\',\''+currSortOrder+'\')" title="'+title+'">'+label+'</a>';
	
	sImg = 'arrowNuetral.gif';
	if (sortField == currSortField) {
		if (currSortOrder == 'ASC')
			sImg = 'arrowup.gif';
		else
			sImg = 'arrowdown.gif';
	}
	sResult += '&nbsp;<img src="images/'+sImg+'" align="middle">';
	
	return sResult;
}

// <div style="height:26px;padding-top:4px"><input type="text" class="filterInActive" name="fName" value="" size="16"></div>
function bldHdr_navSearch_input(srchField, srchValue, inputSize, isLast) {
	navSearch_fields.push(srchField);		// needed when the go button is pushed
	
	fltrClass = 'filterInActive';
	if (srchValue != '')
		fltrClass = 'filterActive';
	sResult = '<input type="text" class="'+fltrClass+'" name="'+srchField+'" value="'+srchValue+'" size="'+inputSize+'">';
	
	return bldHdr_wrapper(sResult, isLast);;
}

function bldHdr_navSearch_select(srchField, srchValue, srchSel, isLast) {
	navSearch_fields.push(srchField);		// needed when the go button is pushed
	
	fltrClass = 'filterInActive';
	if (srchValue != '')
		fltrClass = 'filterActive';
	
	sResult = bldHdr_wrapper(srchSel, isLast);
	sResult += "<script>document.Form1." + srchField + ".className='" + fltrClass + " width120';</script>";
	
	return sResult;
}

function bldHdr_wrapper(srchHTML, isLast) {
	
	var sResult;
	if (isLast) {
		sResult = '<div style="height:37px;margin-top:9px">';
		sResult += '<table style="margin-right:4px"><tr><td>'+srchHTML+'</td>';
		sResult += '<td><input type="image" src="images/go.gif" hspace="4px" border="0" alt="Search" onClick="javascript:goFindFilteredResult()" style="position:relative;top:3px"></td>';
		sResult += '</tr></table>';
	} else 
		sResult = '<div style="height:34px;padding-top:12px">'+srchHTML;
		
	sResult += '</div>';
	return sResult;
}

function goFindFilteredResult(frmName) {
	name = frmName != undefined ? frmName : 'Form1';
	frm = document.forms[name];
	frm._listFrom.value = 1;
	
	srchPairs = '';
	for (ndx=0; ndx<navSearch_fields.length; ndx++) {
		srchField = navSearch_fields[ndx];
		if (frm[srchField]!= undefined)
			srchPairs += '¤'+srchField+'±'+frm[srchField].value;  
	}

	frm._searchItems.value = srchPairs;  
	frm.submit(); 
}

function toggleSrc(newSrc) {
	frm = document.Form1;
	oDiv = document.getElementById(frm._srcType.value);
	if (oDiv != undefined)
		oDiv.style.display='none';
	
	oDiv = document.getElementById(newSrc);
	
	if (oDiv != undefined)
		oDiv.style.display='block';

	frm._srcType.value =newSrc;
}

function clearSrc(divId, doSubmit) {
	oDiv = document.getElementById(divId);
	if (oDiv!=undefined) {
		oInputs = oDiv.getElementsByTagName("INPUT");
		clearFlds(oInputs);
		oSelects= oDiv.getElementsByTagName("SELECT");
		clearFlds(oSelects);
	} else
		alert('not found:'+divId);
		
	frm = document.Form1;
	frm._searchItems.value = "";
	if (doSubmit) {
		// clear the _listFrom field
		oList = document.getElementById("_listFrom");
		if (oList != undefined)
			oList.value = 1;
		frm.submit();
	}
}

function clearFlds(oFlds) {
	for (x=0; x<oFlds.length; x++) {
		oFld = oFlds.item(x);
		type=oFld.type;
		nodeName=oFld.nodeName;
		if (nodeName=='INPUT') {
			if (type=='text')
				oFld.value='';
			else if (type=='checkbox')
				oFld.checked=false;
		} else if (nodeName=='SELECT') {
			oFld.selectedIndex=0;
		} else {
			alert(nodeName);
		}
	}
}

function svSrc(divId) {
	var sResult='';
	oDiv = document.getElementById(divId);
	if (oDiv!=undefined) {
		oInputs = oDiv.getElementsByTagName("INPUT");
		sResult=svFlds(oInputs);
		oSelects= oDiv.getElementsByTagName("SELECT");
		sResult2=svFlds(oSelects);

		if (sResult.length>0 && sResult2.length>0)
			sResult=sResult+'¤'+sResult2;
		else
			sResult=sResult+sResult2;
	} else
		alert('not found:'+divId);
		
	frm = document.Form1;
	frm._searchItems.value = sResult;
	
	// clear the _listFrom field
	oList = document.getElementById("_listFrom");
	if (oList != undefined)
		oList.value = 1;
		
	frm.submit();
}

function svFlds(oFlds) {
	var sResult='';
	for (x=0; x<oFlds.length; x++) {
		fldPair='';
		oFld = oFlds.item(x);
		type=oFld.type;
		nodeName=oFld.nodeName;
		tmpName=oFld.name.split('.');
		// extract the field name, if it exists
		if (tmpName.length > 1)
			fldName=tmpName[1];
		else
			fldName=tmpName[0];
			
		if (nodeName=='INPUT') {
			if (type=='text' || type=='hidden') {
				if (oFld.value!='')
					fldPair=fldName+'±'+oFld.value
			} else if (type=='checkbox') {
				if (oFld.checked==true)
					fldPair=fldName+'±'+oFld.value;
			}
		} else if (nodeName=='SELECT') {
			if (oFld.selectedIndex>0)
				fldPair=fldName+'±'+oFld.options[oFld.selectedIndex].value;
		} else {
			alert(nodeName);
		}
		if (fldPair!='') {
			if (sResult.length>0)
				sResult+='¤';
			sResult+=fldPair;
		}
	}
	return sResult;
}

//function for closing / deleting actions
	// doAction(actionType, itemId, itemType, subType, referenceId, referenceType, oParams, gotoURL)
	function doClsAll(sectionId, refId, refType, gotoURL) {
		itemList = getItems(sectionId);

		if (itemList.length != 0) {
			// itemType Task = 12
			doAction('6', '', '12', '0',
				refId, refType, itemList, gotoURL);
		}
	}
	
	function doDelAll(itemName, sectionId, itemType, refId, refType, gotoURL) {
		itemList = getItems(sectionId);
		
		if (itemList.length != 0) {
			if (confirm("Confirm Deletion of these "+itemName+"?")) {
				doAction('5', '', itemType, '0',
					refId, refType, itemList, gotoURL);
			}
		}
	}
	
	function selectItems(sectionId, val) {
		items = new Array();
		var oTbl = document.getElementById(sectionId);
		if (oTbl != undefined) {
			var oList = oTbl.getElementsByTagName("INPUT");
			
			for (ndx=0; ndx < oList.length; ndx++) {
				if (oList[ndx].name == '_actionItemId' && oList[ndx].disabled != true) {
					oList[ndx].checked = val;
				}
			}
		}
	}
	
	function getItems(sectionId) {
		items = new Array();
		
		var oTbl = document.getElementById(sectionId);
		if (oTbl != undefined) {
			var oList = oTbl.getElementsByTagName("INPUT");
			
			for (ndx=0; ndx < oList.length; ndx++) {
				if (oList[ndx].name == '_actionItemId') {
					if (oList[ndx].checked == true)
						items.push(oList[ndx].value);
				}
			}
		}
		return items.join(",");
	}
	
	var _xmlHttpReq = undefined;		// used to hold the xmlHTTP object
	function loadXMLDoc(url) {
	    // branch for native XMLHttpRequest object
	    if (window.XMLHttpRequest != undefined) {
	        _xmlHttpReq = new XMLHttpRequest();
	    } else if (window.ActiveXObject != undefined) {		// IE
	    	try { 
	    		_xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
     		} catch (e) {
     			try { 
     				_xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); 
     			} catch (e) {}
			}
	    } else if (window.createRequest != undefined) {
			try {
				_xmlHttpReq = window.createRequest();
			} catch (e) { }
		} else {
	    	alert("no xml object found");
	    }
	    	
	    // return to comment code
	    if (_xmlHttpReq) {
        	if (_xmlHttpReq.overrideMimeType) { 
        		_xmlHttpReq.overrideMimeType('text/xml'); 
        	}
	        _xmlHttpReq.onreadystatechange = processXMLHTTPRequest;
	        _xmlHttpReq.open("GET", url, true);
	        _xmlHttpReq.setRequestHeader("Content-Type", "text/xml");
	        _xmlHttpReq.send(null);
	    }
	}
	
	function processXMLHTTPRequest() {
	    if (_xmlHttpReq != undefined) {
		    if (_xmlHttpReq.readyState == 4) { // only if req shows "complete"
		        // only if "OK"
		        if (_xmlHttpReq.status != 200) {
		        	 alert("There was a problem retrieving the XML data:\n" + _xmlHttpReq.statusText);
		       	} else {
		            var response;
		            //alert(_xmlHttpReq.getAllResponseHeaders());
					if (_xmlHttpReq.responseXML == undefined || _xmlHttpReq.responseXML.documentElement == undefined) {
						if (window.ActiveXObject) {
							try { 
					    		response = new ActiveXObject("Msxml2.XMLDOM");
				     		} catch (e) {
				     			try { 
				     				response = new ActiveXObject("Microsoft.XMLDOM"); 
				     			} catch (e) {}
							}
							if (response != undefined) {
								response.async=false;
								response.loadXML(_xmlHttpReq.responseText);
							}
						} else {
							try {
								document.Form1.sessionObjectiveText.value = _xmlHttpReq.responseText;
								var parser = new DOMParser();
								response = parser.parseFromString(_xmlHttpReq.responseText, "text/xml");
							} catch (e) { alert(e); }
						}
					} else {
						response  = _xmlHttpReq.responseXML;
					}
					
					if (response != undefined && response.documentElement != undefined) {
						if ((response.documentElement.tagName == "parserError") ||
					    	(response.documentElement.namespaceURI == "http://www.mozilla.org/newlayout/xml/parsererror.xml")) {
					  		alert("Parsing Error!");
						} else {
							try {
								pageXMLControl(response.documentElement)
							} catch (e) { }
							_xmlHttpReq = undefined;			// needed to keep IE from multiple calls
						}
					}
		        }
		    }
	    }
	}
	
	function itemView(type, itemId) {
				var sUrl = undefined;
				if (type == '1')
					sUrl = 'ContactView.jsp?contactId='+itemId;
				else if (type == '2') 
					sUrl = 'UserView.jsp?userId='+itemId;
				else if (type == '3') 
					sUrl = 'AccountView.jsp?accountId='+itemId;
				else if (type == '4')
					sUrl = 'clientAgendaView.jsp?agendaId='+itemId;

				else if (type == '7')
					sUrl = 'GroupView.jsp?groupId='+itemId;
				else if (type == '20')
					sUrl = 'GoalDetail.jsp?goalId='+itemId;

					
				if (sUrl != undefined)
					gotoURL(sUrl);
			}