// JavaScript Document

// CAROUSEL FOR LOGOS
var mycarousel_itemList = [
    {url: '../images/partners/logos-aoa.jpg', title: 'AOA', linked: 'http://www.aoa.org.uk/'},
	{url: '../images/partners/logos-baca.jpg', title: 'BACA', linked: 'http://www.baca.org.uk/'},
	{url: '../images/partners/logos-bbga.jpg', title: 'BBGA', linked: 'http://www.bbga.aero/'},
	{url: '../images/partners/logos-ecaa.jpg', title: 'EBAA', linked: 'http://www.ebaa.org/'},
	{url: '../images/partners/logos-london-first.jpg', title: 'London First', linked: 'http://www.london-first.co.uk/'},
	{url: '../images/partners/logos-nbaa.jpg', title: 'NBAA', linked: 'http://www.nbaa.org/'},
	{url: '../images/partners/logos-sout-london.jpg', title: 'South London Business', linked: 'http://www.southlondonbusiness.co.uk/'}
];

function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
    // The index() method calculates the index from a
    // given index who is out of the actual item range.
    var idx = carousel.index(i, mycarousel_itemList.length);
    carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[idx - 1]));
};

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    return '<a href="' + item.linked + '" target="_blank"><img src="' + item.url + '" width="202" height="85" alt="' + item.title + '" border="0" /></a>';
};

//CALLS
$(document).ready(function() {
 
   //jCarosel
   jQuery('#mycarousel').jcarousel({
        animation: 1500,
		auto: 4,
		wrap: 'circular',
        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
    });
 
   // HOVER MAIN MENU
   function show() {
	 var menu = $(this);
	 menu.children(".actions").fadeIn();
   }
  
   function hide() { 
	 var menu = $(this);
	 menu.children(".actions").fadeOut();
   }
 
   $(".hover-menu").hoverIntent({
	 sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)
	 interval: 50,   // number = milliseconds for onMouseOver polling interval
	 over: show,     // function = onMouseOver callback (required)
	 timeout: 300,   // number = milliseconds delay before onMouseOut
	 out: hide       // function = onMouseOut callback (required)
   });
   
   	//CARO NUMBERS
	/* function mycarousel_initCallback(carousel) {
		jQuery('.jcarousel-control a').bind('click', function() {
			carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
			return false;
		});
	
		jQuery('#mycarousel2-next').bind('click', function() {
		});
	
		jQuery('#mycarousel2-prev').bind('click', function() {
		});
	}; */
	
	// GOOGLE MAPS
	$('#directions').hide();
	$('a.instruc').click(function() {				   
		$('#directions').slideToggle(400);
		return false;
	});
   
	// JFLOW	
	$("div#controller").jFlow({
		slides: "#slides",
		width: "100%",
		height: "175px"
	});
               
 });
