/** Copyright Notice =========================================================*
  *
  * This file contains proprietary information.
  * Copying or reproduction without prior written approval is prohibited.
  * All rights reserved.
  *
  * Document Information =====================================================*
  *
  * @filename       mi.main.js
  * @version        1.0
  * @description    Indigo Client-side JS
  * @date           2003/12/21
  * @author         Rick Farmer
  *
  * @revised        2003/12/25
  * @author         Rick Farmer
  * @revision       Added Indigo functional code
  *
  * @revised
  * @author
  * @revision
  *
  * Copyright (c) 2003-2004 ===================================================*/

/* Universal code
***************************************************************************/

var debugOn     = 0;
var debugType   = "status"; //alert | status | write
var debugAt     = "server"; //server | client

function debug(s,end){

    var writeType = (debugAt=="server")?"Response":"document";
    var writeType = eval(writeType);

    if(debugOn){
        if(debugAt=="server"){
            writeType.write(s);
            if(end){
                writeType.End();
            }
        }else if(debugAt=="client"){
            if(debugType=="status"){
                window.status=s;
            }else if(debugType=="alert"){
                alert(s);
            }else{
                writeType.write(s);
            }
        }
    return true;
    }
    return false;
}

/* Setup browser checks and add IE5+ emulation for IE4
-----------------------------------------------------------------------*/
// check for common browsers by useragent
var op = /opera 5|opera\/5/i.test(navigator.userAgent);
var ie = !op && /msie/i.test(navigator.userAgent);			// preventing opera being identified as ie
var ns = !op && /mozilla\/4/i.test(navigator.userAgent);	// preventing opera being identified as ns
var n6 = !op && /mozilla\/5/i.test(navigator.userAgent);	// preventing opera being identified as ns6

// Use these vars for more explicit DOM detection of IE and NS versions
var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var NS6 = (document.getElementById && !document.all) ? true : false;

if (ie && document.getElementById == null) {	// ie4 detected - setup IE5 DOM emulation
	document.getElementById = function(sId) {
		return document.all[sId];
	};
}

/* End browser checks
-----------------------------------------------------------------------*/


/* Utility Scripts
***************************************************************************/

function validateSearchbox(thisForm)
{
    if (!hasValue(document.theForm.query.value))
    {
		  alert('Please enter your search criteria.');
		  this.document.theForm.query.focus();
	  }
	  else
    {
      doSearch();
    }
}

function validateSearchboxSafari(thisForm)
{
    if (document.theForm.query.length > 1)
    {
      doSearch();
	  }
	  else
    {
		  alert('Please enter your search criteria.');
		  this.document.theForm.query.focus();
    }
}

function doSearch(){
//Resets current page
this.document.theForm.currentPage.value = "0";
//debug(this.document.theForm.catID.value);
			this.document.theForm.catIDTemp.value = this.document.theForm.catID.value;
			this.document.theForm.catTitleTemp.value = this.document.theForm.catTitle.value;
//debug(this.document.theForm.catIDTemp.value);
				this.document.theForm.bcRefsTemp.value = this.document.theForm.bcRefs.value;
				this.document.theForm.bcTitlesTemp.value = this.document.theForm.bcTitles.value;

doSubmit("main.asp");
}

function doSubmit(url){
//alert("query = " + this.document.theForm.query.value) // query = email

var query = this.document.theForm.query.value;
    	if(query == "") {
    		this.document.theForm.mode.value = "KT";
    	}
    	else {
    		this.document.theForm.mode.value = "Query";
    	}

	if(((isIntegerKB(query)) || (query.match("resid"))) && query!=""){
		this.document.theForm.exactID.value = query;
	}

//debug(this.document.theForm.catIDTemp.value);

    	this.document.theForm.action=url;
    	this.document.theForm.method='POST';
    	this.document.theForm.submit();
}

function enableSubmit() 
    {
        this.document.theForm.Submit.disabled=false;
        //this.document.theForm.feedbackcomment.disabled=false;
    }
    
