$(document).ready(function() {
	
		$('nav ul').addClass('first_level');
		$('nav ul li ul').addClass('second_level');
		$('nav ul li ul li ul').addClass('third_level');
		$('nav ul li ul').removeClass('first_level');
		$('nav ul li ul li ul').removeClass('first_level');
		$('nav ul li ul li ul').removeClass('second_level');
		$('.mob_title').click(function(){
			$('nav > ul').slideToggle();
			// return false;
		});
		
		
		$('nav ul li:has("ul")').prepend('<span class="arrow"></span>');
		
		$('nav ul li span.arrow').click(function(){
			
			$(this).parent('li').find('ul').slideToggle();
		});
		//Friday Alert Archive Module
		$('.archive').on('click', function() {
			var year = "." + "archive" + $(this).attr( "id" );
			var height = $(year).height();
			if (height > 0 && ($(year).css('display') == "block")) {
				$(year).hide();
			} else {
				$(year).css('height','0px');
			  	$(year).show();
			  	$(year).animate({height: height}, 200);
			}
		});
		//Custom Twitter Prompt Integration
		if ($('#twitter-prompt-value').attr('data-twittervalue')) {
			//Create String
			var twitterPrompt = $('#twitter-prompt-value').attr('data-twittervalue');
			twitterPrompt = encodeURIComponent(twitterPrompt);
			var twitterHref = "http://twitter.com/intent/tweet/?text=" + twitterPrompt;
			//Attach String
			$('.ss-button-twitter').attr('href', twitterHref);
		} else {
			//If Field left empty
			var twitterPrompt = "Put your tweet here";
			var blogpostUrl = "&url=" + encodeURIComponent($(location).attr('href'));
			var twitterHref = "http://twitter.com/intent/tweet/?text=" + twitterPrompt + blogpostUrl;
			//Attach String
			$('.ss-button-twitter').attr('href', twitterHref);
		}

});
$(window).resize(function() {
	  var wwidth = $(window).width();
	  leftheight = $('.block2').outerHeight() + 100;
	  rightheight = leftheight - 60;
	  if ((wwidth > 780) && (wwidth < 1150))   {
	  rightheight = rightheight - 65;
	  rightheight = rightheight + "px";	
	  $(".bottomc").css("height", rightheight);
	  } else if (wwidth > 1150) {
	  	righthegiht = rightheight + "px";
	  	$(".bottomc").css("height", rightheight);
	  } else {
	  	$(".bottomc").css("height", "100%");
	  }
});
$(window).load(function() {
 var wwidth = $(window).width();
  leftheight = $('.block2').outerHeight() + 100;
  rightheight = leftheight - 60;
  rightheight = rightheight + "px"
  if (wwidth > 780) {
  $(".bottomc").css("height", rightheight) ;
  } else {
  	$(".bottomc").css("height", "100%");
  }
//Slide Text down
$('.pd-picture').on('click', function() {
if ($(this).attr('class') != 'active') {
	var containerid = $(this).closest("div").attr("id");
	var $bio = $("#pd-" + containerid + "-text");
	var containerwidth = $('#main-poll-content').width() - 5;
	containerwidth = containerwidth + "px";
	$bio.css('width', containerwidth);
	$('.active').css('display','none');
	$('.active').removeClass('active');
	$('.active-picture').removeClass('active-picture');
	$bio.addClass('active');
	$('img', this).addClass('active-picture');
	$bio.fadeIn(2000);
} else {
  $(this).fadeOut("fast");
  $(this).fadeIn("fast");
}
});

	$('ul li:first-child').addClass('first');
	$('ul li:last-child').addClass('last');


	$('.flexslider-one').flexslider({	
		animation: "slide"
	});

});
$(document).ready(function() {
	$('#emailform').click(function() {
		$('#signup-curl').validate();
		var EmailData = $('#emailinput').val();
		$('.results').append(EmailData);
		$.post('/wp-content/sign-up.php', {EmailData: EmailData}, function(response) {
			console.log('it worked you swarthy bastard');
				}
		);
	});
});