function setTopNavItem(anchorID) {
	resetTopNav();
	var linkID = '#' + anchorID + 'Link';
	$(linkID).removeClass('topNavLink');
	$(linkID).addClass('topNavLink-selected');
}
function resetTopNav() {
	$('*').children('.topNavLink-selected').addClass('topNavLink');
	$('*').children('.topNavLink-selected').removeClass('topNavLink-selected');
}
function showSliderGroup(groupHandle, groupItem, groupCount) {
	var groupItemId = groupHandle + '_' + groupItem.toString();
	var i;
	for (i = 1; i <= groupCount; i++) {
		var aGroupItemId = '#' + groupHandle + '_' + i.toString();
		var aGroupItemLink = aGroupItemId + '_Link';
		// interrogate the group item
		if ($(aGroupItemId).length) {
			if (i == groupItem) {
				// this is the one to show
				$(aGroupItemId).show();
				$(aGroupItemLink).removeClass('groupLink');
				$(aGroupItemLink).addClass('groupLink-selected');				
			}
			else {
				// hide the others
				$(aGroupItemId).hide();
				$(aGroupItemLink).removeClass('groupLink-selected');
				$(aGroupItemLink).addClass('groupLink');
			}
		}
	}
}
function badBrowser() {
	//alert($.browser.version);
	/************ MICROSOFT IE ************************************************************************/
	// detect very old IE versions
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { //test for MSIE x.x;
		var ieversion = new Number(RegExp.$1) // capture x.x portion and store as a number
		var iemajorversion = parseInt(ieversion);
		if (iemajorversion <= 5) return true;
	}
	if ($.browser.msie && parseInt($.browser.version) <= 6) { return true; } 	//IE ver. 6.0
	
	/************ OPERA *******************************************************************************/
	if ($.browser.opera) {
		alert($.browser.version);
		if (($.browser.version * 10) < 90) { return true; } 	//Opera ver.  < 9
	}
	
	/************ MOZILLA *****************************************************************************/
	if ($.browser.mozilla) {
		var version = parseFloat($.browser.version.substring(0, $.browser.version.indexOf('.') + 2));
		//alert(version);
		if (version < 1.6) return true;
	}
	
	/*
	if ($.browser.safari && (navigator.appVersion.indexOf("1") != -1)) { return true; }		//Safari ver. 1.0
	if ($.browser.safari && (navigator.appVersion.indexOf("2") != -1)) { return true; } 	//Safari ver. 2.0
	if ($.browser.safari && (navigator.appVersion.indexOf("3") != -1)) { return true; } 	//Safari ver. 3.0
	*/
	return false;
}

function setAlternateCSS() {
	$('link[rel*=style][title]').each(function(i) {
		// loop each style with title
		this.disabled = true;
		if (this.getAttribute('title') == 'siteSinglePageStyle') this.disabled = false;
	});
}
function menuLinkRewriter() {
	$('a').each(function(i) {
		// loop each link
		var linkUrl = this.getAttribute('href');
		//alert(linkUrl);
		var hashIndex = linkUrl.indexOf('#');

		if (hashIndex > 0) {
			// get the target page
			var targetPage = linkUrl.substr(hashIndex + 1) + '.aspx';
			// remove the hash link and add the aspx page request
			targetUrl = linkUrl.substring(0, hashIndex) + targetPage;
			//alert(targetUrl);
			this.setAttribute('href', targetUrl);
		}
	});
}
function IsIPad() {
	return (navigator.userAgent.match(/iPad/i));
}
function IsIPod() {
	return (navigator.userAgent.match(/iPod/i));
}
function IsIPhone() {
	return (navigator.userAgent.match(/iPhone/i));
}
function IsAndroid() {
	return (navigator.userAgent.match(/Android/i));
}
function IsBlackBerry() {
	return (navigator.userAgent.match(/BlackBerry/i));
}

function slideSwitch() {
	var $active = $('#slideshow IMG.active');

	if ($active.length == 0) $active = $('#slideshow IMG:last');

	// use this to pull the images in the order they appear in the markup
	var $next = $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

	// uncomment the 3 lines below to pull the images in random order

	// var $sibs  = $active.siblings();
	// var rndNum = Math.floor(Math.random() * $sibs.length );
	// var $next  = $( $sibs[ rndNum ] );


	$active.addClass('last-active');

	$next.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 1000, function() {
        	$active.removeClass('active last-active');
        });
}