function enableFeedback()
  {
    if(this.document.theForm.feedback(0).checked){
      this.document.theForm.feedbackcomment.disabled=false;
    }else if(this.document.theForm.feedback(1).checked){
      this.document.theForm.feedbackcomment.disabled=false;
    }else{
      alert("Please select Yes or No.");
    }
  }

function restart(state){

    if(state=="init"){
        this.document.theForm.s.value = "init";
    }

    doSubmit("startup.asp");
}

function restart2(state){

    if(state=="init"){
        this.document.theForm.s.value = "init";
    }

    doSubmit("http://mysecurity.earthlink.net");
}

/* Perform a "Request.QueryString" in JavaScript
-----------------------------------------------------------------------*/

  function getQueryString(){
// debug(document.URL);
   var urlEnd = document.URL.indexOf('?');
   var values = new Array();
   var names;

   if (urlEnd != -1){
    var params = document.URL.substring(urlEnd+1, document.URL.length).split('&');
    for(i=0; i<params.length; i++) {
     names = params[i].split('=');
     values[names[0]] = names[1];
    }
   }
   return values;
  }

		// Example of usage on the originating page

		//  QueryString = getQueryString();
		//  var fname = unescape(QueryString["fname"]);
		//  var lname = unescape(QueryString["lname"]);
		//  var email = unescape(QueryString["email"]);

		// document.write("NAME: " + fname + " " + lname + "<br>EMAIL: " + email

/* Encode a String to be JavaScript safe
-----------------------------------------------------------------------*/

function JSencode2(keywords)
  {
  keywords = keywords.replace(/\+/g, " +");
  keywords = keywords.replace(/\+ /g, "+");
  keywords = keywords.replace(/\&quot;/g, "\"");
  keywords = keywords.replace(/\- /g, "-");
  return keywords;
  }

function jsEncode(s)
/**===========================================================================*
  * @purpose
  *    Returns the uuString as client-side JS safe string
  *
  * @dependancies
  *    none
  *
  * @param   uuString - unencoded string
  *
  * @return    A JS-safe string
  *
  * @example
  *
  *     Response.Write(jsEncode(uuString));
  *
  * @author     Rick Farmer
  * @date       2004/05/09
  *==========================================================================*/
  {
    s = s.replace(/\x5C/g, "\\\\");   /* escape backslash [ \ ]--> Dec=92 Hex=\x5C Oct=\134 */
    s = s.replace(/\x27/g, "\\\'");   /* escape quote [ ' ]--> Dec=39 Hex=\x27 Oct=\047 */
    s = s.replace(/\x22/g, "\\\"");   /* escape double quote [ " ]--> Dec=34 Hex=\x22 Oct=\042 */
    s = s.replace(/\x0B/g, "\\v");    /* escape vertical tab [ \v ]--> Dec=11 Hex=\x0B Oct=\013 */
    s = s.replace(/\x09/g, "\\t");    /* escape horizontal tab [ \t ]--> Dec=9 Hex=\x09 Oct=\011 */
    s = s.replace(/\x0D/g, "\\r");    /* escape carriage return [ \r ]--> Dec=13 Hex=\x0D Oct=\015 */
    s = s.replace(/\x0A/g, "\\n");    /* escape newline [ \n]--> Dec=10 Hex=\x0A Oct=\012 */
    s = s.replace(/\x0C/g, "\\f");    /* escape form feed [ \f ]--> Dec=12 Hex=\x0C Oct=\014 */
//    uuString = uuString.replace(/\x08/g, "\\b");     /* escape backspace [ \b ]--> Dec=8 Hex=\x08 Oct=\010 */
//    uuString = uuString.replace(/\x78/g, "\\x");     /* escape 8-bit hex char [ \x ]--> Dec=120 Hex=\x78 Oct=\170 */
//    uuString = uuString.replace(/\x75/g, "\\u");     /* escape 16-bit hex char [ \u ]--> Dec=117 Hex=\x75 Oct=\165 */

  return s;
  }

