/* Author: Liam Baxter

*/

  
  
strLoremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis diam magna, vel ultrices orci. Nunc et fringilla dolor. Cras at nibh tortor. Aenean sit amet nisi metus. Proin aliquam, dui scelerisque lobortis aliquet, urna nunc vestibulum erat, in lobortis neque enim et odio. In nibh orci, molestie vitae interdum non, rhoncus sed tellus. Nam vitae orci nulla. Fusce feugiat, augue condimentum consequat semper, lacus tellus aliquam velit, nec lacinia orci neque a diam…";

jQuery(function($) {
  myMarquee = new Marquee($('div#marquee'),strLoremIpsum, 785);
});

    $(window).load(function() {
				
	$("img.lazy").show().lazyload({ 
    effect : "fadeIn"
});
		
        $('#slider').nivoSlider({
			        captionOpacity: 1, // Universal caption opacity
			directionNav: false, // Next & Prev navigation
        controlNav: false, // 1,2,3... navigation
		 effect: 'fade',
		  pauseTime: 5000 // How long each slide will show
			});



        $('.news-slider').nivoSlider({
			        captionOpacity: 1, // Universal caption opacity
			directionNav: true, // Next & Prev navigation,
			        directionNavHide: false,
        controlNav: false, // 1,2,3... navigation
		 effect: 'fade',
		  pauseTime: 5000,
		   prevText: '&nbsp;', // Prev directionNav text
        nextText: '&nbsp;' // Next directionNav text // How long each slide will show
			});
    });


$(function() {
$(".delete2").click(function() {
$('#load').fadeIn();
var commentContainer = $(this).parent().parent();
var id = $(this).attr("id");
var string = 'id='+ id ;
	
$.ajax({
   type: "GET", 
   url: "../cms/deletehome.php",
   data: string,
   cache: false,
   success: function(){
	commentContainer.fadeOut('slow', function() {$(this).remove();});
	$('#load').fadeOut();
  }
   
 });

return false;
	});
});


$(function() {
	
$('#load').hide();


  // get the action filter option item on page load
  var $filterType = $('#filterOptions li.active a').attr('class');
	
  // get and assign the ourHolder element to the
	// $holder varible for use later
  var $holder = $('ul.ourHolder');

  // clone all items within the pre-assigned $holder element
  var $data = $holder.clone();

  // attempt to call Quicksand when a filter option
	// item is clicked
	$('#filterOptions li a').click(function(e) {
		
		// reset the active class on all the buttons
		$('#filterOptions li').removeClass('active');
		
		// assign the class of the clicked filter option
		// element to our $filterType variable
		var $filterType = $(this).attr('class');
		$(this).parent().addClass('active');
		
		if ($filterType == 'all') {
			// assign all li items to the $filteredData var when
			// the 'All' filter option is clicked
			var $filteredData = $data.find('li');
		} 
		else {
			// find all li elements that have our required $filterType
			// values for the data-type element
			var $filteredData = $data.find('li[data-type~=' + $filterType + ']');
		}
		
		// call quicksand and assign transition parameters
		$holder.quicksand($filteredData, {
			duration: 800,
			easing: 'swing',
			adjustHeight: 'dynamic'

		},
		function() {

	//move the image in pixel
	var move = -15;
	
	//zoom percentage, 1.2 =120%
	var zoom = 1;

	//On mouse over those thumbnail
	$('.imglink').hover(function() {
		
		//Set the width and height according to the zoom percentage
		width = $('.item').width() * zoom;
		height = $('.item').height() * zoom;
		
		//Move and zoom the image 
		//$(this).find('img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200});
		
		//Display the caption
		$(this).find('div.caption').stop(false,true).fadeIn(200);
	},
	function() {
		//Reset the image
		//$(this).find('img').stop(false,true).animate({'width':$('.item').width(), 'height':$('.item').height(), 'top':'0', 'left':'0'}, {duration:100});	

		//Hide the caption
		$(this).find('div.caption').stop(false,true).fadeOut(200);
	});

});
		
		return false;
	});
});


	



$(function() {
$(".delete").click(function() {
$('#load').fadeIn();
var commentContainer = $(this).parent().parent();
var id = $(this).attr("id");
var string = 'id='+ id ;
	 
$.ajax({
   type: "GET",
   url: "../cms/delete.php",
   data: string,
   cache: false,
   success: function(){
	commentContainer.fadeOut('slow', function() {$(this).remove();});
	$('#load').fadeOut();
  }
   
 });

return false;
	});
});




$(document).ready(function(){

	


$(".read-more").toggle(
			    
	  function () {
       $(this).closest(".news-item").animate({height:"550px"});
      },
      function () {
      $(this).closest(".news-item").animate({"height":"395px"});
      }
    );



if(location.href.match('coffee-design.co.uk/work.php#Branding'))
{
$(".Branding").click()

};

if(location.href.match('coffee-design.co.uk/work.php#Print'))
{
$(".Print").click()

};

if(location.href.match('coffee-design.co.uk/work.php#Digital'))
{
$(".Digital").click()

};

if(location.href.match('coffee-design.co.uk/work.php#Campaign'))
{
$(".Campaign").click()

};

if(location.href.match('coffee-design.co.uk/work.php#Packaging'))
{
$(".Packaging").click()

};

if(location.href.match('coffee-design.co.uk/work.php#Retail'))
{
$(".Retail").click()

};

if(location.href.match('coffee-design.co.uk/work.php#all'))
{

$(".all").click()

};



$().UItoTop({ easingType: 'easeOutQuart' });



// Wow! .. One line of code to make the unordered list drag/sortable!
$("#expand").toggle(
			    
	  function () {
        $(".nivo-caption").animate({"height":"90px"});
      },
      function () {
        $(".nivo-caption").animate({"height":"0px"});
      }
    );


$("#top").mousedown(function(){ 
	$("#cover1").stop().animate({left:'660px'},{queue:false, duration:600, easing: 'easeInOutCubic'})

 });


$("#menu_btn").click(
			    
				 function () {
        $("#cover1").animate({"left":"85px"});
		        $("#cover2").animate({"left":"620px"});

      }
    );

$("#menu_btn2").click(
			       function () {
        $("#cover2").animate({"left":"85px"});
		        $("#cover1").animate({"left":"565px"});

      }
    );


	$(".client").click(click_handler);

$("#exit").click(
			       function () {

					   					  $(".gradient").fadeOut(100,function(){;

			  $("header").animate({height:"75px"}, function() {
					  
					  
			 $("#clientlogin").animate({height:"0px"})
$(".client").bind('click', click_handler);

					  
		});			  
	      
        });
    });


function click_handler() { 
   
   	  $("#clientlogin").css("overflow","visible").animate({height:"125px"}, function() {
					  
					  
				  $("header").animate({height:"200px"}, function() {

					  
					  $(".gradient").fadeIn(400);
					   jQuery(".client").unbind("click");

	        });
        });
}
});
				$("#twitter").getTwitter({
					userName: "coffeedesign",
					numTweets: 1,
					loaderText: "Loading tweets...",
					slideIn: true,
					showHeading: false,
					headingText: "Twitter",
					showProfileLink: false
				});
				
	
$(function() {
		$( "#images" ).sortable();
	});
	
	$(function() {
		$( "#sort" ).sortable();
	});
	
	Shadowbox.init({
    handleOversize: "drag",
    modal: true
});
