	var ua = window.navigator.userAgent
	var msie = ua.indexOf ( "MSIE " )
	if(msie>0) {
		IsIE = true;
	}else{
		IsIE = false;
	}
	
	var delay = 0;
	var steps = 50;
	var duration = 2500;
	
    function setButtonText(text){
	    document.getElementById('button_text').innerHTML = text;
    }
	
    if (!window.console || !console.firebug)
    {
        var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
        "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

        window.console = {};
        for (var i = 0; i < names.length; ++i)
            window.console[names[i]] = function() {}
    }


	function getWindowHeight(){
	    if (window.innerHeight && window.scrollMaxY) {// Firefox
		    yWithScroll = window.innerHeight + window.scrollMaxY;
		    xWithScroll = window.innerWidth + window.scrollMaxX;
	    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		    yWithScroll = document.body.scrollHeight;
		    xWithScroll = document.body.scrollWidth;
	    } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		    yWithScroll = document.body.offsetHeight;
		    xWithScroll = document.body.offsetWidth;
  	    }
	    arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	    //alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
    	
	    return arrayPageSizeWithScroll;
    }

	function hideModal(){
		if (IsIE){
			document.body.removeChild(g_PopupIFrame);
    	g_PopupIFrame=null;
		}
	}
	
	
	
	function setDiv() {
		var wh = getWindowHeight(); // Window Height
		var d = document.getElementById('black_box') // Get div element
		var dh = d.offsetHeight // div height
		d.style.height = wh[1] + 'px'; // Set div height to window height
		d.style.width = wh[0] + 'px'; // Set div height to window height
		
		if (IsIE){
			//Increase default zIndex of div by 1, so that DIV appears before IFrame
			d.style.zIndex=d.style.zIndex+1;
			
			var iFrame = document.createElement("IFRAME");
			iFrame.setAttribute("src", "");
			
			//Match IFrame position with d
			iFrame.style.position="absolute";
			iFrame.style.left =d.offsetLeft + 'px';
			iFrame.style.top =d.offsetTop + 'px';
			iFrame.style.width =d.offsetWidth + 'px';
			iFrame.style.height =d.offsetHeight + 'px';
			iFrame.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
			
			document.body.appendChild(iFrame);
			
			//Store iFrame in global variable, so it can get removed when d is hidden 
			g_PopupIFrame=iFrame;
			d.style.display ="";
		}
		
		
	}
	
	
	function setDiv2() {
		var wh = getWindowHeight(); // Window Height
		var d = document.getElementById('black_box2') // Get div element
		var dh = d.offsetHeight // div height
		d.style.height = wh[1] + 'px'; // Set div height to window height
		d.style.width = wh[0] + 'px'; // Set div height to window height
		
		if (IsIE){
			//Increase default zIndex of div by 1, so that DIV appears before IFrame
			d.style.zIndex=d.style.zIndex+1;
			
			var iFrame = document.createElement("IFRAME");
			iFrame.setAttribute("src", "");
			
			//Match IFrame position with d
			iFrame.style.position="absolute";
			iFrame.style.left =d.offsetLeft + 'px';
			iFrame.style.top =d.offsetTop + 'px';
			iFrame.style.width =d.offsetWidth + 'px';
			iFrame.style.height =d.offsetHeight + 'px';
			iFrame.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
			
			document.body.appendChild(iFrame);
			
			//Store iFrame in global variable, so it can get removed when d is hidden 
			g_PopupIFrame=iFrame;
			d.style.display ="";
		}
		
		
	}
	
	
  function setOpacity(level) {            
		var element = document.getElementById("msg"); 
		element.style.opacity = level;
		element.style.MozOpacity = level;
		element.style.KhtmlOpacity = level;
		element.style.filter = "alpha(opacity=" + (level * 100) + ");";
  }
	
  function fadeOut() {         
		var fadeOutComplete;       
		for (i = 0; i <= 1; i += (1 / steps)) {
			setTimeout("setOpacity("  + (1 - i) + ")", i * duration);
			fadeOutComplete = i * duration;
		}                 
    setTimeout("hide()", fadeOutComplete);     
  }
	
  function hide(){
  	document.getElementById("msg").style.display = 'none';     
  }
	
	function removeInstallationItem(){
		text = document.getElementById('InstallationTitle');
		input = document.getElementById('InstallationId');
		text.value = "";
		input.value = 0;
	}
	
	function addInstallationItem(title, id){ 
		text = document.getElementById('InstallationTitle');
		input = document.getElementById('InstallationId');
		text.value = title.toString().replace(/<[^>]*>/gi,"").replace(/^\s+/,"")
		input.value = id;
		return true;
	}
	
	function removeTycomItem(){
		text = document.getElementById('TycomTitle');
		input = document.getElementById('TycomId');
		text.value = "";
		input.value = 0;
	}
	
	function addTycomItem(title, id){ 
		text = document.getElementById('TycomTitle');
		input = document.getElementById('TycomId');
		text.value = title.toString().replace(/<[^>]*>/gi,"").replace(/^\s+/,"")
		input.value = id;
		return true;
	}
	
	function popUp(URL) {
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=820,height=600,left = 390,top = 262');");
	}
	
	function swapDiv(targetId, count){
		for(i=0;i<count;i++){
			document.getElementById("content"+i).style.display = "none";
		}
		for(i=0;i<count;i++){
			document.getElementById("tab"+i).src = document.getElementById("tab"+i).src.replace("_on.jpg", "_off.jpg");
		}
		document.getElementById("content"+targetId).style.display = "";
		document.getElementById("tab"+targetId).src = document.getElementById("tab"+targetId).src.replace("_off.jpg", "_on.jpg");
		return false;
	}
	
	
	
	
	
	
	
	/*  ################################  COMMANDER's COMMAND CONTROLS  ################################  */
	
	var temp_id = 0;
	
	function searchForCommand(id){
		
		var uic = document.getElementById("uic").value;
		
		new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=command&id='+id+'&uic='+uic+'&nocache='+Math.random(),
			{
				method:'get',
				onSuccess: function(transport){
						document.getElementById("command").innerHTML =  transport.responseText;						
				},
				onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
			});
	}
	
	function addCommand(id, command_id){
	    temp_id = id;
		new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=add_command&id='+id+'&command_id='+command_id+'&nocache='+Math.random(),
			{
				method:'get',
				onSuccess: function(transport){		
					reloadCommandList(temp_id);
				},
				onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
			});
	}
	
	function reloadCommandList(id){
		new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=command_list&id='+id+'&nocache='+Math.random(),
			{
				method:'get',
				onSuccess: function(transport){
						document.getElementById("command_list").innerHTML =  transport.responseText;						
				},
				onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
			});
	}
	
	function removeCommand(command_id, id){
	    temp_id = id;
		new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=remove_command&id='+id+'&command_id='+command_id+'&nocache='+Math.random(),
			{
				method:'get',
				onSuccess: function(transport){		
					reloadCommandList(temp_id);
				},
				onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
			});
	}
	
	function deleteCommand(id){
	    if(confirm("Are you sure you want to 'permanently' delete this command?  You will not beable to undo this action")){
		    new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=delete_command&id='+id+'&nocache='+Math.random(),
			    {
				    method:'get',
				    onSuccess: function(transport){		
					    reloadCommandList(id);
				    },
				    onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
			    });
	    }
	}
	
	
	
	
	
	
	
	
	
	
	var disableOmbudsman = false;
	var disableCommander = false;
	
	
	/*  ################################  OMBUDSMAN CONTROLS  ################################  */
	
	
	
	
	function getOmbudsmanList(id, command_id){
		document.getElementById("ombudsman_write_ombudsman_" + id).value = 0;
		ln = document.getElementById("ombudsman_write_last_name_" + id).value;
		fn = document.getElementById("ombudsman_write_first_name_" + id).value;
		e = document.getElementById("ombudsman_write_email_" + id).value;
		p = document.getElementById("ombudsman_write_phone_" + id).value;
		new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=ombudsman_list&db_id='+command_id+'&id='+id+'&ln='+ln+'&fn='+fn+'&e='+e+'&p='+p+''+'&nocache='+Math.random(),
			{
				method:'get',
				onSuccess: function(transport){
						document.getElementById("ombudsman_popup").innerHTML =  transport.responseText;
						var pos = Position.get(document.getElementById("ombudsman_buddy_"+id));
						Position.set("ombudsman_popup",pos,pos, -2, 30);
				},
				onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
			});
	}
	
	function addOmbudsmanFromPopUp(id, db_id, ln, fn, e, p){
		document.getElementById("ombudsman_write_ombudsman_" + id).value = db_id;
		document.getElementById("ombudsman_write_last_name_" + id).value = ln;
		document.getElementById("ombudsman_write_first_name_" + id).value = fn;
		document.getElementById("ombudsman_write_email_" + id).value = e;
		document.getElementById("ombudsman_write_phone_" + id).value = p;
		document.getElementById("ombudsman_popup").innerHTML = "";
	}
	
	function toggleOmbudsman(id){
		db_id = document.getElementById("id").value
		if(document.getElementById("ombudsman_id_"+id).value>0){
			r = document.getElementById("ombudsman_read_"+id);
			w = document.getElementById("ombudsman_write_"+id);
			if(r.style.display == 'none'){
				document.getElementById("ombudsman_popup").innerHTML = "";
				r.style.display = '';
				w.style.display = 'none';
			  disableOmbudsman = false;
			}else{
				if(!disableOmbudsman){
					r.style.display = 'none';
					w.style.display = '';
					disableOmbudsman = true;
				}else{
					alert("ERROR: You must select an ombudsman.");
				}
			}
		}else{
			document.getElementById("ombudsman_popup").innerHTML = "";
			removeOmbudsman(id);
			disableOmbudsman = false;
		}
	}
	
	function updateOmbudsman2(id, member_id){
		new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=get_ombudsman&member_id='+member_id+'&nocache='+Math.random(),
			{
				method:'get',
				onSuccess: function(transport){
					var response = transport.responseText || "no response text";
					response = response.split("||");
					document.getElementById("ombudsman_write_ombudsman_"+id).value = response[0];
					document.getElementById("ombudsman_write_last_name_"+id).value = response[1];
					document.getElementById("ombudsman_write_first_name_"+id).value = response[2];
					document.getElementById("ombudsman_write_email_"+id).value = response[3];
					document.getElementById("ombudsman_write_phone_"+id).value = response[4];
					updateOmbudsman(id);
				},
				onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
			});
	}
	

	function updateOmbudsman(id){
	    var err = false;
	    var msg = "";
	    if(document.getElementById("ombudsman_write_last_name_"+id).value == "" || document.getElementById("ombudsman_write_last_name_"+id).value == "Last Name"){
	        msg += " - Please enter a Last Name \n";
	        err = true;
	    }
	    if(document.getElementById("ombudsman_write_first_name_"+id).value == "" || document.getElementById("ombudsman_write_first_name_"+id).value == "First Name"){
	        msg += " - Please enter a First Name \n";
	        err = true;
	    }
	    if(document.getElementById("ombudsman_write_email_"+id).value == "" || document.getElementById("ombudsman_write_email_"+id).value == "Email Address"){
	        msg += " - Please enter an Email Address \n";
	        err = true;
	    }
	   if(document.getElementById("ombudsman_write_phone_"+id).value == "Phone"){
	        document.getElementById("ombudsman_write_phone_"+id).value = '';
	    }
	   /* if(document.getElementById("ombudsman_write_phone_"+id).value == "" || document.getElementById("ombudsman_write_phone_"+id).value == "Phone"){
	        msg += " - Please enter a valid Phone Number \n";
	        err = true;
	    }*/
	        
	
	    if(err){
	        alert("There are some errors with your submission: \n \n" + msg);
	    }else{
		    document.getElementById("ombudsman_popup").innerHTML = "";
		    db_id = document.getElementById("id").value
		    if(document.getElementById("ombudsman_write_ombudsman_"+id).value>0){
			    document.getElementById("ombudsman_ombudsman_"+id).value = document.getElementById("ombudsman_write_ombudsman_"+id).value;
			    //document.getElementById("ombudsman_read_ombudsman_name_"+id).innerHTML = "<a href=\"?m=ombudsman&a=detail&id="+id+"\">"+document.getElementById("ombudsman_write_last_name_"+id).value + ", " + document.getElementById("ombudsman_write_first_name_"+id).value + "</a>";
			    document.getElementById("ombudsman_read_ombudsman_email_"+id).innerHTML = document.getElementById("ombudsman_write_email_"+id).value + "&nbsp;";
			    document.getElementById("ombudsman_read_ombudsman_phone_"+id).innerHTML = document.getElementById("ombudsman_write_phone_"+id).value + "&nbsp;";
			    document.getElementById("ombudsman_ids").value = document.getElementById("ombudsman_ids").value.replace(","+id+",", ",");
			    document.getElementById("ombudsman_ids").value += id+",";
			    new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=ombudsman&action=update&db_id='+db_id+'&old_id='+document.getElementById("ombudsman_id_"+id).value+'&val='+document.getElementById("ombudsman_ombudsman_"+id).value+'&nocache='+Math.random(),
			    {
				    method:'get',
				    onSuccess: function(transport){
					    var response = transport.responseText || "no response text";
					    response = response.split("||");
					    document.getElementById("ombudsman_id_"+id).value = response[0];
					    document.getElementById("ombudsman_read_ombudsman_name_"+id).innerHTML = "<a href=\"?m=ombudsman&a=detail&command_id="+db_id+"&id="+response[0]+"\">"+document.getElementById("ombudsman_write_last_name_"+id).value + ", " + document.getElementById("ombudsman_write_first_name_"+id).value + "</a>";
    			
					    toggleOmbudsman(id);
				    },
				    onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
			    });
		    }else{
    			
				    document.getElementById("ombudsman_read_ombudsman_email_"+id).innerHTML = document.getElementById("ombudsman_write_email_"+id).value + "&nbsp;";
				    document.getElementById("ombudsman_read_ombudsman_phone_"+id).innerHTML = document.getElementById("ombudsman_write_phone_"+id).value + "&nbsp;";
				    ln = document.getElementById("ombudsman_write_last_name_" + id).value;
				    fn = document.getElementById("ombudsman_write_first_name_" + id).value;
				    e = document.getElementById("ombudsman_write_email_" + id).value;
				    p = document.getElementById("ombudsman_write_phone_" + id).value;
				    new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=ombudsman&action=insert&id='+id+'&db_id='+db_id+'&ln='+ln+'&fn='+fn+'&e='+e+'&p='+p+''+'&nocache='+Math.random(),
				    {
					    method:'get',
					    onSuccess: function(transport){
						    var response = transport.responseText || "no response text";
						    response = response.split("||");
    						
						    if(response[0]=="exists"){
							    msg = "<div id='black_box'></div><div id='modal'>";
							    msg += "<h1>Duplicate Found</h1>";
							    msg += "<p>An ombudsman using the same email has been found. Would you like to use the following ombudsman?</p>";
							    msg += response[1];
							    msg += "<p align='center'><a href='#' onclick=\"updateOmbudsman2('"+id+"', '"+response[2]+"');document.getElementById('ombudsman_msg2').style.display='none';hideModal();return false;\"><img src='/images/btn_modal_yes.gif' border='0' /></a> <a href='#' onclick=\"document.getElementById('ombudsman_msg2').style.display='none';hideModal();return false;\"><img src='/images/btn_modal_no.gif' border='0' /></a></p>";
							    msg += "</div>";
							    
							    
							    
							    
							    
							    
msg = '<div id="black_box"></div><div id="modal"><div id="popper0" style="-moz-user-select: none; position: absolute; top: 0; left: 0; width: 500px; height: 150px; z-index: 99;" unselectable="on">';
msg += '<table cellspacing="0" cellpadding="0" border="0" style="width: 100%; height: 100%; -moz-user-select: none;" unselectable="on">';
msg += '    <tbody>';
msg += '      <tr height="25" unselectable="on">';
msg += '        <td unselectable="on"><table cellspacing="0" cellpadding="0" border="0" style="width: 100%; height: 100%; -moz-user-select: none;" unselectable="on">';
msg += '            <tbody>';
msg += '              <tr id="dragbar0" unselectable="on">';
msg += '                <td width="25" height="25" unselectable="on"><img width="25" height="25" src="/images/popup_topleft.gif" unselectable="on"/> </td>';
msg += '                <td class="popupTitle" width="100%" height="25" style="background-image: url(/images/popup_topbg.gif);" unselectable="on"><div class="PopupDivText" style="width: 520px;" unselectable="on">Duplicate User Found</div></td>';
msg += '                <td width="25" height="25" onclick="SetReturnValue(null); DisposePopup();" unselectable="on"><a href="#" onclick="document.getElementById(\'ombudsman_msg2\').style.display=\'none\';hideModal();return false;"><img width="25" height="25" src="/images/popup_topright.gif" border="0" unselectable="on"/></a> </td>';
msg += '              </tr>';
msg += '            </tbody>';
msg += '          </table></td>';
msg += '      </tr>';
msg += '      <tr>';
msg += '        <td class="popupBody" unselectable="on">' + response[1] + '</td>';
msg += '      </tr>';
msg += '    </tbody>';
msg += '  </table>';
msg += '</div></div>';
							    
							    
							    
							    
							    
							    
							    
							    
							    
							    
							    
							    
							    
							    
							    
							    document.getElementById("ombudsman_msg2").innerHTML = msg;
							    document.getElementById('ombudsman_msg2').style.display='';
							    setDiv();
						    }else if(response[0]=="dup"){
							    document.getElementById("ombudsman_id_"+id).value = response[0];
							    document.getElementById("ombudsman_read_ombudsman_name_"+id).innerHTML = "<a href=\"?m=ombudsman&a=detail&command_id="+db_id+"&id="+response[0]+"\">"+document.getElementById("ombudsman_write_last_name_"+id).value + ", " + document.getElementById("ombudsman_write_first_name_"+id).value + "</a>";
				                document.getElementById("ombudsman_write_ombudsman_"+id).value = response[0];
							   // toggleOmbudsman(id);
							    msg = "<div id='o_msg'>";
							    msg += "<h1>Duplicate Email</h1>";
							    msg += "<p>An ombudsman already exists in the system with the given email address. This ombudsman is also already assigned to this command.</p>";
							    msg += "<p align='right'><a href='#' onclick=\"document.getElementById('o_msg').style.display='none';return false;\">Close</a></p>";
							    msg += "</div>";	
							    document.getElementById("ombudsman_msg").innerHTML = msg;
						    }else{
							    document.getElementById("ombudsman_id_"+id).value = response[0];
							    document.getElementById("ombudsman_read_ombudsman_name_"+id).innerHTML = "<a href=\"?m=ombudsman&a=detail&command_id="+db_id+"&id="+response[0]+"\">"+document.getElementById("ombudsman_write_last_name_"+id).value + ", " + document.getElementById("ombudsman_write_first_name_"+id).value + "</a>";
				                document.getElementById("ombudsman_write_ombudsman_"+id).value = response[0];
							    toggleOmbudsman(id);
							    msg = "<div id='o_msg'>";
							    msg += "<h1>Ombudsman Saved Successfully</h1>";
							    msg += "<p>An activation link has been sent to the Ombudsman.</p>";
							    msg += "<p align='right'><a href='#' onclick=\"document.getElementById('o_msg').style.display='none';return false;\">Close</a></p>";
							    msg += "</div>";	
							    document.getElementById("ombudsman_msg").innerHTML = msg;
						    }
					    },
					    onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
				    });
    				
		    }
		}
	}

	function removeOmbudsman(id){
		if(document.getElementById("ombudsman_write_ombudsman_"+id).value>0 && document.getElementById("ombudsman_id_"+id).value>0){
			val = confirm("Are you sure you want to delete the selected Ombudsman?");
			if(val){
				db_id = document.getElementById("id").value
				new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=ombudsman&action=delete&db_id='+db_id+'&id='+document.getElementById("ombudsman_id_"+id).value+'&nocache='+Math.random(),
				{
					method:'get',
					onSuccess: function(transport){
						var response = transport.responseText || "no response text";
					},
					onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
				});
				r = document.getElementById("ombudsman_read_"+id);
				w = document.getElementById("ombudsman_write_"+id);
				r.parentNode.style.display = 'none';
				w.parentNode.style.display = 'none';
				r.parentNode.innerHTML = "";
				w.parentNode.innerHTML = "";
				document.getElementById("ombudsman_ids").value = document.getElementById("ombudsman_ids").value.replace(","+id+",", ",");
			}
		}else{
			r = document.getElementById("ombudsman_read_"+id);
			w = document.getElementById("ombudsman_write_"+id);
			r.parentNode.style.display = 'none';
			w.parentNode.style.display = 'none';
			r.parentNode.innerHTML = "";
			w.parentNode.innerHTML = "";
			document.getElementById("ombudsman_ids").value = document.getElementById("ombudsman_ids").value.replace(","+id+",", ",");
		}
	}

	function addOmbudsman(target){
		db_id = document.getElementById("id").value
		if(!disableOmbudsman){
			disableOmbudsman = true;
			ids = document.getElementById("ombudsman_ids").value;
			t = document.getElementById(target);
			ids = ids.split(",");
			maxnum = 0;
			for(i=0;i<ids.length;i++){
				if(maxnum < ids[i]){
					maxnum  = ids[i];
				}
			}
			newnum = parseInt(maxnum)+1;
				
			data = '<div><input type="hidden" id="ombudsman_id_'+newnum+'" name="ombudsman_id_'+newnum+'" value="" />';
			data += '<input type="hidden" id="ombudsman_ombudsman_'+newnum+'" name="ombudsman_ombudsman_'+newnum+'" value="" />';
			data += '<table cellspacing="0" cellpadding="0" width="100%" id="ombudsman_read_'+newnum+'" style="display:none;">';
			data += '	<tr>';
      data += '		<td class="white right_border"><a href="#" onClick="javascript:removeOmbudsman('+newnum+', 0);return false;"><img id="ombudsman_expand_{$i}" src="/images/icons/delete.png" border="0" alt="Remove" title="Remove" /></a></td>';
			data += '		<td class="white"><a href="#" onClick="javascript:toggleOmbudsman('+newnum+');return false;"><img src="/images/btn_buddy.jpg" border="0" alt="Edit" title="Edit" /></a></td>';
      data += '		<td nowrap="nowrap" id="ombudsman_read_ombudsman_name_'+newnum+'"> &nbsp;</td>';
			data += '		<td class="white2" width="250" id="ombudsman_read_ombudsman_email_'+newnum+'">&nbsp;</td>';
			data += '		<td class="white2" width="150" id="ombudsman_read_ombudsman_phone_'+newnum+'">&nbsp;</td>';
			data += '		<td class="white2" width="20">&nbsp;</td>';
			data += '	</tr>';
			data += '</table></div>';
						
			data += '<div>';
			data += '<input type="hidden" name="ombudsman_write_ombudsman_'+newnum+'" id="ombudsman_write_ombudsman_'+newnum+'" value="0" />';
			data += '<table cellspacing="0" cellpadding="0" width="100%" id="ombudsman_write_'+newnum+'">';
			data += '<tr>';
     	data += '		<td class="white right_border"><a href="#" onClick="javascript:toggleOmbudsman('+newnum+');return false;"><img id="ombudsman_expand_'+newnum+'" src="/images/btn_red_x.gif" border="0" alt="Remove" title="Remove" /></a></td>';
		 	data += '		<td class="white"><img id="ombudsman_buddy_'+newnum+'" src="/images/btn_buddy.jpg" border="0" alt="Edit" title="Edit" /></td>';
     	data += '		<td nowrap="nowrap"> <input type="text" size="20" name="ombudsman_write_last_name_'+newnum+'" id="ombudsman_write_last_name_'+newnum+'" onkeyup="javascript:getOmbudsmanList('+newnum+', '+db_id+')" value="Last Name" onfocus="if(this.value==\'Last Name\'){this.value=\'\';}"  />, <input type="text" size="20" name="ombudsman_write_first_name_'+newnum+'" id="ombudsman_write_first_name_'+newnum+'" onkeyup="javascript:getOmbudsmanList('+newnum+', '+db_id+')" value="First Name" onfocus="if(this.value==\'First Name\'){this.value=\'\';}"  /></td>';
		 	data += '		<td class="white2" width="250"><input type="text" size="25" name="ombudsman_write_email_'+newnum+'" id="ombudsman_write_email_'+newnum+'" onkeyup="javascript:getOmbudsmanList('+newnum+', '+db_id+')" value="Email Address" onfocus="if(this.value==\'Email Address\'){this.value=\'\';}" /></td>';
		 	data += '		<td class="white2" width="150"><input type="text" size="25" name="ombudsman_write_phone_'+newnum+'" id="ombudsman_write_phone_'+newnum+'" onkeyup="javascript:getOmbudsmanList('+newnum+', '+db_id+')" value="Phone" onfocus="if(this.value==\'Phone\'){this.value=\'\';}" /></td>';
		 	data += '		<td class="white2" width="20"><a href="#" onClick="javascript:updateOmbudsman('+newnum+');return false;"><img src="/images/btn_save.jpg" alt="Save" title="Save" /></a></td>';
			data += '</tr>';
			data += '</table></div>';
		
			document.getElementById("ombudsman_ids").value = document.getElementById("ombudsman_ids").value.replace(","+newnum+",", ",");
			document.getElementById("ombudsman_ids").value += newnum+",";
			t.innerHTML += data;
		}else{
			alert("ERROR: You must save or cancel your open ombudsman.");
		}
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	/*  ################################  COMMANDER CONTROLS  ################################  */
	
	
	
	
	function getCommanderList(id, command_id){
		document.getElementById("commander_write_commander_" + id).value = 0;
		ln = document.getElementById("commander_write_last_name_" + id).value;
		fn = document.getElementById("commander_write_first_name_" + id).value;
		e = document.getElementById("commander_write_email_" + id).value;
		p = document.getElementById("commander_write_phone_" + id).value;
		new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=commander_list&db_id='+command_id+'&id='+id+'&ln='+ln+'&fn='+fn+'&e='+e+'&p='+p+''+'&nocache='+Math.random(),
			{
				method:'get',
				onSuccess: function(transport){
						document.getElementById("commander_popup").innerHTML =  transport.responseText;
						var pos = Position.get(document.getElementById("commander_buddy_"+id));
						Position.set("commander_popup",pos,pos, -2, 30);
				},
				onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
			});
	}
	
	function addCommanderFromPopUp(id, db_id, ln, fn, e, p){
		document.getElementById("commander_write_commander_" + id).value = db_id;
		document.getElementById("commander_write_last_name_" + id).value = ln;
		document.getElementById("commander_write_first_name_" + id).value = fn;
		document.getElementById("commander_write_email_" + id).value = e;
		document.getElementById("commander_write_phone_" + id).value = p;
		document.getElementById("commander_popup").innerHTML = "";
	}
	
	function toggleCommander(id){
		db_id = document.getElementById("id").value
		if(document.getElementById("commander_id_"+id).value>0){
			r = document.getElementById("commander_read_"+id);
			w = document.getElementById("commander_write_"+id);
			if(r.style.display == 'none'){
				document.getElementById("commander_popup").innerHTML = "";
				r.style.display = '';
				w.style.display = 'none';
			  disableCommander = false;
			}else{
				if(!disableCommander){
					r.style.display = 'none';
					w.style.display = '';
					disableCommander = true;
				}else{
					alert("ERROR: You must select an commander.");
				}
			}
		}else{
			document.getElementById("commander_popup").innerHTML = "";
			removeCommander(id);
			disableCommander = false;
		}
	}

	
	
	function updateCommander2(id, member_id){
		new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=get_commander&member_id='+member_id+'&nocache='+Math.random(),
			{
				method:'get',
				onSuccess: function(transport){
					var response = transport.responseText || "no response text";
					response = response.split("||");
	       
					document.getElementById("commander_write_commander_"+id).value = response[0];
					document.getElementById("commander_write_last_name_"+id).value = response[1];
					document.getElementById("commander_write_first_name_"+id).value = response[2];
					document.getElementById("commander_write_email_"+id).value = response[3];
					document.getElementById("commander_write_phone_"+id).value = response[4];
					document.getElementById("commander_read_commander_rank_"+id).value = response[5];
					updateCommander(id);
				},
				onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
			});
	}
	

	function updateCommander(id){
	    var err = false;
	    var msg = "";
	    if(document.getElementById("commander_write_last_name_"+id).value == "" || document.getElementById("commander_write_last_name_"+id).value == "Last Name"){
	        msg += " - Please enter a Last Name \n";
	        err = true;
	    }
	    if(document.getElementById("commander_write_first_name_"+id).value == "" || document.getElementById("commander_write_first_name_"+id).value == "First Name"){
	        msg += " - Please enter a First Name \n";
	        err = true;
	    }
	    if(document.getElementById("commander_write_email_"+id).value == "" || document.getElementById("commander_write_email_"+id).value == "Email Address"){
	        msg += " - Please enter an Email Address \n";
	        err = true;
	    }
	   /* if(document.getElementById("commander_write_phone_"+id).value == "" || document.getElementById("commander_write_phone_"+id).value == "Phone"){
	        msg += " - Please enter a valid Phone Number \n";
	        err = true;
	    }*/
	        
	
	    if(err){
	        alert("There are some errors with your submission: \n \n" + msg);
	    }else{
		    document.getElementById("commander_popup").innerHTML = "";
		    db_id = document.getElementById("id").value
		    if(document.getElementById("commander_write_commander_"+id).value>0){
			    document.getElementById("commander_commander_"+id).value = document.getElementById("commander_write_commander_"+id).value;
			    document.getElementById("commander_read_commander_name_"+id).innerHTML = document.getElementById("commander_write_last_name_"+id).value + ", " + document.getElementById("commander_write_first_name_"+id).value;
			    document.getElementById("commander_read_commander_email_"+id).innerHTML = document.getElementById("commander_write_email_"+id).value + "&nbsp;";
			    document.getElementById("commander_read_commander_phone_"+id).innerHTML = document.getElementById("commander_write_phone_"+id).value + "&nbsp;";
				
				new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=get_commander&member_id='+document.getElementById("commander_write_commander_"+id).value+'&nocache='+Math.random(),
			    {
				    method:'get',
				    onSuccess: function(transport){
					    var response = transport.responseText || "no response text";
					    response = response.split("||");
					    document.getElementById("commander_read_commander_name_"+id).innerHTML += " ("+response[5]+")";
					    document.getElementById("commander_read_commander_rank_"+id).innerHTML = response[5];
				    },
				    onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
			    });
				
				
			    document.getElementById("commander_ids").value = document.getElementById("commander_ids").value.replace(","+id+",", ",");
			    document.getElementById("commander_ids").value += id+",";
			    new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=commander&action=update&db_id='+db_id+'&old_id='+document.getElementById("commander_id_"+id).value+'&val='+document.getElementById("commander_commander_"+id).value+'&nocache='+Math.random(),
			    {
				    method:'get',
				    onSuccess: function(transport){
					    var response = transport.responseText || "no response text";
					    response = response.split("||");
					    document.getElementById("commander_id_"+id).value = response[0];
					    toggleCommander(id);
				    },
				    onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
			    });
		    }else{
    			
				    document.getElementById("commander_read_commander_name_"+id).innerHTML = document.getElementById("commander_write_last_name_"+id).value + ", " + document.getElementById("commander_write_first_name_"+id).value;
				    document.getElementById("commander_read_commander_email_"+id).innerHTML = document.getElementById("commander_write_email_"+id).value + "&nbsp;";
				    document.getElementById("commander_read_commander_phone_"+id).innerHTML = document.getElementById("commander_write_phone_"+id).value + "&nbsp;";
				    ln = document.getElementById("commander_write_last_name_" + id).value;
				    fn = document.getElementById("commander_write_first_name_" + id).value;
				    e = document.getElementById("commander_write_email_" + id).value;
				    p = document.getElementById("commander_write_phone_" + id).value;
				    new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=commander&action=insert&id='+id+'&db_id='+db_id+'&ln='+ln+'&fn='+fn+'&e='+e+'&p='+p+''+'&nocache='+Math.random(),
				    {
					    method:'get',
					    onSuccess: function(transport){
						    var response = transport.responseText || "no response text";
						    response = response.split("||");
    						
						    if(response[0]=="exists"){
							   // msg = "<div id='black_box2'></div><div id='modal'>";
							   // msg += "<h1>Duplicate Found</h1>";
							   // msg += "<p>An commander using the same email has been found. Would you like to use the following commander?</p>";
							   // msg += response[1];
							  //  msg += "<p align='center'><a href='#' onclick=\"updateCommander2('"+id+"', '"+response[2]+"');document.getElementById('commander_msg2').style.display='none';hideModal();return false;\"><img src='/images/btn_modal_yes.gif' border='0' /></a> <a href='#' onclick=\"document.getElementById('commander_msg2').style.display='none';hideModal();return false;\"><img src='/images/btn_modal_no.gif' border='0' /></a></p>";
							  //  msg += "</div>";
							    
							    

							    
msg = '<div id="black_box"></div><div id="modal"><div id="popper0" style="-moz-user-select: none; position: absolute; top: 0; left: 0; width: 500px; height: 150px; z-index: 99;" unselectable="on">';
msg += '<table cellspacing="0" cellpadding="0" border="0" style="width: 100%; height: 100%; -moz-user-select: none;" unselectable="on">';
msg += '    <tbody>';
msg += '      <tr height="25" unselectable="on">';
msg += '        <td unselectable="on"><table cellspacing="0" cellpadding="0" border="0" style="width: 100%; height: 100%; -moz-user-select: none;" unselectable="on">';
msg += '            <tbody>';
msg += '              <tr id="dragbar0" unselectable="on">';
msg += '                <td width="25" height="25" unselectable="on"><img width="25" height="25" src="/images/popup_topleft.gif" unselectable="on"/> </td>';
msg += '                <td class="popupTitle" width="100%" height="25" style="background-image: url(/images/popup_topbg.gif);" unselectable="on"><div class="PopupDivText" style="width: 520px;" unselectable="on">Duplicate User Found</div></td>';
msg += '                <td width="25" height="25" onclick="SetReturnValue(null); DisposePopup();" unselectable="on"><a href="#" onclick="document.getElementById(\'commander_msg2\').style.display=\'none\';hideModal();return false;"><img width="25" height="25" src="/images/popup_topright.gif" border="0" unselectable="on"/></a> </td>';
msg += '              </tr>';
msg += '            </tbody>';
msg += '          </table></td>';
msg += '      </tr>';
msg += '      <tr>';
msg += '        <td class="popupBody" unselectable="on">' + response[1] + '</td>';
msg += '      </tr>';
msg += '    </tbody>';
msg += '  </table>';
msg += '</div></div>';
							    
							    
							    
							    
							    	
							    document.getElementById("commander_msg2").innerHTML = msg;
							    document.getElementById('commander_msg2').style.display='';
							    setDiv2();
    							
						    }else if(response[0]=="dup"){
							    document.getElementById("commander_id_"+id).value = response[0];
							    document.getElementById("commander_write_commander_"+id).value = response[0];
							   // toggleCommander(id);
							    msg = "<div id='msg'>";
							    msg += "<h1>Duplicate Email</h1>";
							    msg += "<p>A commander already exists in the system with the given email address. This commander is also already assigned to this command.</p>";
							    msg += "<p align='right'><a href='#' onclick=\"document.getElementById('msg').style.display='none';return false;\">Close</a></p>";
							    msg += "</div>";	
							    document.getElementById("commander_msg").innerHTML = msg;
						    }else{
							    document.getElementById("commander_id_"+id).value = response[0];
							    document.getElementById("commander_write_commander_"+id).value = response[0];
							    toggleCommander(id);
							    msg = "<div id='msg'>";
							    msg += "<h1>Commander Saved Successfully</h1>";
							    msg += "<p>An activation link has been sent to the Commander.</p>";
							    msg += "<p align='right'><a href='#' onclick=\"document.getElementById('msg').style.display='none';return false;\">Close</a></p>";
							    msg += "</div>";	
							    document.getElementById("commander_msg").innerHTML = msg;
						    }
					    },
					    onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
				    });
    				
		    }
		}
	}

	function removeCommander(id){
		if(document.getElementById("commander_write_commander_"+id).value>0 && document.getElementById("commander_id_"+id).value>0){
			val = confirm("Are you sure you want to delete the selected Commander?");
			if(val){
				db_id = document.getElementById("id").value
				new Ajax.Request('/_modules/command/_ajax/command_controller.aspx?type=commander&action=delete&db_id='+db_id+'&id='+document.getElementById("commander_id_"+id).value+'&nocache='+Math.random(),
				{
					method:'get',
					onSuccess: function(transport){
						var response = transport.responseText || "no response text";
					},
					onFailure: function(){ alert('ERROR: Error loading file.\n\nYou may have lost your session.  Try logging in and back out to alleviate this problem.') }
				});
				r = document.getElementById("commander_read_"+id);
				w = document.getElementById("commander_write_"+id);
				r.parentNode.style.display = 'none';
				w.parentNode.style.display = 'none';
				r.parentNode.innerHTML = "";
				w.parentNode.innerHTML = "";
				document.getElementById("commander_ids").value = document.getElementById("commander_ids").value.replace(","+id+",", ",");
			}
		}else{
			r = document.getElementById("commander_read_"+id);
			w = document.getElementById("commander_write_"+id);
			r.parentNode.style.display = 'none';
			w.parentNode.style.display = 'none';
			r.parentNode.innerHTML = "";
			w.parentNode.innerHTML = "";
			document.getElementById("commander_ids").value = document.getElementById("commander_ids").value.replace(","+id+",", ",");
		}
	}

	function addCommander(target){
		db_id = document.getElementById("id").value
		if(!disableCommander){
			disableCommander = true;
			ids = document.getElementById("commander_ids").value;
			t = document.getElementById(target);
			ids = ids.split(",");
			maxnum = 0;
			for(i=0;i<ids.length;i++){
				if(maxnum < ids[i]){
					maxnum  = ids[i];
				}
			}
			newnum = parseInt(maxnum)+1;
				
			data = '<div><input type="hidden" id="commander_id_'+newnum+'" name="commander_id_'+newnum+'" value="" />';
			data += '<input type="hidden" id="commander_commander_'+newnum+'" name="commander_commander_'+newnum+'" value="" />';
			data += '<table cellspacing="0" cellpadding="0" width="100%" id="commander_read_'+newnum+'" style="display:none;">';
			data += '	<tr>';
            data += '		<td class="white right_border"><a href="#" onClick="javascript:removeCommander('+newnum+', 0);return false;"><img id="commander_expand_{$i}" src="/images/icons/delete.png" border="0" alt="Remove" title="Remove" /></a></td>';
			data += '		<td class="white"><a href="#" onClick="javascript:toggleCommander('+newnum+');return false;"><img src="/images/btn_buddy.jpg" border="0" alt="Edit" title="Edit" /></a></td>';
            data += '		<td nowrap="nowrap" id="commander_read_commander_name_'+newnum+'"> &nbsp;</td>';
			data += '		<!--<td class="white2" width="50" id="commander_read_commander_rank_'+newnum+'">&nbsp;</td>-->';
			data += '		<td class="white2" width="250" id="commander_read_commander_email_'+newnum+'">&nbsp;</td>';
			data += '		<td class="white2" width="150" id="commander_read_commander_phone_'+newnum+'">&nbsp;</td>';
			data += '		<td class="white2" width="20">&nbsp;</td>';
			data += '	</tr>';
			data += '</table></div>';
						
			data += '<div>';
			data += '<input type="hidden" name="commander_write_commander_'+newnum+'" id="commander_write_commander_'+newnum+'" value="0" />';
			data += '<table cellspacing="0" cellpadding="0" width="100%" id="commander_write_'+newnum+'">';
			data += '<tr>';
     	    data += '		<td class="white right_border"><a href="#" onClick="javascript:toggleCommander('+newnum+');return false;"><img id="commander_expand_'+newnum+'" src="/images/btn_red_x.gif" border="0" alt="Remove" title="Remove" /></a></td>';
		 	data += '		<td class="white"><img id="commander_buddy_'+newnum+'" src="/images/btn_buddy.jpg" border="0" alt="Edit" title="Edit" /></td>';
     	    data += '		<td nowrap="nowrap"> <input type="text" size="20" name="commander_write_last_name_'+newnum+'" id="commander_write_last_name_'+newnum+'" onkeyup="javascript:getCommanderList('+newnum+', '+db_id+')" value="Last Name" onfocus="if(this.value==\'Last Name\'){this.value=\'\';}"  />, <input type="text" size="20" name="commander_write_first_name_'+newnum+'" id="commander_write_first_name_'+newnum+'" onkeyup="javascript:getCommanderList('+newnum+', '+db_id+')" value="First Name" onfocus="if(this.value==\'First Name\'){this.value=\'\';}"  /></td>';
		 	data += '		<td class="white2" width="250"><input type="text" size="25" name="commander_write_email_'+newnum+'" id="commander_write_email_'+newnum+'" onkeyup="javascript:getCommanderList('+newnum+', '+db_id+')" value="Email Address" onfocus="if(this.value==\'Email Address\'){this.value=\'\';}" /></td>';
		 	data += '		<td class="white2" width="150"><input type="text" size="25" name="commander_write_phone_'+newnum+'" id="commander_write_phone_'+newnum+'" onkeyup="javascript:getCommanderList('+newnum+', '+db_id+')" value="Phone" onfocus="if(this.value==\'Phone\'){this.value=\'\';}" /></td>';
		 	data += '		<td class="white2" width="20"><a href="#" onClick="javascript:updateCommander('+newnum+');return false;"><img src="/images/btn_save.jpg" alt="Save" title="Save" /></a></td>';
			data += '</tr>';
			data += '</table></div>';
		
			document.getElementById("commander_ids").value = document.getElementById("commander_ids").value.replace(","+newnum+",", ",");
			document.getElementById("commander_ids").value += newnum+",";
			t.innerHTML += data;
		}else{
			alert("ERROR: You must save or cancel your open commander.");
		}
	}
	
	
	/*
	
    var timerPROMPT = 0;
    
    function StopTiming(){
        if(timerPROMPT > 0)
            window.clearTimeout(timerPROMPT)
        if (confirm('Due to inactivity, your session is about to time out. Click OK in the next 30 seconds to extend time.') == 1){
            new Ajax.Request('/',
				{
					method:'get',
					onSuccess: function(transport){
					},
					onFailure: function(){ alert('ERROR: Load File') }
				});
            timerPROMPT = window.setTimeout("StopTiming()",1800000);
        }
    }
    function window_activity() {
        if(timerPROMPT > 0)
            window.clearTimeout(timerPROMPT)

        timerPROMPT = window.setTimeout("StopTiming()",1800000);
    }*/
    function window_activity() {
		}