function jumptourl(url){
window.location=url;
}

// Obsolescent email function
// (document.write not fully XHTML compatible
// when you use Content-Type: application/xhtml+xml; charset=UTF-8)
function writeemail(){
var ic = 0x63;
var io = 0x6F;
var im = 0x6D;
_name_ = "postmaster";
_user_ = String.fromCharCode(0x63, 0x6A, 0x73, 0x65, 0x79, 0x6D, 0x6F, 0x75, 0x72);
_plus_ = "plus";
_at_ = String.fromCharCode(0x40);
_dot_ = String.fromCharCode(0x2E);
_co_ = String.fromCharCode(0x63,0x6F);
_uk_ = String.fromCharCode(0x75,0x6B);
_com_ = String.fromCharCode(ic,io,im);
_mmto_ = String.fromCharCode(0x6D,0x61,0x69,0x6C,0x74,0x6F,0x3A);
e_mail = "My Inquiry";
email = "Contact Us";
document.write('<a href=\"' + _mmto_ + _name_ + _at_ + _user_ + _dot_ + _plus_ + _dot_ + _com_ + '?subject=' + e_mail + '\">');
document.write(email + '<\/a>');
delete _name_;
delete _plus_;
delete e_mail;
}

// Obsolescent counter function (document.write not fully XHTML compatible
// when you use Content-Type: application/xhtml+xml; charset=UTF-8)
// Still used until better method found
/* This script gets the URL of the current page to determine 
   whether a counter URL should be generated, and if so,
   writes the counter URL */
function writecounter(szCtrURL, szAlt){

/* get current URL in plain ASCII */
	var url = unescape(location.href);
/* split URL = <scheme>:<scheme-specific-part> according to RFC 2396 */
	var slstart = url.indexOf(":");
// Get scheme prefix, which should be file or http (could be shorter e.g. ftp)
    var szScheme = url.substring (0, slstart);

    if ( szScheme == "file")
    {
		document.write("Counter suppressed (local file)");
	}
	else
	{
		document.write('<img src="' + szCtrURL + '" alt="' + szAlt + '" />');
	}
}

// New email and counter functions
  
// Electronic mail address generating functions
// Based partly on http://reliableanswers.com/js/mailme.asp
// (replaced old writeemail() because document.write is not compatible with XML)

// Reverse input string:
function Reverse(inpt) 
{
	var i=0;
	var outpt = "";

	for (i = 0; i <= inpt.length; i++) 
	{
    	outpt = inpt.charAt (i) + outpt;
  	}

  return(outpt);
} 


function GetUser()
{
	_name_ = Reverse("retsamtsop");
	fmtInputStr = _name_;
	return (fmtInputStr);
}

function GetDom()
{
	var ic = 0x63;
	var io = 0x6F;
	var im = 0x6D;
	_user_ = String.fromCharCode(0x63, 0x6A, 0x73, 0x65, 0x79, 0x6D, 0x6F, 0x75, 0x72);
	_plus_ = "plus";
	_dot_ = "%23";
	_com_ = String.fromCharCode(ic,io,im);

	subjct = Reverse("=tcejbus?");
	e_inq = Reverse("yriuqnI yM");
	fmtInputStr = _user_ + _dot_ + _plus_ + _dot_ + _com_ + subjct + e_inq;
	return (fmtInputStr);
}

function Replacement()
{
	strDom = GetDom();
	strUser = GetUser();
	_mmto_ = String.fromCharCode(0x6D,0x61,0x69,0x6C,0x74,0x6F,0x3A);
// Construct result, globally replacing %23 matches with a dot
	return(_mmto_+strUser+"@"+strDom.replace(/%23/g,"."));
}

// Globals used for numerology calculations
var seeded = false;
var seed = 0;
var input_str_rnd = "";
var form_rnd;

function SeedRand()  
{
  var d = new Date();
// Generate a seed approx. in the range 0..2^32
// (getMilliseconds returns an integer between 0 and 999)
  seed = 4294967 * d.getMilliseconds();	
  return;
}

function GetRand()
{
  if (seeded===false)
  {
    SeedRand();
    seeded = true;
  }
// Linear congruential generator (LCG) with coeffs from http://www.answers.com/topic/linear-congruential-generator
// 2^32 = 4294967296 = 0x100000000
  seed = (1664525*seed+1013904223)%0x100000000;
// Combine with the built-in random method
  seed = (seed + Math.floor(Math.random()*0x100000000))%0x100000000;

// Return normalised value
  return (seed/0x100000000);
}

