function equalheight(){
	var highestCol = Math.max($('.main-content').height(),$('.sidebar').height());
	$('.main-content').height(highestCol);
	$('.sidebar').height(highestCol);	
}
$.fn.sameHeights = function() {
	$(this).each(function(){
		var tallest = 0;
		$(this).children().each(function(i){
			if (tallest < $(this).height()) { tallest = $(this).height(); }
		});
		$(this).css({'height': tallest});
		$(this).children().css({'height': tallest});
	});
	return this;
};

function subpages(){
	$('.subpages ul.subpages-wrap').sameHeights();
    $('.subpages ul.subpages-wrap li:first-child').show();
   	$('.first.subpage-toggler > li:first-child a').addClass('currentSubpage');
	$('.subpage-toggler a').click(function(){
		$x = $(this).attr('class'); 
		$x = $x.replace(" currentSubpage", "");	
		$('.subpages ul.subpages-wrap > li').hide()
		$('.subpages ul.subpages-wrap > li#'+$x).show();
		$('.subpage-toggler a.currentSubpage').removeClass('currentSubpage');
		$(this).addClass('currentSubpage');
	 });
}


function contact_form_default(){
	$(function() { var defaultText = 'Name'; $('.your-name input[type="text"]') .val(defaultText) .focus(function() { if ( this.value == defaultText ) this.value = ''}) .blur(function() { if ( !$.trim( this.value ) ) this.value = defaultText});});
	$(function() { var defaultText = 'Email'; $('input[type="text"].wpcf7-validates-as-email') .val(defaultText) .focus(function() { if ( this.value == defaultText ) this.value = ''}) .blur(function() { if ( !$.trim( this.value ) ) this.value = defaultText});});
	$(function() { var defaultText = 'Website'; $('input[type="text"].website') .val(defaultText) .focus(function() { if ( this.value == defaultText ) this.value = ''}) .blur(function() { if ( !$.trim( this.value ) ) this.value = defaultText});});	

    $('textarea').val('Your Message Here'); 
    $('textarea').focus(function() {
        if ($(this).val() === 'Your Message Here') $(this).val('');
    });
    $('textarea').blur(function() {
        if ($.trim($(this).val()) === '') $(this).val('Message'); 
    }); 
}

function page_galleries(){
    $('.page-gallery').cycle({
        fx:      'fade',
        timeout:  4000,
        pager:   '.page-gallery-toggler',
        pause: 1,
        cleartype:  0,
        pagerAnchorBuilder: pagerFactory
    });

    function pagerFactory(idx, slide) {
        var s = idx > 2 ? '' : '';
        return '<li><a href="#">'+ $(slide).attr('title') +'</a></li>';
    };
}

function tab_toggle(){
    $(".tab").click(function () {
      $(".tabcontent").slideToggle("slow");
    });	
}

function banner_gallery(){
	$('#banner ul').cycle({ 
    	fx:     'scrollHorz', 
	    prev:   '#prev', 
    	next:   '#next', 
	 	timeout:  7000
	});	
}
function accordian(){
	$('#faq p strong').parent().show();
   	$('#faq p strong').click(function() {
     	$('.open').parent().next().slideToggle();     
     	$('.open').toggleClass("open");
    	$(this).toggleClass("open");
    	$(this).parent().next().slideToggle();	     
   	});	
}
