/***********************************************************************

Author:     Arno Hoogma
URL:        http://www.4rn0.nl

***********************************************************************/


if (typeof window.jQuery != 'undefined') {

	$(function() {
		
		contactAnimation();
		alignTestimonial();
		serviceToggle();
		
	});

	/**
	 *
	 */
	function contactAnimation()
	{
		
		$('div#container').append('<div id="contactAnimation"><a class="contact">Contact</a> ' + $('#contact').html() + '</div>');
		$('#contact').html('');

		$('div#contactAnimation a.contact').one('click', function() {
			
			$(this).html('Contact:').css({
				cursor: 'default',
				textDecoration: 'none'
			});
			
			$('div#contactAnimation').animate({
				width: '21.0em'
			}, 400);

		});
		
	}
	
	/**
	 *
	 */
	function alignTestimonial()
	{
		
		var containerHeight = $('#testimonial').height();
		var containerWidth = $('#testimonial').width();
		
		var elementHeight = $('#testimonial blockquote').height();
		var elementWidth = $('#testimonial blockquote').width();
		
		$('#testimonial blockquote, #testimonial cite').css('left', ((containerWidth - elementWidth) / 2) + 'px');
		$('#testimonial blockquote').css('top', ((containerHeight - elementHeight) / 2) - 10 + 'px');
		$('#testimonial cite').css('top', ((containerHeight - elementHeight) / 2) + elementHeight - elementHeight - 10 + 'px');
				
	}

	/**
	 *
	 */
	function serviceToggle()
	{
		
		$('#service ul ul').hide();
		
		$('#service > ul > li').addClass('toggle').toggle(
			function(e) {
				$('ul', $(this)).show();
			},
			function(e) {
				if (e.target.nodeName != 'A') {
					$('ul', $(this)).hide();
				}
				else {
					// document.location.href = 'http://www.helder-cfa.nl/' + $(e.target).attr('href');
					window.open('http://www.helder-cfa.nl/' + $(e.target).attr('href'), 'service');
				}
			}
		);
		
	}
	
}
