jQuery(document).ready(function(){
// get the initial (full) list
var jQueryfilterList = jQuery('ul.portfolio-list');
// add unique id's
// i don't like having to write these all in the code
// so i wrote a script to id these for me
for(var i=0; i<jQuery('ul.portfolio-list li').length; i++){
jQuery('ul.portfolio-list li:eq(' + i + ')').attr('id','flitem' + i);
}
// clone first collection to get a second collection
var jQuerydata = jQueryfilterList.clone();
// handle trigger clicks
jQuery('#filterButtons a').click(function(e) {
if(jQuery(this).attr('rel') == 'all') {
// get a group of all items
var jQueryfilteredData = jQuerydata.find('li');
} else {
// get a group of items of a particular class
var jQueryfilteredData = jQuerydata.find('li.' + jQuery(this).attr('rel'));
}
// call quicksand
jQuery('ul.portfolio-list').quicksand(jQueryfilteredData, {
duration: 500,
attribute: function(v) {
// this is the unique id attribute we created above
return jQuery(v).attr('id');
}
}, function() {
		jQuery(document).ready(function(){
			jQuery("a[rel^='portfolio']").prettyPhoto({
                    theme: 'dark_square',
					overlay_gallery: false
                    });

                        });
jQuery(document).ready(function() {
	//On mouse over those thumbnail
	jQuery('.port_item_small, .port_item_large').hover(function() {
		//Display the caption
		jQuery(this).find('div.thumb_caption_small_photo, div.thumb_caption_small_video, div.thumb_caption_large_photo, div.thumb_caption_large_video').stop(false,true).fadeIn(500);
	},
	function() {
		//Reset the image
		jQuery(this).find('img').stop(false,true).animate({'width':jQuery('.port_item_small, .port_item_large').width(), 'height':jQuery('.port_item_small, .port_item_large').height(), 'top':'0', 'left':'0'}, {duration:100});	

		//Hide the caption
		jQuery(this).find('div.thumb_caption_small_photo, div.thumb_caption_small_video, div.thumb_caption_large_photo, div.thumb_caption_large_video').stop(false,true).fadeOut(500);
	});

});
                
});
e.preventDefault();
});
});


function button_hover_shortcode(){
	$('.button_link,button[type=submit],button,input[type=submit],input[type=button],input[type=reset]').hover(
		function() {
				$(this).stop().animate({opacity:0.7},400);
			},
			function() {
				$(this).stop().animate({opacity:1},400);
		});
}

$(document).ready(function() {
	if(!$.browser.msie){button_hover_shortcode();}
	
	});

//tabs and accordions

jQuery(function() { 

	jQuery(".accordion").fptabs("div.pane", {tabs: '.tab', effect: 'slide'});
	jQuery("ul.tabs").fptabs("div.panes > div", {effect: 'fade'});
	

//toggles

jQuery(".toggle_title").toggle(
		function(){
			jQuery(this).addClass('toggle_active');
			jQuery(this).siblings('.toggle_content').slideDown("fast");
		},
		function(){
			jQuery(this).removeClass('toggle_active');
			jQuery(this).siblings('.toggle_content').slideUp("fast");
		}
	);
});


// superfish menu
		jQuery(function(){
			jQuery('ul.sf-menu').superfish({
			animation: {height:'show'}	
			});
			
		});	


jQuery(document).ready(function(){
			jQuery("a[rel^='portfolio'], a[rel^='gallery_img']").prettyPhoto({
                    theme: 'dark_square',
					overlay_gallery: false
                    });
                });
				
jQuery(document).ready(function(){
			jQuery("a[rel^='gallery_img']").prettyPhoto({
                    theme: 'dark_square',
					overlay_gallery: true
                    });
                });

//tooltip

jQuery(document).ready(function(){  
jQuery(".tool_tip_content").hover(function() {
jQuery(this).next(".tooltip").stop(true, true).animate({opacity: "show", bottom: "20"}, "slow");
}, function() {
jQuery(this).next(".tooltip").animate({opacity: "hide", bottom: "20"}, "fast");
});
   
 });
 
 jQuery(function() {
$('#vertical_tabs').tabs({ fx: [{opacity:'toggle', duration: 90},   // hide option
                        {opacity:'toggle', duration: 90}] }); // show option

});