function jsEscape(s){

    s = escape(s);
    s = s.replace(/%5C/g, "\\");   /* escape backslash [ \ ]--> Dec=92 Hex=\x5C Oct=\134 */
    s = s.replace(/%27/g, "\'");   /* escape quote [ ' ]--> Dec=39 Hex=\x27 Oct=\047 */
    s = s.replace(/%22/g, "\"");   /* escape double quote [ " ]--> Dec=34 Hex=\x22 Oct=\042 */
    s = s.replace(/%0B/g, "\v");   /* escape vertical tab [ \v ]--> Dec=11 Hex=\x0B Oct=\013 */
    s = s.replace(/%09/g, "\t");   /* escape horizontal tab [ \t ]--> Dec=9 Hex=\x09 Oct=\011 */
    s = s.replace(/%0D/g, "\r");   /* escape carriage return [ \r ]--> Dec=13 Hex=\x0D Oct=\015 */
    s = s.replace(/%0A/g, "\n");   /* escape newline [ \n]--> Dec=10 Hex=\x0A Oct=\012 */
    s = s.replace(/%0C/g, "\f");   /* escape form feed [ \f ]--> Dec=12 Hex=\x0C Oct=\014 */

return jsEncode(unescape(s));
}

function formEscape(s){
    s = s.replace(/"/g, "&quot;");   /* escape backslash [ \ ]--> Dec=92 Hex=\x5C Oct=\134 */
    s = s.replace(/'/g, "&#39;");   /* escape quote [ ' ]--> Dec=39 Hex=\x27 Oct=\047 */

return s;
}

/* Encode a String to be Url safe
-----------------------------------------------------------------------*/

function URLencode(keywords)
  {
  keywords = keywords.replace(/%20/g, " ");
  keywords = keywords.replace(/%22/g, "\"");
  keywords = keywords.replace(/%27/g, "\'");
  keywords = keywords.replace(/%26/g, "\&");
  keywords = keywords.replace(/%2d/g, "-");
  keywords = keywords.replace(/%2f/g, "/");
  return keywords;
  }

/* Switch between layers (turn of ALL layers, turn on selected layer)
-----------------------------------------------------------------------*/

function changeDirectLayer(CurrentLayer,currentPage) {

        this.document.theForm.currentPage.value = currentPage;
        doSubmit("main.asp");


}

/**===========================================================================*
  * Section: functions for use on the startup.asp & case.asp
  *===========================================================================*/


        /* Set values for Category Selection)
        -----------------------------------------------------------------------*/
		function setCategory(refname,title,parentRefname,parentTitle,breadcrumbPos){
		    if(breadcrumbPos>-1){  // rebuild the breadcrumb to the the point selected by the user

                var tempBcRefs = this.document.theForm.bcRefs.value.split("^");
                var tempBcTitles = this.document.theForm.bcTitles.value.split("^");

        		this.document.theForm.bcRefsTemp.value = "";
        		this.document.theForm.bcTitlesTemp.value = "";

                for(var i=0;i<breadcrumbPos+1;i++){
        		    this.document.theForm.bcRefsTemp.value += tempBcRefs[i] + "^";
        			this.document.theForm.bcTitlesTemp.value += tempBcTitles[i] + "^";
                }
		    } else {

    		    if(parentRefname!=""){
    		        this.document.theForm.bcRefsTemp.value = this.document.theForm.bcRefs.value + parentRefname + "^" + refname + "^";
        			this.document.theForm.bcTitlesTemp.value = this.document.theForm.bcTitles.value + parentTitle + "^" + title + "^";
    		    }else{
			if(this.document.theForm.bcRefs.value=="")
			{
        		    this.document.theForm.bcRefsTemp.value = refname + "^";
        			this.document.theForm.bcTitlesTemp.value = title + "^";
			}
			else{

				this.document.theForm.bcRefsTemp.value = this.document.theForm.bcRefs.value + refname + "^";
				this.document.theForm.bcTitlesTemp.value = this.document.theForm.bcTitles.value + title + "^";
        		   // this.document.theForm.bcRefsTemp.value += refname + "^";
        		//	this.document.theForm.bcTitlesTemp.value += title + "^";
			}
    		    }
            }

			this.document.theForm.catIDTemp.value = refname;
			this.document.theForm.catTitleTemp.value = title;
this.document.theForm.currentPage.value = "0";

doSubmit("main.asp");
//doSearch("main.asp");
		}

        /* Set how many results to be displayed per page
        -----------------------------------------------------------------------*/
		function setperPage(max){
			this.document.theForm.perpage.value = max;
			this.document.theForm.currentPage.value = "0";
			doSubmit("main.asp");

		}




		/* Set the unsupported check to be displayed
        -----------------------------------------------------------------------*/
		function setUnsupported(refname,title){

        		this.document.theForm.bcRefs.value = "";
        		this.document.theForm.bcTitles.value = "";
        		this.document.theForm.unsupported.value = "1";
				setCategory(refname,title,'','');

		}

		/* Open the article
		-----------------------------------------------------------------------*/
		function openArticle(articleid,url){
		    this.document.theForm.article.value = articleid;
		    doSubmit(url);
		}

		/* Validates if character is a digit
		-----------------------------------------------------------------------*/
		function isDigitKB (c){
		   return ((c >= "0") && (c <= "9"))
		}

		/* Validates if string is an integer
		-----------------------------------------------------------------------*/
		function isIntegerKB (s){
		   var i;

 		   // Search through string's characters one by one

    		   for (i = 0; i < s.length; i++)
    		  {
        		// Check that current character is number.
        		var c = s.charAt(i);

        		if (!isDigitKB(c)) return false;
    			}

    			// All characters are numbers.
    			return true;
		   }


        /* Prints article content
		-----------------------------------------------------------------------*/
        function PrintThisPage(brand)
        {
            var sOption="toolbar=yes,location=no,directories=yes,status=yes,menubar=yes,scrollbars=yes,width=750,height=600,left=100,top=25";

            var winHTML = document.getElementById('solution').innerHTML;

            var winprint=window.open("","",sOption);
            winprint.document.open();
            winprint.document.write('<html><LINK href=css/' + brand + '.main.css rel=Stylesheet><body>');
            winprint.document.write('<form><center><input type="button" value="  Print  " style="background-color: rgb(192,192,192); color: rgb(0,0,0); font-family: Arial, Verdana; font-weight: bold; border: 1px solid rgb(128,128,128)" onClick="window.print()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="  Close  " style="background-color: rgb(192,192,192); color: rgb(0,0,0); font-family: Arial, Verdana; font-weight: bold; border: 1px solid rgb(128,128,128)" onClick="window.close()"><\/center><\/form>');
            winprint.document.write(winHTML);
            winprint.document.write('</body></html>');
            winprint.document.close();
            winprint.focus();
        }

        /*  Launches email window
		-----------------------------------------------------------------------*/
        function emailThisPage(article, branding)
        {
            var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,";
            sOption+="scrollbars=yes,width=750,height=600,left=100,top=25";

                window.open("case.asp?handler=email&send=1&article=" + article + "&branding=" + branding ,"",sOption);
        }

        /* Validates email address
		-----------------------------------------------------------------------*/
        function echeck(str) {

		    var at="@"
		    var dot="."
		    var lat=str.indexOf(at)
		    var lstr=str.length
		    var ldot=str.indexOf(dot)

		    if (str.indexOf(at)==-1){
		        return false;
		    }

		    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		        return false;
		    }

		    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		        return false;
		    }

		    if (str.indexOf(at,(lat+1))!=-1){
		        return false;
		    }

		    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		        return false;
		    }

		    if (str.indexOf(dot,(lat+2))==-1){
		        return false;
		    }

		    if (str.indexOf(" ")!=-1){
		        return false;
		    }

 		    return true;
	    }

        /* Validates email form
		-----------------------------------------------------------------------*/
        function ValidateForm(){
	        var ToAddress=document.email.ToAddress;
	        var Subject=document.email.Subject;


	        if ((ToAddress.value==null)||(ToAddress.value=="")){
		        alert("Please Enter a To Email Address.");
		        ToAddress.focus();
		        return false;
	        }

	        if (echeck(ToAddress.value)==false){
		        ToAddress.value="";
		        alert("Invalid To Email Address");
		        ToAddress.focus();
		        return false;
	        }

	        if ((Subject.value==null)||(Subject.value=="")){
		        alert("Please Enter an email subject.");
		        Subject.focus();
		        return false;
	        }


	    return true;
        }

        /* Hide graphics
		-----------------------------------------------------------------------*/
        function setImages(flag){
            //debug(flag);
              if (flag=="hide") {
				this.document.theForm.hideImages.value = "1";
				this.document.theForm.submit();
			} else {
				this.document.theForm.hideImages.value = "0";
				this.document.theForm.submit();
		    }

        }

        function setImagesCheckbox(){
            //debug(flag);
                if(this.document.theForm.hideImages.checked) {
				    this.document.theForm.hideImages.value = "1";
			    } else {
				    this.document.theForm.hideImages.value = "0";
		        }

		   }


		/* Response Integration functions
		-----------------------------------------------------------------------*/
		 function changeBrand(brand){
            //debug(brand);
            this.document.theForm.b.value = brand;
            doSubmit('startup.asp');
		   }

    function doPrepPopUp(){

    hasFailed = this.document.getElementById("MIArticleResultFailure").checked;

     if(this.document.theForm.route.value=="chat" && hasFailed) {

        wNewWindow = window.open('','chat','width=472,height=320,status=no,resizable=no,scrollbars=no,location=no,toolbar=no');
        wNewWindow.document.open();
        wNewWindow.document.write("<html><head></head><body><strong>Starting chat session... Please wait.</strong></body></html>");
        wNewWindow.document.close();
        //wNewWindow.document.focus();
        //self.focus();
        }

    }

