<!--//
function js_validate(form_name){
    if(form_name=="frmmain_ws"){
        doc = document.frmmain_ws;
        if(doc.txtun.value!="" && doc.txtpwd.value!="" && doc.txtrepwd.value!=""){
            if(doc.txtpwd.value == doc.txtrepwd.value){
                return true;
            }else{
                alert("Both passwords do not match.  Please try again.");
                doc.txtpwd.value="";
                doc.txtrepwd.value="";
                doc.txtpwd.focus();
                return false;
            }
        }else{
            alert("All fields are required.  Please try again.");
            return false;
        }
    }
}

function js_stop(ip){
    var frm = document.frmmain;
    frm.hidIP.value=ip;
    frm.action='ss_do.jsp?action=0';
    frm.submit();
}

function js_start(ip){
    var frm = document.frmmain;
    frm.hidIP.value=ip;
    frm.action='ss_do.jsp?action=1';
    frm.submit();
}

function js_write_table(){
//collector delimiter is ~
//the field delimiter is ::

    var classname = "";
    var isSilver = true;
    var values = document.frmmain.hidvalue.value;
    //alert("values is "+values);
    if(values!=''){ 
        var output = js_writeTableHeader();
        collectors = values.split("~");
        //alert("collectors.length is " + collectors.length);
        for(i=0;i < collectors.length;i++){
            fields = collectors[i].split("::");
            if(i==0){
                classname="\"datarowtop\"";
            }else{
                if(isSilver){
                    classname="\"datarowsilver\"";
                }else{
                    classname="\"datarowwhite\"";
                }
                isSilver = !isSilver;
            }
            output += "<tr>";
            output += "<td class="+classname+" width=\"5%\"><input type=\"checkbox\" onclick=\"javascript:js_remove('"+i+"')\" name=\"checkbox\" value=\"checkbox\"></td>";
            output += "<td class="+classname+" width=\"20%\">"+fields[0]+"</td>";
            output += "<td class="+classname+" width=\"35%\">";
            if(fields[1]=="in"){
                output += "Internal Process";
            }else{
                output += "External Process";
            }
            output += "</td>";
            output += "<td  class="+classname+">"+fields[2]+"</td>";
            output += "<td  class="+classname+">"+fields[3]+"</td>";
            output += "</tr>";
        }
        var finaloutput = js_writeTail(output);
        
        document.getElementById("dyna_table_row").innerHTML = finaloutput;
    }
}

function js_writeTableHeader(){
    var output = "<table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"3\">";
    output += "      <tr class=\"columnheader\">";
    output +="        <td width=\"5%\">Remove</td>";
    output +="        <td width=\"20%\">Name</td>";
    output +="        <td width=\"10%\">Process Type</td>";
    output +="        <td width=\"30%\">Fully Qualified Name or Path</td>";
    output +="        <td width=\"35%\">Parameters</td>";
    output +="      </tr>   ";
    return output;
}

function js_writeTail(data){
    var output = data;
    output+="      <tr>";
    output+="        <td class=\"datarowtop\">&nbsp;</td>";
    output+="        <td class=\"datarowtop\">&nbsp;</td>";
    output+="        <td class=\"datarowtop\">&nbsp;</td>";
    output+="        <td class=\"datarowtop\">&nbsp;</td>";
    output+="        <td class=\"datarowtop\">&nbsp;</td>";
    output+="      </tr>";
    output+="    </table>   ";
    return output;  
}

function js_attach_value(){
    var doc = document.frmmain;
    if(doc.txtcname.value==''||doc.selprocess.value=='-99'||
        doc.txtfqn.value==''||doc.txtparam.value==''){
            alert("You must fill in all fields.");
            return;
    }else{
    /*
        var fqn = doc.txtfqn.value.replace("\\","/");
        attachment = doc.txtcname.value+"::"+doc.selprocess.value+"::"+fqn+"::"+doc.txtparam.value;
        */
        attachment = doc.txtcname.value+"::"+doc.selprocess.value+"::"+doc.txtfqn.value+"::"+doc.txtparam.value;
        if(doc.hidvalue.value==''){
            doc.hidvalue.value = attachment;
        }else{
            doc.hidvalue.value += "~"+attachment;
        }
        js_write_table();
        doc.txtcname.value="";
        doc.selprocess.value="-99";
        doc.txtfqn.value="";
        doc.txtparam.value="";
    }
}

