/*
* Digital Development Debates
* standard.js
*
* Author: Holger M. Stangl
* Company: Limeflavour | http://www.limeflavour.com
* Date: August 2010
*/


$(document).ready(function(){
	
	
	/* JS enable */
	$("html").addClass("js");
	
	
	$(".navigationCover .currentBox").hide();
	$(".cover-active .currentBox").show();
	
	
	$(".navigationCover").hoverIntent({
		sensitivity: 4, 
		interval: 200, 
		over: function(){
			$(this).addClass('cover-hover');
			$(".currentBox", $(this) ).slideDown(300);
		}, 
		timeout: 500, 
		out:  function(){
			$(this).removeClass('cover-hover');
			$(".currentBox", $(this) ).not(".cover-active .currentBox").slideUp(300);
		}
	});
	
	
	
	$(".navigationImages .selectionBox").hide();

	$(".navigationImages").hoverIntent({
		sensitivity: 4, 
		interval: 200, 
		over: function(){
			$(".selectionBox", $(this) ).fadeIn(100);
			if( $(".thumbImages", $(this) )[0] ){
                $(".thumbImages", $(this) ).scrollable({api: true}).click(0);
            }
		}, 
		timeout: 500, 
		out:  function(){
			$(".selectionBox", $(this) ).fadeOut(100);
		}
	});
	
	
	$('.navigationItem').hover(
		function(){
			$(this).addClass('item-hover');					
		},
		function(){
			$(this).removeClass('item-hover');
		}
	);
	
	
	$('.selectionBox').each(function(){				
		var scrollable = $(".thumbImages", this).scrollable({ 
			items:'.thumbBoxInner',
			prev:'.thumbArrowLeft',
			next:'.thumbArrowRight',
			clickable: true,
			size: 4
		});
		var scrollableAPI = $(".thumbImages", this).scrollable({api: true});
	});
	
	
	
	
	$('#openCommentForm').toggle(
		function(){
			$('#commentForm').slideDown(800);
			$(this).text('Comment this article');
		},
		function(){
			$('#commentForm').slideUp(800);
			$(this).text('Do you want to comment?');
		}
	);
	
	$('#openCommentForm').click(function(){
		$.scrollTo( '.containerFooter', 800 );
		return false;
	});
	
	$('a.comment-read').click(function(){
		$.scrollTo( '.containerComments', 800 );
		return false;
	});
	
	$('a.comment-write').click(function(){
		$.scrollTo( '.containerFooter', 800 );
		$('#commentForm').slideDown(800);
		$('#openCommentForm').text('Comment this article');
		return false;
	});
	
	
	
	/* ScrollTo */
	$('a.top').click(function(){
		$.scrollTo( '#pageTop', 800 );
		return false;
	});
	
	/*
	$('.paginationBox .all a').click(function(){
		$('.pageBox').show();
		$('.pages span').removeClass('active');
		return false;
	});
	
	$('.paginationBox .page a').click(function(){
		$('.pageBox').hide();
	});
	*/
	
	
	// Self-maximize Textaraes
	$('textarea').elastic();
	
	
	
	// Search Field Hover
	$('#searchTerm').focus(
		function() {
			if ( $(this).attr('value') == 'Suchbegriff' ) {
				$(this).attr('value','');
			}
		}
	);
	
	$('#searchTerm').blur(
		function() {
			if ( $(this).attr('value') == '' ) {
				$(this).attr('value','Suchbegriff');
			}
		}
	);

	
	

	/**
	 * Zoom Funktion - Bild im Fliesstext 
	 */	
	$("a.zoom").fancybox({
		'titlePosition'  : 'inside',
		'zoomOpacity' : true,
		'overlayShow' : true,
		'overlayOpacity' : 0.5,
		'padding' : 10,
		'zoomSpeedIn' : 500,
		'zoomSpeedOut' : 500,
		'transitionIn' : 'none',
		'transitionOut'	: 'none',
		
		'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">' + title + '</span>';
		}

	});
	
	$('#cover').wrap('<div class="imageBox" />');
	

});



