$(function(){
	
	

(function($) {

    $.scrollToElement = function( $element, speed ) {



        speed = speed || 750;



        $("html, body").animate({

            scrollTop: $element.offset().top,

            scrollLeft: $element.offset().left

        }, speed);

        return $element;

    };



    $.fn.scrollTo = function( speed ) {

        speed = speed || "normal";

        return $.scrollToElement( this, speed );

    };

})(jQuery);


});


            
 $(document).ready(function() {
	 
 $('.ocult').hide();	 
 
 $('.info').hide();	 
 
 $('#loading').hide();	 
 
 $('#slides').css('visibility','visible'); 
 


 $('.projecte').click(
 	 function() {
	 	$(this).find('.info').slideDown();
		$(this).find('.info').delay(3000).slideUp();
 });

 
	
 $('#header .slides').cycle({  pager:  '#nav' });
                
/*formuuari contacta*/

	var act;
 
	$(":text,:password, #comentari").focus(function () {
      act = $(this).val();
      $(this).css("background","#FFF")
      $(this).val("");
	});
 
	 $(":text,:password, #comentari").blur(function () {
      $(this).css("background","#402408")
 
      if ($(this).val() == "") {$(this).val(act)}
	});

	$('#contactar').submit(function(){
		
	$('#resposta').html(''); 		

       var email = $('#email').val();      
       var nom = $('#nom').val();      
       var empresa = $('#empresa').val();  
	   var comentari = $('#comentari').val();   
	   
	   if ((email=='Email') || (nom=='Persona de contacte') || (empresa=='Empresa') || (comentari=='Consulta')) {
		   
		  $('#resposta').html('<p>Has d\'omplir tots els camps</p>'); 

	   }
	   
	else
	{	   
	   var cos = '';
	   cos = cos + '<ul><li>Empresa: ' + empresa + '</li><li> Persona de contacte: ' + nom + '</li><li> Email contacte: ' + email + '</li><li>Consulta: ' + comentari + '</li></ul>' ;
	   	   
	   
	   $('#loading').show(5);
      	  
 	   $.get('include/back.asp?accio=mail&from=notreply@qdevelopment.cat&to=contact@qdevelopment.cat&asunto=Formulari web&mensaje='+cos, function(data){
		   
		   	if (data!='error') {$('#resposta').html('<p>Enviat correctament</p>');}
			if (data=='error') {$('#resposta').html('<p>Error</p>');}
			
		    	$('#loading').hide();
 
	        });

	}
			
       return false;     

	  });		



/* twitter */
	
	
	$("#tweets").getTwitter({
		userName: "_qdevelopment_",
		numTweets: 3,
		loaderText: "",
		slideIn: true,
		showHeading: false,
		headingText: "",
		showProfileLink: false
		
	});
	
	
	
	
});

