﻿/***************************************************************************\
* Function:     trim                                                        *
* Author:       Terry Tice                                                  *
* Created:      11/08/07                                                    *
* Purpose:      Adds a trim function to the string prototype.               *
\***************************************************************************/
if (!String.trim)
{
    String.prototype.trim = function() 
    {
	    return this.replace(/^\s+|\s+$/g, "");
    }
}

/***************************************************************************\
* Function:     createXmlHttpRequest                                        *
* Author:       Unknown (Added by Terry Tice)                               *
* Created:      Unknown (Added on 09/20/07)                                 *
* Purpose:      Creates an XML HTTP Request object for AJAXing.             *
\***************************************************************************/
function createXmlHttpRequest() 
{
    try { return new ActiveXObject("Msxml2.XMLHTTP");    } catch(e) {}
    try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
    try { return new XMLHttpRequest();                   } catch(e) {}
    return null;
}

/***************************************************************************\
* Function:     $                                                           *
* Author:       Terry Tice                                                  *
* Created:      09/21/07                                                    *
* Accepts:      The ID of the element to find.                              *
* Purpose:      Provides a cross-browser way of finding an element.         *
\***************************************************************************/
function $(id)
{
    if (document.getElementById)
        return document.getElementById(id);
    else if (document.all)
        return document.all[id];
    else
        return null;
}

/***************************************************************************\
* Function:     openPage                                                    *
* Author:       Terry Tice                                                  *
* Created:      07/15/08                                                    *
* Accepts:      The page that is to be opened.                              *
*               The name of the window.                                     *
* Purpose:      Provides an easy way to open a web page in a new window.    *
\***************************************************************************/
function openPage(page, name)
{
	var cartoviewer = window.open(page, name, 
	    "width=600,height=660,toolbar=0,menubar=0,location=0,scrollbars=0,resizable=0");
	    
	if(window.focus)
		cartoviewer.focus();
}