// @name      Brown Richards Edit Functions
// @author    Jon Booth/NewTerminus (www.newterminus.com)

function loadProv(id){
            pid=id;
            sendReq('temp_snippets.php','corebox','','coreData',id,'',0);
            showhide('deptbox','block');
      }

//TOPIC functions
var topic_i=0;
      function addTopic(id,dept_i,topic_i){
	     if(id!="x"){
	     	showhide('topicbox','block');
                sendReq('temp_snippets.php','subt'+topic_i,'subt'+topic_i,'subList',id+'|'+topic_i+'|'+pid,'',0);
            }else{
		updateObj('subt1','');
		updateObj('subt2','');
		showhide('topicbox','none');
		topic_i=0;
            }
      }
function killTopic2(id){
            updateObj('subt'+id,'');
      }    

//FEATURE functions
      var ofeat_i=0;
      function addofeat(id){
            ofeat_i++;
            newcf=document.createElement("DIV");
            newcf.setAttribute('id','subcf_'+ofeat_i);
            document.getElementById('cf_'+id).appendChild(newcf);
            sendReq('temp_snippets.php','subcf_'+ofeat_i,'','cfForm',id+'|'+ofeat_i,'',0)
      }

//GENERAL functions
      function dropFields(id,i){
            if(i){
                  var par=document.getElementById('new'+id);
                  var kid = document.getElementById(id+'_'+i);
                  par.removeChild(kid);
            }else{
                  if(id=='mins'){
                        plid='minimums';
                  }else{
                        plid=id+'s';
                  }
                  updateObj('new'+id,'<a href=\"javascript:addFields(\''+id+'\');\">[add '+plid+']</a>');
            }
      }
      
      function showhide(layer_ref,state,nofade) {
            if (document.getElementById) {
                  el = document.getElementById(layer_ref);
                  el.style.display = state;
                  if(!nofade){
                  if(state=='block' && layer_ref!='suggbox'){Fat.fade_element(layer_ref,12,600,'#ffff00')};
                  }
            }
      }

//FEE functions
      var fee_i=0;
      function addFee(amount,dur,prog,id,dname,pname) {
            newrow=document.createElement("TR");
             newrow.setAttribute('id','fee_'+fee_i);
             document.getElementById('feetable').appendChild(newrow);
             updateObj('fee_'+fee_i,'<td></td><td class=cost>$'+amount+'</td><td class=light>per</td><td>'+dname+'</td><td class=light>for</td><td>'+pname+'<span class=edmode> <a href=javascript:editRecord(\'fee\',\''+amount+'|'+dur+'|'+prog+'|'+fee_i+'\',\'fee_'+fee_i+'\',\''+id+'\');>(e)</a> <a href=javascript:killRecord(\'fee\',\''+dur+prog+'\',\'fee_'+fee_i+'\',\'fee_record\',\''+id+'\');>(x)</a></span></td>');
            fee_i++;
      }
      var rate_i=0;
      function newRate(topic){
            rate_i++;
            newrate=document.createElement("DIV");
            newrate.setAttribute('id','rate'+rate_i);
            newrate.setAttribute('class','onerate');
            document.getElementById('ratebox_'+topic).appendChild(newrate);
            sendReq('temp_snippets.php','rate'+rate_i,'','rateForm',topic,'',0);
      }

//COMMENT functions
      var comm_i=0;
      function commFields(div,type){
            comm_i++;
            newcom=document.createElement("DIV");
            newcom.setAttribute('id','comm_'+comm_i);
            newcom.setAttribute('class','onerate');
            document.getElementById('all_comm').appendChild(newcom);
            sendReq('temp_snippets.php','comm_'+comm_i,'','commForm',comm_i+'|'+type+'|'+comm_i+'|'+pid,'',0);
      }
      
      function dropComm(i){
            var par=document.getElementById('all_comm');
            var kid = document.getElementById('comm_'+i);
            par.removeChild(kid);
      }
      
