// JavaScript Document

//------------------------------------------------------------------------------------------------------------------
//SETUP//
var urlBase ="http://www.udfrance.com/"
var toggleSpeed = 1000        //dropdown speed 
var fadeSpeedIcons = "fast"   //social icons hover speed - possible values: slow,normal,fast or xxxx milliseconds
var facebookPageID ="UnlimitDesign/167541586629542"
var twitterID = "udfrance"
var skypeID ="udfrance"
var helpDesk ="hesk/ticket.php"
var videoTuts ="videotuts/"
var freshIdeas ="freshideas/"
var thinkTank ="thinktank/"
var Home ="index.html"
var Thinking ="thinking.html"
var Solutions ="solutions.html"
var Folio ="folio.html"
var Contact ="contact.html"
var Back ="folio.html"
var f1="folio.html"
var f2="bistro.html"
var f3="sucvia.html"
var f4="tapp.html"
var f5="smn.html"
var f6="whynot.html"
var fsFadeSpeed = 3000; /*fade in-out speed of fullscren slider*/
var fsTimeout = 10000;/*time out before loading next fs img*/

//------------------------------------------------------------------------------------------------------------------



$(document).ready(function(){
	//init carousel
	$('.infiniteCarousel').infiniteCarousel();					 
	
	
		
	Cufon.replace('#nav li a',{hover:true,hoverables:{a:true}}); 
	Cufon.replace('h1', { textShadow: '2px 2px 3px #cccccc' }); 
	Cufon.replace('h2', { textShadow: '2px 2px 3px #cccccc' }); 
	Cufon.replace('h3', { textShadow: '2px 2px 2px #cccccc' });
	
	//SET SOCIAL URLS
	$("a#facebook").attr("href", "http://www.facebook.com/pages/"+facebookPageID)
	$("a#twitter").attr("href", "http://www.twitter.com/"+twitterID)
	$("a#freshIdeas").attr("href", urlBase+freshIdeas)
	$("a#thinkTank").attr("href", urlBase+thinkTank)
	$("a#helpDesk").attr("href", urlBase+helpDesk)
	$("a#videoTuts").attr("href",urlBase+videoTuts)
	$("a#skype").attr("href", "skype:"+skypeID+"?call")
		
	//MAIN NAVIGATION
	$("a#home").attr("href", urlBase+Home)
	$("a#thinking").attr("href", urlBase+Thinking)
	$("a#solutions").attr("href",  urlBase+Solutions)
	$("a#folio").attr("href",  urlBase+Folio)
	$("a#contact").attr("href",  urlBase+Contact)
	
	
	//FOLIO NAVIGATION
	$("a#f1").attr("href", urlBase+f1)
	$("a#f2").attr("href", urlBase+f2)
	$("a#f3").attr("href",  urlBase+f3)
	$("a#f4").attr("href",  urlBase+f4)
	$("a#f5").attr("href",  urlBase+f5)
	$("a#f6").attr("href",  urlBase+f6)
	
	
	

	
	
	//MAIN NAVIGATION
	$("a#back").attr("href", urlBase+Back)
	

	//TWITTER
	$('.tweet').tweet({
	  username: twitterID,
	  count: 1,
	  loading_text: 'Loading tweet...'
	});				
	
	
	//FADE IN PAGE
	//$("#pageContent").css({ opacity: 0.0 });						//hide textual info
	//$("#pageContent").animate({"opacity": "1"}, 2500);				//fade in info
	
	
	//ICON HOVERS
	$(".rollover").css({ opacity: 0.0 });
	
	
	$(".rollover").hover(
						 
			function() {
				$(this).animate({"opacity": "1"}, fadeSpeedIcons);
				
		},
			function() {
				$(this).animate({"opacity": "0"}, fadeSpeedIcons);
				
		});
	
	
	
	//SINGLE FOLIO INFO HOVERS
	$(".infoContainerFullWidth").fadeOut(0);
	$(".infoContainerHalfWidth").fadeOut(0);
	$(".infoContainerFolioFullWidth").fadeOut(0);
	$(".infoContainerFolioHalfWidth").fadeOut(0);
	$(".infoContainer").fadeOut(0);
	$('.imgHolder').mouseenter(function(e) {
		//$(this).children('.imgInnerHolder').children('a').children('span').animate({  height: '20px',  top: '20', width: '680'}, 100);
		$(this).children('a').children('span').fadeIn(300);
	}).mouseleave(function(e) {
		//$(this).children('.imgInnerHolder').children('a').children('span').animate({height: '20', top: '0' , width: '680'}, 100);
		$(this).children('a').children('span').fadeOut(300);
	});
	
	
	//DROPDOWN TOGGLE
		$(function() {
	    var open = false;
		$('.up').hide(); 
	    $('#toggleBut').click(function() {
	        if(open === false) {
	            $('#DropdownContainer').animate({ height: '355px' });
				 $('#DropDownBorder').animate({ marginTop: '350px' });
	            $(this).css('backgroundPosition', 'bottom left');
				//Flip arrow visibility
				$('.down').hide();
				$('.up').show();
	            open = true;
				$(".twitter").animate({"opacity": "0"}, 1000);	
	        } else {
	            $('#DropdownContainer').animate({ height: '0px' });
				 $('#DropDownBorder').animate({ marginTop: '-5px' });
	            $(this).css('backgroundPosition', 'top left');
				//Flip arrow visibility
				$('.down').show();
    			$('.up').hide();
	            open = false;
				$(".twitter").animate({"opacity": "1"}, 1000);	
	        }
	    });
	});
	
	
	
		
		//PORTFOLIO
		// get the action filter option item on page load
		  var $filterType = $('#filterOptions li.active a').attr('class');
			
		  // get and assign the folioHolder element to the
			// $holder varible for use later
		  var $holder = $('ul.folioHolder');
		
		  // clone all items within the pre-assigned $holder element
		  var $data = $holder.clone();
		
		  // attempt to call Quicksand when a filter option
			// item is clicked
			$('#filterOptions li a').click(function(e) {
				// reset the active class on all the buttons
				$('#filterOptions li').removeClass('active');

				
				// assign the class of the clicked filter option
				// element to our $filterType variable
				var $filterType = $(this).attr('class');
				$(this).parent().addClass('active');
				
				if ($filterType == 'all') {
					// assign all li items to the $filteredData var when
					// the 'All' filter option is clicked
					var $filteredData = $data.find('li');
					
				} 
				else {
					// find all li elements that have our required $filterType
					// values for the data-type element
					var $filteredData = $data.find('li[data-type=' + $filterType + ']');
				}
				
				
				// call quicksand and assign transition parameters
				$holder.quicksand($filteredData, {
					duration: 500,
					useScaling: false,
					//easing: 'swing'
					 
					
				}, function() {
					
					$('.imgHolder').mouseenter(function(e) {
						//$(this).children('.imgInnerHolder').children('a').children('span').animate({  height: '20px',  top: '20', width: '680'}, 100);
						$(this).children('a').children('span').fadeIn(300);
					}).mouseleave(function(e) {
						//$(this).children('.imgInnerHolder').children('a').children('span').animate({height: '20', top: '0' , width: '680'}, 100);
						$(this).children('a').children('span').fadeOut(300);
					});
				});
	
				
				return false;
				
			});
			
			
	
		//HOMEPAGE FULLSCREEN SLIDER
		
		/*sizing options*/
		var defaults = { width: 1200,  height: 800, bgID: 'img#bg' };
		var options = $.extend({}, defaults, options); 
		$(document).ready(function() { $(options.bgID).fullscreenrResizer(options);	});
		$(window).bind("resize", function() { $(options.bgID).fullscreenrResizer(options); });		
	
		/* Define the function that triggers to fade in the background */
		$("img#bg").load(function()
			{
				
				
				/* Fade in during 3 seconds */
				$("img#bg").fadeTo(fsFadeSpeed,1);
				$("img#overlayImg").fadeTo(fsFadeSpeed,1);
				
				
				/* Animate the picture description during 1 second */
				setTimeout(function()
					{
						$("#image_description").animate({right: '+=150'}, 1000)
					}, 1000);
	
				/* Set the timeout to fade out after 10 seconds*/
				setTimeout(function()
					{
						$("#image_description").animate({right: '-=150'}, 1000);
						$("img#bg").fadeOut(fsFadeSpeed);
						$("img#overlayImg").fadeOut(fsFadeSpeed);
	
						/* Load the next image after 4 seconds */
						setTimeout(LoadImages,4000);
					},fsTimeout);
			});
	
		/* Start the slideshow one second after the page is ready */
		setTimeout(LoadImages,1000);
		
			
		
		
		
			
			
		
});



