(function($) {

	$.fn.cdInterface = function(settings) {
		settings = jQuery.extend({
		  "slideshowInterval" : 10000,
		  "slideshowAnimationDuration" : 3000
		},settings);
		
    var jQueryMatchedObj = this;
    var slideshowCount=0;
    var slideshowSelected=0;
    var newsletterTouched=false;

	function _initialize() {
	  _start(this,jQueryMatchedObj);
      return false; }
		
    function _start(objClicked,jQueryMatchedObj) {
      _set_interface();
      return; }
    
    function _set_interface() {
      Cufon.replace('h2', {fontFamily:'Black Chancery'});
      Cufon.refresh();
      
      $("a[rel=lightbox], .img").lightBox();
      
      slideshowCount = $("#slideshow > img").length;
      if(slideshowCount>1) {
      	setInterval(function(){
          if(slideshowSelected+1<slideshowCount) {
            $($("#slideshow > img")[slideshowSelected]).fadeOut(settings.slideshowAnimationDuration);
            $($("#slideshow > img")[slideshowSelected+1]).fadeIn(settings.slideshowAnimationDuration);
            slideshowSelected++;
          }
          else {
            $($("#slideshow > img")[slideshowSelected]).fadeOut(settings.slideshowAnimationDuration);
            $($("#slideshow > img")[0]).fadeIn(settings.slideshowAnimationDuration);
            slideshowSelected=0;
          }
        },settings.slideshowInterval);
      }
      
      $("#header h1").hover(
        function(){$(this).addClass("hover");},
        function(){$(this).removeClass("hover");}
      );
      
      $("#newsletter_input").focus(function(){if(!newsletterTouched){$("#newsletter_input").val('');newsletterTouched=true;}});
      
      return; }

    this.each(function() {
      _initialize(); });

    return this; }

})(jQuery);
