$(document).ready(function(){
	
	var options = { 
		target:'#alert',
	}; 
	$('#contactForm').ajaxForm(options);
	
	
	current=$("#portfoliodiv");
	$("#competencediv").slideUp(0);
	$("#contactdiv").slideUp(0);
	
	$('.item').each(function(){
        $('a:not(".ext")', this).lightBox();
    });
	$('#portfoliodiv .item').hover(
			function () {
				$(this).find(".preview").stop().animate({"height":200});
				$(this).find(".display").stop().animate({"height":250});
			},
			function () {
				$(this).find(".preview").stop().animate({"height":100});
				$(this).find(".display").stop().animate({"height":40});
			});
	$('.item a').hover(
			function () {
				$(this).find("img").stop().animate({"opacity":0.5})
			},
			function () {
				$(this).find("img").stop().animate({"opacity":1})
			});

	$('.menu').click(function() {
			url=$(this).attr("href").substring(1)+"div";
			if(!$(this).hasClass("active")){
				$(".active").removeClass("active");
				$(this).addClass("active");
				$(current).stop().slideUp();
				$("#"+url).stop().slideDown();
				current=$("#"+url);
			}
		}
	)
	$("#bonus a").click(function(){
		if ($(this).find("object").length < 1){
			$("#bonus object").remove();
			mp3=$(this).attr("href").substring(29);
			$(this).append('<object height="55" width="187"><param name="movie" value="http://www.deezer.com/embedded/small-widget-v2.swf?idSong='+mp3+'&amp;autoplay=1"><embed src="http://www.deezer.com/embedded/small-widget-v2.swf?idSong='+mp3+'&amp;autoplay=1" type="application/x-shockwave-flash" height="55" width="187"></object>');
		}
		return false;
	});	
	
	$("#full").click(function(){
		$("#full").stop().animate({"width":0});
	});
});
$.fn.clearForm = function() {
	return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form')
			return $(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea')
			this.value = '';
		else if (type == 'checkbox' || type == 'radio')
			this.checked = false;
		else if (tag == 'select')
			this.selectedIndex = -1;
	});
};
