function onAfter(curr, next, opts) {

    var index = opts.currSlide;
    rel = $(next).attr('rel');
    $("#subNavBox a").removeClass('active');
    $("#subNavBox a[rel="+rel+"]").addClass('active');
}

$(function(){
    $('#mainContentTabs').tabs();
	$('#subContentTabBoxes').tabs();
    $('.interior #subContent > ul > li > a.drop').click(function(){
    $(this).parent().children('ul').toggle("slow");
	     return false;
	});
				
	$(window).ready(function() {
		$('li.products ul').show();
        $('li.technical ul').show();
        $('li.tips ul').show();
		$('li.quicklinks ul').show();
	});	

    $('#imageBarSlides').cycle({
		fx:     'fade',
		before:   onAfter,
		timeout:  6000
	});
    
    // Taken from http://www.queness.com/post/77/simple-jquery-modal-window-tutorial
	var popupCookieKey = "PopupTracker=FrontPopup20110127";
    var fnModal = function (id)
    {
        var $id = $("#" + id);
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set height and width to mask to fill up the whole screen
		$('#modalmask').css({'width':maskWidth,'height':maskHeight}).show();
		
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$id.css('top',  winH/2-$id.height()/2);
		$id.css('left', winW/2-$id.width()/2);
	
        //Setup close button
        $id.find(".modalno").click(function(e)
        {
			document.cookie = popupCookieKey + '; expires=1/1/2021 00:00:00';
            $('#modalmask').hide();
            $id.fadeOut();
            return false;
        });
    
		//transition effect
		$id.show();
    }
	
	if(document.cookie.indexOf(popupCookieKey) < 0)
	{ fnModal("frontpopup"); }
	
}); 

$(document).ready(function(){
 $('#pageHeader ul li').hover(function(){
  $(this).find('ul').show();
 },function(){
  $(this).find('ul').hide();
 })
})
