if($.browser.mozilla||$.browser.opera ){document.removeEventListener("DOMContentLoaded",$.ready,false);document.addEventListener("DOMContentLoaded",function(){$.ready()},false)}
jQuery.event.remove( window, "load", jQuery.ready );
jQuery.event.add( window, "load", function(){ jQuery.ready(); } );
jQuery.extend({
	includeStates:{},
	include:function(url,callback,dependency){
		if ( typeof callback!='function'&&!dependency){
			dependency = callback;
			callback = null;
		}
		url = url.replace('\n', '');
		jQuery.includeStates[url] = false;
		var script = document.createElement('script');
		script.type = 'text/javascript';
		script.onload = function () {
			jQuery.includeStates[url] = true;
			if ( callback )
				callback.call(script);
		};
		script.onreadystatechange = function () {
			if ( this.readyState != "complete" && this.readyState != "loaded" ) return;
			jQuery.includeStates[url] = true;
			if ( callback )
				callback.call(script);
		};
		script.src = url;
		if ( dependency ) {
			if ( dependency.constructor != Array )
				dependency = [dependency];
			setTimeout(function(){
				var valid = true;
				$.each(dependency, function(k, v){
					if (! v() ) {
						valid = false;
						return false;
					}
				})
				if ( valid )
					document.getElementsByTagName('head')[0].appendChild(script);
				else
					setTimeout(arguments.callee, 10);
			}, 10);
		}
		else
			document.getElementsByTagName('head')[0].appendChild(script);
		return function(){
			return jQuery.includeStates[url];
		}
	},
	readyOld: jQuery.ready,
	ready: function () {
		if (jQuery.isReady) return;
		imReady = true;
		$.each(jQuery.includeStates, function(url, state) {
			if (! state)
				return imReady = false;
		});
		if (imReady) {
			jQuery.readyOld.apply(jQuery, arguments);
		} else {
			setTimeout(arguments.callee, 10);
		}
	}
});
///// include js files ////////////
$.include('js/jquery.easing.1.3.js');
$.include('js/ddsmoothmenu.js');
$.include('js/cufon/cufon-yui.js');
$.include('js/cufon/FrancophilSans_500-FrancophilSans_700.font.js');
$.include('js/jquery.flexibleColumns.min.js');


$.include('js/jquery.tinycarousel.js');
$.include('js/jquery.tipsy.js');



