
	

	jQuery.extend({dimentions : function(){
		struct = {pageYOffset:0, pageXOffset:0, innerHeight:0, innerWidth:0}
		if (self.innerHeight) {
			struct.pageYOffset = self.pageYOffset;
			struct.pageXOffset = self.pageXOffset;
			struct.innerHeight = self.innerHeight;
			struct.innerWidth = self.innerWidth;
		  } else if (document.documentElement && document.documentElement.clientHeight) {
			  struct.pageYOffset = document.documentElement.scrollTop;
			  struct.pageXOffset = document.documentElement.scrollLeft;
			 struct.innerHeight = document.documentElement.clientHeight;
			 struct.innerWidth = document.documentElement.clientWidth;
		  } else if (document.body) {
			  struct.pageYOffset = document.body.scrollTop;
			  struct.pageXOffset = document.body.scrollLeft;
			  struct.innerHeight = document.body.clientHeight;
			  struct.innerWidth = document.body.clientWidth;
		  }
		  
		  return struct;
	}});

	jQuery.extend({explosion : function(){
		$('#coeur>div').each(function() {
					var varTitle = $(this).find('h2:first').text();
					$(this).find('h2:first a').text('consulter : '+varTitle); //on modifie le texte pour le rendre plus logique avec l'ui
					$(this).dialog({
						title		: varTitle
						, show		: 'slide'
						, position	: ['top', 'right']
						, width		: '870px'
					});
				});
					
				$('.ui-dialog-content').accordion({
					collapsible	: true
					, active	: false
					, header	: 'h2'
				}).find('ul').css({textAlign : 'left'});
			
				
				$('#footer').remove();
			
				$('#cd').remove();
			
				$('#header').dialog({
					title		: 'Fermez ce titre pour consulter le CV'
					, position	: 'top'
					, width		: '800px'
					, zIndex	: 3999
					, modal		: true
				});
	}});