function js_remove(id){
    var collectors = document.frmmain.hidvalue.value.split("~");
    //alert(collectors.length-1);
    if((collectors.length-1)==0){
        remove_all();
        return;
    }
    var newcollectors = new Array(collectors.length-1);
    z=0;
    for(x=0;x<collectors.length;x++){
        if(x!=id){
            newcollectors[z]=collectors[x];
            //alert(collectors[x]);
            z++;
        }
    }
    var doc = document.frmmain;
    var newvalue = "";
    doc.hidvalue.value = "";
    for(y=0;y<newcollectors.length;y++){
        if(y==0){
            newvalue = newcollectors[y];
        }else{
            newvalue += "~"+newcollectors[y];
        }
    }
    doc.hidvalue.value=newvalue;
    //alert("new value is "+newvalue);
    js_write_table();
}

function js_remove_all(){
    var doc = document.frmmain;
    doc.hidvalue.value="";
    document.getElementById("dyna_table_row").innerHTML = "";
}

function js_updatevalues(id,cssclass,value){
    if(document.all){
        document.all(id).innerHTML=value;
    }else if(document.getElementById){
        document.getElementById(id).innerHTML=value;
    }
}

function js_updateColors(id,value){
    if(document.all){
        document.all(id).style.color=value;
    }else if(document.getElementById){
        document.getElementById(id).style.color=value;
    }
}

function openwin(thename,theurl,thewidth,theheight){
    var spec="toolbar=no,status=no,width="+thewidth+",height="+theheight;
    window.open(theurl,thename,spec);
}

//The delimit_opt_label_value param is 
//[option label],[option value];[option label],[option value];...
function js_updatelist(form_name,select_name,delimit_opt_label_value){
    objsel = document.forms[form_name].elements[select_name];
    objoptions = delimit_opt_label_value.split(";");
    if(objsel.options.length>0){
        for(i=0;i<objsel.options.length;i++){
            objsel.options[0]=null
        }
    }
    for(j=0;j<objoptions.length;j++){
        labelvalue=objoptions[j].split(",");
        objsel.options[j]=new Option(labelvalue[0],labelvalue[1]);
    }
}
// For Reset SeeNet Database
function js_checkagent(){
   var doc = document.resetdbform
   if(doc.agent.checked==true){
      doc.component.checked=true;
      doc.counter.checked=true;
   }else{
      doc.component.checked=false;
      doc.counter.checked=false;
      doc.agent.checked=false;
   }
}
// For Reset SeeNet Database   
function js_uncheckall(){
   var doc = document.resetdbform
   doc.component.checked=false;
   doc.counter.checked=false;
   doc.all.checked=false;
   doc.agent.checked=false;
}
// For Reset SeeNet Database
function js_checkall(){
   var doc = document.resetdbform
   if(doc.all.checked==true){
      doc.component.checked=true;
      doc.counter.checked=true;
      doc.agent.checked=true;
   }else{
      doc.component.checked=false;
      doc.counter.checked=false;
      doc.all.checked=false;
      doc.agent.checked=false;
   }
}

function minOrmax(id,pic){
    var tipobj2=document.all? document.all[id] : document.getElementById? document.getElementById(id) : ""
    if(tipobj2.style.visibility=="hidden"){
        tipobj2.style.visibility="visible";
        document[pic].src="images/collapse.gif";
    }else{
        tipobj2.style.visibility="hidden";
        document[pic].src="images/maximize.gif";
    }
}


