jQuery(document).ready(function(){

				
				
// PORTFOLIO FILTER


jQuery('#portfoliofilter > li:first').addClass('current-menu-item');
jQuery('#portfoliofilter > li > a').click(function(){

	jQuery('#portfoliofilter > li').removeClass('current-menu-item');
	jQuery(this).parent().addClass('current-menu-item');
	var term = jQuery(this).attr('title');
	
	if(term == 'showall'){
	jQuery('.portfolio-post').fadeTo('500',1);
	}else{
	jQuery('.portfolio-post').not('.' + term).fadeTo('500',0.3,function(){
	});
	jQuery('.' + term).fadeTo('500',1.0);
	}	
	return false;

});

// Add tooltip to social media icons
jQuery('.epic_socialmedia > li > a').simpletooltip();



jQuery.fn.setAllToMaxHeight = function(){
return this.height( Math.max.apply(this, jQuery.map( this , function(e){ return jQuery(e).height()}) ) );
}

jQuery('.teaser').setAllToMaxHeight();
jQuery('.featured-post').setAllToMaxHeight();

jQuery('.breakline a').click(function(){
	jQuery('html, body').animate({scrollTop: jQuery("#wrapper").offset().top}, 1000);
	return false;
});

var cycle_transition = jQuery("meta[name=cycletransition]").attr('content');
var cycle_interval = jQuery("meta[name=cycleinterval]").attr('content');
var cycle_thumbpager = jQuery("meta[name=cyclethumbnav]").attr('content');

if(cycle_thumbpager == 'true'){
		
// CYCLE SLIDESHOW
jQuery('#cycle-slideshow').cycle({
fx: cycle_transition,
speed:300,
easing: 'easeInOutQuad',
cleartype:  1,
pause:1,
timeout: cycle_interval,
//next:  '#next-slide',
//prev:  '#prev-slide',
pager: '#thumbnav',

	// callback fn that creates a thumbnail to use as pager anchor 
      
    pagerAnchorBuilder: function(idx, slide) { 
       		 return '#thumbnav li:eq(' + idx + ') a'; 
    	 
	} 

});	

}
else{

// CYCLE SLIDESHOW
jQuery('#cycle-slideshow').cycle({
fx: cycle_transition,
speed:300,
easing: 'easeInOutQuad',
cleartype:  1,
pause:1,
timeout: cycle_interval,
//next:  '#next-slide',
//prev:  '#prev-slide',
pager: '#slide-pager'


});	


}

jQuery('#cycle_playButton').hide();

jQuery('#cycle_pauseButton').click(function() { 
    jQuery('#cycle-slideshow').cycle('pause');
    jQuery(this).hide();
    jQuery('#cycle_playButton').show();
    return false;
});

jQuery('#cycle_playButton').click(function() { 
    jQuery('#cycle-slideshow').cycle('resume'); 
    jQuery(this).hide();
    jQuery('#cycle_pauseButton').show();
    return false;
});



// Gallery cycle

// CYCLE SLIDESHOW
jQuery('#epic_gallery').cycle({
fx: cycle_transition,
speed:300,
easing: 'easeInOutQuad',
cleartype:  1,
pause:1,
timeout: 0,
//next:  '#next-slide',
//prev:  '#prev-slide',
pager: '#gallery_thumbs',

pagerAnchorBuilder: function(idx, slide) { 
       		 return '#gallery_thumbs li:eq(' + idx + ') a'; 
    	 
	} 


});	
/*
jQuery('#epic_gallery_wrap').hover(function(){

	jQuery('#epic_gallery_nav').fadeIn();
	},function(){
	jQuery('#epic_gallery_nav').fadeOut();
	});
*/


jQuery('#epic_gallery_nav li a').css({'opacity':'0.4'});
jQuery('#epic_gallery_nav li.activeSlide a').css({'opacity':'1'});

jQuery('#epic_gallery_nav li a').click(function(){
	jQuery('#epic_gallery_nav li a').css({'opacity':'0.4'});
	jQuery('#epic_gallery_nav li.activeSlide a').css({'opacity':'1'});
});







accordionMenu();
toggleMenu();
primaryHover();
tabPanel();
user_tabs();

});

