$(document).ready(function()
{	
	createShadow('h4');
	try {
		Cufon.replace('h3 ', {textShadow: '#333 1px 1px'});
	}
	catch (e)
	{
		$('h3').css('color', '#595959')
		createShadow('h3');		
		$('h3.shadow').css('color', '#CF7871')		
	}
	fetchRss($('#rss-selector').val());
	$('#rss-selector').change(function() 
	{
		fetchRss(this.value);
	});
	$('div.slider').cycle({ 
	    fx: 'fade',	    
	    speed: 1000,
	    timeout: 8000 
	});
	$('#submit-domain').click(function() 
	{	
		$('#submit-domain').hide();
		$('#domain-form div.loading-box').addClass('loading');
		$.post('/index/domain', $('#domain-form').serialize(), function(data)
		{				
			if(data != null)
			{
				$('#domain-form div.loading-box').toggleClass(data.result?'success':'failure')	
			}	
		}		
		, 'json')
		return false;
	})
	$('#domain').keyup(function () {
		$('#submit-domain').show();
		$('#domain-form div.loading-box')
			.removeAttr('class')
			.addClass('loading-box');	
	})
	$('div.promo-box').click(function ()
	{
		window.open('http://www.opvakantieinfrankrijk.nl');
	})
	imageSpace();
})
function createShadow(element) 
{
	$(element).each(function () 
	{		
		var clone = $(this).clone();
		var offset = $(this).position();
		$(clone)
			.insertAfter(this)
			.addClass('shadow')		
	})	
}
function fetchRss(url)
{		
	$('#rss-response').html('<img id="mail-loading" src="/images/loadingAnimation.gif" alt="Laden..." />');
	$.get('/index/rss/?url='+url, function(data)
	{				
		$('#rss-response').html(data);
		$('#rss-response a').tooltip({
			track: true,
		    delay: 0, 
		    showURL: false, 
		    showBody: " - ", 
		    fade: 250
		});
	});		
}

function imageSpace() 
{
 	$('img.content-img').each(function ()
 	{
 		var vspace = $(this).attr('vspace');		
 		if(vspace>0)
 		{			
 			$(this).removeAttr('vspace');
 			$(this).css('marginTop', vspace)	
 			$(this).css('marginBottom', vspace)
 		}
 		var hspace = $(this).attr('hspace');
 		if(hspace>0)
 		{
 			$(this).removeAttr('hspace');
 			$(this).css('marginLeft', hspace)	
 			$(this).css('marginRight', hspace)
 		}		
 		var align = $(this).attr('align');
 		switch (align)
 		{
 			case 'left':
 				$(this).addClass('floatLeft');break; 				
 			case 'right':
 				$(this).addClass('floatRight');break;
 			case 'absBottom':
 				$(this).addClass('verticalAlignAbsBottom');break;
 			case 'absMiddle':
 				$(this).addClass('verticalAlignAbsMiddle');break;
 			case 'baseline':
 				$(this).addClass('verticalAlignBaseline');break;
 			case 'bottom':		
 				$(this).addClass('verticalAlignBottom');break;
 			case 'middle':
 				$(this).addClass('verticalAlignMiddle');break;
 			case 'textTop':
 				$(this).addClass('verticalAlignTextTop');break;
 			case 'top':		
 				$(this).addClass('verticalAlignTop');break;
 		}				
 	}) 	
}
 
