//var   hashes=new Array("","natural","proyectos","equipo","contacto");	
var subs=['identidad', 'packaging', 'retail', 'multimedia'];
$(document).ready(function(){
	
	
	$("a[rel^='prettyPhoto']").prettyPhoto();

	//SCrollTop
	/*$('.webbies a').click(function(){ //Id del elemento cliqueable
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;
	});*/
	
	// Proyectos
	$(function() {
		$('#load-webbies a').click(function(e) {
			
			//$('html, body').animate({scrollTop:0}, 'slow');
			//return false;
			/*if($("#projcnt").css("display")!="none"){
			 	
				$("#projbg").animate({ height: "toggle"},300);
				$("#projcnt").animate({ height: "toggle"},300, function (){
				});
			}*/
			
			$.get( $(this).attr('href'), function(data) {
				$('.webbies').quicksand( $(data).find('li'), {
					useScaling: true,
					adjustHeight: 'dynamic',
					duration: 500,
					}, function() { // callback function
						$('.bar').mosaic({
							animation	:	'slide',
							easing: 'easeInOutQuad',
							speed		: 250
								
						});
						
						if($("#projcnt").css("display")!="none"){
			 				
							//$("#projbg").animate({ height: "toggle"},300);
							$("#projcnt").animate({ height: "toggle"},300, function (){
						});
						}
					});
				});  
				e.preventDefault();  
			});
		}); 
		
		$('.bar').mosaic({
			animation	:	'slide',
			easing: 'easeInOutQuad',
			speed		: 250
		});
	
		$('#slider').bxSlider({
			infiniteLoop: false,
			auto: false,	
			controls: true,
			pause: 6000,
			speed: 750,
			mode: 'horizontal',
			easing: 'easeInOutExpo',
		});

	
	/*var boton_sel= $.inArray(document.location.hash.replace("#/",""),hashes)
		if(boton_sel>0){ selboton(boton_sel)}
		
		$('a[href*="#"]').live('click', function() {
			$.bbq.pushState( '#/' + this.hash.slice(1) );
				return false;
		});
				  
		$(window).bind('hashchange', function(event) {
			
			if (location.hash) {
				var tgt = location.hash.replace(/#\//,'');
				} else {
					var tgt = '#top';
					}
			$.smoothScroll({
				scrollTarget: '#' + tgt,
				easing: 'easeOutExpo',
				speed: 1000
				});
		});
				  
		$(window).trigger('hashchange');
		
	
	// Google Maps
	$("#map").gMap({ markers: [{
		latitude: 41.69030771472101,
        longitude: 2.161930203437805,
		icon: {
			image: "./images/gmap_pin.png",
			iconsize: [40, 44],
			iconanchor: [26,30],
			infowindowanchor: [12, 0] },
		html: "Savia Design",
		popup: false }],
		controls: ["GMenuMapTypeControl", "GLargeMapControl3D"],
		scrollwheel: false,
		zoom: 17
	});*/
	
	/*
	// Equipo
	//Blur Links (Prevents Outline)
	$('a').click(function() {
		this.blur();
	});
		
	//Hide all item descriptions in the info box
	$("#infobox > div").css("display", "none");
		
	//Call in the info box
	$(".more a").click(function(){
		$("#infobox").animate({bottom: '233px' }, 300);
		$("#fade_bg").fadeIn();
		return false;
	});
	
	//Expand more info button on hover
	$(".more").hover(function(){
		$(this).stop().animate({width: '225px', height:'100px' }, 200).css({'z-index' : '10'}); //Change the width increase caption size
	}, function () {
		$(this).stop().animate({width: '25px', height: '25px' }, 200).css({'z-index' : '1'});
	});
  		
	//Show description for selected item
	$("#couch a").click(function(){
		$("#couch_info").show();
	});
			
	$("#plant a").click(function(){
		$("#plant_info").show();
	});
	
	$("#monitor a").click(function(){
		$("#monitor_info").show();
	});
	
	$("#board a").click(function(){
		$("#board_info").show();
	});
						
	//Remove background, info box and hide all descriptions
	$("#fade_bg, .close").click(function(){
		$("#fade_bg").fadeOut();
		$("#infobox").animate({bottom: '-200px' }, 300, function() {
			$("#infobox > div").css("display", "none");
		});
		return false;
	});*/
	
}); //end document.ready

	

	/*//Menu Principal
	function selboton(id){
		$("#menu li a").css("color","#706f6f")
		$("#b"+id+" a").css("color","#00B259")
		}*/
		
		
	//Proyectos: slider
	
	function slideproyecto(){

			if($("#projcnt").css("display")=="none"){
					$("#projcnt").css("opacity",1)
					$("#projcnt").slideDown()
					
					//$("#projbg").css("opacity",1)
					//$("#projbg").slideDown()
			}else{
				$("#projcnt").animate({  opacity: 1});
				}
					//$("#projbg").animate({  opacity: 1});
					/*$('.projslider').bxSlider({
						wrapperClass: 'projslider',
						nextSelector: '.projnext',
						prevSelector: '.projprev',
						speed: 500,
						easing: 'easeOutQuad',
						mode: 'fade',
						controls: true
					});*/
			}
			
		
			
			function cargaproyecto(id,subid){
				//console.log(id)
			 
				$.ajax({url:"proyectos/"+subs[subid]+"/"+id+".html",success:function(e){
					 $("#projcnt").html(e);
						 slideproyecto()
						 
						 $('.projslider').bxSlider({
							infiniteLoop: false,
							auto: true,	
							pause: 6000,
							speed: 500,
							easing: 'easeOutQuad',
							mode: 'horizontal',
							controls: true
							});
				}
												  
			})
	};
			
			
		function cierraproyecto(){
			$("#projcnt").slideUp()
			$("#projcnt").animate({ opacity: 0});
			//$("#projcnt").animate({opacity: 0},300,function(){cargaproyecto(_id);});
			//$("#projbg").slideUp()
		}
			
		function animproj(id,subid){
			var _id=id 
		 	var _subid=subid
			if($("#projcnt").css("display")!="none"){
			 	
				//$("#projbg").animate({ height: "toggle", opacity: 0},300);
				$("#projcnt").animate({opacity: 0},300,function(){cargaproyecto(_id,_subid);});
				$('html, body').animate({scrollTop:0}, 'slow');
			 
				}else{
					cargaproyecto(_id,_subid);
					}	
		}
		
		function verproyecto(id,subid){
		
 			 
 
				setTimeout("animproj("+id+","+subid+")",200)
			
		}
			

		
	
	
