/* Open a new window */
function NewWindow(mypage, myname, w, h, pos, infocus)
{
         var win = null;
         if (pos == "random") {
             myleft = (screen.width) ? Math.floor(Math.random() * (screen.width-w)):100;
             mytop = (screen.height) ? Math.floor(Math.random() * ((screen.height-h)-75)):100;
         }
         if (pos == "center") {
             myleft = (screen.width) ? (screen.width-w) / 2:100;
             mytop = (screen.height) ? (screen.height-h) / 2:100;
         } else if ((pos !='center' && pos != "random") || pos == null) {
           myleft = 0; mytop = 20
         }
         settings = "width=" + w + ", height=" + h + ",top=" + mytop + ",left=" + myleft + ", scrollbars=yes, location=no, directories=no, status=no, menubar=no, toolbar=no, resizable=yes";
         win = window.open(mypage, myname, settings);
         win.focus();
}

function NewWindowOptions(mypage, myname, w, h, pos, infocus, scroll, resize)
{
         var win = null;
         if (pos == "random") {
             myleft = (screen.width) ? Math.floor(Math.random() * (screen.width-w)):100;
             mytop = (screen.height) ? Math.floor(Math.random() * ((screen.height-h)-75)):100;
         }
         if (pos == "center") {
             myleft = (screen.width) ? (screen.width-w) / 2:100;
             mytop = (screen.height) ? (screen.height-h) / 2:100;
         } else if ((pos !='center' && pos != "random") || pos == null) {
           myleft = 0; mytop = 20
         }
         settings = "width=" + w + ", height=" + h + ",top=" + mytop + ",left=" + myleft + ", scrollbars= "+scroll+", location=no, directories=no, status=no, menubar=no, toolbar=no, resizable="+resize;
         win = window.open(mypage, myname, settings);
         win.focus();
}

function openNewWindow(theURL,winName,features) //v2.0
{
  window.open(theURL,winName,features);
}

function trim(string)
{
         return(string.replace(/^\s+|\s+$/g,''));
}

function validName(name)
{
         ok = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM' ";
         for(i=0;i < name.length; i++)
         {
             if(ok.indexOf(name.charAt(i)) < 0)
             {
                return false;
             }
          }
          return true;
}

function validEmail(email)
{
         if(email.length < 7)
         {
            return false;
         }
         else
         {
            ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
            for(i=0;i < email.length; i++)
            {
                if(ok.indexOf(email.charAt(i)) < 0)
                {
                   return false;
                }
            }
        }
        return true;
}

function validURL(url)
{
         if(url.length < 9)
         {
            return false;
         }
         else
         {
            ok = "1234567890qwertyuiopasdfghjklzxcvbnm.-_QWERTYUIOPASDFGHJKLZXCVBNM/~";
            for(i=0;i < url.length; i++)
            {
                if(ok.indexOf(url.charAt(i)) < 0)
                   return false;
                }
          }
          return true;
}

/* Dropdown for Open account - replaces dropdown.js */
sfHover = function() {
	if (document.getElementById("navigation"))
        {
        var sfEls = document.getElementById("navigation").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" over";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" over\\b"), "");
		}
	}
        }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);