if ( $.browser.msie && $.browser.version < 7.0) {
	alert('Attention, devant un triste manque de temps, cet humble CV \'est pas compatible avec msie '+$.browser.version+', essayez firefox :p');
} else {
	
	$(document).ready(function(){
		//si on est encapsulé par du jquery ui, on met des pitis effet en plus :
		if ($.fn.dialog) {
			$.explosion();
		} 
		
		
		
		
		initAffichage();

		var reg = new RegExp("[ ]+", "g");
		$('#competences li').mouseover(function(){
			var unfilteredArray = $.trim($(this).text()).split(reg);
			filteredArray = $.grep(unfilteredArray, function(a){return (a != "" && a.length > 2)})
			if (filteredArray.length == 0) {
				filteredArray.unshift($.trim($(this).text()).split(reg));
			} else { 
				if (filteredArray.length > 2) {
					filteredArray = $.grep(filteredArray, function(a){return a.length > 4})
				} 
				if (filteredArray.length > 2) {
					filteredArray.unshift('informatique');
					filteredArray.unshift('php');
				} 
			}
			
			var searchString = '';
			for(var i = 0; i <= filteredArray.length / 3 && i < 4; i++) {
				searchString = searchString+' '+filteredArray[Math.round(Math.random() * (filteredArray.length-1))]
			}
			
			$('.transparentable').stop().animate({opacity: 1, top: $.dimentions().pageYOffset + 100}, 700, function(){
				searchControl;
				searchControl.execute(searchString);
			});
			
		}).mouseout(function() {
			$('.transparentable.actif').stop().animate({opacity: .2, top: $.dimentions().pageYOffset + 100}, 700);
		})
		
		
		$('#competences ul').each(function() {
			$(this).children('li').slice(1).prepend(', ')
		})
		
		$('h2').animate({height: '40px'}, 700).animate({color: '#eff', fontSize: "24px"}, 700);

		$('.transparentable').mouseover(function(){
			$(this).filter('.actif').stop().animate({opacity: 1}, 700);
		}).mouseout(function(){
			$(this).filter('.actif').stop().animate({opacity: .2}, 700);
		});
		var reg = new RegExp("synd=ig", "g");
		var url = window.location;
		
		if (reg.test(url.toString())) {
			if ( $.browser.msie ) {
				setTimeout('initIGoogle()', 3000);
			} else {
				initIGoogle()
			}
		}
		
		$('.explodeMe').live('click', function() {
			$.getScript('http://les-da-silva.fr/cv/static/js/libs/jquery/jquery-ui-1.7.custom.min.js', function() {
				$.get('http://les-da-silva.fr/ZendFramework/ui/css/redmond/jquery-ui-1.7.custom.css', function(css) {
					$('<style type="text/css"></style>').html(css).appendTo("head");
					$.explosion();
				});
			});


			
		})
	});
}
function initIGoogle() {
	
	
	$('#page, #coeur, #header').css({width: '356px'});
	
	$('#coeur').css({margin: '0px', padding: '0px'});
	$('#coeur div').css({margin: '5px', padding: '5px', border: '0px'});
	$('canvas div').animate({margin:0, padding:0}, 500);
	
	$('#footer, #defilcontrol').slideUp(600);

	$('#coeur div, #coeur span').animate({fontSize: '10px'}, 600);
	$('h2').animate({fontSize: '16px'}, 600);
	
	//$('#cd').hide(600);

}
function initAffichage() {

	$('#cdDefile').toggleClass('defile');
	$('li, .date, .entreprise, h2').toggleClass('blockZoom');
	
	$('#coeur div').not('.discret, #titleAscii').css({backgroundColor: "#0a1119"}).slideDown(1000).animate({
		fontSize: "12px", borderTopWidth:"9px", backgroundColor: "#3a4149"
	}, 1000).animate({
		fontSize:"14px", borderLeftWidth:"15px", backgroundColor: "#1a2129"
	}, 800).mouseover(function(){
		$(this).not('.blockAnim').stop().animate({backgroundColor: '#2a3139'}, 600)
	}).mouseout(function(){
		$(this).not('.blockAnim').stop().animate({backgroundColor: '#1a2129'}, 600)
	});
	
	$('canvas div').animate({margin:0, padding:0}, 500);
		
	
	$('#competences li, .entreprise').mouseover(function(){
		$(this).not('.blockZoom').stop().animate({fontSize: '20px'}, 300)
	}).mouseout(function(){
		$(this).not('.blockZoom').stop().animate({fontSize: '14px'}, 600)
	});
	
	$('.date').mouseover(function(){
		$(this).not('.blockZoom').stop().animate({color:"#90A0AF"}, 300)
	}).mouseout(function(){
		$(this).not('.blockZoom').stop().animate({color:"#D0E0EF"}, 600)
	});

	$('#experiences li').mouseover(function(){
		$(this).not('.blockZoom').stop().animate({marginLeft: '15px', color:"#80C0CF"}, 600, 'elasout')
	}).mouseout(function(){
		$(this).not('.blockZoom').stop().animate({marginLeft: '0px', color:"#FFFFFF"}, 300)
	});
	
	$('#titleAscii').mouseover(function(){
		$(this).not('.blockZoom').stop().animate({color:"#80C0CF"}, 2000, 'elasinout').animate({color:"#A0D0DF"}, 2000, 'elasinout');
	}).mouseout(function(){
		$(this).not('.blockZoom').stop().animate({color:"#FFFFFF"}, 1000);
	});
	
	$('.intitule').mouseover(function(){
		$(this).not('.blockZoom').stop().animate({borderBottom: '1px dotted #80C0CF', color:"#40C0CF"}, 1000)
	}).mouseout(function(){
		$(this).not('.blockZoom').stop().animate({borderBottom: '1px dashed #90D0DF', color:"#80C0CF"}, 1000)
	});
	
	$('h2').mouseover(function(){
		$(this).not('.blockZoom').stop().animate({"height": "80px", color:"#CCFFFF", backgroundColor: "#3a4149"}, 300)
	}).mouseout(function(){
		$(this).not('.blockZoom').stop().animate({"height": "45px", color:"#FFFFFF", backgroundColor: "#1a2129"}, 900, 'elasout')
	}).animate({"height": "45px", color:"#FFFFFF", backgroundColor: "#1a2129"}, 900, 'elasout');
	
	
	
	defilementLogo();
	
	
}


function defilementLogo() {
	if (undefined == this.index) {
		this.list = $.makeArray($('#logosReferals ul li').css({opacity: '0'}));
		this.index = 0;
	}
	
	var self = this;
	this.index++;
	var prevElmt = (this.index - 1 <= 0?this.list.length - 1:this.index - 1);
	//console.debug(this.index, prevElmt);
	$(this.list[prevElmt]).animate({opacity: '0'} , 2000, function() {
		$(self.list[prevElmt]).css({display:"none"});

		$(self.list[self.index]).css({ display:"block"}).animate({opacity: '1'}, 500 ) ;
		if (self.index >= self.list.length - 1) {
			self.index = 0;
		}
		setTimeout('defilementLogo()', 4000);
	});
	
	
}

$(window).scroll(function() {
	$('#cdDefile.defile').stop().css({position: 'absolute'}).animate({top: (parseInt($.dimentions().pageYOffset) + 100) + 'px'}, 1000, 'backinout')
});

