/* Author:  Joel A

*/

 
			
			jQuery(function($){
				
				$('.circle').mosaic({
					opacity		:	0.8			//Opacity for overlay (0-1)
				});
				
				$('.fade').mosaic();
				
				$('.bar').mosaic({
					animation	:	'slide'		//fade or slide
				});
				
				$('.bar2').mosaic({
					animation	:	'slide'		//fade or slide
				});
				
				$('.bar3').mosaic({
					animation	:	'slide',	//fade or slide
					anchor_y	:	'top'		//Vertical anchor position
				});
				
				$('.cover').mosaic({
					animation	:	'slide',	//fade or slide
					hover_x		:	'400px'		//Horizontal position on hover
				});
				
				$('.cover2').mosaic({
					animation	:	'slide',	//fade or slide
					anchor_y	:	'top',		//Vertical anchor position
					hover_y		:	'80px'		//Vertical position on hover
				});
				
				$('.cover3').mosaic({
					animation	:	'slide',	//fade or slide
					hover_x		:	'400px',	//Horizontal position on hover
					hover_y		:	'300px'		//Vertical position on hover
				});
		    
		    });

	    
$(document).ready(function() {

	// load all links in a new window
	$('p a').each(function(){
		$(this).attr('target','_blank');
	});

	// the currently loaded section
	var curLoaded = 'about';

	// start by showing the about us section
	$('#contentContainer').animate({
		height: 30
	},"slow", function(){
		// fade in the content
		$('#' + curLoaded).fadeIn();
	});

	// navigation trigger
	$('#navbar a').each(function() {
		var $this = $(this)
		var target = $this.attr('href').split('#')[1];
		var $contentContainer = $('#contentContainer');
		var oldPos = 30;
		var newPos = 500;

		// add a click handler to each A tag
		$this.click(function(){
			// if the container isn't open, then open it...duh!
			if ($contentContainer.css('height') == '30px') {
				// trigger the animation
				$contentContainer.animate({
					height: newPos
				},"slow", function(){
					// fade in the content
					$('#' + target).fadeIn();
				});
			} else {
				if (curLoaded == target) {
					$contentContainer.animate({
						height: oldPos
					},"slow", function(){
						$('#content div').hide();
					});
				} else {
					$contentContainer.animate({
						height: oldPos
					},"slow", function(){
						$('#content div').hide();
						$contentContainer.animate({
							height: newPos
						},"slow", function(){
							$('#' + target).fadeIn();
						});
					});
				}
			}

			curLoaded = target;

			return false;
		});

	});

	// remove the focus lines
	$('a').focus( function() { $(this).blur(); } );

});


window.onscroll = function()
{
    if( window.XMLHttpRequest ) {
        if (document.documentElement.scrollTop > 147 || self.pageYOffset > 147) {
            $('#bar-nav-lampkategori').css('position','fixed');
            $('#bar-nav-lampkategori').css('top','0');
        } else if (document.documentElement.scrollTop < 147 || self.pageYOffset < 147) {
            $('#bar-nav-lampkategori').css('position','absolute');
            $('#bar-nav-lampkategori').css('top','147px');
        }
    }
}



// Smooth Scroll to Top
	$(document).ready(function() {
	    $('a[href*=#]').click(function() {
	    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
	        && location.hostname == this.hostname) {
	            var $target = $(this.hash);
	            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
	            if ($target.length) {
	                var targetOffset = $target.offset().top;
	                $('html,body').animate({scrollTop: targetOffset}, 700);
	                return false;
	            }
	        }
	    });
	});
		    


