//Still here?
//I'll try to help you again...

//label to value script from here -> http://cssglobe.com/post/2494/using-form-labels-as-text-field-values
this.label2value = function(){	

	var inactive = 'inactive';
	var active = 'active';
	var focused = 'focused';
	
	$('label').each(function(){		
		obj = document.getElementById($(this).attr('for'));
		if(($(obj).attr('type') == 'text') || (obj.tagName.toLowerCase() == 'textarea')){			
			$(obj).addClass(inactive);			
			var text = $(this).text();
			$(this).css('display','none');			
			$(obj).val(text);
			$(obj).focus(function(){	
				$(this).addClass(focused);
				$(this).removeClass(inactive);
				$(this).removeClass(active);								  
				if($(this).val() == text) $(this).val('');
			});	
			$(obj).blur(function(){	
				$(this).removeClass(focused);													 
				if($(this).val() == '') {
					$(this).val(text);
					$(this).addClass(inactive);
				} else {
					$(this).addClass(active);		
				};				
			});				
		};	
	});		
};

$(document).ready(function(){	
						   
// Just put my email again on the page to prevent a lot of sapm in my mailbox.					   
$('.bot').html("marciobda@gmail.com");	
$('.bot2').html('<a href="mailto:marciobda@gmail.com" class="email">marciobda@gmail.com</a>');	

// I only want these scripts in IE7+ browsers. To improve performance on IE6- users. 
var IE6 = (navigator.userAgent.indexOf("MSIE 6")>=0) ? true : false;
if(!IE6){
		
	//The "Know more" script
	$('#mais').css({display: 'none'});
	$('#mais h3, #mais p, #mais ul').css({opacity: 0});
	
	$('.pt #navegacao li').append('<li><a href="#mais" id="more" title="Saiba Mais">saiba mais...</a></li>');
	$('.en #navegacao li').append('<li><a href="#mais" id="more" title="Read more">read more...</a></li>');
	
		$('#more').toggle(
		function(){
			$('#mais').slideDown(600);
			$('#mais h3, #mais p, #mais ul').delay(600).animate({opacity :1.0},600);
			$('#mais h3, #mais p, #mais ul').fadeIn(function() {
			 if ($.browser.msie)
				 this.style.removeAttribute('filter');
			 }); 
			
				},
		function(){
			$('#mais h3, #mais p, #mais ul').animate({opacity :0},600);
			$('#mais').delay(600).slideUp(600);
		});
		
//My portfolio drag'n'drop magic
$("#works").hide();
			
			$("#intro article").after("<div id='container'></div>");
			
			$("#indice li a").easydrag();
			$("#indice li a").ondrag(function(e,element){ 
				$(element).parent().next().children().children().css("margin-left","147px");
				return false;
			});
			
			$("#indice li a").ondrop(function(e, element){
				if(e.pageY>225 && e.pageY<591){
					$(element).parent().next().children().children().css("margin-left","0px");
					$("#indice li a").attr('style', 'position: static; cursor: move;');
					e.preventDefault;
					var id = $(element).attr("href");
					var conteudo = $(id).html();
					$("#container").empty();
					$("#container").css("background","none");
					$("#container").append(conteudo).hide().show();
					$("#container header, #container img, #container p").css({"top:0":"left:0"});
				} else{$("#indice li a").attr('style', 'position: static; cursor: move;');}
			});
			
			
			//Oh yeah... and the bottom slider too...
			var pics = $("#indice ul").children().size();
			var display = 5;
			
			$("#portfolio #intro").append('<a href="#" id="anterior">anterior</a><a href="#" id="posterior">posterior</a>')
					
			$("#anterior").click(function(e){
				e.preventDefault();						  
				display--;
				verify(pics,display);
				$("#indice ul").stop(1,1).animate({'marginLeft': '+=160px'},600);
			});
			
			$("#posterior").click(function(e){
				e.preventDefault();
				display++;
				verify(pics,display);
				$("#indice ul").stop(1,1).animate({'marginLeft':'-=160px'},600);
			});
			
			function verify(pics,display){
				if(pics - display == 8){
					$("#anterior").hide();			
				} else {
					$("#anterior").show();
				}
				if(pics - display == 0){
					$("#posterior").hide();
				} else {
					$("#posterior").show();
				}
			}
			
			verify(pics,display);
			
}
label2value();
//Quite simple, right?
});
