/* --------------------------------------------------
@project		klebinger.de
@file			javascript/functions.js
@date		13.02.2010
@version		2.0
@author		Günther Klebinger
@function		javascript functions
-------------------------------------------------- */

$(document).ready(function() {

	/* fancybox */
	$('a.fancybox').fancybox({ 'titleShow': false, 'titlePosition': 'inside', 'transitionIn': 'fade', 'transitionOut': 'fade', 'hideOnContentClick': false, 'padding': 1, 'imageScale': true, 'overlayOpacity': 0.7, 'overlayColor': '#010101' }); 

	/* Textmarkierung generell deaktivieren */
	$('#viewport').disableTextSelect();
	$('#footer').disableTextSelect();
	
	/* Galerie-Titel einblenden */
	$('.picture').mouseover(function() { $(this).find('.picturetitle').show(); });
	/* Galerie-Titel ausblenden */
	$('.picture').mouseout(function() { $(this).find('.picturetitle').hide(); });
	
	/* Galerie-Titel mit Maus verschieben */
	$('.picture').mousemove(function(e) {
		var position = $(this).position();
		var offset = $(this).offset();
		var x = e.pageX - (offset.left);
		var y = e.pageY - (offset.top);
		
		/* Höhe der Bildfläche und des Beschreibungsfeldes */
		var wrapperheight = parseInt($(this).css('height').replace(/px/, ""), 10);
		var titleheight = parseInt($(this).find('.picturetitle').css('height').replace(/px/, ""), 10);
				
		/* Hole Höhe damit Mauszeiger in der Mitte ist */
		var ycorrected = y - Math.ceil(titleheight / 2);
		
		/* Oben und unten fixieren */
		if(ycorrected < 0)
			ycorrected = 0;
		else if(ycorrected > wrapperheight - titleheight)
			ycorrected = wrapperheight - titleheight;
		
		/* Setze Position */
		$(this).find('.picturetitle').css('top', ycorrected+'px');
		});
		
	/* Filter -  nur Text */
	$('#filter_text').mouseup(function() { $('.post').show(); $('.picture').hide(); });
	/* Filter -  nur Bilder */
	$('#filter_pictures').mouseup(function() { $('.post').hide(); $('.picture').show(); });
	/* Filter -  beides */
	$('#filter_both').mouseup(function() { $('.post').show(); $('.picture').show(); });
		
	/* Stil für Filter-Tooltips */
	$.fn.qtip.styles.filter_tooltip = { background: '#d8ff00', border: { width: 0, radius: 0, color: '#d8ff00' } , color: '#101010', textAlign: 'center', tip: { color: '#d8ff00', corner: 'bottomMiddle', size: { x: 8, y: 6 } } };
	/* Tooltips aus Filter-titeln */
	$('.filter_button').qtip({ hide: { effect: { length: 250 } }, show: { effect: { length: 250 } }, style: 'filter_tooltip', position: { adjust: { x: 0, y: -4 }, corner: { target: 'topMiddle', tooltip: 'bottomMiddle' } } });
	$('.postyear').qtip({ hide: { effect: { length: 250 } }, show: { effect: { length: 250 } }, style: 'filter_tooltip', position: { adjust: { x: 0, y: -4 }, corner: { target: 'topMiddle', tooltip: 'bottomMiddle' } } });
	
	
	/* Tooltip bei 'mehr' */
	$.fn.qtip.styles.more_tooltip = { background: '#d8ff00', border: { width: 0, radius: 0, color: '#d8ff00' } , color: '#101010', textAlign: 'left', tip: { color: '#d8ff00', corner: 'topMiddle', size: { x: 8, y: 6 } } };
	$('.postbreak').qtip({ hide: { effect: { length: 250 } }, show: { effect: { length: 250 } }, style: 'more_tooltip', position: { adjust: { x: 0, y: 10 }, corner: { target: 'bottomMiddle', tooltip: 'topMiddle' } } });
	});