	var $j = jQuery.noConflict();

	jQuery.noConflict();
	
	jQuery(document).ready(function($) {
		
		// vars
		var container_height = $('#page').height();
		var page_height = $('#page').height()
		var window_height = $(window).height();
		
		// classes		
		$('ul li:first-child').addClass('first-child');
		$('ul li:last-child').addClass('last-child');
		$('#main h1:first-child, #main h2:first-child, #main h3:first-child, #main h4:first-child, #main h5:first-child, #main h6:first-child').addClass('first-child');
		$('#main p:last-child').addClass('last-child');
		$('#main p:first-child').addClass('first-child');
		
		// setlocation
		$('.setLocation').click(function(e) {
			var url = $(this).attr("title");
			if(url.length > 0) {
				window.location.href = url; 
			}
			else {
				console.log('ERROR: Some element with .setLocation class has undefined title="" attribute!')
			}
		});
		
		$('.sf-menu > li > a').click(function(e) {
			if($(this).hasClass('sf-with-ul')) {
				$(this).parent().addClass('sfHover');
			}
			else {
				$(this).parent().removeClass('sfHover');
			}
		});
		
		// menu (drop-down)
		$('.sf-menu').superfish({ 
			delay: 0, // one second delay on mouseout 
			speed: 'fast' // faster animation speed 
		});
		$('.sf-menu > li').addClass('parent-li');
		$('.sf-menu > li > a').addClass('parent-a');
		// menu (drop-up)
		var menu1 = $('body#home #nav_main ul li');		
		menu1.hover(
			function() {
				var menu2 = $(this).children('ul');
				menu2.css({'top' : '-' + menu2.height() + 'px'});
			},
			function() {}
		);
		var list1 = $('body#home .sf-menu li li');
		list1.hover(
			function() {
				var list2_ul = $(this).children('ul');
				var list2_li = list1.height();
				var list2_li_count = list2_ul.children('li').length;
				list2_ul.css({'top' : '-' + ((list2_li*list2_li_count)-(1*list2_li)) + 'px'});
			},
			function() {}
		);
		$('.sf-menu li.first-child.last-child').removeClass('first-child').removeClass('last-child').addClass('single');
		
		// gallery
		var thumb = $('#gallery-thumbs ul li img');
		$.each(thumb, function(id, data) {
			$(this).hover(function(e) {
				var image = $(this).attr('src');
				var current_image = thumb[id];
				$('#gallery-image img').attr('src', image);
				thumb.removeClass('active')
				$(current_image).addClass('active')
				return false;
			});
		});
		
		// scroll pane
		jspSettings =  { 
			scrollbarWidth: 11,
			showArrows: true
		}; 
		
		var reinitialiseScrollPane = function() {
			$('div#c63').jScrollPane(jspSettings);
			$('div#c65').jScrollPane(jspSettings);
			$('div#c68').jScrollPane(jspSettings);
			$('div#c70').jScrollPane(jspSettings);
			$('div#c88').jScrollPane(jspSettings);
			$('div#c93').jScrollPane(jspSettings);
			$('div#c94').jScrollPane(jspSettings);
			$('div#c178').jScrollPane(jspSettings);
			$('div#c180').jScrollPane(jspSettings);
		}
		if($('div#c63').length) {
			$('div#c63').jScrollPane(jspSettings);
		}
		if($('div#c65').length) {
			$('div#c65').jScrollPane(jspSettings);
		}
		if($('div#c68').length) {
			$('div#c68').jScrollPane(jspSettings);
		}
		if($('div#c70').length) {
			$('div#c70').jScrollPane(jspSettings);
		}
		if($('div#c88').length) {
			$('div#c88').jScrollPane(jspSettings);
		}
		if($('div#c93').length) {
			$('div#c93').jScrollPane(jspSettings);
		}
		if($('div#c94').length) {
			$('div#c94').jScrollPane(jspSettings);
		}
		if($('div#c178').length) {
			$('div#c178').jScrollPane(jspSettings);
		}
		if($('div#c180').length) {
			$('div#c180').jScrollPane(jspSettings);
		}
		
		// news toggler
		$('#c103 .internal-link').click(function(e) {
			$('#c103').fadeOut();
			$('#c104').fadeIn();
			$('div#c104').jScrollPane(jspSettings);
			return false;
		});
		$('#news div.post:last-child').addClass('last-child');
		
		// video modal window
		$('.view-360').fancybox( {
			'margin': 0,
			'padding': 101,
			'titleShow': false,
			'autoScale': false,
			'transitionIn': 'none',
			'transitionOut': 'none',
			'type': 'swf'
		});

		
	});
