var $jQ = jQuery.noConflict();
var adress = -1;

var triggerVita = function(id, out) {
	var target = 'div#item-team-'+id;

	if (out !== 1) {
		$jQ(target).animate({
    		height: '600px'
  		}, 300);
  		
		$jQ(target + ' .team-teaser').fadeOut('fast', function () {
			$jQ(target +' .team-details').fadeToggle('slow').addClass('opened').removeClass('closed');
			$jQ(target +' .team-details img').fadeToggle('fast');
		}).addClass('closed').removeClass('opened');

	} else {
		$jQ(target).animate({
    		height: '158px'
  		}, 300);
  		
  		$jQ(target +' .team-details img').fadeOut('fast');
  		
		$jQ(target +' .team-details').fadeToggle('fast', function () {
			if (out === 1) {
				$jQ(target +' .team-teaser').fadeIn('fast').addClass('opened').removeClass('closed');
			}
		}).addClass('closed').removeClass('opened');
	}
}
var triggerVitaTeam = function(id, out) {
	var target = 'div#item-team-'+id;

	if (out !== 1) {
		$jQ(target).animate({
    		height: '340px'
  		}, 300);
  		
		$jQ(target + ' .team-teaser').fadeOut('fast', function () {
			$jQ(target +' .team-details').fadeToggle('slow').addClass('opened').removeClass('closed');
			$jQ(target +' .team-details img').fadeToggle('fast');
		}).addClass('closed').removeClass('opened');

	} else {
		$jQ(target).animate({
    		height: '158px'
  		}, 300);
  		
  		$jQ(target +' .team-details img').fadeOut('fast');
  		
		$jQ(target +' .team-details').fadeToggle('fast', function () {
			if (out === 1) {
				$jQ(target +' .team-teaser').fadeIn('fast').addClass('opened').removeClass('closed');
			}
		}).addClass('closed').removeClass('opened');
	}
}
var toggleImmo = function(id, out) {
	
	var target = 'div#immobilie-'+id;

	if (out !== 1) {
		$jQ(target).animate({
    		height: '338px'
  		}, 300);
  		
		$jQ(target + ' .immoClosed').fadeOut('fast', function () {
			$jQ(target +' .immoOpen').fadeToggle('slow').addClass('opened').removeClass('closed');
			$jQ(target +' .immoOpen img').fadeIn('fast');
		}).addClass('closed').removeClass('opened');

	} else {
		$jQ(target).animate({
    		height: '158px'
  		}, 300);
  		
  		$jQ(target +' .immoOpen img').fadeOut('fast');
  		
		$jQ(target +' .immoOpen').fadeToggle('fast', function () {
			if (out === 1) {
				$jQ(target +' .immoClosed').fadeIn('fast').addClass('opened').removeClass('closed');
			}
		}).addClass('closed').removeClass('opened');
	}
}
var closeAdress = function() {
	$jQ(".adress:eq("+adress+")").fadeOut(200);
	adress = -1;
}
var showAdress = function(n) {
	//			alert(n+"  "+adress);
	if (n != adress) {
		$jQ(".adress:eq("+adress+")").fadeOut(200);
		$jQ(".adress:eq("+n+")").fadeIn(400);
		adress = n;
	}
}

var setLocation = function (target) {
	window.location.href = target;	
}

$jQ(document).ready( function() {

	$jQ(".adress").hide();
	$jQ(".map").click( function(event) {
		event.preventDefault();
	});
	$jQ(".map").click( function(event) {
		event.preventDefault();
	});
	
	//$jQ('#imagerySlide img').hide();

	$jQ('#imagerySlide').cycle({
		timeout	:	2300,
		speed	:   5000,
		random	:	1
	});

	$jQ("ul.sf-menu").supersubs({
		minWidth:    2,
		//maxWidth:    14,
		extraWidth:  0
	}).superfish({
		autoArrows:    false,
		dropShadows:   false,
		delay:         250,
		disableHI:     true
	});
	
	
	$jQ('a.immoGal-imgs').fancybox({
		"overlayOpacity": 0.8,
		"overlayColor": "#333"
	});

});
