
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	
	GlobalScripts.css
	
	• Generator: 	Build Projects Plugin
	• Version:      0.1
	• Author:       Christopher Hein
	• Author URL:   http://www.christopherhein.com
	• Author Email: me@christopherhein.com
	
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
		
	// Initializing with the page has loaded
$(document).ready(function()
{
  $('.information').fadeOut(0);
  
  $('form#newsletter_form').submit(function(){
    if( validate('newsletter_form', 'newsletter_field') == false ) {
      return false;
    } else {
      var email = $('#newsletter_field').val();
      $.ajax(
			{
				url: '_assets/includes/functions/Newsletter_Sign_Up.php?newsletter_field='+email+'&newsletter_submit=sign-up!',
				cache: false,
				type: "GET",
				success: function(html)
				{ 
					$('form#newsletter_form').remove();
					$('#thank_you').append("<img src='_assets/images/global/sflove_thank_you_title.jpg' id='thanks' align='center' />");
				}
			});
      return false;
    }
  });
  
  $('form#file_upload').submit(function(){
    CollectUploadData();
    return false;
  });
  
  $('form#contacting_form').submit(function(){
    if( $('#your_name').val() == "" ) {
      alert('You need to enter your name!');
      return false;
    } else if( validate('contacting_form', 'your_email') == false ) {
      return false;
    } else if( $('#your_message').val() == "" ) {
      alert("You need to enter a message..."); 
      return false;
    } else {
      var name = $('#your_name').val();
      var email = $('#your_email').val();
      var msg = $('#your_message').val();
      
      $.ajax(
			{
				url: '_assets/includes/functions/Contact_Us.php?contact_name='+name+'&contact_email='+email+'&contact_message='+msg+'&contact_submit=send!',
				cache: false,
				type: "GET",
				success: function(html)
				{ 
					$('form#contacting_form').remove();
					$('#thank_you_contacting').append("<img src='_assets/images/global/sflove_thank_you_title.jpg' id='thanks' align='center' />");
				}
			});
      return false;
    }
  });
  
    // Newsletter Words 
	$('#newsletter_field').animate({ opacity: "1" })
		.click(function() {
			var thisFor	= $(this).attr('for');
			$('.'+thisFor).focus();
	});
	
	$('#newsletter_field').focus(function() {
	
		$('.newsletter_fade').animate({ marginLeft: "12em", opacity: "0" }, "slow");
	
			if($(this).val() == "email...") {
				$(this).val() == "";
			}
		}).blur(function() {
	
			if($(this).val() == "") {
				$(this).val() == "email...";
				$('.newsletter_fade').animate({ marginLeft: "0em", opacity: "1" }, "slow");
			}
	});
	
	 // Contact Name
	$('#your_name').animate({ opacity: "1" })
		.click(function() {
			var thisFor	= $(this).attr('for');
			$('.'+thisFor).focus();
	});
	
	$('#your_name').focus(function() {
	
		$('#contact_name_fade').animate({ marginLeft: "12em", opacity: "0" }, "slow");
	
			if($(this).val() == "email...") {
				$(this).val() == "";
			}
		}).blur(function() {
	
			if($(this).val() == "") {
				$(this).val() == "name...";
				$('#contact_name_fade').animate({ marginLeft: "0em", opacity: "1" }, "slow");
			}
	});
	
	 // Contact Email
	$('#your_email').animate({ opacity: "1" })
		.click(function() {
			var thisFor	= $(this).attr('for');
			$('.'+thisFor).focus();
	});
	
	$('#your_email').focus(function() {
	
		$('#contact_email_fade').animate({ marginLeft: "12em", opacity: "0" }, "slow");
	
			if($(this).val() == "email...") {
				$(this).val() == "";
			}
		}).blur(function() {
	
			if($(this).val() == "") {
				$(this).val() == "email...";
				$('#contact_email_fade').animate({ marginLeft: "0em", opacity: "1" }, "slow");
			}
	});
	
	 // Contact Message
	$('#your_message').animate({ opacity: "1" })
		.click(function() {
			var thisFor	= $(this).attr('for');
			$('.'+thisFor).focus();
	});
	
	$('#your_message').focus(function() {
	
		$('#contact_message_fade').animate({ marginLeft: "12em", opacity: "0" }, "slow");
	
			if($(this).val() == "talk to us, we get lonely...") {
				$(this).val() == "";
			}
		}).blur(function() {
	
			if($(this).val() == "") {
				$(this).val() == "talk to us, we get lonely...";
				$('#contact_message_fade').animate({ marginLeft: "0em", opacity: "1" }, "slow");
			}
	});
	
    // Footer Twitter Feed
  $(".tweet").tweet({
    join_text: "auto",
    username: "SanFranciscoLuv",
    avatar_size: 0,
    count: 3,
    auto_join_text_default: "we said,", 
    auto_join_text_ed: "we",
    auto_join_text_ing: "we were",
    auto_join_text_reply: "we replied",
    auto_join_text_url: "we were checking out",
    loading_text: "loading tweets..."
  });
  
  $('.information').hover(function() {
    $(this).show();
  }, function() {
    $(this).fadeOut();
  });
  
  $('.admin_pics').hover(function() {
    $('.information', this).fadeIn();
  }, function() {
    $('.information', this).fadeOut();
  });
	
	$('.delete_image').click(function() {
	 var image_id = $(this).attr('alt');
	 var answer = confirm("Are you sure you'd like to delete image?" );
	 
	 if( answer ) {
	   $('.small_headshots.admin_pics#admin_delete_'+image_id).fadeOut(1000, function() {
	     $.ajax({
          url: '../_assets/includes/functions/Delete_Image.php?delete_image='+image_id+'',
          cache: false,
          type: "GET",
          success: function(html)
          { 
          	$('.small_headshots.admin_pics#admin_delete_'+image_id).remove();
          }
	     });
	   });
	 } else {}
	});
	
});
	
	
