// Functions
var login = function(){
  var dbname = document.getElementById('databasename').value;
  xmlhttpPostEval('loginchk.php','dbname='+dbname);
}
function footer(){
text=""
text+=
text+='<table border="0" width="100%">'
text+='<tr>'
text+='<td width="100%" colspan="2" bgcolor="#006666" height="3"></td>'
text+='</tr>'
text+='</table>'
text+='<table border="0" width="99%">'
text+='<tr>'
text+='<td width="70%"><a class="footer">Copyright &copy; Chase Software Solutions. 2006. All rights reserved.</a></td>'
text+='<td>'
text+='<p align="right">'
text+='<a href="index.php" target="_top" class="footer">Home</a>'
text+='<a class="footer"> | (205)252-3119</a>'
text+='</td>'
text+='</tr>'
text+='</table>'
document.write(text)
}
function delconfirm(rdesc,command){
  var winw=370
  var winh=100
  screenw=screen.width
  screenh=screen.height
  var leftpos=(screenw/2)-(winw/2)
  var toppos=(screenh/2)-(winh/2)
  var request='delconfirm.php?request='+rdesc+'&command='+command
  window.open(request,"delconfirm",'width='+winw+',height='+winh+',left='+leftpos+',top='+toppos+',menubar=no,toolbar=no,titlebar=no')
}
function myonkeydown(thisname,root,group){
  key=event.keyCode
  tableid="item";
  if(key==38 && event.ctrlKey==true){ // move up
    tbody=document.getElementById(tableid+"table"+group)
    currowname=document.getElementById(thisname).id.replace(root,tableid)
    currow=document.getElementById(currowname)
    curordname=document.getElementById(thisname).id.replace(root,tableid+"ord")
    curordid=document.getElementById(curordname)
    curinputid=document.getElementById(thisname)
    prevrow=currow.previousSibling
    if(prevrow!=null && prevrow.id!=""){
      prevordname=tableid+"ord"+prevrow.id.replace(tableid,"")
      prevordid=document.getElementById(prevordname)
      previnputname=root+prevrow.id.replace(tableid,"")
      previnputid=document.getElementById(previnputname)
      curord=curordid.value
      curordid.value=prevordid.value
      prevordid.value=curord
      //focus switch required
      previnputid.focus()
      tbody.insertBefore(currow,prevrow)
      curinputid.focus()
    }
  }
  if(key==40 && event.ctrlKey==true){ // move down
    tbody=document.getElementById(tableid+"table"+group)
    currowname=document.getElementById(thisname).id.replace(root,tableid)
    currow=document.getElementById(currowname)
    curordname=document.getElementById(thisname).id.replace(root,tableid+"ord")
    curordid=document.getElementById(curordname)
    nextrow=currow.nextSibling
    if(nextrow!=null){
      nextordname=tableid+"ord"+nextrow.id.replace(tableid,"")
      nextordid=document.getElementById(nextordname)
      curord=curordid.value
      curordid.value=nextordid.value
      nextordid.value=curord
      tbody.insertBefore(nextrow,currow)
    }
  }
  if(key==38 && event.ctrlKey==false){ // up
    currowname=document.getElementById(thisname).id.replace(root,tableid)      
    currow=document.getElementById(currowname)
    prevrow=currow.previousSibling
    if(prevrow!=null && prevrow.id!=""){  
      previnputname=root+prevrow.id.replace(tableid,"")
      previnputid=document.getElementById(previnputname).focus()
    }else{
      document.body.scrollTop=0
    }
  }
  if(key==40 && event.ctrlKey==false){ // down
    currowname=document.getElementById(thisname).id.replace(root,tableid)    
    currow=document.getElementById(currowname)
    nextrow=currow.nextSibling
    if(nextrow!=null){  
      nextinputname=root+nextrow.id.replace(tableid,"")
      nextinputid=document.getElementById(nextinputname).focus()
    }else{
      document.body.scrollTop=document.body.scrollTop+30
   }
  }
}
