var mrMac = (
	navigator.userAgent.indexOf('Mac') != -1
);

startList = function() {
	if (!mrMac) {
		if (document.all&&document.getElementById) {
			navRoot = document.getElementById("primary-nav");
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
	}	
}
window.onload=startList;

/*

Accesible Pop Up Code

This file contains only functions necessary for the article features
The full library code and enhanced versions of the functions present
here can be found at http://v2studio.com/k/code/lib/

MISC CLEANING-AFTER-MICROSOFT STUFF

isUndefined(v)
    returns true if [v] is not defined, false otherwise

    IE 5.0 does not support the undefined keyword, so we cannot do a direct
    comparison such as v===undefined.
*/

// MISC CLEANING-AFTER-MICROSOFT STUFF

function isUndefined(v) {
    var undef;
    return v===undef;
}

function SetSearchIndicator(type)
{
	var indicator = document.getElementById("hdnSearchFlag");
	if(indicator != null)
		indicator.value = type;
}

// These defaults should be changed the way it best fits your site
var _POPUP_FEATURES = '';

function raw_popup(url, target, features) {
    // pops up a window containing url optionally named target, optionally having features
    if (isUndefined(features)) features = _POPUP_FEATURES;
    if (isUndefined(target  )) target   = '_blank';
    var theWindow = window.open(url, target, features);
    theWindow.focus();
    return theWindow;
}

function link_popup(src, features) {
    // to be used in an html event handler as in: <a href="..." onclick="link_popup(this,...)" ...
    // pops up a window grabbing the url from the event source's href
    return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}

var defaultButton=null;

function SetFocus(id){
	defaultButton = document.getElementById(id);
	if (null == defaultButton || window.event.keyCode!=13) 
		return;
	defaultButton.focus();
	defaultButton.click();
  //window.event.returnValue = false;
  return false;
}
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 GoTo(e)
{
	if(e.options[e.selectedIndex].value == "" || e.options[e.selectedIndex].value == "0")
	{
	
	}
	else
	{
		document.location.href = "#"+ e.options[e.selectedIndex].value;
	}
}
function ShowPage(e)
{
	var s = e.options[e.selectedIndex].value;
	if(s.length > 0 && s != "0")
	{
		document.location.href = s;
	}
}
// Form Validation
//browser detection
var strUserAgent = navigator.userAgent.toLowerCase(); 
var isIE = strUserAgent.indexOf("msie") > -1; 
var isNS6 = strUserAgent.indexOf("netscape6") > -1; 
var isNS4 = !isIE && !isNS6  && parseFloat(navigator.appVersion) < 5; 

function GetMyObjectByID(itemID)
{
// In the future will need to build in the ability to handle v4 netscape browsers.
	if (document.getElementById) // Good browsers
		return document.getElementById(itemID)
	else if (document.all) // medium browsers
		return document.all[itemID];
		
	// Need to handle v4 browsers in the future.
}
function CheckField(itemID)
{
	var o = GetMyObjectByID(itemID);
	if(o.value.length<1)
		return false;
	else
		return true;
}

function CheckDD(itemID)
{
	var o = GetMyObjectByID(itemID);
	var select = o.options[o.selectedIndex].value;
	
	if(select.length<1 || select == "0")
		return false;
	else
		return true;
}

function CheckCheckbox(itemID)
{
	var o = GetMyObjectByID(itemID);
	
	return (o.checked);
}

function CheckRadio(FormName,itemID)
{	
	//var o = GetMyObjectByID(itemID);
	var o = document.forms[FormName][itemID];
	
	var cnt = -1;
	for (var i=0; i < o.length; i++) {
		if (o[i].checked) {
	   	cnt = i; 
		i = o.length;
	   }
	}
	if (cnt > -1) 
		return true;
	else 
		return false;
}

function CheckEmail(itemID) 
{
	var o = GetMyObjectByID(itemID);	
	if (o != null)
	{	
		// Make sure we let an email go through that is empty... The required field catcher will get that
		if (o.value.length < 1)
		{
			return false;
		}
		var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;		
		if (!regex.test(o.value))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
}

function isSpecialKey(strValue){
// Returns true if one of these special key codes is pressed
//backspace Ctrl + C,enter, Ctrl + X, Ctrl + V, Ctrl + Z
var reKeyboardChars = /[\x00\x03\x08\x0D\x16\x18\x1A]/;
	return reKeyboardChars.test(strValue);
}

/*
To filter the max length here is some example code 
to catch both key down and to catch paste events
onkeypress="return FilterMaxLength(event,this,250)" onpaste="return CheckPaste(this,250)"
*/
function FilterMaxLength(e,o,max){
// we must allow spaces , backspace etc to go through 
	var iKeyCode, strKey;  
	
	if (isIE) {
		iKeyCode = e.keyCode;
	} else {
		iKeyCode = e.which;
	}	
	strKey = String.fromCharCode(iKeyCode);	
	// Make sure we let special keys go through.
		if (isSpecialKey(strKey))
			return true;	
		var maxLength = max;
     	if(o.value.length > maxLength-1){
	 		alert('You are only able to make a maximum payment of $99,999. Please reduce the amount and try again');
        	return false;
     	}
    	return true
	}
function CheckPaste(o,max){
	var maxLength = max;
	// Get from clipboard
	var data = window.clipboardData.getData("Text");

	var CurrentLength = o.value.length + data.length;
    if (CurrentLength > maxLength)
    {
		alert('You are only able to make a maximum payment of $99,999. Please reduce the amount and try again');
		return false;
	}
	else
		return true;
}
//mask input to allow integer only
function CheckNumeric(objEvent) {
	var iKeyCode, strKey;  
	var reValidChars = /\d/;	
	var reKeyboardChars =       /[\x00\x03\x08\x0D\x16\x18\x1A]/;
	if (isIE) {
		iKeyCode = objEvent.keyCode;
	} else {
		iKeyCode = objEvent.which;
	}
	
	strKey = String.fromCharCode(iKeyCode);
	
	if (!reValidChars.test(strKey) && !reKeyboardChars.test(strKey)) {
		return false;
	}
}
