﻿$(function() {

	$('#portal-image').show();
	$('#portal-news').show();

    $('.slideshow').cycle({
		fx: 'fade',
		timeout: 6000,
		speed: 2000
	});

	// initialize scrollable
	//$(".scrollable").scrollable({circular:true});
	
	

	
	
	$(".scrollable").scrollable({circular:true});
	
		jQuery.fn.scrollableAddClones = function() {
	  // grab scrollable plugin
	  var scrollable;
	  if (!(scrollable = $(this).data('scrollable')) || !scrollable.getConf().circular)
	    return;
	  // grab scrollable elements and remember it's count
	  var nodes = scrollable.getItems();
	  var length = nodes.length;
	  // grab class for the nodes
	  var clonedClass = scrollable.getConf().clonedClass;
	  // get wrap object to append the clones to
	  var wrap = scrollable.getItemWrap();
	  // add 8 clone objects - start at 1 as element[0] was already cloned by scrollable()
	  for (var i = 1; i <= 8; i++) {
	    nodes.eq(i % length).clone().addClass(clonedClass).appendTo(wrap);
	  }
	}
	
	$('.scrollable').scrollableAddClones();
	// Browser switch // Don't blend objects with PNG Transparency in all IE Versions
	if($.browser.msie)
	{
		var speedSlow = 0;
		var speedFast = 0;
	}
	else
	{
		var speedSlow = 600;
		var speedFast = 200;
	}
	
	$(".portal-item-active").hide();
	$('.portal-item-link').click(function() {
		var visible = $(this).siblings('.portal-item-active').is(":visible");
		if( visible == "true" )
		{
			$(this).siblings('.portal-item-active').fadeOut('slow' );
		}
		else
		{
			$('.portal-item-active').fadeOut('fast');
			$('.flyout-menu').fadeOut(speedFast );
			$(this).siblings('.portal-item-active').fadeIn('slow');
		}
	});

	$(".flyout-menu").hide();
	$('.main-menu-link').click(function() {
		var visible = $(this).siblings('.flyout-menu').is(":visible");
		if( visible == true )
		{
			$(this).siblings('.flyout-menu').fadeOut(speedFast );
		}
		else
		{
			$('.portal-item-active').fadeOut('fast');
			$('.flyout-menu').fadeOut(speedFast );
			$(this).siblings('.flyout-menu').fadeIn(speedFast );
		}
	});

});