$('#imprimmer').live('click', function() {
	$("link[media='screen']").attr("href", "./static/css/print.css");
	$('#titleContainer [id^="titleContainer_"]:not(div)').remove();
	
	$('#coeur [id^="coeur_"]:not(div)').remove()
	$('div, h2, h1, li').stop().addClass('blockAnim blockZoom').animate({backgroundColor:'#FFFFFF', color:'#000000'}, 500);
	$('h1 span.poste, h1').animate({fontSize: '24px'}, 600).css({textAlign: 'center'});
	
	$('h2:gt(0)').animate({fontSize: '20px', marginTop:'24px'}, 600);
	$('#coeur, #titleContainer').animate({borderTopWidth:'0px', borderRightWidth:'0px', borderBottomWidth:'0px', borderLeftWidth:'0px'}, 100);
	$('.intitule').css({fontWeight: 'bold', color:'#000011'});
	$('#coeur div:gt(0)').animate({borderBottom: '1px dotted', marginTop:'24px'}, 600)
	$('#experiences .date').css({display:'block'}).animate({marginTop:'24px'}, 600)
	window.print();
})
$('.cdDefileToggle').live('click', function() {
	$(this).animate({marginLeft: '30px' , color:"#B0E67D"}, 500, 'elasinout').animate({marginLeft: "0px", color:"#000000"}, 500, 'elasinout');
	$('#cdDefile').toggleClass('defile');
})
$('.cdFishEyeToggle').live('click', function() {
	$(this).animate({marginLeft: '30px' , color:"#B0E67D"}, 500, 'elasinout').animate({marginLeft: "0px", color:"#000000"}, 500, 'elasinout');
	$('li, .date, .entreprise, h2').toggleClass('blockZoom');
});

$('.searchcontrolToggle').live('click', function() {
	$('#searchcontrol, #searchcontrolTogller').removeClass('transparentable actif').slideUp(600);
});

$('#igoogle').live('click', function() {
	$(this).attr('href', "http://www.google.fr/ig/adde?hl=fr&moduleurl=hosting.gmodules.com/ig/gadgets/file/105087281116209003892/cvV3.xml&source=imag");
});
$('#iGoogleGame').live('click', function() {
	$(this).attr('href', "http://www.google.fr/ig/adde?moduleurl=hosting.gmodules.com/ig/gadgets/file/105087281116209003892/weukHunt.xml");
});



$('#searchcontrol .searchcontrolActive').live('click', function() {
	
	//$(this).text('Loading...');
	$('.transparentable').addClass('actif');
	$('#searchcontrolTogller').show();
	
	///google search
	searchControl = new google.search.SearchControl();
	// Add in a full set of searchers
	var localSearch = new google.search.LocalSearch();
	// Set the Local Search center point
    localSearch.setCenterPoint("Grenoble, France");
    
	var siteSearch2 = new google.search.WebSearch();
    siteSearch2.setUserDefinedLabel("developpez.com");
    siteSearch2.setUserDefinedClassSuffix("siteSearch2");
    siteSearch2.setSiteRestriction("developpez.com");
    searchControl.addSearcher(siteSearch2);
	
    var siteSearch = new google.search.WebSearch();
    siteSearch.setUserDefinedLabel("wikipedia francais");
    siteSearch.setUserDefinedClassSuffix("siteSearch");
    siteSearch.setSiteRestriction("fr.wikipedia.org/");
    searchControl.addSearcher(siteSearch);
    
	
	// Tell the searcher to draw itself and tell it where to attach
	searchControl.draw(document.getElementById("searchcontrol"));
})


//<![CDATA[
google.load("search", "1");
var searchControl = {execute:function(param){}}
//]]>



jQuery.extend({
		easing: {
			easein: function(x, t, b, c, d) {
				return c*(t/=d)*t + b; // in
			},
			easeinout: function(x, t, b, c, d) {
				if (t < d/2) return 2*c*t*t/(d*d) + b;
				var ts = t - d/2;
				return -2*c*ts*ts/(d*d) + 2*c*ts/d + c/2 + b;		
			},
			easeout: function(x, t, b, c, d) {
				return -c*t*t/(d*d) + 2*c*t/d + b;
			},
			elasin: function(x, t, b, c, d) {
				var s=1.70158;var p=0;var a=c;
				if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
				if (a < Math.abs(c)) { a=c; var s=p/4; }
				else var s = p/(2*Math.PI) * Math.asin (c/a);
				return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
			},
			elasout: function(x, t, b, c, d) {
				var s=1.70158;var p=0;var a=c;
				if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
				if (a < Math.abs(c)) { a=c; var s=p/4; }
				else var s = p/(2*Math.PI) * Math.asin (c/a);
				return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
			},
			elasinout: function(x, t, b, c, d) {
				var s=1.70158;var p=0;var a=c;
				if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
				if (a < Math.abs(c)) { a=c; var s=p/4; }
				else var s = p/(2*Math.PI) * Math.asin (c/a);
				if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
				return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
			},
			backin: function(x, t, b, c, d) {
				var s=1.70158;
				return c*(t/=d)*t*((s+1)*t - s) + b;
			},
			backout: function(x, t, b, c, d) {
				var s=1.70158;
				return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
			},
			backinout: function(x, t, b, c, d) {
				var s=1.70158;
				if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
				return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
			},
			linear: function(x, t, b, c, d) {
				return c*t/d + b; //linear
			}
		}
	});
