/*
*
* P6 Js functions
*
*
*/

$(document).ready(function() {

//Style the left menu's last child (no border-bottom)
/*
  $('#main #primary .current-menu-item ul li:last-child').addClass('no-border');
  $('#main #primary .current-menu-item ul ul li:last-child').removeClass('no-border');
  $('#main #primary .current-menu-ancestor ul li:last-child').addClass('no-border');
  $('#main #primary .current-menu-ancestor ul ul li:last-child').removeClass('no-border');
  $('#main #primary .current-menu-ancestor ul li:last-child li:last-child').addClass('no-border');   
  $('#main #primary .current-post-ancestor ul li:last-child').addClass('no-border');
  $('#main #primary .current-post-ancestor ul ul li:last-child').removeClass('no-border');
*/
	if ($('#main #primary .current-menu-ancestor ul li li li').length ) {
		$('#main #primary .current-menu-ancestor ul li:last-child li:last-child li:last-child ').addClass('no-border');
	}else if ($('#main #primary .current-menu-ancestor ul li li').length ){
		$('#main #primary .current-menu-ancestor ul li:last-child li:last-child').addClass('no-border');
	}else if ($('#main #primary .current-menu-ancestor ul li').length ){
		$('#main #primary .current-menu-ancestor ul li:last-child').addClass('no-border');
	}else if ($('#main #primary .current-menu-item ul li li li').length ) {
		$('#main #primary .current-menu-item ul li:last-child li:last-child li:last-child ').addClass('no-border');
	}else if ($('#main #primary .current-menu-item ul li li').length ){
		$('#main #primary .current-menu-item ul li:last-child li:last-child').addClass('no-border');
	}else if ($('#main #primary .current-menu-item ul li').length ){
		$('#main #primary .current-menu-item ul li:last-child').addClass('no-border');
	}else{
		$('#main #primary ul li:last-child').addClass('no-border');
	}
// Collapsible fields with MCE editor

	$('.morebutt1').click(function(){
		if($(this).hasClass('expanded')){
			$('.collaps1').slideToggle();
			$(this).html("Read More");
			$(this).removeClass("expanded");
		}else{
			$('.collaps1').slideToggle();
			$(this).html("Read Less");
			$(this).addClass("expanded");
		}
	});
		$('.morebutt2').click(function(){
		if($(this).hasClass('expanded')){
			$('.collaps2').slideToggle();
			$(this).html("Read More");
			$(this).removeClass("expanded");
		}else{
			$('.collaps2').slideToggle();
			$(this).html("Read Less");
			$(this).addClass("expanded");
		}
	});
		$('.morebutt3').click(function(){
		if($(this).hasClass('expanded')){
			$('.collaps3').slideToggle();
			$(this).html("Read More");
			$(this).removeClass("expanded");
		}else{
			$('.collaps3').slideToggle();
			$(this).html("Read Less");
			$(this).addClass("expanded");
		}
	});
		$('.morebutt4').click(function(){
		if($(this).hasClass('expanded')){
			$('.collaps4').slideToggle();
			$(this).html("Read More");
			$(this).removeClass("expanded");
		}else{
			$('.collaps4').slideToggle();
			$(this).html("Read Less");
			$(this).addClass("expanded");
		}
	});
		$('.morebutt5').click(function(){
		if($(this).hasClass('expanded')){
			$('.collaps5').slideToggle();
			$(this).html("Read More");
			$(this).removeClass("expanded");
		}else{
			$('.collaps5').slideToggle();
			$(this).html("Read Less");
			$(this).addClass("expanded");
		}
	});
		$('.morebutt6').click(function(){
		if($(this).hasClass('expanded')){
			$('.collaps6').slideToggle();
			$(this).html("Read More");
			$(this).removeClass("expanded");
		}else{
			$('.collaps6').slideToggle();
			$(this).html("Read Less");
			$(this).addClass("expanded");
		}
	});
		$('.morebutt7').click(function(){
		if($(this).hasClass('expanded')){
			$('.collaps7').slideToggle();
			$(this).html("Read More");
			$(this).removeClass("expanded");
		}else{
			$('.collaps7').slideToggle();
			$(this).html("Read Less");
			$(this).addClass("expanded");
		}
	});
	
// Sidebar content goes into the rightcolumn
	$('.right-sb').prepend($('.to-right-sb'));
	
//If no sidebar content, then add a class to body and make #container full-sized
	//if ((!($('.to-right-sb').length )) || ((($('.category-4').length )||($('.category-10').length )||($('.category-11').length )||($('.category-13').length )||($('.category-14').length )))){
	if (!($('.to-right-sb').length )){
		$('.right-sb').css("display","none" );
		$('#container').css("width","660px" );
	}


//TRIEX TRIANGLES ANIMATIONS	
//Triangle reduce	
  $(".triangle img").animate({
    width: "277px",
    height: "274px",
    top: "109px",
    left: "181px"
  }, 2000);

//Triex word popping up
  $(".triex-word img").delay(1500).animate({
    width: "46px",
    height: "21px",
    fontSize: "3em",
    paddingLeft: "0",
    paddingTop: "0"
  }, 2000);

//Blocks appearing for Category10
  $(".category-10 .category-efficiency h2").delay(3500).fadeIn(2000);
  $(".category-10 .category-efficiency .entry-content").delay(4500).fadeIn(1000);

  $(".category-10 .category-costs h2").delay(5500).fadeIn(2000);
  $(".category-10 .category-costs .entry-content").delay(6500).fadeIn(1000);

  $(".category-10 .category-harvest h2").delay(7500).fadeIn(2000);
  $(".category-10 .category-harvest .entry-content").delay(8500).fadeIn(1000);

//Blocks appearing for Category11
  $(".category-11 #content .triangle-elem-1 h2").delay(3500).fadeIn(2000);
  $(".category-11 #content .triangle-elem-1 .entry-content-triangle").delay(4500).fadeIn(1000);

  $(".category-11 #content .triangle-elem-2 h2").delay(5500).fadeIn(2000);
  $(".category-11 #content .triangle-elem-2 .entry-content-triangle").delay(6500).fadeIn(1000);

  $(".category-11 #content .triangle-elem-3 h2").delay(7500).fadeIn(2000);
  $(".category-11 #content .triangle-elem-3 .entry-content-triangle").delay(8500).fadeIn(1000);  

});
