$(document).ready(function () {

	$('#tabs div').hide();
	$('#tabs div:first').show();
	$('#tabs ul li:first').addClass('active');
	$('#tabs ul li a').click(function(){ 
	$('#tabs ul li').removeClass('active');
	$(this).parent().addClass('active'); 
	var currentTab = $(this).attr('href'); 
	$('#tabs div').hide();
	$(currentTab).show();
	return false;
	});


	$('#tab-2 a').lightBox();
	$('#tab-3 a').lightBox();


	
	$('img#homeblock1').hover(function() {
	$(this).attr("src","/img/freedesignvisit-over.jpg");
		}, function() {
	$(this).attr("src","/img/freedesignvisit.jpg");
	});
	$('img#homeblock2').hover(function() {
		$(this).attr("src","/img/freebrochure-over.jpg");
			}, function() {
		$(this).attr("src","/img/freebrochure.jpg");
	});
	$('img#homeblock3').hover(function() {
		$(this).attr("src","/img/interactiveplanner-over.jpg");
			}, function() {
		$(this).attr("src","/img/interactiveplanner.jpg");
	});
	$('img#homeblock4').hover(function() {
		$(this).attr("src","/img/tipsfromdesigner-over.jpg");
			}, function() {
		$(this).attr("src","/img/tipsfromdesigner.jpg");
	});
    /**
     * Checks for an asterisk in the accessories and adds *shown to the 
     * description
     */
    var shown = '<em class="shown">*Shown</em>';
    $('.rangebox p:contains(*)').after(shown);  
    
    $('#lightbox-gallery a').lightBox({
        txtImage:        '',
        imageBtnClose:   '/img/lightbox/close.png',
        fixedNavigation: true,
        imageBtnNext:    '/img/lightbox/next.png',
        imageBtnPrev:    '/img/lightbox/previous.png'
    });
    
    function positionFooter(original_height)
    {
        var difference = $(window).height() - $(document.body).height();
        
        if (difference < 0) { 
            difference = 0;
        }
        
        difference = difference + original_height;
        $("#footer").css({height: difference + "px"});
    }
  
    positionFooter(200); 
    

    
    $('.fittedbox').hover(
        function () {
            $(this).find('.title').css('color', 'black');
        },
        function () {
            $(this).find('.title').css('color', 'white');
        }
    );
        
    $('.call_to_action li, .call_to_action-sidebar li').hover(
        function () {
            var img = $(this).find('img').attr('src'),
                temp = '';
            
            temp = img.split('/img/');
            
            img = temp.join('');
            
            $(this).find('img').attr('src', '/img/over_' + img);
        },
        function () {
            var img = $(this).find('img').attr('src'),
                temp = '';
            
            temp = img.split('over_');
            
            img = temp.join('');
            
            $(this).find('img').attr('src', img);
        }
    );    
});