function doSubmitDT(url,DT,Q,A,answerText){

        if(isNaN(this.document.theForm.DTvantiveID.value)){
            alert("Invalid Vantive ID. Please enter a valid Vantive ID number.");
            this.document.theForm.DTvantiveID.focus();
        } else if(validateEmail()){

            var isReset  = false;
            var resetAnswers = new String("");
            //var DTpathID = new String();
            //var DTpath = new String();

            for(i=0;i<this.document.anchors.length;i++){  // handle the questions which must be unanswered, if any

                if(this.document.anchors[i].name.indexOf(Q)>-1){

                    isReset = true;

                } else if(isReset && (this.document.anchors[i].name.indexOf("UA")>-1)) {

                    resetAnswers += this.document.anchors[i].name.replace(/UA/gi,"") + "|";
                    //DTpath     += this.document.getElementById(this.document.anchors[i].name).innerText + "|";
                    //debug(DTpath);

                }
            }

            this.document.theForm.resetAnswers.value    = resetAnswers;
            //this.document.theForm.DTpathID.value      = DTpathID;
            //this.document.theForm.DTpath.value        = DTpath;
            this.document.theForm.DT.value              = DT;
            this.document.theForm.Q.value               = Q;
            this.document.theForm.A.value               = A;
            this.document.theForm.answerText.value      = answerText;
        	this.document.theForm.action                = url;
        	this.document.theForm.method                = 'POST';
        	this.document.theForm.submit();
    	}
}

