// JavaScript Document general scripts for every page

$(document).ready(function(){
		
	//search field empty on click
	var defaultVal = $('input#searchbar').val();
	$('input#searchbar').focus(function(){
		if($(this).val() == defaultVal){
        	$(this).val("");
			
        }
	})
	$('input#searchbar').blur(function(){
		if($(this).val() == ""){
        	$(this).val(defaultVal);
        }		
	});
	
	//newsletter field empty on click
	var defaultVal2 = $('input#newsletter').val();
	$('input#newsletter').focus(function(){
		if($(this).val() == defaultVal2){
        	$(this).val("");
			$(this).removeClass("lbltxt");
        }
	})
	$('input#newsletter').blur(function(){
		if($(this).val() == ""){
        	$(this).val(defaultVal2);
			$(this).addClass("lbltxt");
        }		
	});
	
	// toggle menu
	$('#nav-global ul li').hover(function(){
		if($(this).children('ul').length > 0){
			$(this).children('ul').toggle();
		}
	});
	
	//make spans in mainnav unselectable as it gives problems with dropdowns
	(function ($) {
	$.fn.disableSelection = function () {
		return this.each(function () {
			if (typeof this.onselectstart != 'undefined') {
				this.onselectstart = function() { return false; };
			} else if (typeof this.style.MozUserSelect != 'undefined') {
				this.style.MozUserSelect = 'none';
			} else {
				this.onmousedown = function() { return false; };
			}
		});
	};
	})(jQuery);
	$('#nav-global ul li span').disableSelection();
	
	/* stafflist - 4th and 5th item need a class */
	if($('.staff-item').length > 0){
		$('.staff-item li:nth-child(4n)').addClass('last').next().addClass('first');
	}
	
	/* albumlist - 3th and 4th item need a class */
	if($('.album-item').length > 0){
		$('.album-item li:nth-child(3n)').addClass('last').next().addClass('first');
	}
	
	/* quicklinks list - 3th and 4th item need a class */
	if($('#quicklinks ul').length > 0){
		$('#quicklinks ul li:nth-child(3n)').addClass('last').next().addClass('first');
	}
	
	/* twocols homepage - last and first item need a class */
	if($('.twocols').length > 0){
		$('.twocols').children('div:even').addClass('first');
		$('.twocols').children('div:odd').addClass('last');
	}
	
	/* nivo slider initialize */
	if($('#slider').length > 0){
		$('#slider').nivoSlider({
			effect:'fade', // Specify sets like: random,fold,fade,sliceDown,slideInRight,slideInLeft		
			slices:15, // For slice animations
			boxCols: 8, // For box animations
			boxRows: 4, // For box animations
			animSpeed:800, // Slide transition speed
			pauseTime:6000, // How long each slide will show
			startSlide:0, // Set starting Slide (0 index)
			directionNav:true, // Next & Prev navigation
			directionNavHide:true, // Only show on hover
			controlNav:true, // 1,2,3... navigation
			keyboardNav:true, // Use left & right arrows
			pauseOnHover:false, // Stop animation while hovering
			manualAdvance:false, // Force manual transitions
			captionOpacity:0.65, // Universal caption opacity
			prevText: 'Prev', // Prev directionNav text
			nextText: 'Next' // Next directionNav text
	
		})
	}
	
	/* nyromodal initialize */
	if($('.nyroModal').length > 0){
		$('.nyroModal').nyroModal({filters:['iframe']});
	}

	function closeNyromodal(){
		$.nmTop().close();
	}
	


	/* forms general */
	/*****************/
	//focus input fields
	/*$('input').not('.btn input').focus(function() {
		$(this).addClass("focusField");
		$(this).prev('label').addClass("focusLabel")
	});
	$('input').blur(function() {
		$(this).removeClass("focusField");
		$(this).prev('label').removeClass("focusLabel")
	});*/
	
	//focus textarea
	/*$('textarea').focus(function() {
		$(this).addClass("focusField");
	});
	$('textarea').blur(function() {
		$(this).removeClass("focusField");
	});*/
	
	//focus select
	/*$('select').focus(function() {
		$(this).addClass("focusField");
	});
	$('select').blur(function() {
		$(this).removeClass("focusField");
	});*/

	
	/* FAQ */
	/*******/
	$('.super-list UL LI').children('#list-box').hide();
	$('.super-list UL LI H3, .super-list UL LI H3 a ').click(function(){   
		if ($(this).parents('li').hasClass("opened")) {                      
			$(this).parents('li').children('#list-box').hide();
			$(this).parents('li').removeClass("opened");
		} else {
			$(this).parents('li').children('#list-box').show();
			$(this).parents('li').addClass("opened");
		}
		return false;
	});


	/* 2 columns paragraph even and odd 
	   --------------------------------

	$('.twocols div:odd').addClass('first');
	$('.twocols div:even').addClass('last');
		*/
	
	
});





