//Detect Browser Type.
var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);
var iePos  = appVer.indexOf('msie');
if (iePos !=-1) {
  is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
  is_major = parseInt(is_minor);
}
var isMinNS4 = ((navigator.appName.indexOf("Netscape") >= 0 || agt.indexOf("gecko") >= 0) && is_major >= 4) ? true : false;
var isMinNS6 = (agt.indexOf("gecko") >=0 && is_major >= 5) ? true : false;
var isMinIE4 = (document.all) ? true : false;
var isMinIE5 = (isMinIE4==1 && is_major >= 5) ? true : false;
var isMinIE6 = (isMinIE4 && is_major >= 6) ? true : false;
var isDOM = (document.getElementById) ? true : false;
var isSafari = (agt.indexOf("safari") != -1) ? true : false
var isOpera = (agt.indexOf("opera") != -1) ? true : false
var isIE = (isMinIE4 || isMinIE5 ||  isMinIE6);
var isNN = (isMinNS4 || isMinNS6 );

function get(elementName) {
  var ret = null;
  if (isDOM == 1) {
    if(document.getElementById(elementName)) {
      ret = document.getElementById(elementName);
    }
  }  else if (isMinIE4 == 1) {
    if(document.all(elementName)[0]) {
      ret = document.all(elementName)[0];
    }  else {
      ret = document.all(elementName);
    }
  }
  return ret;
}

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.01
  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 && d.getElementById) x=d.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 swapTabs(id,color1,color2,activeTab)
{
for(i=1;i<=2;i++)
{
tmpDivName = eval("get('"+id+i+"')")
tmpImgName = eval("get('"+id+"Ar"+i+"')")
tmpHeadName = eval("get('"+id+"Head"+i+"')")

	if(activeTab==i)
	{
		tmpDivName.style.display='inline';
		tmpImgName.style.display='inline';
		tmpHeadName.style.background=color1;
	} else {
		tmpDivName.style.display='none';
		tmpImgName.style.display='none';
		tmpHeadName.style.background=color2;
	}
}
}
//Inline javascript

    
//Detect Browser Type.
var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);
var iePos  = appVer.indexOf('msie');
if (iePos !=-1) {
  is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
  is_major = parseInt(is_minor);
}
var isMinNS4 = ((navigator.appName.indexOf("Netscape") >= 0 || agt.indexOf("gecko") >= 0) && is_major >= 4) ? true : false;
var isMinNS6 = (agt.indexOf("gecko") >=0 && is_major >= 5) ? true : false;
var isMinIE4 = (document.all) ? true : false;
var isMinIE5 = (isMinIE4==1 && is_major >= 5) ? true : false;
var isMinIE6 = (isMinIE4 && is_major >= 6) ? true : false;
var isDOM = (document.getElementById) ? true : false;
var isSafari = (agt.indexOf("safari") != -1) ? true : false
var isOpera = (agt.indexOf("opera") != -1) ? true : false
var isIE = (isMinIE4 || isMinIE5 ||  isMinIE6);
var isNN = (isMinNS4 || isMinNS6 );

function get(elementName) {
  var ret = null;
  if (isDOM == 1) {
    if(document.getElementById(elementName)) {
      ret = document.getElementById(elementName);
    }
  }  else if (isMinIE4 == 1) {
    if(document.all(elementName)[0]) {
      ret = document.all(elementName)[0];
    }  else {
      ret = document.all(elementName);
    }
  }
  return ret;
}

function openClubMember() {
    window.open('http://visitors.huntingclub.com/SEM_magazine.asp?siteid=100&promotion=9H5COOL4','BecomeaClubMember','width=500,height=540,toolbar=no,scrollbars=yes');
}
function FlagContent(ContentId,ContentType) {
    window.open('../Main/FlagContent.aspx?id=' + ContentId + '&Type=' + ContentType,'FlagContent','width=200,height=200,toolbar=no,scrollbars=no');
}

var styleToSelect;
function onOk() {
// There is no code here. The Modal Popup Extender needs a java script method to call.
}

function ManageBrowser(strOp,objSender)
{
 switch (strOp)
 {
    case "ho":
            objSender.style.behavior = 'url(#default#homepage)';
            objSender.setHomePage (self.location.href);
            break;
    case "af":
            window.external.AddFavorite(self.location.href,document.title);
            break;
 }
}

//function SetUsernameFocus()
//{
//    var ControlToFocus = get("ctl00_Login1_txtUsername");
//    ControlToFocus.focus();
//}

function WatermarkFocus(txtElem, strWatermark) {
 if (txtElem.value == strWatermark) txtElem.value = '';
}
function WatermarkBlur(txtElem, strWatermark) {
 if (txtElem.value == '') txtElem.value = strWatermark;
}
function OpenPopup(url)
{
window.open(url,'popup','width=695,height=775,left=270,top=180,scrollbars=yes')        
}
    