jQuery(document).ready(function(){
	
	// DropDown Menu Plugin
	ddsmoothmenu.init({
		mainmenuid: "menu", //menu DIV id
		orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
		classname: 'ddsmoothmenu', //class added to menu's outer DIV
		contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
	})
	
	// Cufon Font Load

	Cufon.replace('h1, h2, h3, h4', { fontFamily: 'FrancophilSans', hover: false, color: '-linear-gradient(#727171, #020202)' });	// Only for light theme color
	//Cufon.replace('h1, h2, h3, h4', { fontFamily: 'FrancophilSans', hover: false, color: '-linear-gradient(#ffffff, #bababa)' });	// Only for dark theme color
	Cufon.replace('.big_btn', { fontFamily: 'FrancophilSans', hover: true });
	Cufon.replace('#fsb h3', { fontFamily: 'FrancophilSans', hover: true, textShadow: '1px 1px rgba(0, 0, 0, 0.8)', color: '-linear-gradient(#FCFCFC, #B8B8B8)' });
	Cufon.replace('#fsb h4, .gallery h4, .partners h4, .header_full h2, .header_full h3, .overview h4', { fontFamily: 'FrancophilSans', hover: true, color: '-linear-gradient(#ffffff, #bababa)' });
	
	// Fluid Menu
	jQuery('.ddsmoothmenu li').click(function(){
		var url = jQuery(this).find('a').attr('href');
		document.location.href = url;
	});
	jQuery('.ddsmoothmenu li').hover(function(){
		jQuery(this).find('.menuslide').slideDown();
	},
	function(){
		jQuery(this).find('.menuslide').slideUp();
	});
	
	// *************************************** Images ******************************************************//
	//Horizontal Sliding
	jQuery('.gallery_item').hover(function(){
		jQuery(".cover", this).stop().animate({left:'214px'},{queue:false,duration:250});
	}, function() {
		jQuery(".cover", this).stop().animate({left:'0px'},{queue:false,duration:900});
	});

	// find the div.fade elements and hook the hover event
	jQuery('.portfolio_thumb a').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = jQuery('> .hover_img, > .hover_vid', this);
		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(300, 1);
		} else {
			fade.fadeIn(300);
		}
	}, function () {
		var fade = jQuery('> .hover_img, > .hover_vid', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(300, 0);
		} else {
			fade.fadeOut(300);
		}
	});
 
	// get rid of the text
	jQuery('.portfolio_thumb a > .hover_img, .portfolio_thumb a > .hover_img').empty();

	// Partners Page

	//move the image in pixel
	var move = -15;
	//zoom percentage, 1.2 =120%
	var zoom = 1.2;
	//On mouse over those thumbnail
	jQuery('.partner_item').hover(function() {
		
		//Set the width and height according to the zoom percentage
		width = jQuery('.partner_item').width() * zoom;
		height = jQuery('.partner_item').height() * zoom;
		
		//Move and zoom the image
		jQuery(this).find('img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200});
		
		//Display the caption
		jQuery(this).find('div.caption').css({"visibility":"visible",opacity:0.8});
	},
	function() {
		//Reset the image
		jQuery(this).find('img').stop(false,true).animate({'width':jQuery('.partner_item').width(), 'height':jQuery('.partner_item').height(), 'top':'0', 'left':'0'}, {duration:100});	

		//Hide the caption
		jQuery(this).find('div.caption').css({"visibility":"hidden",opacity:0});
	});
	
		// *************************************** Shortcodes ******************************************************//
		


	
	// jQuery Tinycarousel
	if (jQuery("#slider-code").length) {
		jQuery('#slider-code').tinycarousel({
			start: 2, // where should the carousel start?
			display: 4, // how many blocks do you want to move at 1 time?
			axis: 'x', // vertical or horizontal scroller? ( x || y ).
			controls: true, // show left and right navigation buttons.
			pager: false, // is there a page number navigation present?
			interval: false, // move to another block on intervals.
			intervaltime: 3000, // interval time in milliseconds.
			rewind: false, // If interval is true and rewind is true it will play in reverse if the last slide is reached.
			animation: true, // false is instant, true is animate.
			duration: 1000, // how fast must the animation move in ms?
			callback: null // function that executes after every move
		});
	}
	
	
	



	
});

		// *************************************** Functions ******************************************************//

function slide(navigation_id, pad_out, pad_in, time, multiplier)
{
	// creates the target paths
	var list_elements = navigation_id + " li";
	var link_elements = list_elements + " a";
	
	// initiates the timer used for the sliding animation
	var timer = 0;
	
	// creates the slide animation for all list elements 
	jQuery(list_elements).each(function(i)
	{
		// margin left = - ([width of element] + [total vertical padding of element])
		jQuery(this).css("margin-left","-15px");
		// updates timer
		timer = (timer*multiplier + time);
		jQuery(this).animate({ marginLeft: "0" }, timer);
		jQuery(this).animate({ marginLeft: "15px" }, timer);
		jQuery(this).animate({ marginLeft: "0" }, timer);
	});

	// creates the hover-slide effect for all link elements 		
	jQuery(link_elements).each(function(i)
	{
		jQuery(this).hover(
		function()
		{
			jQuery(this).animate({ paddingLeft: pad_out }, 150);
		},		
		function()
		{
			jQuery(this).animate({ paddingLeft: pad_in }, 150);
		});
	});
}
