jQuery(document).ready(function()	{
								
//jQuery("#gallery").easySlider({

//});

jQuery("#gallery-content").easySlider({

});

//jQuery('#gallery-content').css('display', 'inline-block');
//jQuery('#gallery-content').css('filter', 'alpha(opacity=100)');


function imgCycle(){
	alert('cycle');
jQuery('.main-img-ul').cycle({
    fx:     'scrollHorz', 
//	speed:  'slow', 	";
    timeout: 5000, 
    pause:   1,
    pager:  '#thumb-img-ul',
        pagerAnchorBuilder: function(idx, slide) { 
        return '#thumb-img-ul li:eq(' + idx + ') a'; 
    } 
	});
}




jQuery('#page-inner #img-gallery').live('mouseenter mouseleave', function(event) {
  if (event.type == 'mouseenter') {
    			jQuery("#thumb-img").slideDown("fast");
  } else {
   				jQuery("#thumb-img").slideUp("fast");
  }
});

								
	jQuery("#gallery li a").mouseover(function()
			  { 
				jQuery(".excerpt",this).slideDown("fast");
	 });


	var navTimers = [];
	jQuery( "a.teaser-img" ).hover(
		function () {
			var id = jQuery.data( this );
			var jQuerythis = jQuery( this );
			navTimers[id] = setTimeout( function() {
				jQuerythis.fadeTo( 300,1 );
				navTimers[id] = "";
			}, 300 );
		},
		function () {
			var id = jQuery.data( this );
			if ( navTimers[id] != "" ) {
				clearTimeout( navTimers[id] );
			} else {
				jQuery( this ).fadeTo( 200, .4 );
				//alert('off');
			}
		}
	);
	

var navTimers2 = [];

jQuery('a.relatedimage').live('mouseenter mouseleave', function(event) {
  if (event.type == 'mouseenter') {
    			jQuery(this).fadeTo("slow", 1);
				jQuery(".excerpt",this).slideDown("fast");
  } else {
   				jQuery(".excerpt",this).slideUp("fast");
				jQuery(this).fadeTo("slow", 0.4);
  }
});

jQuery('.img-bg a').live('mouseenter mouseleave', function(event) {
  if (event.type == 'mouseenter') {
    			jQuery(this).fadeTo("slow", 1);
				jQuery(".excerpt",this).slideDown("fast");
  } else {
   				jQuery(".excerpt",this).slideUp("fast");
				jQuery(this).fadeTo("slow", 0.4);
  }
});
	

jQuery("#gallery li a").mouseleave(function()
	 { 
				jQuery(".excerpt",this).slideUp("fast");
	 });

jQuery('#img-gallery a').click(function()
										{
	return false;
	});
	
jQuery('#tabs li a').mouseenter(function()
			  { 
				jQuery('.on',this).fadeIn('fast');
	
	 });

//jQuery('#social li a').css('filter', 'alpha(opacity=40)');


jQuery('#social li a').live('mouseenter mouseleave', function(event) {
  if (event.type == 'mouseenter') {
    			jQuery(this).fadeTo("slow", 1);
				//jQuery(".excerpt",this).slideDown("fast");
  } else {
   				//jQuery(".excerpt",this).slideUp("fast");
				jQuery(this).fadeTo("slow", 0.4);
  }
});
	
	
	
	
	jQuery('.viewmore').click(function()
			  { 
				jQuery.scrollTo("#more",1000);
			return false;
	
	 });	

	jQuery('#logo2 a').mouseenter(function()
			  { 
				jQuery('.on',this).fadeIn('fast');
	
	 });
	jQuery('#logo2 a').mouseleave(function()
			  { 
				jQuery('.on',this).fadeOut('slow');
	
	 });	
	
	jQuery('#tabs li a').mouseleave(function()
			  { 
				jQuery('.on',this).fadeOut('slow');
				
	
	 });	

jQuery('.hiding').click(function()
			  { 
				jQuery('.hidden',this).slideToggle('slow');
				return false;
	
	 });	
	
	var selected = '#web a'; 
	
	jQuery('#gallery-tabs li#identity a').live('click', function(event){	
				jQuery('#fancybox-loading').customFadeIn();
			
			if(selected ="#case-studies a"){
					jQuery("#prevBtn").customFadeIn();
					jQuery("#nextBtn").customFadeIn();			
			}
				jQuery("#gallery-tabs li#identity a").removeClass("unselected");
					jQuery("#gallery-tabs li#identity a").addClass("selected");
					jQuery(selected).removeClass("selected");
					jQuery(selected).addClass("unselected");
					jQuery("#portfolio").fadeTo("slow",0,function(){

					jQuery("#gallery-content").load("/flooid-portfolio-and-work/identity/?where=identity", function(){	
						jQuery("#portfolio").fadeTo("slow",1,function(){
											 																 
						selected ="#identity a";
				 		});
				//jQuery('#flooid_loading').fadeOut();
				jQuery('#fancybox-loading').customFadeOut();

			});

			})
			
		//event.stopPropagation();
	
		//jQuery(this).click();
		
	return false;
	});	


	jQuery('#gallery-tabs li#web a').live('click', function(event){	
					jQuery('#prevBtn').customFadeIn();
					jQuery('#nextBtn').customFadeIn();
					jQuery('#fancybox-loading').customFadeIn();
			
			jQuery("#gallery-tabs li#web a").removeClass("unselected");
			jQuery("#gallery-tabs li#web a").addClass("selected");
			jQuery(selected).removeClass("selected");
			jQuery(selected).addClass("unselected");	
			jQuery("#portfolio").fadeTo("slow",0,function(){
				jQuery('#gallery-content').load('/flooid-portfolio-and-work/identity/?where=portfolio', function(){	
	
																 
				jQuery("#portfolio").fadeTo("slow",1,function(){
							//jQuery("#gallery-content").easySlider({
				//alert('faded');
			//});												 
																 // });
				selected ='#web a';
				jQuery('#fancybox-loading').customFadeOut();
				//jQuery('#flooid_loading').fadeOut();
				});	
	
				});

			})
			
		//event.stopPropagation();
	
		//jQuery(this).click();
		
	return false;
	});	

jQuery('#gallery-tabs li#case-studies a').live('click', function(event){	
		//alert('clicked');
			//jQuery('#flooid_loading').fadeIn();
				jQuery('#fancybox-loading').customFadeIn();
						//jQuery("#fancybox-loading div").css({backgroundPosition: '0px 0px'});
						//jQuery("#fancybox-loading div").stop().animate(
			//{backgroundPosition:"(0 -250px)"}, 
			//{duration:500});

			
					jQuery("#prevBtn").customFadeOut();
					jQuery("#nextBtn").customFadeOut();			
					jQuery("#gallery-tabs li#case-studies a").removeClass("unselected");
					jQuery("#gallery-tabs li#case-studies a").addClass("selected");
					jQuery(selected).removeClass("selected");
					jQuery(selected).addClass("unselected");
					jQuery("#portfolio").fadeTo("slow",0,function(){

					//jQuery("#gallery-content").load("/test.html", function(){
					jQuery("#gallery-content").load("/flooid-portfolio-and-work/identity/?where=case-studies", function(){	
						jQuery("#portfolio").fadeTo("slow",1,function(){
											 																 
						selected ="#case-studies a";
				 	jQuery('#fancybox-loading').customFadeOut();
					});
				//jQuery('#flooid_loading').fadeOut();
					

			});

			})
			
		//event.stopPropagation();
	
		//jQuery(this).click();
		
	return false;
	});	
	

	 jQuery('a.fb_dynamic').each(function(){
           var dWidth 	= parseInt($(this).attr('href').match(/width=[0-9]+/i)[0].replace('width=',''));
           var dHeight 	=  parseInt($(this).attr('href').match(/height=[0-9]+/i)[0].replace('height=',''));
			jQuery(this).fancybox({
				'width':dWidth,
				'height':dHeight,
				'autoScale'     	: false,
				'transitionIn'		: 'fade',
				'swf'			: {
					'wmode'		: 'transparent'
				//'allowfullscreen'	: 'true'
			},
				'transitionOut'		: 'fade',
			'overlayOpacity': 0.9, 
			'overlayColor': '#000',					
				'type'			: 'iframe'
			});
      });



		
	jQuery("a.fancyboxed").live('click', function(event){	
		//alert('clicked');
		jQuery(this).fancybox({ 
			'autoScale'		: false,
			'autoDimensions': false,
			'width' : 740,
			'height' : 480,
			'overlayShow':	true,	
			'overlayOpacity': 0.9, 
			'overlayColor': '#000',				  			  				  
			'titleShow' : false,
			'centerOnScroll': false,
			'scrolling':false,
			'hideOnContentClick': false
					
			});
		event.stopPropagation();
		

		jQuery(this).click();
		//imgcycle();
	return false;
	});
	

	
jQuery(".modal-prev").live('click', function(event){	
		//alert('prev clicked');
		jQuery(this).fancybox({ 
			'autoScale'		: false,
			'autoDimensions': false,
			'width' : 740,
			'height' : 480,
			'overlayShow':	true,	
			'overlayOpacity': 0.9, 
			'overlayColor': '#000',				  			  				  
			'titleShow' : false,
			'centerOnScroll': false,
			'scrolling':false,
			'hideOnContentClick': false
			});
		
		jQuery(this).click();
	event.stopPropagation();
	return false;
	});	

jQuery(".modal-next").live('click', function(event){	
		//alert('prev clicked');
		jQuery(this).fancybox({ 
			'autoScale'		: false,
			'autoDimensions': false,
			'width' : 740,
			'height' : 480,
			'overlayShow':	true,	
			'overlayOpacity': 0.9, 
			'overlayColor': '#000',				  			  				  
			'titleShow' : false,
			'scrolling':false,
			'centerOnScroll': false,
			'hideOnContentClick': false
			});
		//event.stopPropagation();
		jQuery(this).click();
		event.stopPropagation();
	return false;
	});	
function formatTitle(title, currentArray, currentIndex, currentOpts) {
    return '<div id="tip7-title"><span><a href="javascript:;" onclick="jQuery.fancybox.close();"><img src="/data/closelabel.gif" /></a></span>' + (title && title.length ? '<b>' + title + '</b>' : '' ) + 'Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</div>';
}

jQuery("a.fancyboxy").fancybox({ 				  
			'autoScale'		: false,
			'autoDimensions': false,
			'overlayShow':	true,	
			'overlayOpacity': 0.5, 
			'overlayColor': '#000',				  			  				  
			'titleShow' : true,
			'titlePosition':'over',
//			'titleFormat'		: formatTitle,
			'centerOnScroll': false,
			'hideOnContentClick': false
			
	});
	jQuery(".swf").fancybox({ 
							'autoScale'		: false,
							'autoDimensions': true,
			'overlayOpacity': 0.9, 
			'overlayColor': '#000',	
			'showTitle' : true,
			'overlayShow':	true,
			//'width'		: 680,
			//'height'		: 900,
			'centerOnScroll': false,
			//'titlePosition' 		: 'inside',
			//'titleFormat'		: formatTitle,
			'hideOnContentClick': false,
			//'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent'
				//'allowfullscreen'	: 'true'
			}


			
	});
	
		jQuery(".swf-justice").fancybox({ 
							'autoScale'		: false,
							'autoDimensions': true,
			'overlayOpacity': 0.9, 
			'overlayColor': '#000',	
			'showTitle' : true,
			'overlayShow':	true,
			'width'		: 680,
			'height'		: 880,
			'centerOnScroll': false,
			//'titlePosition' 		: 'inside',
			//'titleFormat'		: formatTitle,
			'hideOnContentClick': false,
			//'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent'
				//'allowfullscreen'	: 'true'
			}


			
	});

});


	function loadHomeContent(){
		jQuery('#home-gallery-content').load('/home-gallery/', function(){	
	
																 
				jQuery('#home-gallery-content').customFadeIn('slow',function(){
					homeGallery();	
				});	
	
				});
	}	
		

	function onAfter(curr, next, opts) {
		var index = opts.currSlide;
		jQuery('#prevHome')[index == 0 ? 'hide' : 'show']();
		jQuery('#nextHome')[index == opts.slideCount - 1 ? 'hide' : 'show']();
}

	function homeGallery(){
		jQuery('#home-gallery-content').cycle({
		fx:     'scrollHorz', 
		timeout: 5000, 
		pause:   1,
		after:   onAfter,
		prev:  '#prevHome',
		next:  '#nextHome'
	});
	}

