

// MAIN NAVIGATION DROP DOWN

$(function () {
	if ($.browser.msie && $.browser.version < 7) {
		$('#mainNav li li a')
			.css('line-height','1.0em')
			.css('padding-top','4px')
			.css('padding-bottom','4px');
	}
	$('#mainNav ul li').each(function () {
		if ($(this).find('ul').length == 1) {
			// this item has a sub nav
			// add decoy elements
			var $anchor = $(this).find('a:first');
			var tabClass = 'tab';
			var decoy = '<a class="decoy" href="' + $anchor.attr('href') + '">' + $anchor.html() + '</a>';
			if (!$.browser.msie) {
				decoy = '<div class="decoy"></div>' + decoy;
			}
			if ($anchor.hasClass('last')) {
				tabClass = 'last-tab';
				$(this).addClass('last-tab');
			}
			$anchor.after(decoy)
					.addClass(tabClass);

			// add event handlers
			$(this).mouseover(function(e) {
				var pos = $(this).offset();
				if ($.browser.msie) {
					$(this).find('a.decoy')
						.css('left', pos.left + 'px');
				}
				$ulRight = $(this).find('ul.right');
				if ($ulRight.length > 0) {
					var l = pos.left - ($ulRight.outerWidth() - $(this).outerWidth() - 1);
					if ($(this).hasClass('last-tab')) {
						l -= 9;
					}
					$ulRight.css('left', l + 'px');
				}
				$(this).addClass('parent');
				return false;
			})
			.mouseout(function(e) {
				$(this).removeClass('parent');
				return false;
			});
		}
	});
});





// MAIL CHIMP MODAL DIALOG BOX


function gradient(id, level)
{
	var box = document.getElementById(id);
	box.style.opacity = level;
	box.style.MozOpacity = level;
	box.style.KhtmlOpacity = level;
	box.style.filter = "alpha(opacity=" + level * 100 + ")";
	box.style.display="block";
	return;
}


function fadein(id) 
{
	var level = 0;
	while(level <= 1)
	{
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
		level += 0.01;
	}
}


// Open the lightbox


function openbox(formtitle, fadin)
{
  var box = document.getElementById('box'); 
  document.getElementById('filter').style.display='block';
  
  if(fadin)
  {
	 gradient("box", 0);
	 fadein("box");
  }
  else
  { 	
    box.style.display='block';
  }  	
}


// Close the lightbox

function closebox()
{
   document.getElementById('box').style.display='none';
   document.getElementById('filter').style.display='none';
}





