
// place any jQuery/helper plugins in here, instead of separate, slower script files.
(function($){
		/*
		$('#scroll a.up').bind('mouseenter click',function(){
			scrollup = $('body').scrollTop()-50;
			$('body').animate({scrollTop:scrollup}, '1000', 'swing');
			return false;
		});
		$('#scroll a.down').bind('mouseenter click',function(){
			scrollup = $('body').scrollTop()+50;
			$('body').animate({scrollTop:scrollup}, '1000', 'swing');
			return false;
		});*/	
		
		$('#devis a').click(function(){
			h=$(document).height();
			w=$(document).width();
			sct=$(document).scrollTop()+10;
			scl=$(document).scrollLeft()+10;
			$('body').append('<div id="devisbg"></div><div id="devisform">loading...</div>');
			$.ajax({
				url: '/devis.html',
				cache: false,
				success: function(msg){
					$('#devisform').html(msg);
					$('#devisform').prepend('<span id="devisclose">Fermer</span>');
					$('#devisclose').click(function(){$('#devisbg').remove();$('#devisform').remove();});
					initForm();
				}
			});
			$('#devisbg').animate({
					opacity: 0.6,
					height: h+"px",
					width: w+"px"}, '300', 'swing',function(){
						wF=(w-$('#devisform').width())/2;
						$('#devisform').animate({top:sct,left:wF},'300','swing');
			}).click(function(){$('#devisbg').remove();$('#devisform').remove();});
			$(window).scroll(function () { 
				if($('#devisform')){
					sct=$(document).scrollTop()+10;
					scl=$(document).scrollLeft()+10;
					wF=(w-$('#devisform').width())/2;
      		$('#devisform').css({top:sct,left:wF}); 
				}
    	})
			return false;
		});
		
		/*longCar=$('#carousel figure').length;
		h = window.location.hash;
		try {
			current = parseInt(h.split('#pict')[1], 10);
		}catch (e) { /* squeltch */ /*}
		current = isNaN(current) ? 1 : current;
		
		$('#carouselprev a').click(function(){
			current = (current==1)?longCar:Math.max(current-1, 1);
			update();
			return false;
		});
		
		$('#carouselnext a').click(function(){
			current = (current==longCar)?1:Math.min(current + 1, longCar);
			update();
			return false;
		});*/
		
		update = function(){
			if (history.pushState) {
				 history.pushState(current, 'Slide ' + current, '#pict' + current);
			} else {
				//window.location.hash = 'pict' + current;
			}// = 'slide' + this.current;
			posTop= 343*(current-1);
      //alert(h+'//'+current+'--'+posTop);
			$("#carousel section").animate({scrollTop: posTop}, '1000', 'swing');
		}
		$('#competences li a.more').parents('li').click(function(){document.location.href=$(this).children("a.more").attr("href");});
		$('#competences li a.more').parents('li').children("a").click(function(){$(this).parents('li').click();return false;});		
		
		//Effet
			var inspire=new Array();	
			var offset = $('#inspire3d').offset();	
			
			inspire['W']=$('#inspire3d').width()/2;
			inspire['H']=$('#inspire3d').height()/2;
			inspire['L']=offset.left;
			inspire['T']=offset.top;
			inspire[0]=0.15;
			inspire[1]=0.2;
			inspire[2]=0.1;
			
		$('#test').bind('mousemove',function(e){
			initX=(e.pageX-inspire['L'])-(inspire['W']);
			initY=(e.pageY-inspire['T'])-(inspire['H']);	
			$('#inspire3d div').each(function(index){
				$(this).css({left:Math.round(initX*inspire[index])+28, top:Math.round(initY*inspire[index])+20});
			});
		}).mouseout(function(){
			$('#inspire3d div').each(function(index){
				$(this).css({left:28, top:20});
				//$(this).animate({left:28, top:20}, '500');
			});
		});
})(jQuery);