// Return a random integer between imin and imax
function myrandom(imin, imax)
{
  var rand;

  rand = GetRand();
// Math.floor(Math.random()*max+1)
// will get numbers between 1 and max
  return (Math.floor(rand*imax+imin));
}

   
// Copyright 2005 by Colmasys/C. J. Seymour www.colmasys.co.uk
// Converts input colour data and generate output colour data in various formats
//
// Converted for numcalc1.htm 17/6/06: 
// itype = 0 : Calculate standard schemes
// itype = 1 : Calculate random scheme
function calcnums(form, itype) 
	{
	var InputStr;
	var NumStatus;

// Get the input data
	if ( itype === 0)
	{
		InputStr = form.MyInputStd.value;
	}
	else if ( itype === 1)
	{
		InputStr = form.MyInputRnd.value;
	}

// Get rid of leading and trailing spaces
	var fmtInputStr = TruncateExtSpaces(InputStr);

	if ( itype === 0)
	{
		ClearForm_Std ( form );
// Show error status in dec result if input was hex
// Calculate numerological stuff from input
		NumStatus = Numcalc_Input(form, fmtInputStr, itype );
// Display status (true or false)
//		form.StdStatus.value = NumStrRes;
	}
// else calculate random scheme (TODO)
    else
	{
		NumStatus = rnumercalc(form, fmtInputStr, itype );
	}

// Return false to prevent form being submitted to CGI
	return ( false );
}

// Copyright 2005 by Colmasys/C. J. Seymour www.colmasys.co.uk
// Removes all leading and trailing spaces from string InputStrHex
// Returns modified string
function TruncateExtSpaces(InputStrHex)
{
        var ichar;
		var fmtInputStrHex = "";

        var ifirst = 0;
        var ilast = 0;
// Identify the first non-space character position
		for (ichar=0; ichar<InputStrHex.length; ichar=ichar+1)
			{
			if ( InputStrHex.charAt ( ichar ) != ' ' )
			  {
			    ifirst = ichar;
			    break;
			  }
			}
// Identify the last non-space character position
		for (ichar=InputStrHex.length-1; ichar>=0; ichar=ichar-1)
			{
			if ( InputStrHex.charAt ( ichar ) != ' ' )
			  {
			    ilast = ichar;
			    break;
			  }
			}
// Copy the part excluding the leading and trailing spaces 
// (spaces may be embedded in this part)
		for (ichar=ifirst; ichar<=ilast; ichar=ichar+1)
			{
			var ch = InputStrHex.charAt ( ichar );
            fmtInputStrHex = fmtInputStrHex + ch;
			}

  return (fmtInputStrHex);
}


// Numerological calculations
/*	function Numcalc_Input ( input_str, itype )
	{
		var retstr = "";
		retstr += "Numcalc Test"
		return (retstr);
	}*/

// Copyright 2005 by Colmasys/C. J. Seymour www.colmasys.co.uk
// Display sample colour for RGB input form
// itype==0 for hex input, 1 for decimal input
// For type 0 colour sample, colour is set for object "ColSamp_H_RGB"
// For type 1 colour sample, colour is set for object "ColSamp_D_RGB"
/*	function Display_Colour_RGB_In ( form, colHex, itype) 
	{
// object/feature detection, see "Using Web Standards in Your Web Pages"
// http://www.mozilla.org/docs/web-developer/upgrade_2.html
// document.getElementById is supported by Internet Explorer version 5 and above, 
// Gecko-based browsers (Mozilla & Firefox), Safari, and Opera
// IE4 uses document.all instead.
      if ( itype === 0)
      {
        if (document.getElementById &&
            document.getElementById("ColSamp_H_RGB") &&
            document.getElementById("ColSamp_H_RGB").style)
        {
		  document.getElementById("ColSamp_H_RGB").style.backgroundColor = "#" + colHex;
		}
		else if (document.all)	// try MSFT IE 4 method
        {
			ColSamp_H_RGB.style.backgroundColor = colHex;
		}
	  }
// form fields Removed
//	  else
//      {
//        if (document.getElementById &&
//            document.getElementById("ColSamp_D_RGB") &&
//            document.getElementById("ColSamp_D_RGB").style)
//        {
//		  document.getElementById("ColSamp_D_RGB").style.backgroundColor = "#" + colHex;
//		}
//		else if (document.all)	// try MSFT IE 4 method
//        {
//			ColSamp_D_RGB.style.backgroundColor = colHex;
//		}
//      }
	}
*/


