//**Start Encode**

// Declare global string to be removed from the string s
var bagstring = " \t\n\r";

//  stripCharsInBag (STRING s, STRING bag)
// 
// Removes all characters which appear in string bag from string s.
function stripCharsInBag (s, bag)
{   
	var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
	if (returnString.length <1) return false;
	else return true;
}

// Removes all whitespace characters from s.
// Global variable bagstring (see above)
// defines which characters are considered whitespace.

function stripWhitespace (s)
{
return stripCharsInBag (s, bagstring);
}

// alerterr (STRING TheField)
//
// Inform the user that an error has been encountered
function alerterr(TheField) {
	alert (TheField);
	
}
// Check whether string s is empty.
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

// Returns true if string s is empty or 
// whitespace characters only.
function isWhitespace (s)
{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (bagstring.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

// isEmail (STRING s)
// 
// Email address must be of form a@b.c -- in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
function isEmail (s){ 
if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return false;
       else return (isEmail.arguments[1] == true);
   
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

// isNumeric (STRING n, g)
// 
// String n must be numeric and be greater than numeric g
function isNumeric (n,g) { 
/*
var p
p = parseInt(n)
alert("N: "+n)
x = isNaN(p)
alert("Parseint: "+p+"\nisNaN: "+x)
alert("N: "+parseInt(n)+ "\nG: "+parseInt(g))
*/
//If return n= false then it must be a natural number
if ((!isNaN(parseInt(n))) &&
//If return g = false then it must be a natural number
    (!isNaN(parseInt(g))) && 
    (parseInt(n) >= parseInt(g))) {
	return true;
	}
	return false;
}

// isNumeric (STRING n, g)
// 
// String n must be numeric
function isStrNumeric (n) { 
  var d ="";
  for (i = 0; i < n.length; i++)
  {   

      d = n.charAt(i);
	  if (isNaN(parseInt(d))) {
		return false;
	  }
  }
  return true;
}


// ReplaceStrip (STRING a, CHAR b, CHAR c)
// 
// String 'a' is the string that will contain the replacement chars
// String 'b' will be the char to search for within 'a'
// String 'c' will be the char to be replaced within 'a' appended to 'result'
function ReplaceStrip(a,b,c) { 
	var d ="";
	var result ="";
	
	//alert(a);
    
	for (i = 0; i < a.length; i++) {   
        d = a.charAt(i);
		//alert('char: ' + d + ' Compaire: ' + b)
		if (d == b) 
			result +=c 
		else 
			result += d
    }
	return result;
}

// GetLength (STRING str, INTEGER Maxlength)
// 
// String 'str' the string to evaluate
// Integer 'Maxlength' the maximum length of the string
function GetLength(Str, Maxlength) {
//================================
if (Str.length > Maxlength) {
	return false;
}
	return true;
}

// GetWordCount (STRING str, INTEGER MaxWords)
// 
// String 'str' the string to evaluate
// Integer 'MaxWords' the maximum words within the string, delimited by comma

function GetWordCount(Str, MaxWords) {
//==================================
var Arrwords = new Array;
Arrwords = Str.split(",")
if (Arrwords.length >MaxWords) {
	return false;
}
	return true
}

// USAGE: DetectBrowser (NULL)
// 
// Check for browser type
function DetectBrowser()
{   
var browser_name
	
	browser_name = "Browser: ["+navigator.appName + "]\n"
	browser_name = browser_name+"Version: ["+ navigator.appVersion + "]\n"
	return browser_name;
}

// USAGE: DetectPlatform(NULL)
// Detect the client platform

function DetectPlatform()
{
var platform_type

	platform_type = navigator.platform
	return platform_type
}

function setCookie(cookieName) {
//============================

	expireDate = new Date;
	expireDate.setMonth(expireDate.getMonth()+6);
	if (document.cookie != "") {
		cookieName = document.cookie.split("=")[1];
	}
	document.cookie = "cookieName="+cookieName+";expires=" + expireDate.toGMTString();
}

function deletecookie(cookieName){
//==============================
	if (document.cookie != "") {
     	thisCookie = document.cookie.split("; ")
    	  	expireDate = new Date
    	    	expireDate.setDate(expireDate.getDate()-1)
    	    	for (i=0; i<thisCookie.length; i++) {
			cookieName = thisCookie[i].split("=")[0]
    	    document.cookie = "cookieName="+cookieName + "=;expires=" + expireDate.toGMTString()
    	}
   	}
}

function Message(PerName, ArrI, Path) {
//----------------------------------
alert
var ArrMessages = new Array();
ArrMessages[0] = "This will create an order reference number for this order.\n\nClick OK to continue"
ArrMessages[1] = ""

if (confirm(PerName+"\n\nConfirmation:\n\n"+ArrMessages[ArrI])) { 
		location.href = Path;
	}
}

// USAGE: CheckedBoxes(form object)
// At least one checkbox MUST be selected
function CheckedBoxes(objform) {
//----------------------------
var any_selected;
any_selected = -1;
	for (var x = 0;x < objform.length; x++) {
    	var e = objform.elements[x];
		if (e.checked) {
			any_selected = 0;
			break;
		}
	}

	if (any_selected <0) {return false}
	else {return true}
}

// USAGE: CheckAllBoxes(form object)
// Check all checkboxes in the current form
function CheckAllBoxes(objform) {
//----------------------------
var x, e;
for (x = 0;x < objform.length; x++) {
    e = objform.elements[x];
	e.checked = objform.all_delete.checked;
	}
}

function TimerCheck(intStart, intStop, BoolReDir, StrPath, TimerID) {
//---------------------------------------
/*
USAGE:
	Intid = window.setInterval("TimerCheck(1,20,false,'','');", 200);
	window.onload = TimerCheck(1,20,false,'',Intid);

*/
	if (intStart == intStop) {
		window.clearInterval(TimerID);
		if (BoolReDir) {location.href = StrPath;}
	}
	else {intStart++};

Check.innerHTML = Check.innerHTML +".";
}