// JavaScript Document

$(document).ready(function() {
						   
	$(".openAndClose").click(function (slide) {
									
			// slide.preventDefault();

			var total = $('.gallery .file').size();
			
			if(count < total) {
				var target_file = $('.description.show').next();
				var target_description = $('.description.show').next().next();
					$('.file.show').removeClass('show').addClass('hide'); 
					$('.description.show').removeClass('show').addClass('hide'); 
				target_file.removeClass('hide').addClass('show'); 
				target_description.removeClass('hide').addClass('show'); 		
			} else {
				// go to first child
				$('.file.show').removeClass('show').addClass('hide'); 
				$('.description.show').removeClass('show').addClass('hide'); 
				
				$('.gallery p:first-child').removeClass('hide').addClass('show'); 
				$('.gallery p:first-child').next().removeClass('hide').addClass('show');
				
				count = 0;
			}
			
			count = count + 1;

    });	
	
	$('.selector_options').addClass('hide');	
	
	$(".selector .openAndClose").hover(			
							 
	 function () {
		 $(this).find('.selector_options').removeClass('hide');	
	  }, 
	  function () {
		  $(this).find('.selector_options').addClass('hide');	
	  }
										  

	);

	// GALLERY SLIDE
	var count = 1;
				
	$(".nextslide").click(function (slide) {
									
			slide.preventDefault();

			var total = $('.gallery .file').size();
			
			if(count < total) {
				var target_file = $('.description.show').next();
				var target_description = $('.description.show').next().next();
					$('.file.show').removeClass('show').addClass('hide'); 
					$('.description.show').removeClass('show').addClass('hide'); 
				target_file.removeClass('hide').addClass('show'); 
				target_description.removeClass('hide').addClass('show'); 		
			} else {
				// go to first child
				$('.file.show').removeClass('show').addClass('hide'); 
				$('.description.show').removeClass('show').addClass('hide'); 
				
				$('.gallery p:first-child').removeClass('hide').addClass('show'); 
				$('.gallery p:first-child').next().removeClass('hide').addClass('show');
				
				count = 0;
			}
			
			count = count + 1;

    });
	
	// FEATURED SLIDE next
	var count = 1;
				
	$(".home .featured-arrow .next a").click(function (slide) {
									
			slide.preventDefault();

			var total = $('#featured .hentry').size();
			
			if(count >= total) {
				$('#featured .show').addClass('hide'); 
				$('#featured .show').removeClass('show');
				
				$('#featured .hentry:first').removeClass('hide');
				$('#featured .hentry:first').addClass('show');
				
				count = 1;
			} else {
				var target_file = $('#featured .show').next();
				$('#featured .show').addClass('hide'); 
				$('#featured .show').removeClass('show'); 
				target_file.removeClass('hide');
				target_file.addClass('show');
				
				count = count + 1;
			}


    });
	
	// FEATURED SLIDE prev
	var count = 1;
				
	$(".home .featured-arrow .prev a").click(function (slide) {
												  
												  
									
			slide.preventDefault();

			var total = $('#featured .hentry').size();
			
			
			if(count == 1) {
				$('#featured .show').addClass('hide'); 
				$('#featured .show').removeClass('show');
				
				$('#featured-posts .hentry:last').removeClass('hide');
				$('#featured-posts .hentry:last').addClass('show');
				
				count = total;
			} else {
				var target_file = $('#featured .show').prev();
				$('#featured .show').addClass('hide'); 
				$('#featured .show').removeClass('show'); 
				target_file.removeClass('hide');
				target_file.addClass('show');
			
				count = count - 1;
			}
			
			

    });

	// direct video
	$(".img-to-video").click(function (direct) {
									
			direct.preventDefault();
			
			var fetchVideoID = $(this).attr('ID');
			
			var text = $('#video-' + fetchVideoID).val();
			
			$(this).parent().html(text);
			
	});

	$(".img-to-video").hover(
							 
	 function () {
		 $(this).find('.play').addClass('active');	
	  }, 
	  function () {
		  $(this).find('.play').removeClass('active');	
	  }
										  

	);
	
	// roll-over show arrows
	$(".not-home #featured").hover(
							 
	 function () {
		 $(this).addClass('show-arrows');
	  }, 
	  function () {
		 $(this).removeClass('show-arrows');
	  }
										  

	);
	
	$(".single #featured-posts").hover(
							 
	 function () {
		 $(this).find('.slideshow-next').removeClass('hide');	
		 $(this).find('.slideshow-next').addClass('show');	
	  }, 
	  function () {
		 $(this).find('.slideshow-next').removeClass('show');	
		 $(this).find('.slideshow-next').addClass('hide');	
	  }
										  

	);

 });

