if (!FreedomKitchens) var FreedomKitchens = {}

FreedomKitchens.setup = function () {
	$('#colourtool').click(function(e) {
    	e.preventDefault();
    	var day = new Date();
		var id = day.getTime();
		eval("page" + id + " = window.open('http://freedomkitchens.com.au/colourtool/colourtoolv6.php', '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=916,height=860');");
  	});
  	
  	if($('#mycarousel').length > 0) jQuery('#mycarousel').jcarousel({ auto: 5, wrap: 'circular', scroll: 1 });
  	
    if($('.installation-map').length > 0) {
        $('.installation-map').lightBox();
    }

  	if($('#image_gallery').length > 0) {
  	    $('#image_gallery a').lightBox();
  		jQuery('#image_gallery').jcarousel({ 
  			wrap: 'circular',
  			scroll: 1, 
  			visible: 1,
  			initCallback: gallery_initCallback,
        	buttonNextHTML: null,
        	buttonPrevHTML: null 
  		});
  	}
}

$(function() {
	FreedomKitchens.setup();
});

function Days30() {
    $.modal('<a href="http://hfw.30daysofhomefoodandwine.com.au/win-your-very-own-dream-kitchen.htm"><img src="http://www.freedomkitchens.com.au/images/30days-apr-page.gif" /></a>');
    return false;
}

function Days30Video() {
	$.modal('<iframe width="560" height="349" src="http://www.youtube.com/embed/ONn8TNATpAg" frameborder="0"></iframe>');
	return false;
}

function BookADesigner() {
	$.modal('<iframe width="525" height="670" src="http://www.freedomkitchens.com.au/enquire_new.php?form_type=bkds&referrer=freedesignpage&custom_referal=30days-edm-may11" frameborder="0"></iframe>');
	return false;
}

function RequestCatalogue() {
	$.modal('<iframe width="525" height="670" src="http://www.freedomkitchens.com.au/enquire_new.php?form_type=SPOD&topic_id=326&obj_id=50&referal=webbrochure&referrer=&custom_referal=30days-edm-may11" frameborder="0"></iframe>');
	return false;
}


function RequestGuide() {
	$.modal('<iframe width="525" height="670" src="http://www.freedomkitchens.com.au/enquire_new.php?form_type=RENG&topic_id=388&obj_id=56&referal=renoguide&custom_referal=30days-edm-may11" frameborder="0"></iframe>');
	return false;
}



function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

function gallery_initCallback(carousel) {
	jQuery('#gallery_next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#gallery_previous').bind('click', function() {
        carousel.prev();
        return false;
    });
};

