$(document).ready(function() {

	/* Use this js doc for all application specific JS */

	/* TABS --------------------------------- */
	/* Remove if you don't need :) */
	
	var tabs = $('dl.tabs');
		tabsContent = $('ul.tabs-content')
	
	tabs.each(function(i) {
		//Get all tabs
		var tab = $(this).children('dd').children('a');
		tab.click(function(e) {
			
			//Get Location of tab'sL content
			var contentLocation = $(this).attr("href")
			contentLocation = contentLocation + "Tab";
			
			//Let go if not a hashed one
			if(contentLocation.charAt(0)=="#") {
			
				e.preventDefault();
			
				//Make Tab Active
				tab.removeClass('active');
				$(this).addClass('active');
				
				//Show Tab Content
				$(contentLocation).parent('.tabs-content').children('li').css({"display":"none"});
				$(contentLocation).css({"display":"block"});
				
			} 
		});
	});
	
	
	/* PLACEHOLDER FOR FORMS ------------- */
	/* Remove if you don't need :) */
	
	$('[placeholder]').focus(function() {
		var input = $(this);
		if (input.val() == input.attr('placeholder')) {
			input.val('');
			input.removeClass('placeholder');
		}
		}).blur(function() {
			var input = $(this);
			if (input.val() == '' || input.val() == input.attr('placeholder')) {
				input.addClass('placeholder');
				input.val(input.attr('placeholder'));
		}
	}).blur();
	$('[placeholder]').parents('form').submit(function() {
		$(this).find('[placeholder]').each(function() {
			var input = $(this);
			if (input.val() == input.attr('placeholder')) {
				input.val('');
			}
		});
	});
	
	/* Custom Slider */
	 $('.slider').each(function(){
    var lis = $(this).children('ol').children('li').size(),
    selected = $(this).children('ol').children('li.selected').index() + 1;
    $(this).children('p').html($(this).children('ol').children('li').eq(selected - 1).html());
    $(this).slider({
      value: selected,
			min: 1,
			max: lis,
			step: 1,
			slide: function( event, ui ) {
			  $(ui.handle).siblings('p').html($(ui.handle).siblings('ol').children('li').eq(ui.value - 1).html());
			}
    });
  });
  
  $('#homepageOnly').delay(800).fadeIn(200);
  $('.close-promo').click(function(){
  	$('#homepageOnly').fadeOut(200);
  });
  
	
	$('.right-person').live('click', function(e){
		e.preventDefault();
		$(this).toggleClass('active');
	});
	
	$('.notify-me').live('click', function(e){
		e.preventDefault();
		$(this).toggleClass('active');
	});
	
	$('.premium-filters li').hover(function(){
		$(this).children('.filter-hover').show(0);
	}, function(){
		$(this).children('.filter-hover').hide(0);
	});
	
	$('.rest-of-results').infinitescroll({
      navSelector  : "div.navigation",            
      nextSelector : "div.navigation a:first",    
      itemSelector : ".rest-of-results .row"      
  });
  
  $('#registerPost').click(function(e) {
    e.preventDefault();
    window.location = 'index.php#new-signup'
    //$('<div class="container" id="accountCreatedNotification">Your account has been created!</div>').insertBefore('div.header').slideDown(300).delay(3000).slideUp(300);
  });
  	if ($(location).attr('href').indexOf('#new-signup') > -1) 
	{
		if ( $("#pending_review_id").val()=='')
		{
  			$('<div id="accountCreatedNotification"><div class="container"><div class="row"><div class="twelve columns"><h3>Thanks for registering!</h3><p class="thanks-alert">You&#39;re one step closer to getting a free month subscription! Check your email for details. <a href="write-review.php">Write a review?</a></p></div></div></div></div>').insertBefore('div.header').slideDown(300).delay(5000).slideUp(300);
		}
		else
		{
  			$('<div id="accountCreatedNotification"><div class="container"><div class="row"><div class="twelve columns"><h3>Thanks for your review!</h3><p class="thanks-alert">You&#39;re one step closer to getting a free month subscription! Check your email for details. <a href="write-review.php">Write another review?</a></p></div></div></div></div>').insertBefore('div.header').slideDown(300).delay(5000).slideUp(300);
		}
	}
	else if ($(location).attr('href').indexOf('#logout') > -1)
	{
  		$('<div id="accountCreatedNotification"><div class="container"><div class="row"><div class="twelve columns"><h3>Thanks for using Mirror!</h3><p class="thanks-alert">You are now logged out.  Sign back in to post and experience premium access.</a></p></div></div></div></div>').insertBefore('div.header').slideDown(300).delay(5000).slideUp(300);
	
	}

});

