$(document).ready(function() {
  
  DD_roundies.addRule('.rounded', '4px');
  $('.image').append('<i class="cn tl" /> \
                      <i class="cn tr" /> \
                      <i class="cn bl" /> \
                      <i class="cn br" />');
  
  $('.nav li').each(function() {
    if (!$(this).children('.sub').length) return;
    $(this).hover(function() {
      $(this).addClass('hover');
	  if($(this).attr('id') == 'first') {
		$(this).removeClass('first');
	  }
    }, function() {
      $(this).removeClass('hover');
	  if($(this).attr('id') == 'first') {
		$(this).addClass('first');
	  }
    });
  });
  
  $('.splash').append('<a href="#" class="prev" id="splash-prev">«</a><ul id="splash-nav" /><a href="#" class="next" id="splash-next">»</a>');
  $('.splash-container').cycle({ 
    timeout: 10000,
    pager: '#splash-nav',
    next: '#splash-next',
    prev: '#splash-prev',
    pagerAnchorBuilder: function(idx, slide) { 
      return '<li><a href="#">' + (idx + 1) + '</a></li>'; 
    }
  });
  
  $('input[title], textarea[title]').each(function() {
    var title = $(this).attr('title');
    $(this).addClass('hinted');
    if ($(this).is('input')) {
      $(this).attr('value', title);
      $(this).focus(function() {
        if ($(this).attr('value') == title) {
          $(this).removeClass('hinted').attr('value', '');
        };
      });
      $(this).blur(function() {
        if ($(this).attr('value').length == 0) {
          $(this).addClass('hinted').attr('value', title);
        };
      });
    } else {
      $(this).html(title);
      $(this).focus(function() {
        if ($(this).val() == title) {
          $(this).removeClass('hinted').empty();
        };
      });
      $(this).blur(function() {
        if ($(this).val().length == 0) {
          $(this).addClass('hinted').html(title);
        };
      });
    };
  });
  
  if ($.browser.msie && $('.intro').length) {
    DD_roundies.addRule('.main', '6px');
  };

});