function showPic (whichpic) {
 if (document.getElementById) {

  document.getElementById('modal-img')
  .src = whichpic.href;
  document.getElementById('modal-img-href')
  .href = whichpic.name;

  return false;
 } else {
  return true;
 }
}

(function(jQuery) {
    jQuery.fn.customFadeIn = function(speed, callback) {
        jQuery(this).fadeIn(speed, function() {
                if(jQuery.browser.msie)
                        jQuery(this).get(0).style.removeAttribute('filter');
                if(callback != undefined)
                        callback();
        });
    };
    jQuery.fn.customFadeOut = function(speed, callback) {
        jQuery(this).fadeOut(speed, function() {
                if(jQuery.browser.msie)
                        jQuery(this).get(0).style.removeAttribute('filter');
                if(callback != undefined)
                        callback();
        });
    };
})(jQuery);



function displayImages(data) {
	var htmlString = "";
    jQuery.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?id=35528673@N07&lang=en-us&format=json&jsoncallback=?",
        function(data){
          jQuery.each(data.items, function(i,item){
		   var sourceSquare = (item.media.m).replace("_m.jpg",  "_s.jpg");
           var sourceURL = (item.media.m).replace("_m.jpg",  ".jpg");
		   // jQuery("<img/>").attr("src", sourceSquare).appendTo("#images");
        htmlString += '<li><a rel="gallery" class="fancyboxy" href="' + sourceURL + '" target="_blank">';
        htmlString += '<img title="' + item.title + '" src="' + sourceSquare;
        htmlString += '" alt="'; 
		htmlString += item.title + '" />';
        htmlString += '</a></li>';
			if ( i == 11 ) return false;
          });
jQuery('#images').html(htmlString);
});


   
}