function js_writesystable(val){
//	alert(val);
//	alert(js_sysmonheader());
	head="";
//	head=js_sysmonheader();
	body="";
//	vals=val.split(";");
	vals=val.split("`");
	
	if(vals[0]=="-^^^"){
		head=js_sysmonheader(vals[1]);
		body="  <tr><td colspan=\"5\" class=\"sys_lvl1\" align=\"center\">0 SERVERS ARE COLLECTED</td></tr>";
	}else{
		head=js_sysmonheader(vals[1]);
		recs = vals[0].split(";");
		for(i=0;i<recs.length;i++){
			fields=recs[i].split(",");
			if(i==0)
				body="<tr><td colspan=\"5\" class=\"sys_lvl1\">"+ fields[0] +"</td></tr>";
			else
				body+="<tr><td colspan=\"5\" class=\"sys_lvl1\">"+ fields[0] +"</td></tr>";
			
			body+="<tr>";
			body+="<td class=\"sys_lvl2\"><a href=\"javascript:js_openwin('syswin','sysdetail.jsp?agent_id="+fields[7]+"&type=1','690','580')\"><img border=\"0\" src=\""+js_getImage(fields[3])+"\" width=\"16\" height=\"16\"></a></td>";										
			body+="<td class=\"sys_lvl2\"><a href=\"javascript:js_openwin('syswin','sysdetail.jsp?agent_id="+fields[7]+"&type=2','690','580')\"><img border=\"0\" src=\""+js_getImage(fields[1])+"\" width=\"16\" height=\"16\"></a></td>";										
			body+="<td class=\"sys_lvl2\"><a href=\"javascript:js_openwin('syswin','sysdetail.jsp?agent_id="+fields[7]+"&type=4','690','580')\"><img border=\"0\" src=\""+js_getImage(fields[2])+"\" width=\"16\" height=\"16\"></a></td>";										
			body+="<td class=\"sys_lvl2\"><a href=\"javascript:js_openwin('syswin','sysdetail.jsp?agent_id="+fields[7]+"&type=3','690','580')\"><img border=\"0\" src=\""+js_getImage(fields[5])+"\" width=\"16\" height=\"16\"></a></td>";										
			body+="<td class=\"sys_lvl2\">"+js_procGood(fields[4])+"</td>";
			body+="</tr>";
		}
	}
	tail="</table>";
	output=head+body+tail;
//	alert(output);
	
	divsys=document.all? document.all['divsysmon'] : document.getElementById? document.getElementById('divsysmon') : ""
	divsys.innerHTML=output;
}
function js_procGood(val){
	if(val=="-666"){
		return "0";
	}else{
		return val;
	}
}
function js_getImage(val){
    goodimg=new Image()
    goodimg.src="images/good.gif";
    yelimg=new Image();
    yelimg.src="images/yel_warn.gif";
    redimg=new Image();
    redimg.src="images/red_err.gif";
    nodataimg=new Image();
    nodataimg.src="images/nodata.gif";
    if(val=="-666")
        return nodataimg.src;
    else if(parseFloat(val)>=0 && parseFloat(val)<=30)
        return goodimg.src;
    else if(parseFloat(val)>30 && parseFloat(val)<=60)
        return yelimg.src;
    else if(parseFloat(val)>60)
        return redimg.src;
    else
        return nodataimg.src;       
}


function js_sysmonheader(val){
    htm="<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\">"+
      "<tr align=\"right\">"+
        "<td colspan=\"5\" class=\"sys_legend\"><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"3\">"+
        "      <tr>"+
        "        <td width=\"50%\" align=\"left\"><img src=\"images/good.gif\" width=\"16\" height=\"16\" align=\"middle\"> 0% - 30% </td>"+
        "        <td width=\"50%\" align=\"left\"><img src=\"images/yel_warn.gif\" width=\"16\" height=\"16\" align=\"middle\"> 31% - 60% </td>"+
        "      </tr>"+
        "      <tr>"+
        "        <td align=\"left\"><img src=\"images/red_err.gif\" width=\"16\" height=\"16\" align=\"middle\"> 61% - 100+% </td>"+
        "        <td align=\"left\"><img src=\"images/nodata.gif\" width=\"16\" height=\"16\" align=\"middle\"> NO DATA </td>"+
        "      </tr>"+
        "    </table></td>"+
      "</tr>"+
      "<tr align=\"right\">"+
      "  <td colspan=\"5\" class=\"asof\" align=\"center\"><span id=\"asof\">"+val+"</span></td>"+
      "</tr>"+
      "<tr>"+
        "<td width=\"39\" class=\"sys_legend\"><img src=\"images/cpu_lbl.gif\" width=\"32\" height=\"45\"></td>"+
        "<td width=\"39\" class=\"sys_legend\"><img src=\"images/memory_lbl.gif\" width=\"32\" height=\"45\"></td>"+
        "<td width=\"39\" class=\"sys_legend\"><img src=\"images/disk_lbl.gif\" width=\"32\" height=\"45\"></td>"+
        "<td width=\"39\" class=\"sys_legend\"><img src=\"images/nic_lbl.gif\" width=\"32\" height=\"45\"></td>"+
        "<td width=\"39\" class=\"sys_legend\"><img src=\"images/process_lbl.gif\" width=\"32\" height=\"45\"></td>"+
      "</tr>";
    return htm; 
}

function js_text(id,val){
    label=document.all? document.all[id] : document.getElementById? document.getElementById(id) : ""
    label.innerHTML=val;
}

function msg(val){
    alert(val);
}

function js_openwin(thename,theurl,thewidth,theheight){
    var spec="toolbar=no,status=no,width="+thewidth+",height="+theheight;
    window.open(theurl,thename,spec);
}

-->