$(document).ready(function()
{

	//SELECT
	$('.styled').easySelectBox();
	$('.styled-office-select').easySelectBox({className:'easy-select-box office-select'});
	$('.styled-service-select').easySelectBox({className:'easy-select-box service-select'});

	$('.lang-form .easy-select-box ul li a').click(function()
	{
		if ($(this).attr('rel') != '') {
			location.replace($(this).attr('rel'));
		}
	});

	//SLIDESHOW
	$('#slideshow').cycle({
		fx:	 'fade',
		speed:  'slow',
		timeout: 9000
	});
	
	//TOOLTIP
	$(".tooltip").qtip({
		position: {
			corner: {
				target: 'topMiddle',
				tooltip: 'topMiddle'
			},
			adjust: { y: -60 }
		},
		style: {
			tip: {
				corner: 'bottomMiddle',
				size:	 {x:15,y:8}
			},
			border: {
				radius: 4,
				width: 1,
				color: '#b1b3b4'
			},
			width: 140,
			background: '#ebebeb',
			color: '#525455'
		}
	});

//TEAM IE6 HOVER
	$('.team em').hover(
		function() { $(this).addClass('hover'); },
		function() { $(this).removeClass('hover'); }
	);

	$('.filter-letters-select').click(function(){
		var self = $(this),
			toSelect = self.attr('rel'),
			nowSelected = $('.filter-letters-select.active').attr('rel');

		$('.filter-letters-select.active').removeClass('active');
		$('#'+nowSelected).hide();
		$('#'+toSelect).show();
		self.addClass('active');
	});

	$('.module.team').mosaic({maxElements: 6, fadeInterval: 3000});

});
// SCROLLER + OUR TEAM MOSAIC
(function($)
{
	$(function() { $("#scroller").simplyScroll({ autoMode: 'loop', speed:	2 }); });


	// MOSAIC HOVER
	$(function() {
		$('.module.team li').hover(
			function(){ $(this).addClass('hovered'); },
			function(){ $(this).removeClass('hovered');}
		);
	});
	// MOSAIC
	$.fn.mosaic = function(userSettings)
	{
		var defaultSettings = { fadeInterval: 4000, fadeSpeed: 'slow', maxElements: 9 };
		var settings = $.extend(defaultSettings, userSettings);

		$.fn.mosaic.fadeInOut = function ()
		{
			var visiblePerson = $('.module.team li:not(.hidden):not(.last):not(.hovered)').random(1), hiddenPerson = $('.module.team li.hidden:not(.last)').random(1), toShow = hiddenPerson.html(), toHide = visiblePerson.html(); $('.module.team li.last').removeClass('last');
			visiblePerson.fadeOut(settings.fadeSpeed, function(){ visiblePerson.html(toShow); hiddenPerson.html(toHide).addClass('last'); visiblePerson.fadeIn(settings.fadeSpeed).addClass('last'); });
		};

		if ($('.module.team li').length > settings.maxElements)
		{
			var interval = setInterval('$.fn.mosaic.fadeInOut()', settings.fadeInterval);
		}
	};
})(jQuery);


// Random
/**
 *
 * jQuery Random plugin
 *
 * @author   Michel Belleville <michel.belleville@gmail.com>
 * @version  1.1.0
 * @requires jQuery v1.3.2 or later
 * @license  GPLv3 [http://www.gnu.org/licenses/gpl.html]
 *
 * @description Picks element(s) at random in a selection.
 * @param integer num (optional) number of elements to pick
 *
 * Use :
 * $('#whatever .you .like').random();
 * $('.you_can_event select .more_than_one').random(10);
 *
 */
(function($) { $.fn.random = function(num) { num = parseInt(num); if (num > this.length) {return this.pushStack(this)}; if (! num || num < 1) {num = 1}; var to_take = new Array(); this.each(function(i) { to_take.push(i); }); var to_keep = new Array(); var invert = num > (this.length / 2); if (invert) {num = this.length - num}; for (; num > 0; num--) { for (var i = parseInt(Math.random() * to_take.length); i > 0; i--) { to_take.push(to_take.shift()); } to_keep.push(to_take.shift()); } if (invert) {to_keep = to_take}; return this.filter(function(i) { return $.inArray(i, to_keep) != -1; }); }; }) (jQuery);
