$(function(){
  $('a[@href^="http"]').not('[@href^="http://www.kenstylesounds.com/"]').attr({ target: "_blank" });
  $('a[@href$=".pdf"]').addClass('pdfLink').attr({ target: "_blank" });
});

$(function(){
  $('#header li a').hover(function(){
  $(this).not('.current').animate({
  height:'44px',
  marginTop:'0',
  marginBottom:'0'},180);
  },function(){
  $(this).not('.current').animate({
  height:'30px',
  marginTop:'5px',
  marginBottom:'9px'},200);
  });
});

$(function(){
  $('#sideMenu dd a,#sideMenu li a').hover(function(){
  $(this).animate({
  color:'#ffffff',
  backgroundColor:'#252525'},60);
  },function(){
  $(this).animate({
  color:'#b0b0b0',
  backgroundColor:'#181818'},400);
  });
  $('div#sideMenu dt:first-child').css({borderTop:'none'});
});

$(function(){
  $('div.sidebox').hover(function(){
  $(this).animate({
  color:'#ffffff',
  backgroundColor:'#303030'},200);
  },function(){
  $(this).animate({
  color:'#b0b0b0',
  backgroundColor:'#1E1E1E'},400);
  });
  $('div.sidebox').corner('6px');
});

$(function(){
  $('#footer dd a,dl.sitemap dd a,div.entryBox li a,div.archives li a').hover(function(){
  $(this).animate({
  color:'#ffffff',
  backgroundColor:'#222222'},60);
  },function(){
  $(this).animate({
  color:'#b0b0b0',
  backgroundColor:'#141414'},400);
  });
});

$(function(){
  $('a[href^=#]').click(function() { 
  var href= this.hash; 
  var $target = $(href == '#top' ? '#top' : href);
  if($target.size()) {
  var top = $target.offset().top;
  $('body,html').animate({scrollTop:top}, 800, 'swing');
  }
  return false;
 });
});

$(function(){
  $('div.date').corner('bl 8px').corner('tr 8px');
});


//▼フォントサイズ変更
$(function(){
  $("#header h1").after('<dl>');
  $("#header dl").append('<dt id="textSize">文字サイズ変更</dt>')
  .append('<dd class="sizeS"><a class="sizeS_on" href="#top">通常の文字サイズ</a></dd>')
  .append('<dd class="sizeM"><a href="#top">大きめの文字サイズ</a></dd>')
  .append('<dd class="sizeL"><a href="#top">大きい文字サイズ</a></dd>');
  $("#header ul").css({marginTop:"25px"});
});

$(function(){
   var currentstyle = readCookie('fontStyle');
   if (currentstyle){
   switchFont(currentstyle);
   };
   $('dd.sizeL a').click(function(){
   switchFont('fontL');
   return false;
   });
   $('dd.sizeM a').click(function(){
   switchFont('fontM');
   return false;
   });
   $('dd.sizeS a').click(function(){
   switchFont('fontS');
   return false;
  });
});
function switchFont(className){
   $('body').removeAttr('class').addClass(className);
   createCookie('fontStyle', className, 60);
};

$(function(){
   var currentstyle = readCookie('FontImage');
   if (currentstyle){
   switchImage(currentstyle);
   };
   $('dd.sizeL a').click(function(){
   switchImage('sizeL_on');
   $('dd.sizeS a').removeAttr('class');
   $('dd.sizeM a').removeAttr('class');
   return false;
   });
   $('dd.sizeM a').click(function(){
   switchImage('sizeM_on');
   $('dd.sizeS a').removeAttr('class');
   $('dd.sizeL a').removeAttr('class');
   return false;
   });
   $('dd.sizeS a').click(function(){
   switchImage('sizeS_on');
   $('dd.sizeM a').removeAttr('class');
   $('dd.sizeL a').removeAttr('class');
   return false;
  });
});
function switchImage(className){
   $('dd.sizeL a').removeAttr('class').addClass(className);
   $('dd.sizeM a').removeAttr('class').addClass(className);
   $('dd.sizeS a').removeAttr('class').addClass(className);
   createCookie('FontImage', className, 60);
};

function createCookie(name,value,days){
   if (days){
   var date = new Date();
   date.setTime(date.getTime()+(days*24*60*60*1000));
   var expires = "; expires="+date.toGMTString();
   }
   else var expires = "";
   document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name){
   var nameEQ = name + "=";
   var ca = document.cookie.split(';');
   for(var i=0;i < ca.length;i++)
   {
   var c = ca[i];
   while (c.charAt(0)==' ') c = c.substring(1,c.length);
   if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
   }
   return null;
}