// Copyright 2005 by Colmasys/C. J. Seymour www.colmasys.co.uk
// Clear all form fields
	function ClearForm_Std ( form )
	{
//		Display_Colour_RGB_In ( form, "FFFFFF", 0);
//		Display_Colour_RGB_In ( form, "FFFFFF", 1);
/*		form.Red_RGB.value = "";
		form.Grn_RGB.value = "";
		form.Blu_RGB.value = "";
		form.Cya_RGB.value = "";
		form.Mag_RGB.value = "";
		form.Yel_RGB.value = "";
        form.Blk_RGB.value = "";
        form.Cyak_RGB.value = "";
        form.Magk_RGB.value = "";
        form.Yelk_RGB.value = ""; */
		form.MyInputStd.focus ();
	}
   

// Numerological calculations




// Used by numercalc:
// Copyright 2006 by C. J. Seymour
// Removes all space chars including embedded, leading and trailing from string InputStr
// ( To preserve embedded spaces, use TruncateExtSpaces() )
// Returns modified string
function RemoveSpaces(InputStr)
{
	var nchars;
    var ichar;
    var ch = '';
	var fmtOutputStr = "";

	nchars = InputStr.length;

	for (ichar=0; ichar<nchars; ichar=ichar+1)
	{
		ch = InputStr.charAt ( ichar );
		if ( ch != ' ' )
	    {
	    	fmtOutputStr = fmtOutputStr + ch;
		}
	}

  return (fmtOutputStr);
}

// Calculate number codes and return a numerical sum of them
function numersumcount(InputStr, scheme)
{
  var ichar;
  var icode = 0;
  var x = 0;

// Calculate the char codes
		for (ichar=0; ichar<InputStr.length; ichar=ichar+1)
		{
			icode = scheme[InputStr.charCodeAt(ichar)-97];	/* for lower case */
			x = x + icode;
		}

  return (x);
}


// Case sensitive version of numersumcount for ASCII scheme only
function ASCIIsumcount(InputStr)
{
	var ichar;
	var icode = 0;
	var x = 0;

// Calculate the char codes (no look-up needed for ASCII)
	for (ichar=0; ichar<InputStr.length; ichar=ichar+1)
	{
		icode = InputStr.charCodeAt(ichar);
// Check for numeric digits and translate them
		if ( (icode>=48) && (icode<=57) ) { icode = icode - 48; }
		x = x + icode;
	}

	return (x);
}


// Calculate number codes and return a concatenated string of them
function numersumstr(InputStr, scheme)
{
  var ichar;
  var icode = 0;
  var y = '';

// Calculate the char codes
		for (ichar=0; ichar<InputStr.length; ichar=ichar+1)
		{
			icode = scheme[InputStr.charCodeAt(ichar)-97];	/* for lower case */
			if (y==="")
			{
			  y = y + String(icode);
		    }
		    else
			{
			  y = y + ',' + String(icode);
		    }
		}

  return (y);
}

// Case sensitive version of numersumstr for ASCII scheme only
function ASCIIsumstr(InputStr)
{
  var ichar;
  var icode = 0;
  var y = '';

// Calculate the char codes (no look-up needed for ASCII)
		for (ichar=0; ichar<InputStr.length; ichar=ichar+1)
		{
			icode = InputStr.charCodeAt(ichar);
// Check for numeric digits and translate them
		    if ( (icode>=48) && (icode<=57) ) { icode = icode - 48; }
			if (y==="")
			{
			  y = y + String(icode);
		    }
		    else
			{
			  y = y + ',' + String(icode);
		    }
		}

  return (y);
}