function validateEmail(){
//debug("email");
    var atChar = "@";
    var dotChar = ".";
    var email = this.document.theForm.DTuserEmail.value;
    var atIndex = email.indexOf(atChar);
    var dotIndex = email.indexOf(dotChar);
    if(email!=""){
                if(atIndex == -1 || atIndex == 0){
                    alert("Please enter a valid email address for example johndoe@earthlink.net.");
                    this.document.theForm.DTuserEmail.focus();
                    return false;
                }
                if(dotIndex == -1 || dotIndex == 0){
                    alert("Please enter a valid email address for example johndoe@earthlink.net.");
                   this.document.theForm.DTuserEmail.focus();
                    return false;
                }
                return true;
    }
                return true;
}
function selectDT(DT){
        this.document.theForm.DT.value              = DT;
    	this.document.theForm.method                = 'POST';
    	this.document.theForm.action                = 'dtree.asp';
    	this.document.theForm.submit();
}

function reviewSessID(sessID){
    var tSessID = sessID.split("-");
    //  debug(tSessID.length);
      var key = tSessID[tSessID.length-1];
    //  debug(key);
    sessID = "";
    if(tSessID.length>2){
        for(i=0;i<tSessID.length-1;i++){
            sessID = sessID + tSessID[i];
    //        debug(sessID);
        }
        sessID = sessID + "-" + tSessID[tSessID.length-1];
        //this.document.theForm.sessID.value = sessID;
    }
    else{
        sessID = this.document.theForm.sessID.value;
    }
    //debug(sessID);
    this.document.location.href='sesslog.asp?sessID='+sessID;
}
function validateFeedbackFraud()
{    
    if(document.theForm.fraudHeaders.value.length < 20 ){
      alert("In order for EarthLink to properly investigate your issue, please make sure to copy and paste the entire email message & header in the space provided.");
      return false;

    } else {
      if(this.document.theForm.MIArticleResultSuccess.checked)
      {
        this.document.theForm.MI_Submit.id='MI_Submit';
        doPrepPopUp();
        doSubmit('mi.mail.asp');
        return true;
      }
      else if(this.document.theForm.MIArticleResultFailure.checked)
      {
        this.document.theForm.MI_Submit.id='MI_Submit';
        doPrepPopUp();
        doSubmit('mi.mail.asp');
        return true;
      }
      else
      {
        alert("Please select Yes or No.");
        return false;
      }
    }
}

