 function goScanAlert(uri) {
    if(!uri || uri == '') { uri = '/'; }
    if(window.name == 'ScanAlert') {
       document.location = uri;
       window.moveTo(0,0);
       window.resizeTo(840,screen.height-40);
       //window.resizeTo(screen.width,screen.height);
    } else {
       var w = window.open(uri,'ScanAlert','left=0,top=0,width=810,height=600');
       w.moveTo(0,0);
       w.resizeTo(screen.width,screen.height);
       window.close();
    }
 }
//-----------------------------------------
function rowOn(key) {
   var ele = document.getElementById(key);
   ele.bgColor      = '#ebebeb';
   ele.style.cursor = 'hand';
}
function rowOff(key) {
   var ele = document.getElementById(key);
   ele.bgColor = '#ffffff';
   ele.style.cursor = '';
}
//-----------------------------------------
var img_nav_arrow_circ_on = new Image(); img_nav_arrow_circ_on.src = "//images.scanalert.com/images/nav_arrow_circ_on.gif";
var img_nav_arrow_circ    = new Image(); img_nav_arrow_circ.src    = "//images.scanalert.com/images/nav_arrow_circ.gif";
var img_nav_arrow_org     = new Image(); img_nav_arrow_org.src     = "//images.scanalert.com/images/nav_arrow_org.gif";
var img_nav_arrow_right   = new Image(); img_nav_arrow_right.src   = "//images.scanalert.com/images/nav_arrow_right.gif";
function navSwapOn(img,row) {
   img_ele = document.getElementById(img);
   row_ele = document.getElementById(row);
   imgswap(img_ele,img_nav_arrow_circ_on);
   //bgswap(row_ele,'99ccff');
   bgswap(row_ele,'8fb5db');
}
function navSwapOff(img,row) {
   img_ele = document.getElementById(img);
   row_ele = document.getElementById(row);
   imgswap(img_ele,img_nav_arrow_circ);
   bgswap(row_ele,'6699cc');
}
function nav2SwapOn(img,row) {
   img_ele = document.getElementById(img);
   row_ele = document.getElementById(row);
   imgswap(img_ele,img_nav_arrow_org);
   //bgswap(row_ele,'99ccff');
   bgswap(row_ele,'8fb5db');
}
function nav2SwapOff(img,row) {
   img_ele = document.getElementById(img);
   row_ele = document.getElementById(row);
   imgswap(img_ele,img_nav_arrow_right);
   bgswap(row_ele,'6699cc');
}
function imgswap(ele,img) {
   if(ele) ele.src = img.src;
}
function bgswap(ele,color) {
   if(ele) ele.style.backgroundColor = '#'+color;
}
//-----------------------------------------
function rpcDomain(d) {
   if(d.indexOf(".") > 0) {
      window.open("/help/dnsrpc.jsp?domain="+escape(d),"dnsrpc","WIDTH=10,HEIGHT=10,LEFT=10,RIGHT=10");
   }
}
function link(url) { golink(url); }
function golink(url) { document.location = url; }
function linkConf(url) { if(confirm("Are you sure?")) { golink(url); } }
function isItSafe() { var w = showUrl('/Shoppers?tab=10',700,500,'isitsafe'); w.focus(); }
function contextHelp(id,to,nf,height,width) { 
   if(!height) { height = 300; }
   if(!width ) { width  = 200; }
   showUrl('/Help?helpId='+id+'&to='+to+'&nf='+nf,height,width);
}
function faq(id) { return showUrl('/Merchants?tab=8#'+id,500,400,'FAQ'); }
function showUrl(url,w,h,tit) {
   var l = (screen.width/2)-(w/2);
   var t = (screen.height/2)-(h/2);
   if(!tit) { tit = ''; }
   var w = window.open(url,tit,"SCROLLBARS=1,WIDTH="+w+",HEIGHT="+h+",LEFT="+l+",TOP="+t);
   w.focus();
   return w;
}
function validDomain(p) {
   var domain = new String(p);
   return true;
}
function validIp(p) {
   var ip = new String(p);
   if(ip.length > 15) { return false; }
   if(ip.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) != -1) {
      var ar = ip.split(".");
      if (ar[0] >  255 || ar[1] >  255 || ar[2] >  255 || ar[3] >  255) { return false; }
      if (ar[0] == 0   && ar[1] == 0   && ar[2] == 0   && ar[3] == 0  ) { return false; }
      return true;
    } 
    return false;
}
function validEmail(p) {
   var em = new String(p);
   return (em.search(/^.+\@.+\w{1,3}$/) != -1);
   

}
function privateIp(p) {
   var ip = new String(p);
   if(ip.indexOf("192.168.")==0 || ip.indexOf("127.0.0.")==0 || ip.indexOf("10."     )==0 ||
      ip.indexOf("172.16." )==0 || ip.indexOf("172.17." )==0 || ip.indexOf("172.18." )==0 ||
      ip.indexOf("172.19." )==0 || ip.indexOf("172.20." )==0 || ip.indexOf("172.21." )==0 ||
      ip.indexOf("172.22." )==0 || ip.indexOf("172.23." )==0 || ip.indexOf("172.24." )==0 ||
      ip.indexOf("172.25." )==0 || ip.indexOf("172.26." )==0 || ip.indexOf("172.27." )==0 ||
      ip.indexOf("172.28." )==0 || ip.indexOf("172.29." )==0 || ip.indexOf("172.30"  )==0 ||
      ip.indexOf("172.31"  )==0) { return false; }
}
function linkConf(url) {
   if(confirm("Are you sure?")) { golink(url); }
}

function loginas(aid,cid,red) {
   if(!red) { red = ''; }
   if(!cid) { cid = ''; }
   uri = '/loginas/index.jsp?type=admin&acctId='+aid+'&companyId='+cid+'&ref='+escape(document.location)+'&red='+escape(red);
   document.location = uri;
}