// Copyright 2006 by C. J. Seymour
// Numerology calculator
// For a concise list of schemes, and an alternative Java coding, see http://www.merriampark.com/numbeast.htm
function Numcalc_Input (form, input_str, itype )
{
// Letters of the alphabet coded as 100 to 125; numerologists' code that
// maps "Hitler" to the no. of the beast 
// Tabulated schemes, case insensitive
//                        A,  B,  C,  D,  E,  F,  G,  H,  I,  J,  K,  L,   M,  N,  O,  P,  Q,  R,  S,  T,  U,  V,  W,  X,  Y,  Z
  var Roman_Scheme =   [  0,  0,100,500,  0,  0,  0,  0,  1,  1,  0, 50,1000,  0,  0,  0,  0,  0,  0,  0,  5,  5, 10, 10,  0,  0];
  var Tolstoy_Scheme = [  1,  2,  3,  4,  5,  6,  7,  8,  9,  9, 10, 20,  30, 40, 50, 60, 70, 80, 90,100,110,120,130,140,150,160];
  var Bungus_Scheme =  [  1,  2,  3,  4,  5,  6,  7,  8,  1,  9, 10, 20,  30, 40, 50, 60, 70, 80, 90,100,200,200,300,400,500,600];
  var numerolo_scheme =[100,101,102,103,104,105,106,107,108,109,110,111, 112,113,114,115,116,117,118,119,120,121,122,123,124,125];
  var Blevin_Scheme =  [  6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72,  78, 84, 90, 96,102,108,114,120,126,132,138,144,150,156];
    
  var InputStr;
  var ichar;
  var iresult = 0;
  var icode = 0;
  var isum = [0,0,0,0,0,0,0];
  var outputstr = ["","","","","","",""];
  var x1 = "", s1="";
  var x2 = "", s2="";
  var x3 = "", s3="";
  var x4 = "", s4="";
  var x5 = "", s5="";
  var x6 = "", s6="";

/* Get the input string and calculate stuff from it */
	InputStr = input_str;

	var fmtInputStr = RemoveSpaces(InputStr);
	var lcInputStr = fmtInputStr.toLowerCase();

	if ( lcInputStr.length > 0 )
	{
// Calculate the char codes
        x1 = numersumcount(lcInputStr, Roman_Scheme);
        s1 = numersumstr(lcInputStr, Roman_Scheme);
        x2 = numersumcount(lcInputStr, Tolstoy_Scheme);
        s2 = numersumstr(lcInputStr, Tolstoy_Scheme);
        x3 = numersumcount(lcInputStr, Bungus_Scheme);
        s3 = numersumstr(lcInputStr, Bungus_Scheme);
        x4 = numersumcount(lcInputStr, numerolo_scheme);
        s4 = numersumstr(lcInputStr, numerolo_scheme);
        x5 = numersumcount(lcInputStr, Blevin_Scheme);
        s5 = numersumstr(lcInputStr, Blevin_Scheme);
        x6 = ASCIIsumcount(fmtInputStr);
        s6 = ASCIIsumstr(fmtInputStr);

/*		for (ichar=0; ichar<lcInputStr.length; ichar=ichar+1)
		{
			icode = numerolo_scheme[lcInputStr.charCodeAt(ichar)-97];	// for lower case
			isum[0] = isum[0] + icode;
			if (outputstr[0]==="")
			{
			  outputstr[0] = outputstr[0] + String(icode);
		    }
		    else
			{
			  outputstr[0] = outputstr[0] + ',' + String(icode);
		    }
// remove surplus space
          outputstr[0] = TruncateExtSpaces(outputstr[0]);
		}
*/

			form.Result1.value = s1;
			form.sum1.value = String(x1);
			form.Result2.value = s2;
			form.sum2.value = String(x2);
			form.Result3.value = s3;
			form.sum3.value = String(x3);
			form.Result4.value = s4;
			form.sum4.value = String(x4);
			form.Result5.value = s5;
			form.sum5.value = String(x5);
			form.Result6.value = s6;
			form.sum6.value = String(x6);
		    form.StdStatus.value = "Finished.";
	}
	else
	{
		form.status.value = "Invalid Length";
	}

	form.MyInputStd.focus ();
// Return false to prevent form being submitted to CGI
	return ( false );
}


// constraint = 0 means use minimum constraints on random values
function randomscheme(constraint)
{
  var strrnd = [ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0];
  var ic;

//  strrnd[0] = 100;	// init (same as numerolo scheme for test)
// Set the starting number and increment
  if (constraint===1)
  {	// generate a series 1n,2n,3n...26n where n is increment
    increment = myrandom(1,10);
    strrnd[0] = increment;
  }
  else if (constraint===2)
  {	// generate a series with a random start and a regular random increment
    increment = myrandom(1,100);
    strrnd[0] = myrandom(1,100);
  }
  else
  { // min. constraint (random start, random increment)
    strrnd[0] = myrandom(1,100);
  }
    
  for (ic=1; ic<26; ic=ic+1)
  { // Next number is set in the range strrnd[ic-1]+1 to strrnd[ic-1]+10
    if (constraint===0)
    { // min. constraint, random increment
      strrnd[ic] = strrnd[ic-1] + myrandom(1,10);
    }
    else
    {
      strrnd[ic] = strrnd[ic-1] + increment;
    }
  }

  return (strrnd);  
}