// Fix z-indexing issues in internet explorer 8.0
if(jQuery.browser.msie && jQuery.browser.version=="8.0"){
jQuery(function() {
	var zIndexNumber = 1000;
	jQuery('div').not('#slideshow-fixed div').each(function() {
		jQuery(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});
});
}


  jQuery(function() {
    jQuery("#submit_contactform").click(function() {
      // validate and process form here
    });



  });
  
  
 
 function primaryHover(){
	
		jQuery("#menu-primary .sub-menu").hover(function(){
			jQuery(this).parent().find("a").addClass("primary-active");
			},function(){
			jQuery(this).parent().find("a").removeClass("primary-active");
			
		});
	
}


// TAB PANEL
function tabPanel(){
	
		//Default Action
			jQuery(".tabcontent").hide(); //Hide all content
			jQuery(" #epic_tabnav > li:first").addClass("current-menu-item").fadeIn('fast'); //Activate first tab
			jQuery(".tabcontent:first").show(); //Show first tab content
			
			
			//On Click Event
			jQuery("#epic_tabnav > li").click(function() {
				jQuery("#epic_tabnav > li").removeClass("current-menu-item"); //Remove any "active" class
				jQuery(this).addClass("current-menu-item"); //Add "active" class to selected tab
				jQuery(".tabcontent").hide(); //Hide all content
				var activeTab = jQuery(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
				jQuery(activeTab).stop().show(); //Fade in the active content
				return false;
			});
			
	
	}
	
// TAB PANEL
function user_tabs(){
	
		//Default Action
			jQuery(".formcontent").hide(); //Hide all content
			jQuery(" ,.epic_usertabnav > li:first").addClass("current-menu-item").fadeIn('fast'); //Activate first tab
			jQuery(".formcontent:first").show(); //Show first tab content
			
			
			//On Click Event
			jQuery(".epic_usertabnav > li").click(function() {
				jQuery(".epic_usertabnav > li").removeClass("current-menu-item"); //Remove any "active" class
				jQuery(this).addClass("current-menu-item"); //Add "active" class to selected tab
				jQuery(".formcontent").hide(); //Hide all content
				var activeTab = jQuery(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
				jQuery(activeTab).stop().show(); //Fade in the active content
				return false;
			});
			
	
	}
	
// TOGGLE
function toggleMenu(){
	
	jQuery(".togglecontainer").hide(); 

	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	jQuery(".togglehandle").click(function(){
		jQuery(this).toggleClass("active").next().slideToggle("normal");
		return false; //Prevent the browser jump to the link anchor
	});
						
}

function accordionMenu(){

	//Set default open/close settings
	jQuery('.acc_container').hide(); //Hide/close all containers
	//jQuery('.acc_handle:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container

	//On Click
	jQuery('.acc_handle').click(function(){
	
	if( jQuery(this).next().is(':hidden') ) { //If immediate next container is closed...
		jQuery('.acc_handle').removeClass('active').next().slideUp('fast'); //Remove all "active" state and slide up the immediate next container
		jQuery(this).toggleClass('active').next().slideDown('fast'); //Add "active" state to clicked trigger and slide down the immediate next container
	}
	
	return false; //Prevent the browser jump to the link anchor
});

}


// Tell the fullwidth cycle slider to always fit in the window.
jQuery(window).resize(function() {
	
  jQuery('#slideshow-full, #slideshow-full > #cycle-slideshow, #slideshow-full > .slide').css({'width': jQuery(window).width() + 'px'},500);
  jQuery('#slideshow-full > .slide-image').css({'background-position':'center top'});
});



/*********************
//* 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/
*********************/

//Update: April 12th, 10: Fixed compat issue with jquery 1.4x

//Specify full URL to down and right arrow images (23 is padding-right to add to top level LIs with drop downs):

// Check to see if drop down is enabled
var menudropdown = jQuery("meta[name=menudropdown]").attr('content');

// If 'regular'...
if(menudropdown == 'regular'){

// Run the script...
var siteurl = jQuery("meta[name=siteurl]").attr('content');
var arrowimages={down:['downarrowclass', siteurl + '/library/images/arrow_down.png', 18], right:['rightarrowclass', siteurl +'/library/images/arrow_right.png']}

var jqueryslidemenu={

animateduration: {over: 200, out: 100}, //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.children("a:eq(0)").css(this.istopheader? {paddingRight: arrowsvar.down[2]} : {}).append(
				'<img src="'+ (this.istopheader? arrowsvar.down[1] : arrowsvar.right[1])
				+'" class="' + (this.istopheader? arrowsvar.down[0] : arrowsvar.right[0])
				+ '" style="border: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
			$curobj.click(function(){
				$(this).children("ul:eq(0)").hide()
			})
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible'})
	}) //end document.ready
}
}

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

}

