/* === Cufon Font replace === */

Cufon.replace('#nav ul a', {hover: true});
Cufon.set('fontFamily', 'Century Gothic', 'fontWeight', '700').replace('#nav ul a')('h2')('h3')('h4')('h5')('#hero-intro')('#home-hero-intro')('.hero-intro')('.sofabeds-hero-price a')('div#fabric-request-btn a')('#delivery-time p')('#side-animation p')('a.content-btn', {hover: true})('.cufon')('#billing p')('#side-tech-spec a');

/* === Smoothscroll === */

$(function(){
    $('a[href*=#]').click(function() {
    	if($(this).hasClass('no-scroll'))return true;
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                $('html,body').animate({scrollTop: targetOffset}, 1000);   
                return false; 
            } 
        } 
    }); 
});

/* === Leather / Fabric Switcher for Sofa Beds Page Galelry === */

$(function(){	
	$('a#leather').click(function(){
		if($(this).parent().hasClass('active')) {
			
		} else {
		$(this).parent().addClass('active');
		$('a#fabric').parent().removeClass('active');	
		}
		$('#sofa-detail-hero2').css('display','block');
		$('#sofa-detail-hero').css('display','none');		
	});		
	$('a#fabric').click(function(){	
		if($(this).parent().hasClass('active')) {
			
		} else {
		$(this).parent().addClass('active');	
		$('a#leather').parent().removeClass('active');
		}	
		$('#sofa-detail-hero2').css('display','none');
		$('#sofa-detail-hero').css('display','block');
	});	
});

function add_to_order(type, id){
	if(type == '')
		url = '/order/update_defaults/';
	else
		url = '/order/update_defaults/'+type+'|'+id;
	$.get(url, function(data){
		window.location = '/order';
	});
}
