//Cufon font replacement
Cufon.replace('.slide_title, .content_slide_title', { fontFamily: 'Myriad Pro Semibold', hover: true }); 
Cufon.replace('h1, h3, h4, h5, h6, .service_name', { fontFamily: 'Myriad Pro Regular', hover: true }); 

//Latest projects slider settings
$(document).ready(function(){
    $('#projects').bxSlider({
    	displaySlideQty: 3,
        moveSlideQty: 1,
		auto: true,             
        });
});
	
	
$(document).ready(function(){
	$(".item, .fade, .img").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	$(".item, .fade, .img").hover(function(){
		$(this).fadeTo("fast", 0.8); // This should set the opacity to 100% on hover
		},function(){
		$(this).fadeTo("fast", 1.0); // This should set the opacity back to 30% on mouseout
		});
});
	
 
// Accordion
$(document).ready(function(){

	//Set default open/close settings
	$('#joblist .position').hide(); //Hide/close all containers
	$('#joblist .header:first').addClass('opened').next().show(); //Add "opened" class to first trigger, then show/open the immediate next container

	//On Click
	$('#joblist .header').click(function(){
		if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
			$('#joblist .header').removeClass('opened').next().slideUp(); //Remove all .header classes and slide up the immediate next container
			$(this).toggleClass('opened').next().slideDown(); //Add .acc_trigger class to clicked trigger and slide down the immediate next container
		}
	return true; //Prevent the browser jump to the link anchor
});


//Sliding sidebar navigation
$(document).ready(function(){
	slide("#sidebar-navigation", 10, 0, 150, .8);
	});

	function slide(navigation_id, pad_out, pad_in, time, multiplier){
		// creates the target paths
		var list_elements = navigation_id + " li";
		var link_elements = list_elements + " a";
	
		// initiates the timer used for the sliding animation
		var timer = 0;
		
		// creates the slide animation for all list elements 
		$(list_elements).each(function(i){
			// margin left = - ([width of element] + [total vertical padding of element])
			if($(this).attr('class') !== 'active' && $(this).attr('class') !== 'heading') {
			
				$(this).css("margin-left","0px");
				// updates timer
				timer = (timer*multiplier + time);
				$(this).animate({ marginLeft: "0" }, timer);
				$(this).animate({ marginLeft: "10px" }, timer);
				$(this).animate({ marginLeft: "0" }, timer);
			}
	});

	// creates the hover-slide effect for all link elements 		
	$(link_elements).each(function(i){
		if($(this).parent().attr('class') !== 'active' && $(this).parent().attr('class') !== 'heading') {
			$(this).hover(
				function(){
					$(this).animate({ marginLeft: pad_out }, 150);
				},		
				function(){
					$(this).animate({ marginLeft: pad_in }, 150);
				});
			}
		});
	}

});



//Prettyphoto
$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto();
});


// Tweet
$(document).ready(function(){
	$(".sidebar-tweet").tweet({
		username: "smartdoc",
		join_text: null,
		avatar_size: null,
		count: 3,
		auto_join_text_default: "we said,", 
		auto_join_text_ed: "we",
		auto_join_text_ing: "we were",
		auto_join_text_reply: "we replied to",
		auto_join_text_url: "we were checking out",
		loading_text: "loading tweets..."
	});
});

// Back to top
$(document).ready(function(){
	$(".scroll").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();

		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;

		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];

		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top-50;

		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 500);
	});
});
