$(function() {
var Toggled=false;
      $(document).ready(function() {
          $('a.tab').hover(function(){
            if(Toggled==false){$('a.tab p').text('It\'s ok, we got your back'); Toggled=true;}
            else{$('a.tab p').text('Eww, these colors are gross');Toggled=false;}
            return false;
         });
     });
});
$(function () {
			$('#words .word').click(function() {
				
				$(this).addClass('labeled');
				$(this).closest("ul").attr('id', 'wordsoff');
				$('#percent').css({opacity:0, visibility: "visible"}).animate({opacity:100}, "slow");
				$('.word').unbind('click');
				
				wtfid_raw =$(this).closest("ul").attr('class');
				wtfid = wtfid_raw.substring(3);
				
				lid_raw =$(this).closest("li").attr('class');
				lid = lid_raw.substring(5);
				
				label = $(this).text();
				
					$.ajax({
					url: '/js/label.php',
					type: 'POST',
					data: 'wtfid=' + wtfid + '&lid=' + lid,
					success: function(result) {

						}
				  });
				return false;	
		});		
});
$(function () {
		
			$('#wtfform #submit').click(function() {
				
				$('#submit').replaceWith('<div class="loader"></div>');
				
				w = $('#w').val();
				t = $('#t').val();
				f = $('#f').val();
				twitter = $('#twitter').val();
				name = $('#name').val();
				email = $('#email').val();
				url = $('#url').val();
				user = $('#remember:checked').val();
				thanks = 'thanks';
				
				sluggy = w.replace(/[^a-zA-Z]/g, "") +'-'+ t.replace(/[^a-zA-Z]/g, "") +'-'+ f.replace(/[^a-zA-Z]/g, "");
				slug = sluggy.toLowerCase();
				
				wcheck = w.toLowerCase().substr(0,1);
				tcheck = t.toLowerCase().substr(0,1);
				fcheck = f.toLowerCase().substr(0,1);
				
					$.ajax({
					url: '/js/wtf.php',
					type: 'POST',
					data: 'w='+ w +'&t='+ t +'&f='+ f +'&slug='+ slug +'&twitter='+ twitter +'&name='+ name +'&email='+ email +'&url='+ url +'&user='+ user +'&thanks='+ thanks,
					success: function(result) {
						
							if (wcheck == 'w' && tcheck == 't' && fcheck == 'f') {
	
							top.location = 'http://wtfgenerator.com/' + slug + '?thanks';
							
							} else {
	
							top.location = 'http://wtfgenerator.com/submit?error';
							}
						}
				  });	
				return false;
		});
});
$(function () {
			$('#themes .wrap div').click(function() {
				
				pathname = window.location.pathname;
				style = $(this).attr('class');
				$.cookie('wtfstyle', style, { expires: 365, path: '/', domain: '.wtfgenerator.com'});
		
				top.location = pathname;
				
				return false;
		});
});
