
var tablist = Array();

function Trim(str)
{  while(str.charAt(0) == (" ") )
  {  str = str.substring(1);
  }
  while(str.charAt(str.length-1) == " " )
  {  str = str.substring(0,str.length-1);
  }
  return str;
}


function registerTabs(tabdiv, element, element2){

    tablist.push = new tabList(tabdiv, element, element2);

}

function tabList(tabdiv, element, element2){
    this.elements = element.split(",");
    this.nameelements = element2.split(",");
    this.panellist = new Array(); 
    this.newtab;
    this.tabArr = new Array();
    this.switchTab = switchTab;
    
    for(i=0; i<this.elements.length; i++){

        tablistDiv = document.getElementById(tabdiv);
        this.newtab = document.createElement("li");
        if(i==0){
            this.newtab.className = "tabListItemSel";
        }else{
            this.newtab.className = "tabListItem";
        }
;
        this.newtab.setAttribute("id", "tab"+i);
        this.newtab.innerHTML = this.nameelements[i];
        this.newtab.switchTab = switchTab;
        this.newtab.onclick = function(){this.switchTab();} 

        this.newtab.onmouseover = function(){
            if(this.className=="tabListItem"){
                this.className="tabListItemHov";
            }
        }

        this.newtab.onmouseout = function(){
            if(this.className=="tabListItemHov"){
                this.className="tabListItem";
            }   
        }       

        this.newtab.style.cursor = "pointer"; 
        this.newtab.target = this.elements[i];
        tablistDiv.appendChild(this.newtab);
        this.panellist.push(this.elements[i]);
        this.tabArr.push(this.newtab);
        this.newtab.panellist = this.panellist; 
        this.newtab.tabArr = this.tabArr;
    }

}

function switchTab(){
    tabs = this.panellist;
    tab = this.target;
    tab = tab.replace(" ", "");
    
        

    for(i=0; i<this.tabArr.length; i++){
        
        this.tabArr[i].className = "tabListItem";
        
    }   

    for(i=0; i<tabs.length;i++){        // cycle through tabs
        tabs[i]=tabs[i].replace(" ", "");
        var tabTarg = document.getElementById(tabs[i]);
        if(tabs[i]!=tab){
            tabTarg.className = "hidpage";
        }else{
            this.className = "tabListItemSel";
            tabTarg.className = "vispage";
        }
    }
}







function xmlhttpPost(strURL) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(strURL);
}


function copyvalues(){
    window.frames['saveframe'].setdatavalue(document.getElementById('sourcetarget').value);

}

    function updatepage(str){
        document.getElementById('sourcetarget').value = str;
        copyvalues();
    }

    function backupPage(){
        indicator('Backing Up Site!');
        document.getElementById('backupframe').src="admin/debug/backup.php"
    }
    
    function fadeOut(i){
        if(!i)i=0;
        if(i<100){
            i++;            
            window.setTimeout("fadeOut("+i+")", 300);
            document.getElementById('backupindicator').style.MozOpacity=(1/i);
        }
                
    }
    
    function indicator(value){
        fadeOut();
        document.getElementById('backupindicator').innerHTML=value;
        setTimeout("clearindicator()", 3000);
    }
    
    function clearindicator(){
        document.getElementById('backupindicator').innerHTML="";
    
    }
    
    function loadPage(value){
        src ="admin/debug/loadfile.php?file=";
        setMinHeading(value);
        xmlhttpPost(src + value);
    //  document.getElementById('sourcetarget').value = value; 
    }
    
    function setMinHeading(value){
        //window.frames['saveframe'].document.
        window.frames['saveframe'].setnamevalue(value);
        document.getElementById('minorheading').innerHTML = "Editing File: " + value;
    }
    
    
    function checkNull(value, object){
        if(value=="null"){
            object.disabled=true;   
        }else{
            object.disabled=false;

        }
    }
    
    function newNote(){
    
    }

