/****************************************************************
  © by agentur-vida.de
  STANDARDS
*****************************************************************/
var Theme =
{
	hoverRow: function(el, state)
	{
		var items = $(el).getChildren();

		for (var i=0; i<items.length; i++)
		{
			if (items[i].nodeName.toLowerCase() == 'ul')
			{
				items[i].setStyle('background-color', (state ? '#ebfdd7' : ''));
			}
		}
	},

	hoverDiv: function(el, state)
	{
		$(el).setStyle('background-color', (state ? '#ebfdd7' : ''));
	}
};

function makeNewsListe( liste )
{
	$('newsliste').removeClass('sichtbar');
	$('blogliste').removeClass('sichtbar');
	$('btn_newsliste').removeClass('active');
	$('btn_blogliste').removeClass('active');
	
	$(liste).addClass('sichtbar');
	$('btn_'+liste).addClass('active');
}

function fadein( img )
{
	$(img).fade(1);
}

function fadeout( img )
{
	$(img).fade(0);
}


var Projekte =
{
	/**
	 * Von der Projektliste zum Projekt
	 */
	jumpToProjekt: function( id )
	{
		new Request(
		{
			url: 'ajax.php?action=fmd&id=2&projekt='+id,
						
			onComplete: function(txt, xml)
			{
				window.location = 'referenzen.html';
   			}
		}).send();
	},
	
	/**
	 * Projektdetails nachladen
	 */
	loadProjekt: function( id, title )
	{		
		new Request(
		{
			url: 'ajax.php?action=fmd&id=5&projekt='+id,
			
			onRequest: function()
			{
				// Altes Projekt schliessen
				var old = $('aktivesprojekt').value;
				if( old )
				{
					$('projektfade_'+old).style.display = 'block';
					$('projektfade_'+old).fade(1);
				}
				
				$('ProjektDetails').removeClass('invisible');
				$('ProjektDetails').addClass('loading');
				Projekte.expandProjekt( '300' );
				$('projektfade_'+id).style.display = 'none';
				$('projektfade_'+id).fade(0);
				$('projektbox').fade(0);
				$('aktivesprojekt').value = id;
			},
			
			onComplete: function(txt, xml)
			{
				window.setTimeout( function()
				{
					$('ProjektDetails').removeClass('loading');
					$('projektbox').innerHTML = txt;
					$('projektbox').fade(1);
					Projekte.addHoverEffekt();
					
					var pageTracker = _gat._getTracker("UA-2495631-2");
        	pageTracker._trackEvent("Projektdetails",title, 'angesehen');
					
				}, 800);
   			}
		}).send();
		
		return false;
	},
	
	
	/**
	 * Tween the DIV
	 */
	expandProjekt: function( height )
	{
		var newTween = new Fx.Tween( $('fader') );
		newTween.set('tween',
		{
			duration: 500,
			transition: Fx.Transitions.easeOut
		});
			
		newTween.start('height', height+'px');
	},
	
	/**
	 * Den HoverEffekt auslösen
	 */
	addHoverEffekt: function()
	{
		var height = $('hoehe').value;
		$('projektbild').addEvents(
		{
			'mouseenter': function()
			{
				this.set('tween', 
				{
					duration: 500,
					transition: Fx.Transitions.easeOut
				}).tween('height', height+'px');
			},
			'mouseleave': function()
			{
				this.set('tween', {}).tween('height', '300px');
			}
		});
	},
	
	addTracking: function(el, title)
	{
	  var pageTracker = _gat._getTracker("UA-2495631-2");
  	pageTracker._trackEvent("Projektdetails",title, 'geklickt');
	}
}
