try {
	String.prototype.trim = function() {

		// skip leading and trailing whitespace
		// and return everything in between
		if (this) {
			var x=this;
			try {
				x=x.replace(/^\s*(.*)/, "$1");
				x=x.replace(/(.*)\s*$/, "$1");
				x=x.replace(/(.*?)\s*$/, "$1");
				return x;
			}
			catch (ex) {
				return x;
			}
		}
	}
}
catch (ex) {};

var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById) ? true : false;
var oDotNetForm = document.forms.__aspnetForm;
 
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 isEmpty(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.prototype.method = function (name, func) {
    this.prototype[name] = func;
    return this;
};

String.method('entityify', function () {
    return this.replace(/&/g, "&amp;").replace(/</g,
        "&lt;").replace(/>/g, "&gt;");
});



// Return base url. 
// Sample: 
// BaseUrl().concat('aw/standard/inc/img/p.gif')
// BaseUrl = Replace(Replace(Left(Request("URL"), InStrRev(Request("URL"),g_sWebRoot)+1),"\","/"),"//","/")
function BaseUrl ()
{
    var url = window.document.location.pathname.toLowerCase()
    var regEx = /\b(admin|agreement|content|faq|login|news|product|purchase|service|site|sitemap|standard|template)\b/i;
    var base = ""
	var i = 1
	while (!regEx.test(url.split("/")[i])) {
		base = base + "/" + url.split("/")[i]
		i = i + 1
	}
	return base
	//url = window.document.location.pathname.toLowerCase().split('aw')[0];	
	//return url;
}

function ElementTextColor (id, newColor) 
{
	if((document.getElementById)&& (document.getElementById(id)!=null)) 
	{
		var eElement = document.getElementById(id);
	 	if ((eElement.style)&& (eElement.style.color!=null)) 
	 	{
			eElement.style.color = newColor;
		}
	}
}

// Show/Hide functions for non-pointer layer/objects
 
function show (id) {
	var oId = document.getElementById(id);
	if (ie4||ns6) {
		if (oId) {
			oId.style.visibility = "visible";
		}
	} else if (ns4) {
		if (oId) {
			oId.visibility = "show";
		}
	}
}
 

function hide (id) {
	var oId = document.getElementById(id);
	if (ie4||ns6) {
		if (oId) {
			oId.style.visibility = "hidden"; 
		}
	} else if (ns4) {
		if (oId) {
			oId.visibility = "hide";
		}
	}
}

 
function MoveDiv (name,x,y) {
      ie_x = x + 0; // ie_x and ie_y compensate for differences
      ie_y = y + 0; // in alignment between ie and netscape
      
      if (ns4) {
          document.layers[name].top=y
          document.layers[name].left=x
      } else if (ie4) {
          document.all[name].style.top=ie_y  
          document.all[name].style.left=ie_x
      } else if (ns6) {
          document.getElementById(name).style.top = y + "px" 
          document.getElementById(name).style.left = x + "px"
      }
}

/* <form name="myForm" action="fo.asp" method="post" onsubmit="return checkForm(this)" > 
 <input type="hidden" name="companyName_required" value="Please provide a company name" /> */
function checkForm(thisform)
        {
        returnval=true;
        for (var j=0; j<(thisform.elements.length); j++)
                {
                indx = thisform.elements[j].name.indexOf('_required');
                if (indx != -1)
                        {
                        fieldname=thisform.elements[j].name.substring(0,indx);
                        if (thisform.elements[fieldname].value.length == 0)
                                {
                                alert(thisform.elements[j].value);
                                j = (thisform.elements.length);
                                returnval = false;
                                }
                        }
                }
        return returnval;
        }
        
function newbrowser()
{
	var dr
	top.newwin=window.open('');
	dr = top.newwin.document.open('text/html','replace');
	dr.location=self.document.location;
	top.newwin.focus();
}	

// ====================================================================
// Original post: Unkown person - I lost my notes on who did this first
//                Unkown source
// Modified by:   Walter Torres &lt;walter@torres.ws&gt; [www.torres.ws]
//                2001/04/29
//                I found the secret to remove the prompt!
//                Original post did not have this gem to it.
//
// This accesses a built-in Windows command that can perform Magic!
// And yes, this is a Windows ONLY solution.
// In fact, it only works in IE. :(
//
// This still doesn't work with Frames!  :(
//
//          INPUT: intOLEcmd   = integer between 1 and 37, only a few are of use
//                 intOLEparam = parameter integer for function - optional
//         OUTPUT: none
//   DEPENDANCIES: none
//
//           NOTE: intOLEparam is not optional in the Object call,
//                 I just made it optional here to make life easier.
//                 All command values use '1' execept print, thus my reasoning.
//
//        EXAMPLE: // This prints given window/frame WITHOUT prompt!
//                 objWinName.ieExecWB(6, -1)
//
//                 // This prints given window/frame WITH prompt!
//                 objWinName.ieExecWB(6)

// 	               // This will display the Print Preview window
//                 objWinName.ieExecWB(7)
//
//         VALUES: intOLEcmd has these possible values
//                 OLECMDID_OPEN         = 1
//                 OLECMDID_NEW          = 2    warning, this kills IE windows!
//                 OLECMDID_SAVE         = 3
//                 OLECMDID_SAVEAS       = 4
//                 OLECMDID_SAVECOPYAS   = 5    note: does nothing in IE
//                 OLECMDID_PRINT        = 6    note: give '-1' as param - no prompt!
//                 OLECMDID_PRINTPREVIEW = 7
//                 OLECMDID_PAGESETUP    = 8
//                          Others have no use in IE

function ieExecWB( intOLEcmd, intOLEparam )
{
	// Create OLE Object
	var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 

	// Place Object on page
	document.body.insertAdjacentHTML('beforeEnd', WebBrowser);

	// if intOLEparam is not defined, set it
	if ( ( ! intOLEparam ) || ( intOLEparam < -1 )  || ( intOLEparam > 1 ) )
		intOLEparam = 1;

	// Execute Object
	WebBrowser1.ExecWB( intOLEcmd, intOLEparam );

	// Destroy Object
	WebBrowser1.outerHTML = "";
}

function printpr() 
{ 
	var PROMPT = 1; // 2 DONTPROMPTUSER 
	ieExecWB(7);
}

function setFramesetStyleSheet()
{
	if (top.frames.length>0 ) //if in frames
	{
		enableActiveStyleSheet('Frameset');
	}
	else
	{
		disableActiveStyleSheet('Frameset');
	}
}

//Make ToolTip work with IE. Ignore JavaScript error.
function ElementAddHoverClass(node){
	if (!ie4) { return; } // other browser does not need to run this code.
	try {
		re = new RegExp("ToolTip\\b")
		if (node.className)
		{
			if (re.test(node.className)) {
				node.onmouseover = function() { 
							this.className +=" over"; 
							cite = this.getElementsByTagName('cite')(0);
							cite.style.pixelTop = window.event.clientY + document.body.scrollTop;
							cite.style.pixelLeft = window.event.clientX + document.body.scrollLeft-50;
							if (cite.style.pixelLeft<=0) 
							{ 
								cite.style.pixelLeft=0; 
							}
				}
				node.onmouseout = function() { this.className = this.className.replace(new RegExp(" over\\b"),""); } 
			}
		}
	}
	catch (ex) {};
}
function DocumentProcess() {
	try {
		if (ie)
		{
			var oAll = document.body.all;
			var len = document.body.all.length;
			for (var i=0; i<len; i++) { 
				ElementAddHoverClass(oAll(i)); 
			}
		}
		if (window.history)
		{
			if (window.history.length==0)
			{
				if (document.getElementById)
				{
					if (document.getElementById('BackButton1'))
					{
						document.getElementById('BackButton1').style.display='none';
					}
				}
			}
		}
	}
	catch (ex) {};
}
if (window.attachEvent) window.attachEvent("onload",DocumentProcess)

function ElementIsVisible(node){
returnval=true;
	try {
		if (node.currentStyle) {
			if (node.currentStyle.display=='none') {
				returnval = false;
			}
		}
		else if (node.style) {
			if (node.style.display=='none') {
				returnval = false;
			}
		}
	}
	catch (ex) {};
	return returnval;
}

function ElementAddClass(node,NewClassName){
	try {
		if (isString(node))
		{
			node = document.getElementById(node);
		}
		re = new RegExp("\\b"+NewClassName+"\\b")
		if (node.className)
		{
			if (!re.test(node.className)) {
				node.className = node.className + ' ' + NewClassName; 
			}
		}
	}
	catch (ex) {};
}

function ElementRemoveClass(node,DeleteClassName){
	try {
		if (isString(node))
		{
			node = document.getElementById(node);
		}
		re = new RegExp("\\b"+DeleteClassName+"\\b")
		if (node.className)
		{
			if (re.test(node.className)) {
				node.className = RegExp.leftContext; 
			}
		}
	}
	catch (ex) {};
}

function ElementToggleClass(node,NewClassName){
	try {
		if (isString(node))
		{
			node = document.getElementById(node);
		}
		re = new RegExp("\\b"+NewClassName+"\\b")
		if (node.className)
		{
			if (re.test(node.className)) {
				ElementRemoveClass(node,NewClassName)
			}
			else
			{
				ElementAddClass(node,NewClassName)
			}
		}
	}
	catch (ex) {};
}

/*
OpenHelp('auhelp','1000')
*/
function OpenHelp(HelpProject,PageHelpContextId)
{
try {
		window.open('about:blank', '__webCshStub', 'toolbar=no,menubar=no,directories=no,scrollbars=yes,status=no,width=700,height=500,left=100,top=100,resizable=yes'); window.open('http://www.avantra.se/roboapi.asp?project=' + HelpProject + '&ctxid=' + PageHelpContextId + '>noNavWindow','__webCshStub');
	}
catch (ex) {};
}

function GetDotNetElementById(innerId)
{
	return document.getElementById("pageTemplate__PageTemplate_innerHolder__ctl0_" + innerId)
}