/***************************************************
		  DROPDOWN MENU
***************************************************/
/*********************
//* jQuery Multi Level CSS Menu #2- By Dynamic Drive: http://www.dynamicdrive.com/
//* Last update: Nov 7th, 08': Limit # of queued animations to minmize animation stuttering
//* Menu avaiable at DD CSS Library: http://www.dynamicdrive.com/style/
*********************/

//Specify full URL to down and right arrow images (23 is padding-right to add to top level LIs with drop downs):
var arrowimages={down:[]}

var jqueryslidemenu={

animateduration: {over: 300, out: 300}, //duration of slide in/ out animation, in milliseconds

buildmenu:function(menuid, arrowsvar){
	jQuery(document).ready(function($){
		var $mainmenu=$("#"+menuid+">ul")
		var $headers=$mainmenu.find("ul").parent()
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			$subul.css({top:this.istopheader? this._dimensions.h+"px" : 0})

			$curobj.hover(
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					this._offsets={left:$(this).offset().left, top:$(this).offset().top}
					var menuleft=this.istopheader? 0 : this._dimensions.w
					menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft
					if ($targetul.queue().length<=1) //if 1 or less queued animations
						$targetul.css({left:menuleft+"px", width:this._dimensions.subulw+'px'}).slideDown(jqueryslidemenu.animateduration.over)
				},
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					$targetul.slideUp(jqueryslidemenu.animateduration.out)
				}
			) //end hover
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible'})
	}) //end document.ready
}
}

//build menu with ID="myslidemenu" on page:
jqueryslidemenu.buildmenu("myslidemenu", arrowimages)






/***************************************************
		  ZOOM PORTFOLIO HOVER - COLUMN
***************************************************/
jQuery(document).ready(function(){

	jQuery(".column a").contents("img").hover(function(){
		jQuery(this).stop().animate({opacity:0.4}, 400);
	}, function() {
		jQuery(this).stop().animate({opacity:1}, 400);
	});

});



/***************************************************
	     ZOOM PORTFOLIO HOVER - COLUMN-LIST
***************************************************/
jQuery(document).ready(function(){

	jQuery(".column-list a").contents("img").hover(function(){
		jQuery(this).stop().animate({opacity:0.4}, 400);
	}, function() {
		jQuery(this).stop().animate({opacity:1}, 400);
	});

});





/***************************************************
				  PORTFOLIO COLUMN
***************************************************/
$(document).ready(function(){	
	$('a[href^="http://"]')	.attr({ target: "_blank" });
	function smartColumns() {		
		$(".column").css({ 'width' : "100%"});		
		var colWrap = $(".column").width();
		var colNum = Math.floor(colWrap / 200);
		var colFixed = Math.floor(colWrap / colNum);	
		
		$(".column").css({ 'width' : colWrap});
		$(".column li").css({ 'width' : colFixed});		
	}		
	smartColumns();	
	$(window).resize(function () {
		smartColumns();		
	}); 		
});	





/***************************************************
				  PORTFOLIO COLUMN-LIST
***************************************************/
$(document).ready(function(){	
	$('a[href^="http://"]')	.attr({ target: "_blank" });
	function smartColumns() {		
		$(".column-list").css({ 'width' : "100%"});		
		var colWrap = $(".column-list").width();
		var colNum = Math.floor(colWrap / 900);
		var colFixed = Math.floor(colWrap / colNum);	
		
		$(".column-list").css({ 'width' : colWrap});
		$(".column-list li").css({ 'width' : colFixed});		
	}		
	smartColumns();	
	$(window).resize(function () {
		smartColumns();		
	}); 		
});	




/***************************************************
				  PORTFOLIO FILTERABLE
***************************************************/
/*
* Copyright (C) 2009 Joel Sutherland.
* Liscenced under the MIT liscense
*/
(function($) {
	$.fn.filterable = function(settings) {
		settings = $.extend({
			useHash: true,
			animationSpeed: 800,
			show: { width: 'show', opacity: 'show' },
			hide: { width: 'hide', opacity: 'hide' },
			useTags: true,
			tagSelector: '#portfolio-filter a',
			selectedTagClass: 'current',
			allTag: 'all'
		}, settings);
		
		return $(this).each(function(){
		
			/* FILTER: select a tag and filter */
			$(this).bind("filter", function( e, tagToShow ){
				if(settings.useTags){
					$(settings.tagSelector).removeClass(settings.selectedTagClass);
					$(settings.tagSelector + '[href=' + tagToShow + ']').addClass(settings.selectedTagClass);
				}
				$(this).trigger("filterportfolio", [ tagToShow.substr(1) ]);
			});
		
			/* FILTERPORTFOLIO: pass in a class to show, all others will be hidden */
			$(this).bind("filterportfolio", function( e, classToShow ){
				if(classToShow == settings.allTag){
					$(this).trigger("show");
				}else{
					$(this).trigger("show", [ '.' + classToShow ] );
					$(this).trigger("hide", [ ':not(.' + classToShow + ')' ] );
				}
				if(settings.useHash){
					location.hash = '#' + classToShow;
				}
			});
			
			/* SHOW: show a single class*/
			$(this).bind("show", function( e, selectorToShow ){
				$(this).children(selectorToShow).animate(settings.show, settings.animationSpeed);
			});
			
			/* SHOW: hide a single class*/
			$(this).bind("hide", function( e, selectorToHide ){
				$(this).children(selectorToHide).animate(settings.hide, settings.animationSpeed);	
			});
			
			/* ============ Check URL Hash ====================*/
			if(settings.useHash){
				if(location.hash != '')
					$(this).trigger("filter", [ location.hash ]);
				else
					$(this).trigger("filter", [ '#' + settings.allTag ]);
			}
			
			/* ============ Setup Tags ====================*/
			if(settings.useTags){
				$(settings.tagSelector).click(function(){
					$('.column ul').trigger("filter", [ $(this).attr('href') ]);
					$('.column-list ul').trigger("filter", [ $(this).attr('href') ]);					
					$(settings.tagSelector).removeClass('current');
					$(this).addClass('current');
				});
			}
		});
	}
})(jQuery);

$(document).ready(function(){	
	$('.column ul').filterable();
	$('.column-list ul').filterable();
});





/***************************************************
				SLIDING TABS
***************************************************/
$(document).ready(function() {	
  $('#tabMenu > li').click(function(){
    $('#tabMenu > li').removeClass('selected');
    $(this).addClass('selected');
    $('.boxBody div').slideUp('1500');
        $('.boxBody div:eq(' + $('#tabMenu > li').index(this) + ')').slideDown('1500');    
  });	
});