// Fixes rnumercalcfunc to delay calculation allowing a status field to update
function rnumercalc(form, input_str, itype)
{
	var delay = 75;	// time in ms (enough to allow form settings)

// Clear the form and indicate changed input
    form.status2.value = "Calculating...";
	form.numscheme.value = "";
	form.schemtype.value = "";
	form.sumr.value = "";
    form.Resultr.value = "";

// store the input in a global
	input_str_rnd = input_str;
	form_rnd = form;
// After the specified delay, the timeout will start a new thread
// http://www.howtocreate.co.uk/tutorials/javascript/timers
	var cmd = "rnumercalcfunc()";	// construct the command
	setTimeout(cmd, delay);
}

// Copyright 2005 by C. J. Seymour
// Random Numerological calculator with automatic scheme optimisation
function rnumercalcfunc() 
{
//                        A,  B,  C,  D,  E,  F,  G,  H,  I,  J,  K,  L,  M,  N,  O,  P,  Q,  R,  S,  T,  U,  V,  W,  X,  Y,  Z
  var Random_Scheme =   [ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0];
    
  var InputStr;
  var ichar;
  var iresult = 0;
  var icode = 0;
  var isum = 0;
  var outputstr = "";
  var bnotdone = true;
  var numschemestr = "";
  var ic;
  var date0 = new Date();	// ref time
  var diff;
// max time allowed in ms (longer than 3 sec may cause IE to complain
// that a script is running slowly)
  var tmax = 3000;	

//  Changing form field doesn't update till calculation finished
//	alert("Calculating");	// modal
//   window.defaultStatus = "Calculating";	// status bar doesn't update either
    form_rnd.schemtype.value = "";

/* Get the input string and calculate stuff from it */
	InputStr = input_str_rnd;

	var fmtInputStr = RemoveSpaces(InputStr);
	var lcInputStr = fmtInputStr.toLowerCase();

	if ( lcInputStr.length > 0 )
	{
// Calculate the char codes
        while (bnotdone) 
  	    {
          var date1 = new Date();	// get current time
          t0 = date0.getTime();
  	      t1 = date1.getTime();
          diff = t1 - t0;    //difference in milliseconds
  	      if (diff<(tmax/3))
  	      {
            Random_Scheme = randomscheme(1);
            form_rnd.schemtype.value = "Regular interval and starting value";
          }
  	      else if (diff<((2*tmax)/3))
  	      {
            Random_Scheme = randomscheme(2);
            form_rnd.schemtype.value = "Random start, regular step";
          }
          else
          {
            Random_Scheme = randomscheme(0);
            form_rnd.schemtype.value = "Random increasing values";
          }
          isum = numersumcount(lcInputStr, Random_Scheme);
          if ( (isum === 666) || (diff>tmax) )
          {
		    bnotdone = false;
	      }
		}
		
		if (diff>tmax)
		{
		  form_rnd.numscheme.value = "";
		  form_rnd.status2.value = "Time Expired";
		  form_rnd.sumr.value = "";
		}
		else
		{
// Generate a list of the numbers in the scheme:
          numschemestr = String(Random_Scheme[0]);
          for (ic=1; ic<26; ic=ic+1)
          {
            numschemestr = numschemestr + ", " + String(Random_Scheme[ic]);
          }
		  form_rnd.numscheme.value = numschemestr;

		  outputstr = numersumstr(lcInputStr, Random_Scheme);
		  form_rnd.Resultr.value = outputstr;
		  form_rnd.sumr.value = String(isum);
          form_rnd.status2.value = "Finished.";
		}
	}
	else
	{
	  form_rnd.numscheme.value = "";
	  form_rnd.status2.value = "Invalid Length";
	  form_rnd.sumr.value = "";
	}

	form_rnd.MyInputRnd.focus ();
// Return false to prevent form being submitted to CGI
	return ( false );
}

// Shows when user has changed input and clears results
// itype = 0 : form is standard scheme form
// itype = 1 : form is random scheme form
function changedinput(form, itype )
{
	if ( itype === 0)
	{
    // Clear the form and indicate changed input
	    form.StdStatus.value = "Changed Input";
		form.Result1.value = "";
		form.sum1.value = "";
		form.Result2.value = "";
		form.sum2.value = "";
		form.Result3.value = "";
		form.sum3.value = "";
		form.Result4.value = "";
		form.sum4.value = "";
		form.Result5.value = "";
		form.sum5.value = "";
		form.Result6.value = "";
		form.sum6.value = "";
	}
	else if ( itype === 1)
	{
    // Clear the form and indicate changed input
    	form.status2.value = "Changed Input";
		form.numscheme.value = "";
		form.schemtype.value = "";
		form.sumr.value = "";
    	form.Resultr.value = "";
	}
}

