// BrowserCheck Object
// provides most commonly needed browser checking variables

function BrowserCheck() 
{
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.v = parseInt(navigator.appVersion)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	if (this.ie5) this.v = 5
	this.min = (this.ns||this.ie)
	var p = navigator.platform
	//if (p=="MacPPC") this.p = "mac"
	//else this.p = p
}


// automatically create the "is" object
is = new BrowserCheck()


// determine relevant browser attributes
browser = (document.images) ? 1 : 0;

function OpenOffsitePage(lb, wnd)
{
	var SelIndex = lb.selectedIndex;
	if (lb.selectedIndex <= 1) return;
	var Value = lb.options[SelIndex].value;

	// Get first char from Value
	var FirstChar = Value.substr(0, 1);

	// Get URL from Value
	var URL = Value.substr(1);

	// Determine whether to open in same frame or new window
	if(FirstChar == '1')
	{
		wnd.location.href = URL;
	}
	else
	{
		winStats='toolbar=yes,location=yes,directories=no,menubar=yes,resizable=yes,'
		winStats+='scrollbars=yes'
		if (navigator.appName.indexOf("Microsoft")>=0) 
		{
			winStats+=',left=50,top=50,width=600,height=400'
		}
		else
		{
			winStats+=',screenX=50,screenY=50,width=600,height=400'
		}
		adWindow=window.open(URL,"",winStats)     
		adWindow.focus()
	}
}


function OpenInNewWindowCSSOrg(Url)
{
	OpenInNewWindowEx(Url,  'width=800,height=600,toolbar=yes,location=yes,directories=no,menubar=yes,resizable=yes,scrollbars=yes');
}

function OpenInNewWindowSUW(Url)
{
	OpenInNewWindowEx(Url,  'width=1000,height=600,toolbar=yes,location=yes,directories=no,menubar=yes,resizable=yes,scrollbars=yes');
}


function OpenInNewWindow(Url)
{
	OpenInNewWindowEx(Url,  'width=750,height=600,toolbar=yes,location=yes,directories=no,menubar=yes,resizable=yes,scrollbars=yes');
}
function OpenInNewWindowSurvey(Url)
{
	OpenInNewWindowEx(Url,  'width=650,height=500,toolbar=yes,location=yes,directories=no,menubar=yes,resizable=yes,scrollbars=yes');
}

function OpenInNewWindowService(Url)
{
	OpenInNewWindowEx(Url,  'width=880,height=500,toolbar=no,location=no,directories=no,menubar=no,resizable=yes,scrollbars=yes');
}

function IgnoreOpenInNewWindowService(Url)
{
	alert('Due to the seasonal nature of this service request, \nself-service options are currently not active. \nThe service will be activated upon seasonal demand.')
}

function OpenInNewWindowWhat(Url)
{
	OpenInNewWindowEx(Url,  'width=600,height=300,toolbar=no,location=no,directories=no,menubar=no,resizable=no,scrollbars=no');
}

function OpenInNewWindowSlide(Url)
{
	OpenInNewWindowEx(Url,  'width=450,height=500,toolbar=no,location=no,directories=no,menubar=no,resizable=yes,scrollbars=yes');
}


function OpenInNewWindowEx(Url, OpenParams)
{
	open(Url, 'EX', OpenParams);
        //alert('testing new OpeninNewWindow. This should go away shortly');
        //location.replace(Url);
}

function OpenInNewWindowSm(Url)
{
	OpenInNewWindowEx(Url,  'width=340,height=305,toolbar=no,location=yes,directories=no,menubar=no,resizable=yes,scrollbars=yes');
}

function OpenInNewWindowState(Url)
{
	OpenInNewWindowEx(Url,  'width=340,height=330,toolbar=no,location=yes,directories=no,menubar=no,resizable=no,scrollbars=no');
}

function OpenInNewWindowBuzz(Url)
{
	OpenInNewWindowEx(Url,  'width=425,height=420,toolbar=no,location=yes,directories=no,menubar=no,resizable=no,scrollbars=no');
}

function OpenInNewWindowMayor(Url)
{
	OpenInNewWindowEx(Url,  'width=400,height=330,toolbar=yes,location=yes,directories=no,menubar=yes,resizable=yes,scrollbars=yes');
}

