// remap jQuery to $
(function($){
 
	sfHover = function() {
	var sfEls = document.getElementById("dropdown").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
	if (window.attachEvent) window.attachEvent("onload", sfHover);
	 	

	function setup(){
		// OPACITY OF BUTTON SET TO 50%
		$(".transparentbg, .expand").css("opacity",".125");
		
		// ON MOUSE OVER
		$("header, .expand, .collapse").hover(function () {
		
			// SET OPACITY TO 100%
			$(".transparentbg, .expand, .collapse").stop().animate({
			opacity: .75
			}, "fast");
		},
		
		// ON MOUSE OUT
		function () {
			
				// SET OPACITY BACK TO 50%
				$(".transparentbg, .expand, .collapse").stop().animate({opacity: .125}, "fast");
			
		});
		
		$(function()
		{
		    var collapse = $('.collapse');
		    $('.expand').each(
				function(i)
				{
					var a = $(this).bind(
						'click',
						function()
						{
							if ($(this).hasClass('open')){
								$(this).removeClass('open');
								
								collapse.hide();
							} else {
								$(this).addClass('open');
								collapse.show();
		
								collapse.jScrollPane({
									showArrows: $(this).is('.arrow')
								});   
		
								var api = collapse.data('jsp');
						    	var throttleTimeout;
						    	$(window).bind('resize',function(){
									if ($.browser.msie) {
										// IE fires multiple resize events while you are dragging the browser window which
										// causes it to crash if you try to update the scrollpane on every one. So we need
										// to throttle it to fire a maximum of once every 50 milliseconds...
										if (!throttleTimeout) {
											throttleTimeout = setTimeout(
											function(){
												api.reinitialise();
												throttleTimeout = null;
												},
												50
						    					);}
						    		} else {api.reinitialise();}
						    	});
							
							}
							return false;
						}
					);
				}
			);
		});
		
/*
		Galleria.loadTheme('assets/images/fullscreen-theme/galleria.fullscreen.js');
	    
		$('#galleria').galleria({
		    preload: 3,
		    image_crop: true, // donêt crop images
		    transition: 'none', // sliding transition
		    show_info: false, // donêt show captions
		    thumbnails: false, // hide the thumbnails
		    image_pan: false  // allow mouse to pan the image
		});
*/
		
/* 		$('#galleria').fadeIn('fast') */
	}

	
	if ($.browser.msie) {
		if ($.browser.version.substr(0,1)>6) {
			setup();
		} 
	} else {
		setup();	
	}
	
})(window.jQuery);


























