﻿// JScript File

// Set focus to supplied form field
function setFocus(passedformfield)
{
    eval("document.all." + passedformfield + ".focus();")
    eval("document.all." + passedformfield + ".blur();")
    eval("document.all." + passedformfield + ".select();")
}

// Redirect to supplied URL
function jump(oThis, sURL){
    var cid = oThis.options[oThis.selectedIndex].value;
    
    //alert(sURL+cid);
    if(cid != ''){
        //alert(sURL+cid);
        window.location=(sURL+cid);
    }
}

// Open page in new window
function openNewWindow(sUrl, sWindowName, sAttributes){
    window.open(sUrl, sWindowName, sAttributes);
    //window.open("http://www.sportsmansguide.com/main/custnum.asp","custnum","toolbar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1");
    return false;
}


// Set Navigator family
if (document.layers) {navigator.family = "nn4"}
if (document.all) {navigator.family = "ie4"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}

// Browser Detection Javascript
// copyright 1 February 2003, by Stephen Chapman, Felgall Pty Ltd
function whichBrowser() {
    var agt=navigator.userAgent.toLowerCase();
    if (agt.indexOf("opera") != -1) return 'Opera';
    if (agt.indexOf("staroffice") != -1) return 'Star Office';
    if (agt.indexOf("webtv") != -1) return 'WebTV';
    if (agt.indexOf("beonex") != -1) return 'Beonex';
    if (agt.indexOf("chimera") != -1) return 'Chimera';
    if (agt.indexOf("netpositive") != -1) return 'NetPositive';
    if (agt.indexOf("phoenix") != -1) return 'Phoenix';
    if (agt.indexOf("firefox") != -1) return 'Firefox';
    if (agt.indexOf("safari") != -1) return 'Safari';
    if (agt.indexOf("skipstone") != -1) return 'SkipStone';
    if (agt.indexOf("msie") != -1) return 'Internet Explorer';
    if (agt.indexOf("netscape") != -1) return 'Netscape';
    if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
    if (agt.indexOf('\/') != -1) {
        if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
            return navigator.userAgent.substr(0,agt.indexOf('\/'));
        }
        else
            return 'Netscape';
    } 
    else if (agt.indexOf(' ') != -1)
        return navigator.userAgent.substr(0,agt.indexOf(' '));
    else
        return navigator.userAgent;
}

//URL Encode string
//        function urlDecode(str){
//            str=str.replace(new RegExp('\\+','g'),' ');
//            return unescape(str);
//        }

// URL Decode string
//        function urlEncode(str){
//            str=escape(str);
//            str=str.replace(new RegExp('\\+','g'),'%2B');
//            return str.replace(new RegExp('%20','g'),'+');
//        }

function getCookie(NameOfCookie)
{
    // First we check to see if there is a cookie stored.
    // Otherwise the length of document.cookie would be zero.

    if (document.cookie.length > 0) 
    { 
        // Second we check to see if the cookie's name is stored in the
        // "document.cookie" object for the page.

        // Since more than one cookie can be set on a
        // single page it is possible that our cookie
        // is not present, even though the "document.cookie" object
        // is not just an empty text.
        // If our cookie name is not present the value -1 is stored
        // in the variable called "begin".

        begin = document.cookie.indexOf(NameOfCookie+"="); 
        if (begin != -1) // Note: != means "is not equal to"
        { 
            // Our cookie was set. 
            // The value stored in the cookie is returned from the function.

            begin += NameOfCookie.length+1; 
            end = document.cookie.indexOf(";", begin);
            if (end == -1) end = document.cookie.length;
            return unescape(document.cookie.substring(begin, end));
        } 
    }
    return null; 

    // Our cookie was not set. 
    // The value "null" is returned from the function.
}

function setCookie(NameOfCookie, value, expiredays) 
{
    // Three variables are used to set the new cookie. 
    // The name of the cookie, the value to be stored,
    // and finally the number of days until the cookie expires.
    // The first lines in the function convert 
    // the number of days to a valid date.

    var ExpireDate = new Date ();
    ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

    // The next line stores the cookie, simply by assigning 
    // the values to the "document.cookie" object.
    // Note the date is converted to Greenwich Mean time using
    // the "toGMTstring()" function.

    document.cookie = NameOfCookie + "=" + escape(value) + 
        ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function delCookie (NameOfCookie) 
{
    // The function simply checks to see if the cookie is set.
    // If so, the expiration date is set to Jan. 1st 1970.

    if (getCookie(NameOfCookie)) {
    document.cookie = NameOfCookie + "=" +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function popUp(url) {
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=700,height=450');
	self.name = "mainWin";
}

function large_popup(imagefile, sCaption){
	var loc
	if(typeof sCaption == 'undefined'){ sCaption = ''; }
	loc="/zoom/largepop.asp?i=" + imagefile + "&c=" + sCaption;
	zoompop=window.open(loc,"zoom",'toolbar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=420,height=420');
}
function xlarge_popup(imagefile, sSize, sCaption){
	var loc
	if(typeof sCaption == 'undefined'){ sCaption = ''; }
	loc="/zoom/xlargepop.asp?i=" + imagefile + "&s=" + sSize + "&c=" + sCaption;
	zoompop=window.open(loc,"zoom",'toolbar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=720,height=420');
}
function zoom_popup(imagefile, sHeight, sWidth, sBackColor, sUserInt, sMaxClicks, sClickFactor, sNavLoc, sCaption){
	var loc
	if(typeof sCaption == 'undefined'){ sCaption = ''; }
	loc="/zoom/zoompop.asp?i=" + imagefile + "&h=" + sHeight + "&w=" + sWidth + "&bgc=" + sBackColor + "&ui=" + sUserInt + "&mc=" + sMaxClicks + "&cf=" + sClickFactor + "&nv=" + sNavLoc + "&c=" + sCaption;
	zoompop=window.open(loc,"zoom",'toolbar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=500,height=500');
}

function closeDiv(aDivId)
{
  elem = document.getElementById(aDivId);
  if (elem != null)
  {
     elem.style.display = "none";
  }
}