jQuery.noConflict();
(function($) {

	/*
	$('.gallery').cycle({ 
	    fx:     'scrollHorz', 
	    prev:   '#prev1', 
	    next:   '#next1',
	    next:	'.gallery',
	    speed:   300,
	    timeout: 3000, 
	    pause:   1,
	    containerResize: 1	    
	});
	*/
	
	
	$('.gallery').cycle({
		fx: 'scrollHorz',
   	    prev:   '#prev1', 
	    next:   '#next1',    
		containerResize: 1,
		timeout: 5000,
		pause:   1
	});
	
	
	$('span.view-large').hide();
	$('span.black').hide();
	myOp = 1;
	
	//$('#topbar').css backgroundColor = '#ccc';
	
	//	230 * 5 + 40
		
	//this.cols = Math.floor( ( containerWidth + this.options.gutterWidth ) / this.columnWidth );
    //this.cols = Math.max( this.cols, 1 );
		
	//var barcount = Math.floor(($(window).width() - 40) / 230);
	//var cols = Math.floor( ( ( $('#sort').width()) + 10) / 240 ); // 10 = hack, scrollbar?
	var cols = Math.floor( ( ( $(window).width()) - 40 + 10) / 240 ); // 40 = padding-left,  10 = hack, scrollbar?

	cols = Math.max( cols, 1 );

	var barwidth = cols * 230 + 10 * (cols-1);
	
	$('#topbar').css('width', barwidth);
	//$('#topbar').css('width', 230 * 4 + 30);

	$('#header').css('width', barwidth);
	
	$('#pagetxt').css('width', barwidth);

	
	$(window).resize(function() {
	

		//barcount = Math.floor(($(window).width() - 50) / 230)
		//cols = Math.floor( ( $('#sort').width()) / 240 );
		cols = Math.floor( ( ( $(window).width()) - 40 ) / 240 );
		barwidth = cols * 230 + 10 * (cols-1);
		$('#topbar').css('width', barwidth);
		
		//$('#topbar').animate({
		//	width: barwidth;
		//  }
		
		/*
		$('#sort').masonry({ 
			animate: false,
			columnWidth: 240,
			itemSelector: '.box'
		});
		*/
		
		$('#header').css('width', barwidth);
		
		$('#pagetxt').css('width', barwidth);
		

	});
	
	

	
	
	$(window).load(function(){
		
		$('#sort').masonry({
			itemSelector: '.box',
			columnWidth: 240
			
		},
		


		
		 
		function() { $(this).css({
			margin: '10px'
			});
		});
	});
	
	
	// MouseOver Events
		$('.box').hover(function() {
			$('img', this).fadeTo("fast", 0.666).addClass('box-hover')
			//$('span.black', this).fadeTo("fast", 1)
		},
	function(){
			$('img', this).fadeTo("fast", myOp).removeClass('box-hover')
			//$('span.view-large', this).fadeTo("fast", 0)
			//$('span.black', this).fadeTo("fast", 0)
	});
	
	
	// Colorbox
	$("a[rel='gallery']").colorbox({
		maxWidth: '85%',
		maxHeight: '85%'
	});
	
})(jQuery);
