// HOME HOVER EFFECT ===============================================================================		    
    $(document).ready(function() {
        $('.thumb_1').mouseenter(function(e) {
            $(this).children('a').children('img').animate({ height: '90', left: '0', top: '0', width: '150'}, 400);
            $(this).children('a').children('span').fadeIn(300);
        }).mouseleave(function(e) {
            $(this).children('a').children('img').animate({ height: '90', left: '0', top: '0', width: '150'}, 400);
            $(this).children('a').children('span').fadeOut(300);
        });
});

//CENTER VERTICALLY ===============================================================================	
$(document).ready(function(){
						   
	$(window).resize(function(){

		$('.content_wrapper').css({
			position:'relative',
			left: ($(window).width() - $('.content_wrapper').outerWidth())/2,
			top: ($(window).height() - $('.content_wrapper').outerHeight())/2
		});
		
	});
	// To initially run the function:
	$(window).resize();
});	
// AUDIO PLAYER ================================================
//<![CDATA[
$(document).ready(function(){

	var Playlist = function(instance, playlist, options) {
		var self = this;

		this.instance = instance; // String: To associate specific HTML with this playlist
		this.playlist = playlist; // Array of Objects: The playlist
		this.options = options; // Object: The jPlayer constructor options for this playlist

		this.current = 0;

		this.cssId = {
			jPlayer: "jquery_jplayer_",
			interface: "jp_interface_",
			playlist: "jp_playlist_"
		};
		this.cssSelector = {};

		$.each(this.cssId, function(entity, id) {
			self.cssSelector[entity] = "#" + id + self.instance;
		});

		if(!this.options.cssSelectorAncestor) {
			this.options.cssSelectorAncestor = this.cssSelector.interface;
		}

		$(this.cssSelector.jPlayer).jPlayer(this.options);

		$(this.cssSelector.interface + " .jp-previous").click(function() {
			self.playlistPrev();
			$(this).blur();
			return false;
		});

		$(this.cssSelector.interface + " .jp-next").click(function() {
			self.playlistNext();
			$(this).blur();
			return false;
		});
	};

	Playlist.prototype = {
		displayPlaylist: function() {
			var self = this;
			$(this.cssSelector.playlist + " ul").empty();
			for (i=0; i < this.playlist.length; i++) {
				var listItem = (i === this.playlist.length-1) ? "<li class='jp-playlist-last'>" : "<li>";
				listItem += "<a href='#' id='" + this.cssId.playlist + this.instance + "_item_" + i +"' tabindex='1'>"+ this.playlist[i].name +"</a>";

				// Create links to free media
				if(this.playlist[i].free) {
					var first = true;
					listItem += "<div class='jp-free-media'>(";
					$.each(this.playlist[i], function(property,value) {
						if($.jPlayer.prototype.format[property]) { // Check property is a media format.
							if(first) {
								first = false;
							} else {
								listItem += " | ";
							}
							listItem += "<a id='" + self.cssId.playlist + self.instance + "_item_" + i + "_" + property + "' href='" + value + "' tabindex='1'>" + property + "</a>";
						}
					});
					listItem += ")</span>";
				}

				listItem += "</li>";

				// Associate playlist items with their media
				$(this.cssSelector.playlist + " ul").append(listItem);
				$(this.cssSelector.playlist + "_item_" + i).data("index", i).click(function() {
					var index = $(this).data("index");
					if(self.current !== index) {
						self.playlistChange(index);
					} else {
						$(self.cssSelector.jPlayer).jPlayer("play");
					}
					$(this).blur();
					return false;
				});

				// Disable free media links to force access via right click
				if(this.playlist[i].free) {
					$.each(this.playlist[i], function(property,value) {
						if($.jPlayer.prototype.format[property]) { // Check property is a media format.
							$(self.cssSelector.playlist + "_item_" + i + "_" + property).data("index", i).click(function() {
								var index = $(this).data("index");
								$(self.cssSelector.playlist + "_item_" + index).click();
								$(this).blur();
								return false;
							});
						}
					});
				}
			}
		},
		playlistInit: function(autoplay) {
			if(autoplay) {
				this.playlistChange(this.current);
			} else {
				this.playlistConfig(this.current);
			}
		},
		playlistConfig: function(index) {
			$(this.cssSelector.playlist + "_item_" + this.current).removeClass("jp-playlist-current").parent().removeClass("jp-playlist-current");
			$(this.cssSelector.playlist + "_item_" + index).addClass("jp-playlist-current").parent().addClass("jp-playlist-current");
			this.current = index;
			$(this.cssSelector.jPlayer).jPlayer("setMedia", this.playlist[this.current]);
		},
		playlistChange: function(index) {
			this.playlistConfig(index);
			$(this.cssSelector.jPlayer).jPlayer("play");
		},
		playlistNext: function() {
			var index = (this.current + 1 < this.playlist.length) ? this.current + 1 : 0;
			this.playlistChange(index);
		},
		playlistPrev: function() {
			var index = (this.current - 1 >= 0) ? this.current - 1 : this.playlist.length - 1;
			this.playlistChange(index);
		}
	};

	var audioPlaylist = new Playlist("2", [
		{
			name:"Its a Beautiful Day",
			mp3:"http://www.brunofotos.com/mp3/itsabeautifulday.mp3",
		    oga:"55555http://www.ansonika.com/unique/mp3/swords.ogg"
		},
		{
			name:"Beautiful World",
			mp3:"http://www.brunofotos.com/mp3/BeautifulWorld.mp3",
			oga:"55555http://www.ansonika.com/unique/mp3/melt.ogg"
		},
		{
			name:"End Result",
			mp3:"http://www.brunofotos.com/mp3/endresult.mp3",
			oga:"55555http://www.ansonika.com/unique/mp3/release.ogg"
		},

		{
			name:"Breathe",
			mp3:"http://www.brunofotos.com/mp3/Breathe.mp3",
			oga:"55555http://www.ansonika.com/unique/mp3/el_cid.ogg"
		}

	], {
		ready: function() {
			audioPlaylist.displayPlaylist();
			audioPlaylist.playlistInit(true); // Parameter is a boolean for autoplay.
		},
		ended: function() {
			audioPlaylist.playlistNext(true);
		},
		play: function() {
			$(this).jPlayer("pauseOthers");
		},
		swfPath: "js",
		supplied: "oga, mp3"
	});
});
//]]>