//CJB 12Nov08 added function to swap out inages on default page
function changepic(img_name,img_src,img2_name,img2_src,showCmsDiv,hideCmsDiv) {
    tmpshowCmsDiv = eval("get('"+showCmsDiv+"')")
    tmphideCmsDive = eval("get('"+hideCmsDiv+"')")
    document[img_name].src=img_src;
    document[img2_name].src=img2_src;
    tmpshowCmsDiv.style.display='inline';
    tmphideCmsDive.style.display='none';
}

function setFooterColor(color, selector) {

    var elements = getElementsBySelector(selector);
    for(var i = 0; i < elements.length; i++){
        var node = elements.item(i);
       	for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == 'arbot') {
				    for(var k = 0; k < node.childNodes.length - 1;k++) {
					    node.childNodes.item(k).style.borderTopColor = color;
					    node.childNodes.item(k).style.borderBottomColor = color;
					    node.childNodes.item(k).style.backgroundColor = color;
					}  
				}
			}
		}     
    }
}

/* document.getElementsBySelector(selector)
   - returns an array of element objects from the current document
     matching the CSS selector. Selectors can contain element names, 
     class names and ids and can be nested. For example:
     
       elements = document.getElementsBySelect('div#main p a.external')
     
     Will return an array of all 'a' elements with 'external' in their 
     class attribute that are contained inside 'p' elements that are 
     contained inside the 'div' element which has id="main"

   New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
   See http://www.w3.org/TR/css3-selectors/#attribute-selectors

   Version 0.4 - Simon Willison, March 25th 2003
   -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
   -- Opera 7 fails 
*/

function getAllChildren(e) {
  // Returns all children of element. Workaround required for IE5/Windows. Ugh.
  return e.all ? e.all : e.getElementsByTagName('*');
}

document.getElementsBySelector = function(selector) {
  // Attempt to fail gracefully in lesser browsers
  if (!document.getElementsByTagName) {
    return new Array();
  }
  // Split selector in to tokens
  var tokens = selector.split(' ');
  var currentContext = new Array(document);
  for (var i = 0; i < tokens.length; i++) {
    token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
    if (token.indexOf('#') > -1) {
      // Token is an ID selector
      var bits = token.split('#');
      var tagName = bits[0];
      var id = bits[1];
      var element = document.getElementById(id);
      if (tagName && element.nodeName.toLowerCase() != tagName) {
        // tag with that ID not found, return false
        return new Array();
      }
      // Set currentContext to contain just this element
      currentContext = new Array(element);
      continue; // Skip to next token
    }
    if (token.indexOf('.') > -1) {
      // Token contains a class selector
      var bits = token.split('.');
      var tagName = bits[0];
      var className = bits[1];
      if (!tagName) {
        tagName = '*';
      }
      // Get elements matching tag, filter them for class selector
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        if (tagName == '*') {
            elements = getAllChildren(currentContext[h]);
        } else {
            elements = currentContext[h].getElementsByTagName(tagName);
        }
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      continue; // Skip to next token
    }
    // Code to deal with attribute selectors
    if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
      var tagName = RegExp.$1;
      var attrName = RegExp.$2;
      var attrOperator = RegExp.$3;
      var attrValue = RegExp.$4;
      if (!tagName) {
        tagName = '*';
      }
      // Grab all of the tagName elements within current context
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        if (tagName == '*') {
            elements = getAllChildren(currentContext[h]);
        } else {
            elements = currentContext[h].getElementsByTagName(tagName);
        }
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      var checkFunction; // This function will be used to filter the elements
      switch (attrOperator) {
        case '=': // Equality
          checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
          break;
        case '~': // Match one of space seperated words 
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
          break;
        case '|': // Match start with value followed by optional hyphen
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
          break;
        case '^': // Match starts with value
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
          break;
        case '$': // Match ends with value - fails with "Warning" in Opera 7
          checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
          break;
        case '*': // Match ends with value
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
          break;
        default :
          // Just test for existence of attribute
          checkFunction = function(e) { return e.getAttribute(attrName); };
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (checkFunction(found[k])) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
      continue; // Skip to next token
    }
    // If we get here, token is JUST an element (not a class or ID selector)
    tagName = token;
    var found = new Array;
    var foundCount = 0;
    for (var h = 0; h < currentContext.length; h++) {
      var elements = currentContext[h].getElementsByTagName(tagName);
      for (var j = 0; j < elements.length; j++) {
        found[foundCount++] = elements[j];
      }
    }
    currentContext = found;
  }
  return currentContext;
}

/* That revolting regular expression explained 
/^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
  \---/  \---/\-------------/    \-------/
    |      |         |               |
    |      |         |           The value
    |      |    ~,|,^,$,* or =
    |   Attribute 
   Tag
*/
