
    // more code using $ as alias to jQuery

jQuery.noConflict();
(function($) { 
  $(function() {
	  
	$.fn.vAlign = function() {
		return this.each(function(i) {
			var ah = $(this).height();
			var ph = $(this).parent().height();
			var mh = (ph - ah) / 2;
			$(this).css('margin-top', mh);
		});
	};
	
	$.fn.drawer = function(time) {
		$(this).slideToggle(time);
		return this;
	};
	
	

	/**************************************************************************** b-clb hover */
	
	/*
	var config = {    
		timeout: 3000,   
		over:	function() { $( '#lgn-frm' ).animate({ top:0 }, 75 ); },  
		out:	function() { $( '#lgn-frm' ).animate({ top:-29 }, 100 ); }
	};

	$("#b-clb").hoverIntent( config );
	*/
	
	$( '#nav-main' ).hoverIntent(
		function() {
			$( '#nav-main ul' ).slideToggle( 160 );
		}, function() {
			$( '#nav-main ul' ).slideToggle( 200 );
		}
	);
	
	
	/**************************************************************************** drawer */

	$('.biz').prepend(
		'<a class="switch" id="on" style="display:none;" href="">Anzeigen</a>'
	).prepend(
		'<a class="switch" id="off" href="">Schliessen</a>'
	);
	
    var drawerState = $.cookies.get('fb_drawer');


	if(!drawerState) {
		$('#off').css("display","block");
		$('#on').css("display","none");
		$('.biz .col-100').css("display","block");
		$.cookies.set('fb_drawer', 'open', {path: "/"});
	}
	
	if (drawerState == 'closed') {
		$('.biz .col-100').css("display","none");
		$('#off').css("display","none");
		$('#on').css("display","block");
	}


	if (drawerState == 'open') {
		$('.biz .col-100').css("display","block");
		$('#off').css("display","block");
		$('#on').css("display","none");
	}
	
	
	$('#on').click(function() {
		$('.biz .col-100').drawer(100);
		$('#on').css("display","none");
		$('#off').css("display","block");
		$.cookies.set('fb_drawer', 'open', {path: "/"});
		return false;
	});

	$('#off').click(function() {
		$('.biz .col-100').drawer(100);
		$('#off').css("display","none");
		$('#on').css("display","block");
		$.cookies.set('fb_drawer', 'closed', {path: "/"});
		return false;
	});



//	.toggle(function() {
//		$(this).text('Anzeigen');
//		$.cookie('fb_drawer', 'closed');
//	}, function() {
//		$(this).text('Schliessen');
//		$.cookie('fb_drawer', 'open');
//	});


	/**************************************************************************** img-gal */
	
	var $ig = $( '.img-gal' );
	var $tg = $( '.teaser-gal' );
	
	$( '.news-single-img img' ).vAlign();
	
  	if ( $( '.img-gal > div' ).length > 1 || $( '.teaser-gal > div' ).length > 1 ) {
		
		$( '.news-img-grp' ).prepend(
			'<div class="img-gal-ctrls" id="img-gal-ctrls"></div>'
		);
	
		$( '.img-gal-ctrls' ).prepend(
			'<a class="csc-ctrl csc-prev"></a><a class="csc-ctrl csc-next"></a>'
		);
		


		
		$ig.before('<div class="slidetabs" id="nav" style="z-index: 10000">').cycle({
			fx		: 'fade', 
			speed	: 'fast', 
			timeout	: 0, 		
			next	: '.csc-next',
			prev	: '.csc-prev',
			pager	: '#nav'
		});
	
		$tg.before('<div class="slidetabs" id="nav" style="z-index: 10000">').cycle({
			fx		: 'fade',
			speed	: 'slow', 
			timeout	: 5000, 		
			pause	: 1
		});
	
	}

  
	
	$(document).keydown(function(e){
		if(e.which == 37 || e.which == 80){ $('.csc-prev').click();}
		else if(e.which == 39 || e.which == 78){ $('.csc-next').click();}
		else return;
	});



	/**************************************************************************** rgstr */
	
	$( '.one' ).click( function() {
		$( '.me' ).show();
		$( '.friend' ).hide();
		$( '.id' ).hide();
		return true;
	});
	$( '.two' ).click( function() {
		$( '.friend' ).show();
		$( '.me' ).hide();
		$( '.id' ).hide();
		return true;
	});
	$( '.three' ).click( function() {
		$( '.id' ).show();
		$( '.friend' ).hide();
		$( '.me' ).hide();
		return true;
	});
	
	

  });
})(jQuery);