$(document).ready(function() {
   
    $('a[href=#top]').click(function(){
        $('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });

});

jQuery(document).ready(function() { //hides image and shows background loading image
    jQuery(".recent_project_loader img, .portfolio_small_thumb_shadow img, .portfolio_large_thumb_shadow img").css("display", "none");
});
jQuery(window).load(function() { //fades in image and hides loading image
    jQuery(".recent_project_loader img, .portfolio_small_thumb_shadow img, .portfolio_large_thumb_shadow img").fadeIn(500);
});



	jQuery(document).ready(function() {
		
		jQuery('#testimonial_slider blockquote').quovolver();
		
	});

jQuery(document).ready(function(){
// get the initial (full) list
var jQueryfilterList = jQuery('div.ca-item');
// add unique id's
// i don't like having to write these all in the code
// so i wrote a script to id these for me
for(var i=0; i<jQuery('div.ca-item').length; i++){
jQuery('div.ca-item:eq(' + i + ')').attr('class','ca-item ca-item-' + i);
}
jQuery("#cn_list li:first-child").addClass("selected");
});

// blog news

 $(function() {
                //caching
				//next and prev buttons
				var $cn_next	= $('#cn_next');
				var $cn_prev	= $('#cn_prev');
				//wrapper of the left items
				var $cn_list 	= $('#cn_list');
				var $pages		= $cn_list.find('.cn_page');
				//how many pages
				var cnt_pages	= $pages.length;
				//the default page is the first one
				var page		= 1;
				//list of news (left items)
				var $items 		= $cn_list.find('.cn_item');
				//the current item being viewed (right side)
				var $cn_preview = $('#cn_preview');
				//index of the item being viewed. 
				//the default is the first one
				var current		= 1;
				
				/*
				for each item we store its index relative to all the document.
				we bind a click event that slides up or down the current item
				and slides up or down the clicked one. 
				Moving up or down will depend if the clicked item is after or
				before the current one
				*/
				$items.each(function(i){
					var $item = $(this);
					$item.data('idx',i+1);
					
					$item.bind('click',function(){
						var $this 		= $(this);
						$cn_list.find('.selected').removeClass('selected');
						$this.addClass('selected');
						var idx			= $(this).data('idx');
						var $current 	= $cn_preview.find('.cn_content:nth-child('+current+')');
						var $next		= $cn_preview.find('.cn_content:nth-child('+idx+')');
						
						if(idx > current){
							$current.stop().animate({'top':'-300px'},600,'easeOutBack',function(){
								$(this).css({'top':'310px'});
							});
							$next.css({'top':'310px'}).stop().animate({'top':'0px'},600,'easeOutBack');
						}
						else if(idx < current){
							$current.stop().animate({'top':'310px'},600,'easeOutBack',function(){
								$(this).css({'top':'310px'});
							});
							$next.css({'top':'-300px'}).stop().animate({'top':'0px'},600,'easeOutBack');
						}
						current = idx;
					});
				});
				
				/*
				shows next page if exists:
				the next page fades in
				also checks if the button should get disabled
				*/
				$cn_next.bind('click',function(e){
					var $this = $(this);
					$cn_prev.removeClass('disabled');
					++page;
					if(page == cnt_pages)
						$this.addClass('disabled');
					if(page > cnt_pages){ 
						page = cnt_pages;
						return;
					}	
					$pages.hide();
					$cn_list.find('.cn_page:nth-child('+page+')').fadeIn();
					e.preventDefault();
				});
				/*
				shows previous page if exists:
				the previous page fades in
				also checks if the button should get disabled
				*/
				$cn_prev.bind('click',function(e){
					var $this = $(this);
					$cn_next.removeClass('disabled');
					--page;
					if(page == 1)
						$this.addClass('disabled');
					if(page < 1){ 
						page = 1;
						return;
					}
					$pages.hide();
					$cn_list.find('.cn_page:nth-child('+page+')').fadeIn();
					e.preventDefault();
				});
				
            });
