$(document).ready(function() {
	
	$(".wrapper ul").removeClass("cssOnly");
	function addMega(){
		$(this).find("ul.subnav").fadeIn(200);
		$(this).find("a.rootNav").addClass("bgcol");
		}
	function removeMega(){
		$(this).find("ul.subnav").fadeOut(200);
		$(this).find("a.rootNav").removeClass("bgcol");
		}
	var megaConfig = {
		interval: 300,
		sensitivity: 4,
		over: addMega,
		timeout: 300,
		out: removeMega
	};
	$("#menuTop li").hoverIntent(megaConfig)
  
});


/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/
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');
        });
}


$(function(){

	$("ul.tabs").tabs("div.panes > div.thetabs");
	$('ul.tabs a').attr('style', 'display: block;');
	
	$('.scroll-pane').jScrollPane();
	$('.scroll-pane-arrows').jScrollPane(
		{
			showArrows: true,
			horizontalGutter: 10
		}
	);
	$('.scroll-pane-home').jScrollPane(
		{
			showArrows: true,
			horizontalGutter: 10
		}
	);

	setInterval( "slideSwitch()", 5000 );

	$("a#example_elastic").fancybox({
		'titleShow'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
	$("a[rel=example_group]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
		
	
});


function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}

function textLimit(field, maxlen) {
if (field.value.length > maxlen + 1)
alert('Maximum of 60 characters');
if (field.value.length > maxlen)
field.value = field.value.substring(0, maxlen);
}

