$(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');
				
				fmlid_raw =$(this).closest("ul").attr('class');
				fmlid = fmlid_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: 'fmlid=' + fmlid + '&lid=' + lid,
					success: function(result) {

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