// Cufon setup
Cufon.set('fontFamily', 'Avenir Light').replace('#promos h3')('#content-sidebar .subnav a', { hover: true });
Cufon.set('fontFamily', 'Engravers').replace('#content-main h2')('#content-main h3');


$(function() {
  // Self-labeled form fields
	$("input[title], textarea[title]").each(function() {
		if($(this).val() === "") {
			$(this).val($(this).attr("title"));	
		}

		$(this).focus(function() {
			if($(this).val() == $(this).attr("title")) {
				$(this).val("").addClass("focused");	
			}
		});
		
		$(this).blur(function() {
			if($(this).val() === "") {
				$(this).val($(this).attr("title")).removeClass("focused");	
			}
		});
	});
  
  $('#slideshow').cycle({
    fx: 'fade',
    timeout: 5000
  });
  
  // Select all links with lightbox class
  $('#lightbox-1 a.lightbox').lightBox();
  $('#lightbox-2 a.lightbox').lightBox();
  $('#lightbox-3 a.lightbox').lightBox();
  $('#lightbox-4 a.lightbox').lightBox();
  $('#lightbox-5 a.lightbox').lightBox();
  
  $("a#open-table-form").fancybox({
  	'padding'         : 0,
  	'margin'          : 0,
  	'overlayOpacity'	: 0.54,
  	'speedIn'         : 300,
  	'speedOut'        : 300,
  	'overlayColor'    : '#000',
  	'titleShow'       : false,
  	'autoDimensions'  : false,
  	'width'           : 300,
  	'height'          : 234,
  	'centerOnScroll'  : true
  });
  
  $("a#email-form").fancybox({
  	'padding'         : 0,
  	'margin'          : 0,
  	'overlayOpacity'	: 0.54,
  	'speedIn'         : 300,
  	'speedOut'        : 300,
  	'overlayColor'    : '#000',
  	'titleShow'       : false,
  	'autoDimensions'  : false,
  	'width'           : 430,
  	'height'          : 319,
  	'centerOnScroll'  : true
  });
  
  var settings = {
    tl: { radius: 20 },
    tr: { radius: 20 },
    bl: { radius: 20 },
    br: { radius: 20 },
    antiAlias: true
  }

  curvyCorners(settings, ".rounded");
  
});	 

function clear_form_elements(ele) { 
    $(ele).find(':input').each(function() {
        switch(this.type) {
            case 'password':
            case 'select-multiple':
            case 'select-one':
            case 'text':
            case 'textarea':
                $(this).val('');
                break;
            case 'checkbox':
            case 'radio':
                this.checked = false;
        }
    });
}