function validateFeedback()
{
    if(this.document.theForm.MIArticleResultSuccess.checked)
    {
        this.document.theForm.MI_Submit.id='MI_Submit';
        doPrepPopUp();
        doSubmit('mi.mail.asp');
        return true;
    }
    else if(this.document.theForm.MIArticleResultFailure.checked)
    {

        this.document.theForm.MI_Submit.id='MI_Submit';
        doPrepPopUp();
        doSubmit('mi.mail.asp');
        return true;
    }
    else
    {
        alert("Please select Yes or No.");
        return false;
    }
}



function validateFeedbackMac()
{
    if(this.document.theForm2.MIArticleResultSuccess.checked)
    {
        this.document.theForm2.MI_Submit.id='MI_Submit';
        doPrepPopUp();
        doSubmit('mi.mail.asp');
        return true;
    }
    else if(this.document.theForm2.MIArticleResultFailure.checked)
    {

        this.document.theForm2.MI_Submit.id='MI_Submit';
        doPrepPopUp();
        doSubmit('mi.mail.asp');
        return true;
    }
    else
    {
        alert("Please select Yes or No.");
        return false;
    }
}


Function.prototype.method = function (name, func) {
    this.prototype[name] = func;
    return this;
};

Function.method('inherits', function (parent) {
    var d = 0, p = (this.prototype = new parent());
    this.method('uber', function uber(name) {
        var f, r, t = d, v = parent.prototype;
        if (t) {
            while (t) {
                v = v.constructor.prototype;
                t -= 1;
            }
            f = v[name];
        } else {
            f = p[name];
            if (f == this[name]) {
                f = v[name];
            }
        }
        d += 1;
        r = f.apply(this, Array.prototype.slice.apply(arguments, [1]));
        d -= 1;
        return r;
    });
    return this;
});

function hasValue(a) {
    if (isUndefined(a)||a=="undefined"||a==""||isNull(a)||isWhitespace(a)||a=="<!---->")
        return false;
    return true;
}

function isAlien(a) {
   return isObject(a) && typeof a.constructor != 'function';
}

function isArray(a) {
    return isObject(a) && a.constructor == Array;
}

function isBoolean(a) {
    return typeof a == 'boolean';
}

function isEmptyKB(o) {
    var i, v;
    if (isObject(o)) {
        for (i in o) {
            v = o[i];
            if (isUndefined(v) && isFunction(v)) {
                return false;
            }
        }
    }
    return true;
}

function isFunction(a) {
    return typeof a == 'function';
}

function isNull(a) {
    return typeof a == 'object' && !a;
}
function isNumber(a) {
    return typeof a == 'number' && isFinite(a);
}

function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}

function isString(a) {
    return typeof a == 'string';
}

function isUndefined(a) {
    return typeof a == 'undefined';
}

