// Fix background image flickering in IE
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) { }

/* begin - Navigation Primary */
var NavigationPrimary = {
  init: function() {
    if (false /*$.browser.msie*/) // iframe to fix dropdowns over select items
        $('#NavigationPrimary li').append('<iframe style="display: none;" src="javascript:false;" frameBorder="0" scrolling="no"></iframe>');
		
		var c = this;
		var n = $('#NavigationPrimary');
		// Mark parent elements so that we can style them with CSS
		$('> li', n).each(function() { c.markParents(this); });
  	
    $('li', n).hover(
      function() {
        $(this).addClass('over').children('a').addClass('over');
        if (false /*$.browser.msie*/)
        {
          var u = $('> ul', $(this));
          var h = u.height();
          var w = u.width();
          var i = $(this).children('iframe');
          var l = u.css('left');
          var t = u.css('top');
          if (i.length > 0 && h != null && w != null)
            i.height(h).width(w).css({ left: l, top: t }).show();  
        }
      },
      function() {
        $(this).removeClass('over').children('a').removeClass('over');
        if (false /*$.browser.msie*/)
          $(this).children('iframe').hide();
      }
    );
  },
  markParents: function(li) {
    var c = this;
    if ($('> ul', li).size() > 0)
	    $(li).addClass('parent').find('> a').addClass('parent').end().find('> ul li').each( function() { c.markParents(this); });
	}
	
};
$(function() { NavigationPrimary.init(); });
/* end - Primary Navigation */


/* begin - mailto functions */
/* These functions are used to hide email addresses in the content from robots */
function emsales () {
document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,115,97,108,101,115,64,115,121,109,112,104,111,110,105,113,46,99,111,109,34,62,115,97,108,101,115,64,115,121,109,112,104,111,110,105,113,46,99,111,109,60,47,97,62))
}

function eminfo () {
document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,105,110,102,111,64,115,121,109,112,104,111,110,105,113,46,99,111,109,34,62,105,110,102,111,64,115,121,109,112,104,111,110,105,113,46,99,111,109,60,47,97,62))
}

function emorders () {
document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,111,114,100,101,114,115,64,115,121,109,112,104,111,110,105,113,46,99,111,109,34,62,111,114,100,101,114,115,64,115,121,109,112,104,111,110,105,113,46,99,111,109,60,47,97,62))
}

function empartners () {
document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,112,97,114,116,110,101,114,115,64,115,121,109,112,104,111,110,105,113,46,99,111,109,34,62,112,97,114,116,110,101,114,115,64,115,121,109,112,104,111,110,105,113,46,99,111,109,60,47,97,62))
}
/* end - mailto functions */

/* ***********************Begin toggle div tags*********************** */
function toggledivs() {
  var inc, endInc=arguments.length;
  for (inc=0; inc<endInc; inc+=2) {
    var id = arguments[inc];
    if (arguments[inc+1] == 'none')
    	$('#' + id).hide();
    else if(arguments[inc+1]=='block')
	    $('#' + id).show();
  }
}

function getElementsByClass(searchClass,node,tag) {
  // This function gets the elements that all share a class name
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function an_toggleDisplay(theid) {
	// This function toggles between the tabs and the corresponding content for the tabs.  The tabs <li> must correspond 1-1 with the order of the content UL content elements.
	// if your 3rd tab is "tab for content z" then ensure that your UL for the content is placed as the 3rd element.
	// we could give the tabs an id in order to match the id of the actual content, but it was kept this way in order to save on logic processing time and added code to the HTML (yet more id's to keep track of).
  
	var contentelmt = getElementsByClass('tab_contents');
	var tabelmt = getElementsByClass('litab');
	var match = false;
		for (i = 0; i < contentelmt.length; i++) {
			if (theid == contentelmt[i].id) {
				match = true;
				contentelmt[i].style.display = "block";
				tabelmt[i].className ="litab active";
			}
			else {
				contentelmt[i].style.display = "none";
				tabelmt[i].className = "litab";			
			}		
		}
		if (!match) {
			contentelmt[0].style.display = "block";
			tabelmt[0].className="litab active";
		}
}
/* ***********************end toggle div tags*********************** */
function openpopupwindow(url, name) {
  popupWin = window.open(url, name, 'width=600,height=400,left=20,top=20,resizable=0,scrollbars=0')
}

var Search = {
  prompt: "Search", // default value - should get real value from markup
  init: function() { this.prompt = $('#search').focus(this.focus).blur(this.blur).val(); },
  focus: function() { if (this.value == Search.prompt) { this.value = ''; } },
  blur: function() { if (this.value.length == 0) { this.value = Search.prompt} }
};
$(function() { Search.init(); });

$(function() {
			function activateFirst() {
				$('#FirstActive').show()
					.next().hide() // #FirstInactive
					.next().hide() // #SecondActive
					.next().show() // #SecondInactive
					.next().hide() // #ThirdActive
					.next().show(); // #ThirdInactive
				$('#MastOne').show()
					.next().hide() // #MastTwo
					.next().hide(); // #MastThree
			}

			function activateSecond() {
				$('#FirstActive').hide()
					.next().show() // #FirstInactive
					.next().show() // #SecondActive
					.next().hide() // #SecondInactive
					.next().hide() // #ThirdActive
					.next().show(); // #ThirdInactive
				$('#MastOne').hide()
					.next().show() // #MastTwo
					.next().hide(); // #MastThree
			}

			function activateThird() {
				$('#FirstActive').hide()
					.next().show() // #FirstInactive
					.next().hide() // #SecondActive
					.next().show() // #SecondInactive
					.next().show() // #ThirdActive
					.next().hide(); // #ThirdInactive
				$('#MastOne').hide()
					.next().hide() // #MastTwo
					.next().show(); // #MastThree
			}

			
			$('#FirstActive').hoverIntent(activateFirst, function() { });
			$('#FirstInactive').hoverIntent(activateFirst, function() { });
			$('#SecondActive').hoverIntent(activateSecond, function() { });
			$('#SecondInactive').hoverIntent(activateSecond, function() { });
			$('#ThirdActive').hoverIntent(activateThird, function() { });
			$('#ThirdInactive').hoverIntent(activateThird, function() { });

		    // Show appropriate mast buttons
		    $('#FirstInactive').hide();
		    $('#SecondActive').hide();
		    $('#ThirdActive').hide();
		    
		    // Show appropriate mast images
		    $('#MastTwo').hide();
		    $('#MastThree').hide();
		});	
