$(document).ready(function() {
  
  DD_roundies.addRule('div#branding', '8px 8px 0 0', true);
  DD_roundies.addRule('div#nav-primary ul li a', '8px 8px 0 0', true);
  DD_roundies.addRule('div#content-primary h3', '8px 8px 0 0', true);
  DD_roundies.addRule('body.features div#content-primary h3', '0', true);
  DD_roundies.addRule('div#standard', '8px', true);
  DD_roundies.addRule('div#premium', '8px', true);
  DD_roundies.addRule('div#free-trial', '8px', true);
  DD_roundies.addRule('div#testimonials', '8px', true);
  DD_roundies.addRule('div#footer', '0 0 8px 8px', true);
  DD_roundies.addRule('div#content-tertiary h3', '8px 8px 0 0', true);
  
  if ($('#slider').length) {
    $('#slider').anythingSlider({
      easing: "swing", // Anything other than "linear" or "swing" requires the easing plugin
      autoPlay: true, // This turns off the entire FUNCTIONALY, not just if it starts running or not.
      delay: 7000, // How long between slide transitions in AutoPlay mode
      startStopped: false, // If autoPlay is on, this can force it to start stopped
      animationTime: 400, // How long the slide transition takes
      hashTags: false, // Should links change the hashtag in the URL?
      buildNavigation: false, // If true, builds and list of anchor links to link to each slide
      pauseOnHover: false // If true, and autoPlay is enabled, the show will pause on hover
    });
  };
  
  if ($('div#free-trial form input#free-trial-name').length) {
    $('div#free-trial form input#free-trial-name').keypress(function() {
      if( $('div#free-trial form input#free-trial-name').val() == "Enter your name" ) {
        $('div#free-trial form input#free-trial-name').val("");
        $('div#free-trial form input#free-trial-name').css('color', '#646464');
      }
    });
    $('div#free-trial form input#free-trial-name').click(function() {
      if( $('div#free-trial form input#free-trial-name').val() == "Enter your name" ) {
        $('div#free-trial form input#free-trial-name').css('color', '#ccc');
      }
    });
    $('div#free-trial form input#free-trial-name').blur(function() {
      if( $('div#free-trial form input#free-trial-name').val() == "Enter your name" ) {
        $('div#free-trial form input#free-trial-name').css('color', '#646464');
      }
      if( $('div#free-trial form input#free-trial-name').val() == "" ) {
        $('div#free-trial form input#free-trial-name').val("Enter your name");
        $('div#free-trial form input#free-trial-name').css('color', '#646464');
      }
    });
  };    
    
  if ($('div#free-trial form input#free-trial-email').length) {    
    $('div#free-trial form input#free-trial-email').keypress(function() {
      if( $('div#free-trial form input#free-trial-email').val() == "Enter your email address" ) {
        $('div#free-trial form input#free-trial-email').val("");
        $('div#free-trial form input#free-trial-email').css('color', '#646464');
      }
    });
    $('div#free-trial form input#free-trial-email').click(function() {
      if( $('div#free-trial form input#free-trial-email').val() == "Enter your email address" ) {
        $('div#free-trial form input#free-trial-email').css('color', '#ccc');
      }
    });
    $('div#free-trial form input#free-trial-email').blur(function() {
      if( $('div#free-trial form input#free-trial-email').val() == "Enter your email address" ) {
        $('div#free-trial form input#free-trial-email').css('color', '#646464');
      }
      if( $('div#free-trial form input#free-trial-email').val() == "" ) {
        $('div#free-trial form input#free-trial-email').val("Enter your email address");
        $('div#free-trial form input#free-trial-email').css('color', '#646464');
      }
    });
  };    
    
  if ($('div#free-trial form input#free-trial-telephone').length) {    
    $('div#free-trial form input#free-trial-telephone').keypress(function() {
      if( $('div#free-trial form input#free-trial-telephone').val() == "Enter your telephone (optional)" ) {
        $('div#free-trial form input#free-trial-telephone').val("");
        $('div#free-trial form input#free-trial-telephone').css('color', '#646464');
      }
    });
    $('div#free-trial form input#free-trial-telephone').click(function() {
      if( $('div#free-trial form input#free-trial-telephone').val() == "Enter your telephone (optional)" ) {
        $('div#free-trial form input#free-trial-telephone').css('color', '#ccc');
      }
    });
    $('div#free-trial form input#free-trial-telephone').blur(function() {
      if( $('div#free-trial form input#free-trial-telephone').val() == "Enter your telephone (optional)" ) {
        $('div#free-trial form input#free-trial-telephone').css('color', '#646464');
      }
      if( $('div#free-trial form input#free-trial-telephone').val() == "" ) {
        $('div#free-trial form input#free-trial-telephone').val("Enter your telephone (optional)");
        $('div#free-trial form input#free-trial-telephone').css('color', '#646464');
      }
    }); 
  };
  
  if ($('div.accordion').length) {
    $("div.accordion").accordion({ active: false, header: 'div.header', collapsible: 'true', autoHeight: false });
  };

  if ($('a#iframe').length) {
    $('a#iframe').fancybox({
      'width'       : '60%',
      'height'      : '90%',
      'autoScale'       : false,
      'transitionIn'    : 'none',
      'transitionOut'   : 'none',
      'centerOnScroll'  : 'true',
      'overlayColor'    : '#000',
      'type'            : 'iframe'
    });
  };
  
  if ($('a.pop-up').length) {
    $('a.pop-up').fancybox({
      'transitionIn'    : 'elastic',
      'orig'            : $('div#testimonials')
    });
  };
  
  if ($('ul.product-list').length) {
    $('.coda_bubble').codaBubble({
      distances : [10,10,10,10,10,10,10,10,10,10,10,10],
      leftShifts : [0,0,0,0,0,0,0,0,0,0,0,0],
      bubbleTimes : [400,400,400,400,400,400,400,400,400,400,400,400],
      hideDelays : [0,0,0,0,0,0,0,0,0,0,0,0],
      bubbleWidths : [400,400,400,400,400,400,400,400,400,400,400,400],
      bubbleImagesPath : '/assets/img/layout/bubble/',      
      msieFix : true
    });
  };
      
});
