

var backup = [];
var position = 'home';



function init_menulink(menu_link, carousel)
{
	 jQuery('#' + menu_link).bind('click', function() {
		if (position == 'location')
		{
//			alert('change to developer');
			myimages = backup;
			carousel.reset();
			carousel.scroll(jQuery.jcarousel.intval(1));
		}
		if (position == 'home')
			window.scrollBy(0,150); 
		position = menu_link;
        //carousel.scroll(jQuery.jcarousel.intval(9));
		jQuery('#text_frame').attr('src', './texts/' + menu_link + '.html');
        return false;
    });
	
	
	
};


function mycarousel_initCallback(carousel) {
	   jQuery('#location').bind('click', function() {
		if (position != 'location')
		{
//			alert('change to location');
		position = 'location';											  
		backup = myimages;
		myimages = myimages_loc;
		//carousel.reload();
		carousel.reset();
        carousel.scroll(jQuery.jcarousel.intval(1));
		jQuery('#text_frame').attr('src', './texts/location.html');
		}
        return false;
    });
};


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 pathname = window.location.pathname;
	var test = pathname.indexOf('awards');
	var test2 = pathname.indexOf('staff');
	var test3 = pathname.indexOf('about');
	if(test > 0)
		var idx = carousel.index(i + 1, myimages.length);
	else if(test2 > 0)
    	var idx = carousel.index(i + 2, myimages.length);
	else if(test3 > 0)
	    	var idx = carousel.index(i + 1, myimages.length);
	else
		var idx = carousel.index(i, myimages.length);
    carousel.add(i, myimages[idx - 1]);
};

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
};


/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    return '<img src="' + item.url + '" width="952" height="387" />';
};

jQuery(document).ready(function() {
    
	jQuery('#mycarousel').jcarousel({
        wrap: 'circular',
	  	scroll:1,
        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback},
		initCallback: mycarousel_initCallback
    });

	$("#scroller").simplyScroll({
			speed: 2.5
		});
	$('#pj1').mouseover(function() {
		$('#gallery_text_1').css("color", "#ffffff");
	});
	$('#pj1').mouseout(function() {
		$('#gallery_text_1').css("color", "#CBBA6F");
	});
	$('#pj2').mouseover(function() {
		$('#gallery_text_2').css("color", "#ffffff");
	});
	$('#pj2').mouseout(function() {
		$('#gallery_text_2').css("color", "#CBBA6F");
	});
	$('#pj3').mouseover(function() {
		$('#gallery_text_3').css("color", "#ffffff");
	});
	$('#pj3').mouseout(function() {
		$('#gallery_text_3').css("color", "#CBBA6F");
	});
	$('#pj4').mouseover(function() {
		$('#gallery_text_4').css("color", "#ffffff");
	});
	$('#pj4').mouseout(function() {
		$('#gallery_text_4').css("color", "#CBBA6F");
	});
	$('#pj5').mouseover(function() {
		$('#gallery_text_5').css("color", "#ffffff");
	});
	$('#pj5').mouseout(function() {
		$('#gallery_text_5').css("color", "#CBBA6F");
	});
	$('#pj6').mouseover(function() {
		$('#gallery_text_6').css("color", "#ffffff");
	});
	$('#pj6').mouseout(function() {
		$('#gallery_text_6').css("color", "#CBBA6F");
	});
	$('#pj7').mouseover(function() {
		$('#gallery_text_7').css("color", "#ffffff");
	});
	$('#pj7').mouseout(function() {
		$('#gallery_text_7').css("color", "#CBBA6F");
	});
	$('#pj8').mouseover(function() {
		$('#gallery_text_8').css("color", "#ffffff");
	});
	$('#pj8').mouseout(function() {
		$('#gallery_text_8').css("color", "#CBBA6F");
	});
	$('#pj9').mouseover(function() {
		$('#gallery_text_9').css("color", "#ffffff");
	});
	$('#pj9').mouseout(function() {
		$('#gallery_text_9').css("color", "#CBBA6F");
	});
	$('#pj10').mouseover(function() {
		$('#gallery_text_10').css("color", "#ffffff");
	});
	$('#pj10').mouseout(function() {
		$('#gallery_text_10').css("color", "#CBBA6F");
	});
	$('#pj11').mouseover(function() {
		$('#gallery_text_11').css("color", "#ffffff");
	});
	$('#pj11').mouseout(function() {
		$('#gallery_text_11').css("color", "#CBBA6F");
	});
	$('#pj12').mouseover(function() {
		$('#gallery_text_12').css("color", "#ffffff");
	});
	$('#pj12').mouseout(function() {
		$('#gallery_text_12').css("color", "#CBBA6F");
	});
	$('#pj13').mouseover(function() {
		$('#gallery_text_13').css("color", "#ffffff");
	});
	$('#pj13').mouseout(function() {
		$('#gallery_text_13').css("color", "#CBBA6F");
	});
	$('#pj14').mouseover(function() {
		$('#gallery_text_14').css("color", "#ffffff");
	});
	$('#pj14').mouseout(function() {
		$('#gallery_text_14').css("color", "#CBBA6F");
	});
	$('#pj15').mouseover(function() {
		$('#gallery_text_15').css("color", "#ffffff");
	});
	$('#pj15').mouseout(function() {
		$('#gallery_text_15').css("color", "#CBBA6F");
	});
	$('#pj16').mouseover(function() {
		$('#gallery_text_16').css("color", "#ffffff");
	});
	$('#pj16').mouseout(function() {
		$('#gallery_text_16').css("color", "#CBBA6F");
	});
	$('#pj17').mouseover(function() {
		$('#gallery_text_17').css("color", "#ffffff");
	});
	$('#pj17').mouseout(function() {
		$('#gallery_text_17').css("color", "#CBBA6F");
	});
	$('#pj18').mouseover(function() {
		$('#gallery_text_18').css("color", "#ffffff");
	});
	$('#pj18').mouseout(function() {
		$('#gallery_text_18').css("color", "#CBBA6F");
	});
	$('#pj19').mouseover(function() {
		$('#gallery_text_19').css("color", "#ffffff");
	});
	$('#pj19').mouseout(function() {
		$('#gallery_text_19').css("color", "#CBBA6F");
	});
});
