$(function(){
	var $infoSpeed = 150;
	
	$('li.action1 a').live('click', function(e) {
		if ($("#content").hasClass("work-active")) {
			$closeHeight = 90;
		} else {
			$closeHeight = 0;
		}
		
		var $this			= $(this);
		var $parentClass	= $this.parent().attr('class');
		
		var pageId = $this.attr('name');
		
		$.ajax({
			type: 'POST',
			url: "/cmsfiles/components/ajaxrequests/get_info.php",
			data: ({id : pageId}),
			success: function(html){ 
				
				$("#text").show();				
				$curH = $("#content-inner").height()+160;
												
				// INDIEN AL OPEN						
				if ($curH != 0) {
					
					$("#content-inner").animate({
						opacity: 0
					}, $infoSpeed, function(){
						$('#content-inner').html(html);
						$curH = $("#content-inner").height()+160;
						if ($curH < 326) {
							$curH = 326;
						}
						$("#content").animate({
							height: $curH
						}, $infoSpeed, function(){
							$('#content').animate({
								opacity: 1
							}, $infoSpeed, function(){
								$('.close-button').addClass('info-active');
							});
						});
						
						$("#content-inner").animate({
							opacity: 1
						});
						
					});
				// INDIEN NOG NIET OPEN
				} else {
					$('#content-inner').html(html);
					$curH = $("#content-inner").height()+125;
					if ($curH < 326) {
						$curH = 326;
					}
					$("#content").animate({
						height: $curH
					}, $infoSpeed, function(){
						$('#content').animate({
							opacity: 1
						}, $infoSpeed, function(){
							$('.close-button').addClass('info-active');
						});
					});	
				}
				
			}
		});
		e.preventDefault();
	});
	
	$('.close-button').live('click', function() {
		if ($("#content").hasClass("work-active")) {
			$closeHeight = 90;
		} else {
			$closeHeight = 0;
		}
		
		//$(this).animate({opacity: 0}, $infoSpeed);
		$('#content').animate({opacity: 0}, $infoSpeed, function() { 
			$("#text").show();
	
			$("#content").animate({
				opacity:0,
				height: $closeHeight
			}, $infoSpeed);
		});
		
		$('.close-button').removeClass('info-active');
		
	});
});
