function open_menu(menu_id, title)
{
	var menu = jQuery('#' + menu_id);
	if (menu.length == 0 || jQuery('#' + menu_id).css('display') == 'block')
	{
		if (jQuery('#' + menu_id).css('display') == 'block')
		{
			jQuery('#' + menu_id).slideToggle('slow');
			title.className = 'categ_title';
		}
		return ;
	}

	// set all li positions to static so IE behaves
	if (jQuery.browser.msie)
		menu.parents('#nav').find('li').each(function () { jQuery(this).attr('prevPosition', jQuery(this).css('position')).css('position', 'static')} );

	// hide all level 2 menus until animation is complete
	menu.parents('#nav').find('.categ > ul ul').css('visibility', 'hidden');

	// alert(menu_id);
	jQuery('#nav .categ > ul').each(function () {
		if (jQuery(this).css('display') == 'block')
		{
			// save the prevbgcolor to an attribute of the element and set current bg color to white
			if (jQuery(this).css('background-color') == 'transparent')
				jQuery(this).attr('prevBgColor', jQuery(this).css('background-color')).css('background-color', 'white');

			// toggle
			jQuery(this).slideToggle('slow', function () {
				var bgColor;
				// when done revert the bg color
				jQuery(this).css('background-color', (bgColor = jQuery(this).attr('prevBgColor')) ? bgColor : 'transparent');
			});

			return false;
		}
	});

	jQuery('#nav a').each(function () {
		if (jQuery(this).attr('name') == 'categ_title')
			this.className = 'categ_title';
	});

	menu.slideToggle('slow', function () {
		// revert the IE hack
		if (jQuery.browser.msie)
			jQuery(this).parents('#nav').find('li').each(function () {
				jQuery(this).css('position', (position = jQuery(this).attr('prevPosition')) ? position : 'relative' );
			});

		// show all level 2 menus
		jQuery(this).parents('#nav').find('.categ > ul ul').css('visibility', 'visible');
	});
	title.className = 'categ_title open';
}

function show_img(src, img_id, original)
{
	jQuery("#" + img_id +" > img").attr("src", src);
	jQuery("#" + img_id).attr("href", original);
	jQuery("#hr_link").attr("href", original);
}

function switch_tab(tab)
{
	var key = '';
	jQuery("#the_tabs > div").each(function () {
			if (jQuery(this).attr("class") != "clearfloat")
			{
				key = this.id.substr(2);
				if (key == tab)
				{
					jQuery(this).attr("class", "tab selected");
					jQuery("#d_"+key)[0].style.display = "block";
				}
				else
				{
					jQuery(this).attr("class", "tab");
					jQuery("#d_"+key)[0].style.display = "none";
				}
			}
	});;
}

function openReport(id)
{
	newwindow = window.open('newsletter.html?id='+id+'&pdf='+pdf, title, 'height=600, width=800');

	if (window.focus)
		newwindow.focus();

	return false;
}

function changePage(option)
{
	document.location.href = base_href + option.value;
}

function browser_info()
{
	if (navigator.appName == 'Microsoft Internet Explorer') {
	  verNumIE() ;
	} else {
	  verNumOt() ;
	}
	
	alert(navName +"\n"+ brNum);
}

var navName = navigator.appName ;
var brVer = navigator.userAgent; var brNum; var reg = new RegExp('/');
function verNumIE() {
   var brVerId = brVer.indexOf('MSIE');
   brNum = brVer.substr(brVerId,8);
}
function verNumOt() {
   var brVerId = brVer.search(reg);
   brNum = brVer.substring(brVerId+1);
}

jQuery(document).ready(function() {

	jQuery("a#single_image").fancybox();

	jQuery("a#inline").fancybox({
		'hideOnContentClick': true
	});

	jQuery("a.iframe").fancybox({
		'hideOnContentClick': false,
		'frameWidth' : jQuery(window).width() - 200,
		'frameHeight': jQuery(window).height() - 100
	});

	jQuery("a.group").fancybox({
		'zoomSpeedIn':	300,
		'zoomSpeedOut':	300,
		'overlayShow':	true,
		'overlayOpacity': 0.7
	});
});

jQuery(document).ready(function (){
	if (jQuery("#custom_links"))
	{
		jQuery("#custom_links img").hover(
			function() {
				jQuery(this).attr('src', jQuery(this).attr('src').replace(/\.([a-z]*)$/i, '_h.$1'));
			},
			function () {
				jQuery(this).attr('src', jQuery(this).attr('src').replace(/_h\.([a-z]*)$/i, '.$1'));
			}
		);
	}
});

jQuery(document).ready(function () {
	if (jQuery("#the_tabs") && self.document.location.hash == "#reviews")
	{
		switch_tab(2);
	}
});

