

function isWhiteSpace( s )
{
   for( Pos = 0; Pos < s.length; Pos++ )
   {
       if( s.charAt(Pos) > ' ' ) return false;
   }
   // All characters are whitespace
   return true;
}


function openPopup ( cUrl, iwidth, iheight, cWindow )
{
    if( ( cWindow == null ) || isWhiteSpace( cWindow ) )
        cWindow = "popWin";


    newWindow = window.open( cUrl, cWindow, 'width=' + iwidth + ', height=' + iheight + ', top=' + (screen.height-iheight)/2 + ', left=' + (screen.width-iwidth)/2 + ', channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0' );

//    newWindow = window.open( cUrl, cWindow, 'width=' + iwidth + ', height=' + iheight + ', top=' + (screen.height-iheight)/2 + ', left=' + (screen.width-iwidth)/2 + ', scrollBars=yes, resizable=yes' );
    newWindow.focus();
}


function printPage()
{
  if( window.print ) // NS4, IE5
    window.print();
  else // unsupported feature
    alert( "Sorry, your browser doesn't support this automatic print feature. Please right-click on the page and choose the Print option." );
}


function setImageSrc(img, s)
{
   document.images[img].src = s;
}


function goBack()
{
    location.href = document.referrer;
}


function emailCheck (emailStr)
{
    var emailPat=/^(.+)@(.+)$/
    var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
    var validChars="\[^\\s" + specialChars + "\]"
    var quotedUser="(\"[^\"]*\")"
    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
    var atom=validChars + '+'
    var word="(" + atom + "|" + quotedUser + ")"
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
    var matchArray=emailStr.match(emailPat)
    if (matchArray==null)
    {
        // alert("Email address seems incorrect (check @ and .'s)")
        return false
    }

    var user=matchArray[1]
    var domain=matchArray[2]
    if (user.match(userPat)==null)
    {
        // alert("The username doesn't seem to be valid.")
        return false
    }

    var IPArray=domain.match(ipDomainPat)
    if (IPArray!=null)
    {
        for (var i=1;i<=4;i++)
        {
            if (IPArray[i]>255)
            {
                //alert("Destination IP address is invalid!")
                return false
            }
        }

        return true
    }

    // Domain is symbolic name
    var domainArray=domain.match(domainPat)
    if (domainArray==null)
    {
        //alert("The domain name doesn't seem to be valid.")
        return false
    }

    var atomPat=new RegExp(atom,"g")
    var domArr=domain.match(atomPat)
    var len=domArr.length
    if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
    {
        //alert("The address must end in a three-letter domain, or two letter country.")
        return false
    }
    if (len<2)
    {
        var errStr="This address is missing a hostname!"
        //alert(errStr)
        return false
    }

    return true;
}



