jQuery(document).ready(function($){

	//Remove empty placeholders for widgets in IE7
	$('#page > div, #footer > div').each(function() {
		if($(this).html().trim() == '') {
			$(this).css('display', 'none')
		}
	});

	//Add margin on odd pods
	$('.homeBody #teaserTop .column:odd').addClass('margin-odd');

	//Add classes to links in home page bottom pod
	$('.homeBody #include_post-13 a:nth(0)').addClass('fsb');
	$('.homeBody #include_post-13 a:nth(1)').addClass('buy_white');
	$('.homeBody #include_post-13 a:nth(2)').addClass('which');
	$('.homeBody #include_post-13 a:nth(3)').addClass('dass');
	$('.homeBody #include_post-13 a:nth(4)').addClass('uk_whitegoods');
	$('.homeBody #include_post-13 a:nth(5)').addClass('retra');

	//Add class to first image in content, usually it is header
	$('.internalBody #content img:nth(0)').addClass('heading-image');

	//Reloacate sales pod list from teaserbottom to content
	$('#content').append( $('.teaserBottom_item_1'));
	$('#include_post-54 br').remove();
	$('.internalBody #content #include_post-54 ul li:nth-child(3n)').addClass('no-margin');

	//Relocate internal logo pod inside content
	$('#content').append( $('.teaserBottom_item_2'));

	//sidebar 1 pods under navigation content force

	//CTA
	$('a[href="#cta-pod"]').click( function() {
		$('.sidebar_1_item_5').show(0, function() {
			$.fancybox({
				'type'			: 'inline',
				'href'			: '#' + $('.sidebar_1_item_5').attr('id'),
				'onClosed'		: function() {
					$('.sidebar_1_item_5').hide(0);
				}
			});
		});
		$('#fancybox-content').css('list-style-position', 'inside');
		return false;
	});

	//FORM
	$('a[href="#contact-form"]').click( function() {
		$.fancybox({
			'type'	: 'inline',
			'href'	: '#' + $('.wpcf7').attr('id')
		});
		return false;
	});

	//MAP
	$('a[href="#map"]').click( function() {
		$.fancybox({
			'type'	: 'inline',
			'href'	: '#map'
		});
		return false;
	});

	//Fill up sidebar height
	$('#sidebar_1').css('min-height', ($('body').height() - 187));

	//Teaser bottom
	$('#teaserTop > div, #include_post-12, #include_post-74').each( function() {
		$(this).css('background', 'url(' + $(this).find('img').attr('src') + ') scroll center center no-repeat');
		$(this).find('img').remove();
	});

	//these lines are needed for something, I suppose
	$('#teaserTop > div').click( function() {
		window.location = $(this).find('a').attr('href');
	})

	//Form
	$("#im-an-account-customer input").click(function() {
    	if( $(this).val() === 'yes' ) {
    		$('.wpcf7 p.full.account-name').slideDown('100');
    	}else{
    		$('.wpcf7 p.full.account-name').slideUp('100');
    	}
	});

	// your actions will have counter-actions
	$("#appliance-type").change(function() {
		if( $(this).val() === 'Other' ) {
			$('.wpcf7 span.wpcf7-form-control-wrap.other-appliance-type').show();
		}else{
			$('.wpcf7 span.wpcf7-form-control-wrap.other-appliance-type').hide();
		}
	});
});

/* fire AddThis manually, mostly for IE issues*/
window.onload = function() {
	addthis.toolbox(".addthis_toolbox");
}
