
// -- CUSTOM FUNCTIONS AND EFFECTS --

// -- NO CONFLICT MODE

var $s = jQuery.noConflict();

$s(document).ready(function(){

	// -- HIDE IMAGES BEFORE LOADING

	$s(".port2_img, .port4_img, .port_ls_img, .cycle_slider li, #nivo_slider li").addClass('preload').find('img').hide();


	// -- NAVIGATION MENU

	$s('.nav1 ul').css({display: "none"});
	$s('.nav1 li').hover(function(){
		$s(this).find('ul:first').css({visibility: "visible",display: "none"}).fadeIn(200);
	},
	function(){
		$s(this).find('ul:first').css({visibility: "visible",display: "none"});
	});


	// -- ACCORDION

	$s('h5.handle').click(function() {
		$s(this).next().toggle('fast');
		$s(this).toggleClass("activehandle");
		return false;
	}).next().hide();


	// -- TOGGLE

	$s('h5.toggle').click(function() {
		$s(this).next().toggle('fast');
		$s(this).toggleClass("activetoggle");
		return false;
	}).next().hide();


	// -- PRETTYPHOTO INIT

	$s("a[rel^='prettyPhoto[group1]'], a[rel^='prettyPhoto[group2]']").prettyPhoto({
		animation_speed: 'fast',
		slideshow: 5000,
		autoplay_slideshow: false,
		opacity: 0.80,
		show_title: false,
		theme: 'pp_default', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
		overlay_gallery: false,
		social_tools: false
	});


	// -- TOP OF PAGE

	$s('.top').click(function(){
		$s('html, body').animate({scrollTop:0}, 500 );
		return false;
	});


}) // END DOCUMENT.READY

$s(window).load( function() {

	// -- SHOW IMAGES ON LOAD

	$s(".port2_img, .port4_img, .port_ls_img, .cycle_slider li, #nivo_slider li").removeClass('preload').find('img').fadeIn();

	// -- CYCLE SLIDER INIT

	$s('.cycle_slider').cycle({
		fx:     'fade',
		speed:  400,
		timeout: 4000,
		next: '.next',
		prev: '.prev',
		pause: 1,
		cleartype: true,
		pager:  '.cycle_nav',
		pagerAnchorBuilder: function(idx, slide) {
			return '<li><a href="#"></a></li>';
		}
	});


	// -- SHOW/HIDE SLIDER CONTROLS

	$s('.show_desc').fadeIn();
	$s('.slider').hover(function(){
		$s('.controls').show();
	}, function() {
		$s('.controls').hide();
	});

	$s('.controls a.prev').hover(function(){
		$s('.controls a.next').fadeOut(300);
	}, function() {
		$s('.controls a.next').fadeIn(300);
	});

	$s('.controls a.next').hover(function(){
		$s('.controls a.prev').fadeOut(300);
	}, function() {
		$s('.controls a.prev').fadeIn(300);
	});
})
