// JavaScript Document


/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 10;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("dt.gallery-icon a").hover(function(e){
		
		//alert('gallery hover');
		
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' /></p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("dt.gallery-icon a").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

$(document).ready(function(){
	
	//turn on imagePreview
	imagePreview();
	
		
	// buety tips nav page name on hover			
	$('div.nav-dots ul li a,a.port-nav').bt({
		  hoverIntentOpts: {
			interval: 0,
			timeout: 0
		  },
		  contentSelector: "$(this).html()", /*get text of inner content of hidden div*/
		  killTitle: false,
		  strokeWidth: 0,
		  fill:'#7fb237',
		  spikeLength: 10,
		  spikeGirth: 20,
		  cornerRadius: 0,
		  cssStyles: {
			  color: 'white', fontWeight: 'bold', width: 'auto', padding: '5px 10px'
		  },
		  positions: ['bottom'],
			  windowMargin: 20
		});
		
		//full page background fade in
		$("#full-bg img").fadeIn(1000);
		
		//thumb fade in on team page		
		$("#our-team ul li img").each(function(i) {
			$(this).stop().delay(200).fadeIn();
		});
		
		//port page load
		
		//$("#port div.item img").hide();	
		//$("#port div.item img").each(function(i) {
		//	$(this).stop().delay(i * 100).fadeIn();
		//});
		
		$('#port-tag-switch').click(function() {
			$("#port-tag-box").slideDown('normal');
			$("#port-cat-box").slideUp('normal');
			$("#port-client-box").slideUp('normal');
		});
		
		$('#port-cat-switch').click(function() {
			$("#port-tag-box").slideUp('normal');
			$("#port-cat-box").slideDown('normal');
			$("#port-client-box").slideUp('normal');
		});
		
		$('#port-client-switch').click(function() {
			$("#port-tag-box").slideUp('normal');
			$("#port-cat-box").slideUp('normal');
			$("#port-client-box").slideDown('normal');
		});
			
		$('div.close-list a').click(function() {
			$('div.port-filter-list').slideUp('normal');
		});
		
		
		$('div.item').hover(function() {
        	$(this).children('img').stop(true, true).animate({
				top: '-160px'
				}, 500, 'easeOutBounce');
    	}, function() {
	    	$(this).children('img').stop(true, true).animate({ 
				top: '0' 
				}, 500, 'easeOutBounce');
		});
			
		//cycle for our services
		 $('#our-services-content').cycle({ 
			fx:			'turnDown', 
			speed: 		250,
			timeout: 	0,
			pager:      '#our-services-nav ul',
			pagerEvent: 'mouseover' ,
			inDelay:	250, 
			easing: 	'swing', 	
			pause:      true,
			
			pagerAnchorBuilder: function(idx, slide) {
				return '#our-services-nav ul li:eq(' + (idx) + ') a';
			}
	    });
		
		//cycle for big 8
		 $('#big-8').cycle({ 
			fx:			'turnDown', 
			speed: 		250,
			timeout: 	0,
			next:      'div.next a',
			inDelay:	250, 
			easing: 	'swing', 	
			pause:      true,
		});	
		
		//subnav hide content for ajax functions
		//$('div.nav-dots ul li a, #panel_arrow_left, #panel_arrow_right').click(function () {
 			//$('.content').animate({height: 0, opacity: 0}, function() {
			//	$('.content').fadeOut();
				//$('#slider_container').fadeIn();
			//});
  		//});
				
		//cycle for our space
		 $('#our-space .slide').cycle({ 
			fx:			'fade', 
			speed: 		250,
			timeout: 	7000,
			next:      '#next-photo a',
			inDelay:	250, 
			easing: 	'swing', 	
			pause:      true,
		});		
		
		//button hover
		$('div.port-close span').stop().animate({"opacity": "0"}, "slow");
		
		$("div.port-close").hover(
			function() {
			$('div.port-close span').stop().animate({"opacity": "1"}, "slow");
			},
			function() {
			$('div.port-close span').stop().animate({"opacity": "0"}, "slow");
		});
		
		//back to top
		$('a[href=#top]').click(function(){
			//alert('clicked');
	        $('html, body').animate({scrollTop:0}, 'slow');
	        return false;
		});
		
});		
