

	function findObj(theObj, theDoc)                {
        var p, i, foundObj;

        if(!theDoc) theDoc = document;

        if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)              {
                theDoc = parent.frames[theObj.substring(p+1)].document;
                theObj = theObj.substring(0,p);
        }

        if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all 
[theObj];

        for (i=0; !foundObj && i < theDoc.forms.length; i++)
                foundObj = theDoc.forms[i][theObj];
                for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
                        foundObj = findObj(theObj,theDoc.layers[i].document);

        if(!foundObj && document.getElementById) foundObj =  
document.getElementById(theObj);
        return foundObj;
}





function sendcommand( scommand, sessionid )
{
	var xmlHttpReq = false;
    var self = this;
    var d = new Date();
    
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }     
    
    self.xmlHttpReq.open('GET', "https://www.lockboxdata.com/l/folder.php?sessionid=" + sessionid + scommand + "&d=" + d.valueOf() , true);
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send();
}



function loadfile( fileid, sessionid )
{
	var xmlHttpReq = false;
    var self = this;
    var d = new Date();
    
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }     
    
    self.xmlHttpReq.open('GET', "https://www.lockboxdata.com/l/filedetails.php?sessionid=" + sessionid + "&file=" + fileid + "&d=" + d.valueOf() , true);
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            findObj("datacell").innerHTML=self.xmlHttpReq.responseText;
            ddtreemenu.createTree("treemenu3", false )
        }
    }
    self.xmlHttpReq.send("");
}



function checkemail( email , sessionid)
{
	var xmlHttpReq = false;
    var self = this;
    var d = new Date();
    
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }     
    
    self.xmlHttpReq.open('GET', "https://www.lockboxdata.com/l/checkemail.php?sessionid=" + sessionid + "&email=" + email + "&d=" + d.valueOf() , true);
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            checkcomplete(self.xmlHttpReq.responseText);
            
        }
    }
    self.xmlHttpReq.send("");
}


function checkaccount( account , sessionid)
{
	var xmlHttpReq = false;
    var self = this;
    var d = new Date();
    
    if( account.length < 6 )
    {
    	  accountcheckcomplete("short");
    	  
    	  return;
    }
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }     
    
    self.xmlHttpReq.open('GET', "https://www.lockboxdata.com/l/checkaccount.php?sessionid=" + sessionid + "&account=" + account + "&d=" + d.valueOf() , true);
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            accountcheckcomplete(self.xmlHttpReq.responseText);
            
        }
    }
    self.xmlHttpReq.send("");
}


function accountcheckcomplete(v )
{
	if( v ==  "OK" )
	{
		findObj('res').innerHTML="<b class=highlight>Account Available!</b>";
		return;
	}
	if( v ==  "short" )
	{
		findObj('res').innerHTML="<b class=error>The acccount name must be at least 6 characters.</b>";
		return;
	}
	
	findObj('res').innerHTML="<b class=error>That acccount name has already been used.</b>";
	findObj('actname').value="";
	
}
function checkid( salesid , sessionid)
{
	var xmlHttpReq = false;
    var self = this;
    var d = new Date();
    
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }     
    
    self.xmlHttpReq.open('GET', "https://www.lockboxdata.com/l/checkid.php?sessionid=" + sessionid + "&salesid=" + salesid + "&d=" + d.valueOf() , true);
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            idcheckcomplete(self.xmlHttpReq.responseText);
            
        }
    }
    self.xmlHttpReq.send("");
}


function addnewfoldercall( fileid, foldername )
{
	var xmlHttpReq = false;
    var self = this;
    var d = new Date();
    
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }     
    
    self.xmlHttpReq.open('GET', "https://www.lockboxdata.com/l/addfolder.php?sessionid=" + sessionid + "&foldername=" + foldername + "&fileid=" + fileid + "&d=" + d.valueOf() , true);
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            shownewfolder(self.xmlHttpReq.responseText, foldername);
        }
    }
    self.xmlHttpReq.send();
}




function updatepage(str){

  alert(str);
  
}
 
 
var aclasslist = new Array();
var aidlist = new Array();
var acount=0;

// preaload some things
aclasslist[0]="addit";
aidlist[0]="addit";

acount=1;

function cbtoggle( oid )
{
  if( ! findObj(oid ) ) return;
  
  var o = findObj(oid);
  
  if( acount==0 )
  {
    cbaddid( oid );
  }
  else
  {
     if( cbindex(oid)==-1 )
     {
       cbaddid(oid);
     }
  }
  if( o.className=='hidden' )
  {
     o.className=cbgetclass( oid );     

  }  
  else
    o.className='hidden';
    
}


function cbhover( oid )
{
  if( ! findObj(oid ) ) return;
  
  var o = findObj(oid);
  
  if( acount==0 )
  {
    cbaddid( oid );
  }
  else
  {
     if( cbindex(oid)==-1 )
     {
       cbaddid(oid);
     }
  }
  if( o.className=='isselected' )
  {
     o.className='notselected'
     
  }  
  else
    o.className='isselected';
    
}

function cbnohover( oid, oid2 )
{

  
  
  if( ! findObj(oid ) ) return;
  if( ! findObj(oid2 ) ) return;
  
  var o = findObj(oid);
  var o2 = findObj(oid2);
  if( acount==0 )
  {
    cbaddid( oid );
  }
  else
  {
     if( cbindex(oid)==-1 )
     {
       cbaddid(oid);
     }
  }
  
  if( o2.checked )
     o.className='isselected'
  else
    o.className='notselected';
    
}


function cbaddid( oid )
{
   aidlist[acount]=oid;
   if( findObj(oid).className != '' && findObj(oid).className !='hidden' )
     aclasslist[acount]=findObj(oid).className;
   else
     aclasslist[acount]='shown';
   acount++;
   
   
}

function cbindex( oid )
{
  for( i=0; i < acount; i++ )
  {
    if( aidlist[i]==oid )
      return i;
  }
  return -1;
}    

function cbgetclass( oid )
{
  var i=cbindex(oid )
  if( i > -1 )
  {
    return aclasslist[i];
  }
  return '';
}


function cbhidediv( oid )
{
  
    var obj=findObj(oid);
    if( obj) 
       obj.className='hidden';
 
}

 
 function cbhidediv( oid )
{
  
    var obj=findObj(oid);
    if( obj) 
       obj.className='hidden';
 
}

function cbshowdiv( oid, height, width )
{
    //hideElms('SELECT');
   
    var obj=findObj(oid);
    
	var top = (screen.availHeight-height) / 3;
	var left = ((document.body.clientWidth-width) / 2)+document.body.scrollLeft;
	top+=document.body.scrollTop;
    //left+=document.body.scrollLeft;
	obj.style.position="Absolute";
	obj.style.top=top;
	obj.style.left=left;
	obj.style.width=width;
	obj.style.height=height;
	//obj.style.display='';
	//cbtoggle( obj.id )
	cbtoggle( oid );
	obj.style.borderBottom='midnightblue 1px solid';
	obj.style.borderTop='midnightblue 1px solid';
	obj.style.borderLeft='midnightblue 1px solid';
	obj.style.borderRight='midnightblue 1px solid';
	
	
}