// ACCORDION SLIDER EVENT HANDLERS

jQuery(function () {
	
	jQuery('.slideimage').hide();
	jQuery('.slide-minicaption').hide();
	jQuery('.slidecaption').hide();
});




jQuery(window).bind("load", function() {
		
		
		
		//jQuery(".slidecaption").hide();
		jQuery(".slidecaption").css({'opacity':'0'});
		jQuery('.slide-minicaption').show();
		//jQuery('.slidecaption').show();
		jQuery('.slideimage:hidden').fadeIn(500);
		jQuery(".slide-minicaption").fadeTo(1, 0.8);
		
		
		maxwidth = jQuery('#kwicks').width() - 80;
		//alert (divwidth);
			
		jQuery('.kwicks').kwicks({
			
			max :  maxwidth,
			spacing:0
		});

});

jQuery(function(){ 
		jQuery(".accslide").hover(function() {
		jQuery(".slide-minicaption",this).stop().animate({opacity: 0},200, 'easeInSine').parent().find(".slidecaption").show().stop().delay(400).animate({opacity: 0.8, bottom: '20'},400, 'easeOutSine');	
		},function(){
		jQuery(".slide-minicaption",this).stop().animate({opacity: 0.8},200, 'easeOutSine');
		jQuery(".slidecaption",this).stop().animate({opacity: 0, bottom: '-20'}, 200, 'easeInSine').hide();				
		});
});




/* 
 * Cross-browser event handling, by Scott Andrew
 */
function addEvent(element, eventType, lamdaFunction, useCapture) {
    if (element.addEventListener) {
        element.addEventListener(eventType, lamdaFunction, useCapture);
        return true;
    } else if (element.attachEvent) {
        var r = element.attachEvent('on' + eventType, lamdaFunction);
        return r;
    } else {
        return false;
    }
}

/*
 * Clear Default Text: functions for clearing and replacing default text in
 * <input> elements.
 *
 * by Ross Shannon, http://www.yourhtmlsource.com/
 */

addEvent(window, 'load', init, false);

function init() {
    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];
        
        if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) {  
            /* Add event handlers */          
            addEvent(theInput, 'focus', clearDefaultText, false);
            addEvent(theInput, 'blur', replaceDefaultText, false);
            
            /* Save the current value */
            if (theInput.value != '') {
                theInput.defaultText = theInput.value;
            }
        }
    }
}

function clearDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == target.defaultText) {
        target.value = '';
    }
}

function replaceDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == '' && target.defaultText) {
        target.value = target.defaultText;
    }
}



// OPEN LINKS IN NEW WINDOW
jQuery(function() {
	jQuery('a[rel*=external]').click( function() {
		window.open(this.href);
		return false;
	});
});


/**
*
*	simpleTooltip jQuery plugin, by Marius ILIE
*	visit http://dev.mariusilie.net for details
*
**/
(function($){ $.fn.simpletooltip = function(){
	return this.each(function() {
		var text = $(this).attr("title");
		$(this).attr("title", "");
		if(text != undefined) {
			$(this).hover(function(e){
				var tipX = e.pageX + 12;
				var tipY = e.pageY + 12;
				$(this).attr("title", ""); 
				$("body").append("<div id='simpleTooltip' style='position:absolute; z-index: 9999; display: none;'>" + text + "</div>");
				if($.browser.msie) var tipWidth = $("#simpleTooltip").outerWidth(true)
				else var tipWidth = $("#simpleTooltip").width()
				$("#simpleTooltip").width(tipWidth);
				$("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
			}, function(){
				$("#simpleTooltip").remove();
				$(this).attr("title", text);
			});
			$(this).mousemove(function(e){
				var tipX = e.pageX - 10;
				var tipY = e.pageY - 40;
				var tipWidth = $("#simpleTooltip").outerWidth(true);
				var tipHeight = $("#simpleTooltip").outerHeight(true);
				if(tipX + tipWidth > $(window).scrollLeft() + $(window).width()) tipX = e.pageX - tipWidth;
				if($(window).height()+$(window).scrollTop() < tipY + tipHeight) tipY = e.pageY - tipHeight;
				$("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
			});
		}
	});
}})(jQuery);



/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright © 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
