bannedips=["149.68.", "198.143.", "61.220.197", "211.22.117", "61.218", "220.130.154", "61.219.68", "211.23.168", "211.72.242", "220.128.150", "218.214.146.28","192.168", "64.49", "137.205.", "192.87.50.", "194.104.224.254", "163.1.34", "202.173.189.32", "192.245.136.3", "136.242.", "208.125", "66.194", "64.83.234", "152.65.", "194.81", "194.36", "194.80", "130.209.", "134.48", "152.97.", "67.159.64", "152.16", "152.3.", "66.251.112", "129.74", "66.254", "129.97", "150.101.221.105", "12.4.242.224", "149.68", "198.30", "70.60.31.250", "169.130.90.18", "150.108", "75.149", "64.69", "213.6.95.70", "134.2.", "192.148.", "203.10.", "78.137.130.100", "142.3.", "136.167."];


function paypalInfo()
{
win = open('paypal.htm', 'paypalwin', 'width=400,height=400,top=0,left=0');

}


function databaseInfo()
{
win = open('database instructions.htm', 'paypalwin', 'width=900,height=500,top=0,left=0');

}

function doMail(whc)
{

url = 'http://www.theway.org.uk/efriend.htm?' + whc ;
win1 = open(url, 'efriendwin', 'width=400,height=800,top=0,left=0');

}



function doList()
{
url = 'http://www.theway.org.uk/mailinglist.htm';
win2 = open(url, 'listwin', 'width=400,height=800,top=0,left=0');

}

function doFeedback()
{
url = 'http://www.theway.org.uk/feed_back.htm';
win3 = open(url, 'feedbackwin', 'width=400,height=800,top=0,left=0');

}
function isEmpty( str){
    strRE = new RegExp( );
    strRE.compile( '^[\s ]*$', 'gi' );
    return strRE.test( str.value );
}


function validate_form ( )
{
    valid = true;

    if ( document.subsform.forename.value == "" )
    {
        alert ("Please fill in the 'forename' box.");
        valid = false;
    }

    
if ( document.subsform.surname.value == "" )
    {
        alert ( "Please fill in the 'surname' box." );
        valid = false;
    }

if ( document.subsform.email.value == "" )
    {
        alert ( "Please fill in the 'e-mail address' box." );
        valid = false;
    }
    

if ( document.subsform.street.value == "" )
    {
        alert ( "Please fill in the 'street address' box." );
        valid = false;
    }

    


if ( document.subsform.town.value == "" )
    {
        alert ( "Please fill in the 'town' box." );
        valid = false;
    }

    


if ( document.subsform.country.value == "" )
    {
        alert ( "Please fill in the 'country' box, even if you live in the UK. It is needed to work out your subscription rate." );
        valid = false;
    }

    


if ( document.subsform.postcode.value == "" && document.subsform.country.value == "UNITED STATES" )
    {
		alert ( "Please fill in your zip code." );
        valid = false;
    }

   
if ( document.subsform.postcode.value == "" && document.subsform.country.value == "UNITED KINGDOM" )
    {
        alert ( "Please fill in your postcode." );
        valid = false;
    }

    


if ( document.subsform.gift.value == "1" && document.subsform.shipforename.value == "" )
    {
        alert ( "If you are giving a gift subscription, please fill in the recipient's forename." );
        valid = false;
    }

    


if ( document.subsform.gift.value == "1" &&  document.subsform.shipsurname.value == "" )
    {
        alert ( "If you are giving a gift subscription, please fill in the recipient's surname." );
        valid = false;
    }

    


if ( document.subsform.gift.value == "1" &&  document.subsform.shipstreet.value == "" )
    {
        alert ( "If you are giving a gift subscription, please fill in the recipient's street address." );
        valid = false;
    }

    


if ( document.subsform.gift.value == "1" && document.subsform.shiptown.value == "" )
    {
        alert ( "If you are giving a gift subscription, please fill in the recipient's town." );
        valid = false;
    }

    


if ( document.subsform.gift.value == "1" && document.subsform.shipcountry.value == "" )
    {
        alert ( "If you are giving a gift subscription, please fill in the recipient's country." );
        valid = false;
    }

    


if ( document.subsform.gift.value == "1" && document.subsform.shipcountry.value == "UNITED STATES" && document.subsform.shippostcode.value == "" )
    {
        alert ( "If you are giving a gift subscription, please fill in the recipient's zip code." );
        valid = false;
    }

    


if ( document.subsform.gift.value == "1" && document.subsform.shipcountry.value == "UNITED KINGDOM" && document.subsform.shippostcode.value == "" )
    {
        alert ( "If you are giving a gift subscription, please fill in the recipient's postcode." );
        valid = false;
    }


    return valid;

}

