jQuery(window).load(function() {
   
   	jQuery('.flexslider').flexslider({
         
	animation: "slide",
	slideDirection: "horizontal",    
	manualControls: ".flex-control-nav li a"  ,
    directionNav: true,
    prevText: "Previous",
	nextText: "Next"
   });
});



jQuery(document).ready(function(){


				
				


// 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;
});




		





accordionMenu();
toggleMenu();
primaryHover();
tabPanel();
widgetTabPanel();
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').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, .hometabcontent").hide(); //Hide all content
			jQuery(" #epic_tabnav li:first").addClass("current-menu-item").fadeIn('fast'); //Activate first tab
			jQuery(".tabcontent:first, .hometabcontent:first").show(); //Show first tab content
			
			
			//On Click Event
			jQuery("#epic_tabnav li ").click(function() {
			
			
				var activeTab = jQuery(this).find("a").attr("href"); 
				
				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, .hometabcontent").slideUp('fast'); //Hide all content
				
				jQuery(activeTab).delay('200').slideDown(); //Fade in the active content
				return false;
			});
			
	
	}
	
// WIDGET TAB PANEL
function widgetTabPanel(){
	
		//Default Action
			jQuery(".widgettabcontent").hide(); //Hide all content
			jQuery(" #epic_widget_tabnav li:first").addClass("current-menu-item").fadeIn('fast'); //Activate first tab
			jQuery(".widgettabcontent:first").show(); //Show first tab content
			
			
			//On Click Event
			jQuery("#epic_widget_tabnav li ").click(function() {
			
			
				var activeTab = jQuery(this).find("a").attr("href"); 
				
				jQuery("#epic_widget_tabnav > li").removeClass("current-menu-item"); //Remove any "active" class
				jQuery(this).addClass("current-menu-item"); //Add "active" class to selected tab
				jQuery(".widgettabcontent").slideUp('fast'); //Hide all content
				
				jQuery(activeTab).delay('200').slideDown(); //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").slideUp(); //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().slideDown(); //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(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();				
		});
});


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

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