/*

File: custom.js

Spectrum Design & Graphics
Created: 03/09/11



--- TABLE OF CONTENTS ---


1. IMAGE ZOOM
2. SHOW MENU SEARCH
3. PORTFOLIO 4 SLIDING CAPTIONS
4. JMENU
5. PAGE JUMP
6. FANCYBOX
7. LATEST TWEETS
8. TIPSY FOR REPLACING THE "TITLE" ATTRIBUTE VALUES 
9. JCAROUSEL
10. PIKA CHOOSE


*/

/* 1 *** IMAGE ZOOM */
jQuery(document).ready(function() {
	$("a.zoom img").mouseover(function(){
		$(this).stop(true,true);
		$(this).fadeTo(300, 0.6);
	});
	
	$("a.zoom img").mouseout(function(){
		$(this).fadeTo(400, 1.0);
	});
 
});



/* 2 *** SHOW MENU SEARCH
$(document).ready(function() {
	$(".menu-search, .search-close").click(function () {
		$("#searchform").toggle("slow");
	});
}); */

$(document).ready(function () {

 $('.menu-search, .search-close').click(function () {

        var $search = $('#searchform');

        if ($search.is(':visible')) {

        $search.fadeOut(1000);

        } else {

        $search.fadeIn(1000);

        }

 });

});



/* 3 *** PORTFOLIO 4 SLIDING CAPTIONS */
$(document).ready(function() {

	$('.boxgrid.captionfull').hover(function(){
	$(".cover", this).stop().animate({top:'-0px'},{queue:false,duration:200});
	}, function() {
	$(".cover", this).stop().animate({top:'-145px'},{queue:false,duration:700});
	});

});



/* 4 *** JMENU */
jQuery(document).ready(function() {
    $('#menu').jmenu({
	    animation:'slide',
	    duration:300
    });
});



/* 5 *** PAGE JUMP */
$('.jump').click(function() {
	var elementClicked = $(this).attr("href");
	var destination = $(elementClicked).offset().top;
	$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 1000 );
	return false;
});



/* 6 *** FANCYBOX */
jQuery(document).ready(function() {

	//display image
	$("a.zoom").fancybox();

});



/* 7 *** LATEST TWEETS */
jQuery(window).load(function() {

getTwitters('myTweets', {
        id: 'spectrumak',	// twitter user id
        prefix: '<a href="http://twitter.com/%screen_name%">%name%</a> said: ', 
        clearContents: false, // leave the original message in place
        count: 2, 
        withFriends: true,
        ignoreReplies: false,
	 enableLinks: true,
        newwindow: true
    });
    
});



/* 8 *** TIPSY FOR REPLACING THE "TITLE" ATTRIBUTE VALUES */
jQuery(document).ready(function(){
	
	$('a.tipsy').tipsy({
	
		delayIn: 0,      // delay before showing tooltip (ms)
		delayOut: 0,     // delay before hiding tooltip (ms)
		fade: true,     // fade tooltips in/out?
		fallback: '',    // fallback text to use when no tooltip text
		gravity: 's',    // gravity
		html: false,     // is tooltip content HTML?
		live: false,     // use live event support?
		offset: 15,       // pixel offset of tooltip from element
		opacity: 0.8,    // opacity of tooltip
		title: 'title',  // attribute/callback containing tooltip text
		trigger: 'hover' // how tooltip is triggered - hover | focus | manual
	
	});
	
});



/* 9 *** JCAROUSEL */
jQuery(document).ready(function() {
    jQuery('.imageCarousel').jcarousel({
        auto: 3,
        scroll: 1,
        wrap: 'last',
        animation: 700,
        initCallback: mycarousel_initCallback,
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});

function mycarousel_initCallback(carousel) {
    jQuery('.carousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('.carousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};



/* 10 *** Pika Choose */
jQuery(document).ready(function (){
	var a = function(self){
		self.anchor.fancybox();
	};
	$("#pikame").PikaChoose({
		speed: 2500,
		buildFinished:a
	});
});