function validate_renew ( )
{
    valid = true;

    if ( document.subsform.name.value == "" && document.subsform.org.value == "" )
    {
        alert ("Please fill in the 'name' box or the 'organization' box.");
        valid = false;
    }

      

if ( document.subsform.street.value == "" )
    {
        alert ( "Please fill in the 'street address' box." );
        valid = false;
    }

    
if ( document.subsform.email.value == "" )
    {
        alert ( "Please fill in the 'e-mail address' box." );
        valid = false;
    }

if ( document.subsform.town.value == "" )
    {
        alert ( "Please fill in the 'town' box." );
        valid = false;
    }

    


if ( document.subsform.country.value == "" )
    {
        alert ( "Please fill in the 'country' box, even if you live in the UK. It is needed to work out your subscription rate." );
        valid = false;
    }

    


if ( document.subsform.postcode.value == "" && document.subsform.country.value == "UNITED STATES" )
    {
		alert ( "Please fill in your zip code." );
        valid = false;
    }

   
if ( document.subsform.postcode.value == "" && document.subsform.country.value == "UNITED KINGDOM" )
    {
        alert ( "Please fill in your postcode." );
        valid = false;
    }

    


if ( document.subsform.gift.value == "1" && document.subsform.shipname.value == "" && document.subsform.shiporg.value == "")
    {
        alert ( "If you are giving a gift subscription, please fill in the recipient's name or organization." );
        valid = false;
    }

    

 


if ( document.subsform.gift.value == "1" &&  document.subsform.shipstreet.value == "" )
    {
        alert ( "If you are giving a gift subscription, please fill in the recipient's street address." );
        valid = false;
    }

    


if ( document.subsform.gift.value == "1" && document.subsform.shiptown.value == "" )
    {
        alert ( "If you are giving a gift subscription, please fill in the recipient's town." );
        valid = false;
    }

    


if ( document.subsform.gift.value == "1" && document.subsform.shipcountry.value == "" )
    {
        alert ( "If you are giving a gift subscription, please fill in the recipient's country." );
        valid = false;
    }

    


if ( document.subsform.gift.value == "1" && document.subsform.shipcountry.value == "UNITED STATES" && document.subsform.shippostcode.value == "" )
    {
        alert ( "If you are giving a gift subscription, please fill in the recipient's zip code." );
        valid = false;
    }

    


if ( document.subsform.gift.value == "1" && document.subsform.shipcountry.value == "UNITED KINGDOM" && document.subsform.shippostcode.value == "" )
    {
        alert ( "If you are giving a gift subscription, please fill in the recipient's postcode." );
        valid = false;
    }


    return valid;

}

function validate_sub ( ) {
	valid = true;
	letter = document.renewsub.cu.value
	
	if ( letter.slice(0,2) == "cu"  ||	 letter.slice(0,2) == "CU" )
    {
        alert ( "Please just enter the numbers from you password, without the CU-. Thank you." );
        valid = false;
    }


    return valid;

}

function IP( ){

var ip = '<!--#echo var="REMOTE_ADDR"-->'

var handleips=bannedips.join("|")
handleips=new RegExp(handleips, "i")

if (ip.search(handleips)!=-1){ 

document.theform.action = "subs.asp";
document.theform.submit();

} else {window.location.replace("http://www.theway.org.uk/websubs/websubgateway.asp");
}
}

function validate_various ( ) {
	valid = true;
	
	
	if ( document.various.email.value == "" )
    {
        alert ( "Please enter an e-mail address. Thank you." );
        valid = false;
    }


    return valid;

}


function fixAccents(french) {

french = french.replace(/á/g,"a");
french = french.replace(/â/g,"a");
french = french.replace(/à/g,"a");
french = french.replace(/ä/g,"a");
french = french.replace(/ã/g,"a");
french = french.replace(/å/g,"a");
french = french.replace(/æ/g,"ae");
french = french.replace(/ç/g,"c");
french = french.replace(/é/g,"e");
french = french.replace(/ê/g,"e");
french = french.replace(/è/g,"e");
french = french.replace(/ë/g,"e");
french = french.replace(/í/g,"i");
french = french.replace(/ï/g,"i");
french = french.replace(/ì/g,"i");
french = french.replace(/î/g,"i");
french = french.replace(/ñ/g,"n");
french = french.replace(/ó/g,"o");
french = french.replace(/ô/g,"o");
french = french.replace(/ö/g,"o");
french = french.replace(/õ/g,"o");
french = french.replace(/ò/g,"o");
french = french.replace(/ø/g,"o");
french = french.replace(/œ/g,"oe");
french = french.replace(/ß/g,"ss");
french = french.replace(/þ/g,"th");
french = french.replace(/ð/g,"th");
french = french.replace(/ú/g,"u");
french = french.replace(/û/g,"u");
french = french.replace(/ü/g,"u");
french = french.replace(/ù/g,"u");


}


function get_cookie(cookie_name)
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 46 || charCode > 57))
            return false;

         return true;
      }