function isWhitespace(s){

    var whitespace = " \v\t\n\r\f";

    if((s==null)||(s.length==0))
        return true;

	for (var i=0;i<s.length;i++)
	{
	 var c=s.charAt(i);
	 if(whitespace.indexOf(c)==-1)
	 		return false;
	}
	return true;
}

function IsNumeric(sText){
    var ValidChars = "0123456789";
    var IsNumber=true;
    var Char;
    for (i = 0; i < sText.length && IsNumber == true; i++)
       {
       Char = sText.charAt(i);
       if (ValidChars.indexOf(Char) == -1)
          {
          IsNumber = false;
          }
       }
    return IsNumber;
}

function isHTML(s){
     if(s.match(/<\S[^>]*>/g))
        return true;
    return false;
}

String.method('entityify', function () {
    return this.replace(/&/g, "&amp;").replace(/</g,
        "&lt;").replace(/>/g, "&gt;");
});

String.method('supplant', function (o) {
    var i, j, s = this, v;
    for (;;) {
        i = s.lastIndexOf('{');
        if (i < 0) {
            break;
        }
        j = s.indexOf('}', i);
        if (i + 1 >= j) {
            break;
        }
        v = o[s.substring(i + 1, j)];
        if (!isString(v) && !isNumber(v)) {
            break;
        }
        s = s.substring(0, i) + v + s.substring(j + 1);
    }
    return s;
});

String.method('trim', function () {
    return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
});

if (!isFunction(Function.apply)) {
    Function.method('apply', function (o, a) {
        var r, x = '____apply';
        if (!isObject(o)) {
            o = {};
        }
        o[x] = this;
        switch ((a && a.length) || 0) {
        case 0:
            r = o[x]();
            break;
        case 1:
            r = o[x](a[0]);
            break;
        case 2:
            r = o[x](a[0], a[1]);
            break;
        case 3:
            r = o[x](a[0], a[1], a[2]);
            break;
        case 4:
            r = o[x](a[0], a[1], a[2], a[3]);
            break;
        case 5:
            r = o[x](a[0], a[1], a[2], a[3], a[4]);
            break;
        case 6:
            r = o[x](a[0], a[1], a[2], a[3], a[4], a[5]);
            break;
        default:
            alert('Too many arguments to apply.');
        }
        delete o[x];
        return r;
    });
}

if (!isFunction(Array.prototype.pop)) {
    Array.method('pop', function () {
        return this.splice(this.length - 1, 1)[0];
    });
}

if (!isFunction(Array.prototype.push)) {
    Array.method('push', function () {
        this.splice.apply(this,
            [this.length, 0].concat(Array.prototype.slice.apply(arguments)));
        return this.length;
    });
}

if (!isFunction(Array.prototype.shift)) {
    Array.method('shift', function () {
        return this.splice(0, 1)[0];
    });
}

if (!isFunction(Array.prototype.splice)) {
    Array.method('splice', function (s, d) {
        var max = Math.max,
            min = Math.min,
            a = [], // The return value array
            e,  // element
            i = max(arguments.length - 2, 0),   // insert count
            k = 0,
            l = this.length,
            n,  // new length
            v,  // delta
            x;  // shift count

        s = s || 0;
        if (s < 0) {
            s += l;
        }
        s = max(min(s, l), 0);  // start point
        d = max(min(isNumber(d) ? d : l, l - s), 0);    // delete count
        v = i - d;
        n = l + v;
        while (k < d) {
            e = this[s + k];
            if (!isUndefined(e)) {
                a[k] = e;
            }
            k += 1;
        }
        x = l - s - d;
        if (v < 0) {
            k = s + i;
            while (x) {
                this[k] = this[k - v];
                k += 1;
                x -= 1;
            }
            this.length = n;
        } else if (v > 0) {
            k = 1;
            while (x) {
                this[n - k] = this[l - k];
                k += 1;
                x -= 1;
            }
        }
        for (k = 0; k < i; ++k) {
            this[s + k] = arguments[k + 2];
        }
        return a;
    });
}

if (!isFunction(Array.prototype.unshift)) {
    Array.method('unshift', function () {
        this.splice.apply(this,
            [0, 0].concat(Array.prototype.slice.apply(arguments)));
        return this.length;
    });
}