//PLAYLIST ===============================================================================	
$(document).ready(function(){


    $(".slidingDiv").hide();
	$(".show_hide").show();
	
	$('.show_hide').click(function(){
	$(".slidingDiv").slideToggle();
	});

});		
//FANCYBOX BOX VIEWER ===============================================================================	

	
$("a.fancy").fancybox({
				'titleShow'		: true,
				'autoScale'		: true,
				'transitionIn'	: 'elastic',
				'padding': 0, 
					'margin': 70, 
				'transitionOut'	: 'elastic',
				'titlePosition'	: 'over',
				 'overlayOpacity': '0.9',
				  'overlayColor': '#000'
			});
			
$('a.fancy').each(function() {
        $(this).removeAttr('data-rel').attr('rel', 'fancybox');
});			
	$("a.iframe_content").fancybox({
'padding': 0, // optional
'width': 940, //or whatever you like
'height': 500,
'overlayOpacity': '0.9',
'overlayColor': '#000',
'type': 'iframe' ,
'transitionIn'	: 'elastic',
'transitionOut'	: 'elastic',
'scrolling': 'no'
});		
		
	$(".vimeo").click(function() {
		$.fancybox({
			'autoScale'		: false,
			'padding': 0, 
	        'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'titlePosition'	: 'over',
				 'overlayOpacity': '0.9',
				  'overlayColor': '#000',
			'title'			: this.title,
			'width'			: 830,
			'height'		: 470,
			'href'			: this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
			'type'			: 'swf'
		});
		return false;
	});


$(".video_youtube").click(function() {
$.fancybox({
'autoScale'		: false,
'transitionIn'	: 'elastic',
'transitionOut'	: 'elastic',
'titlePosition'	: 'over',
'overlayOpacity': '0.9',
'padding': 0, // optional
'overlayColor': '#000',
'title'         : this.title,
'width'			: 890,
'height'		: 470,
'href'          : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
'type'			: 'swf',
'wmode'             : 'transparent'
		});

		return false;
	});		
//NAVIGATION HORIZONTAL SCROLL ===============================================================================	
$(function() {
                $('ul.nav a').bind('click',function(event){
                    var $anchor = $(this);
                    $('html, body').stop().animate({
                        scrollLeft: $($anchor.attr('href')).offset().left
                    }, 1000);
                    event.preventDefault();
                });
            });
			
