// JavaScript Document

// OnFocus Form Clear
function formFocus(id){
	if(id=='message'){
		$('#'+id).css({'font-size':'14px'});
	}
	$('#'+id).val('');
	$('#'+id).css({'color':'white'});
		
}

function formBlur(id,name){
	if($('#'+id).val()==""){
		$('#'+id).val(name);
		$('#'+id).css({'color':'grey'});
		if(id=='message'){
			$('#'+id).css({'font-size':'18px'});
		}
	}
}

function popupClose(){
	$('#emailForm').fadeOut();
	$('#shareEmail').fadeOut();
}

$(document).ready(function(){
	/* Lazy Load
	$("img").lazyload({
		placeholder : "images/spacer.gif",
	    effect      : "fadeIn"
	});
	*/
	// Contact
	$('img.contact').toggle(
		function()
		{
			$('#contactForm').slideDown("slow");
			$('#contactTab').animate({
				'top' : '360px'
			},'slow');
			$('#upClose').attr("src", "/images/collapse.png");
		},
		function()
		{
			$('#contactForm').slideUp("slow");
			$('#contactTab').animate({
				'top' : '0px'
			},'slow');
			$('#upClose').attr("src", "/images/expand.png");
	});
	$('.submitContact').click(function(){
		$.post("/ajax/send.php", { email: $('#email').val(), subject: $('#subject').val(), message:$('#message').val() },
		  function(){
			$('#contactForm').empty();
			$('#contactForm').html('Thank you for you inquiry. I will get back to you as soon as possible.');
		});
	});
	
	$('#popupClose').click(function(){
		$('#emailForm').fadeOut();
		$('#shareEmail').fadeOut();
	});
	
	$('.submitShare').click(function(){
		$.post("/ajax/share_send.php", { your_email: $('#your_email').val(), thier_email: $('#thier_email').val(), subjectShare: $('#subjectShare').val(), comment:$('#your_email').val()+' thought you might enjoy this link:\n\n'+$('#linkTitle').val()+'\n'+$('#linkURL').val()+'\n'+$('#comment').val() },
		//$.post("/codeigniter/index.php/email/send", { your_email: $('#your_email').val(), thier_email: $('#thier_email').val(), subjectShare: $('#subjectShare').val(), comment:$('#comment').val() },
		//$.post("/codeigniter/index.php/email/send/"+$('#your_email').val()+"/"+$('#thier_email').val()+"/"+$('#subjectShare')+"/"+$('#comment').val(), { },
		  function(){
			$('#emailForm').empty();
			//$('#emailForm').html();
			$('#emailForm').html('<div align="right"><a href="javascript:popupClose();">x</a></div>Thank you for you inquiry. I will get back to you as soon as possible.');
		});
	});
	
	// Social Media Slider
   
	$('.kwicks').kwicks({  
        max : 570,  
        spacing : 5,  
        sticky: true 
    });   
	
});