function MM_swapImgRestore() //v3.0
{ 
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() //v3.0
{ 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) //v4.0
{ 
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) 
	{
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
    }
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}


function MM_swapImage() //v3.0
{ 
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


/********************************************************************************/

function date()
{
    // Array of month Names
    var monthNames = new Array(
    "January","February","March","April","May","June","July",
    "August","September","October","November","December");

    var now = new Date();
    document.write(monthNames[now.getMonth()] + " " + 
    now.getDate() + ", " + now.getFullYear());
}


/********************************************************************************/
function openpop(pop, size)
{
	if (size == "small")
	{
		window.open(pop,"","width=200,height=100,");
	}
	else if (size == "medium")
	{
		window.open(pop,"","width=410,height=285,");
	}
	else if (size == "large")
	{
		window.open(pop,"","width=325,height=330,");
	}
	else if (size == "video-320x240")
	{
		window.open(pop,"","width=340,height=380,");
	}
	else if (size == "video-480x360")
	{
		window.open(pop,"","width=500,height=400,");
	}
}


/********************************************************************************/ 
function GetCookie(cookieName) 
{
	var returnValue = "notfound";
  
	if (document.cookie.length > 0) 
	{
		offset = document.cookie.indexOf(cookieName);
		if (offset != -1) 
		{ 
			returnValue="found";
		}
	}
	return returnValue;
}
 

/********************************************************************************/ 
function LoadOnce(pop, size)
{
	if (GetCookie("poppedup")=="notfound")
	{
		openpop(pop, size)
		document.cookie="poppedup";
	}
}

function LTrim(str)
/***
        PURPOSE: Remove leading blanks from our string.
        IN: str - the string we want to LTrim

        RETVAL: An LTrimmed string!
***/
{
        var whitespace = new String(" \t\n\r");

        var s = new String(str);

        if (whitespace.indexOf(s.charAt(0)) != -1) {
            // We have a string with leading blank(s)...

            var j=0, i = s.length;

            // Iterate from the far left of string until we
            // don't have any more whitespace...
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;


            // Get the substring from the first non-whitespace
            // character to the end of the string...
            s = s.substring(j, i);
        }

        return s;
}


function RTrim(str)
/***
        PURPOSE: Remove trailing blanks from our string.
        IN: str - the string we want to RTrim

        RETVAL: An RTrimmed string!
***/
{
        // We don't want to trip JUST spaces, but also tabs,
        // line feeds, etc.  Add anything else you want to
        // "trim" here in Whitespace
        var whitespace = new String(" \t\n\r");

        var s = new String(str);

        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
            // We have a string with trailing blank(s)...

            var i = s.length - 1;       // Get length of string

            // Iterate from the far right of string until we
            // don't have any more whitespace...
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                i--;


            // Get the substring from the front of the string to
            // where the last non-whitespace character is...
            s = s.substring(0, i+1);
        }

        return s;
}


function Trim(str)
/***
        PURPOSE: Remove trailing and leading blanks from our string.
        IN: str - the string we want to Trim

        RETVAL: A Trimmed string!
***/
{
        return RTrim(LTrim(str));
}
 
// Returns true if the string only contains alpha characters (empty string = true)
function isAlpha(txt)
{
	return ValidString(txt,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz');
}

// Returns true if the string only contains numeric characters (empty string = true)
function isNumeric(txt)
{
	return ValidString(txt,'0123456789');
}

// Returns true if the string only contains alpha numeric characters (empty string = true)
function isAlphaNumeric(txt)
{
	return ValidString(txt,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789');
}

// Returns true if the CheckString only contains characters passed in ValidString (empty string = true)
function ValidString(ChkString,ValidString)
{
	for (i=0; i<ChkString.length; i++)
	{
		if (ValidString.indexOf(ChkString.substring(i,i+1)) == -1) return false;
	}
	return true;
}

function popCrimeStat(site){
			var mainWin = window.open(site,'mainWin','width=750,height=700,scrollbars=1,menubar=1,status=0,toolbar=0,location=1,resizable=1,screenX=0,screenY=0,left=50,top=50');
			mainWin.focus();
		}