// HOVER IMAGE MAGNIFY===============================================================================
$(document).ready(function(){

    //Set opacity on each span to 0%
    $(".magnify").css({'opacity':'0'});

	$('li .image a').hover(
		function() {
			$(this).find('.magnify').stop().fadeTo(500, 1);
		},
		function() {
			$(this).find('.magnify').stop().fadeTo(500, 0);
		}
	)

});	
$(document).ready(function(){

    //Set opacity on each span to 0%
    $(".magnify").css({'opacity':'0'});

	$('li .image_2 a').hover(
		function() {
			$(this).find('.magnify').stop().fadeTo(500, 1);
		},
		function() {
			$(this).find('.magnify').stop().fadeTo(500, 0);
		}
	)

});	
$(document).ready(function(){

    //Set opacity on each span to 0%
    $(".magnify_vimeo").css({'opacity':'0'});

	$('li .image a').hover(
		function() {
			$(this).find('.magnify_vimeo').stop().fadeTo(500, 1);
		},
		function() {
			$(this).find('.magnify_vimeo').stop().fadeTo(500, 0);
		}
	)

});	
$(document).ready(function(){

    //Set opacity on each span to 0%
    $(".magnify_youtube").css({'opacity':'0'});

	$('li .image a').hover(
		function() {
			$(this).find('.magnify_youtube').stop().fadeTo(500, 1);
		},
		function() {
			$(this).find('.magnify_youtube').stop().fadeTo(500, 0);
		}
	)

});			

// HOME GALLERY ===============================================================================
		$(function() {
				$('#sti-menu').iconmenu({
					animMouseenter	: {
						'mText' : {speed : 200, easing : 'easeOutExpo', delay : 0, dir : 1},
						'sText' : {speed : 600, easing : 'easeOutExpo', delay : 400, dir : 1}
					},
					animMouseleave	: {
						'mText' : {speed : 200, easing : 'easeInExpo', delay : 150, dir : 1},
						'sText' : {speed : 200, easing : 'easeInExpo', delay : 0, dir : 1}
					}
				});
			});
// GALLERY PAGINATION===============================================================================
/*
 * 	Easy Paginate 1.0 - jQuery plugin
 *	written by Alen Grakalic	
 *	http://cssglobe.com/
 *
 *	Copyright (c) 2011 Alen Grakalic (http://cssglobe.com)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */

(function($) {
		  
	$.fn.easyPaginate = function(options){

		var defaults = {				
			delay: 200,
			numeric: false,
			nextprev: true,
			auto:false,
			pause:4000,
			clickstop:true,
			controls: 'pagination',
			current: 'current' 
		}; 
		
		var options = $.extend(defaults, options); 
		var step = options.step;
		var lower, upper;
		var children = $(this).children();
		var count = children.length;
		var obj, next, prev;		
		var page = 1;
		var timeout;
		var clicked = false;
		
		function show(){
			clearTimeout(timeout);
			lower = ((page-1) * step);
			upper = lower+step;
			$(children).each(function(i){
				var child = $(this);
				child.hide();
				if(i>=lower && i<upper){ setTimeout(function(){ child.fadeIn('slow') }, ( i-( Math.floor(i/step) * step) )*options.delay ); }
				if(options.nextprev){
					if(upper >= count) { next.fadeOut('slow'); } else { next.fadeIn('slow'); };
					if(lower >= 1) { prev.fadeIn('slow'); } else { prev.fadeOut('slow'); };
				};
			});	
			$('li','#'+ options.controls).removeClass(options.current);
			$('li[data-index="'+page+'"]','#'+ options.controls).addClass(options.current);
			
			if(options.auto){
				if(options.clickstop && clicked){}else{ timeout = setTimeout(auto,options.pause); };
			};
		};
		
		function auto(){
			if(upper <= count){ page++; show(); }			
		};
		
		this.each(function(){ 
			
			obj = this;
			
			if(count>step){
				
				var pages = Math.floor(count/step);
				if((count/step) > pages) pages++;
				
				var ol = $('<ol id="'+ options.controls +'"></ol>').insertAfter(obj);
				
				if(options.nextprev){
					prev = $('<li class="prev">Previous</li>')
						.hide()
						.appendTo(ol)
						.click(function(){
							clicked = true;
							page--;
							show();
						});
				};
				
				if(options.numeric){
					for(var i=1;i<=pages;i++){
					$('<li data-index="'+ i +'">'+ i +'</li>')
						.appendTo(ol)
						.click(function(){	
							clicked = true;
							page = $(this).attr('data-index');
							show();
						});					
					};				
				};
				
				if(options.nextprev){
					next = $('<li class="next">Next</li>')
						.hide()
						.appendTo(ol)
						.click(function(){
							clicked = true;			
							page++;
							show();
						});
				};
			
				show();
			};
		});	
		
	};	

})(jQuery);

// GALLERY add or remove items group ===============================================================================
jQuery(function($){
	
	$('ul#items').easyPaginate({
		step:12
	});
	
	$('ul#items_2').easyPaginate({
		step:12
	});
	
	$('ul#items_3').easyPaginate({
		step:12
	});
	
	$('ul#items_4').easyPaginate({
		step:12
	});
	
});    




	

