$(function() {
    $('.entry-list li:nth-child(odd)').css({
      backgroundColor:'#EBEBEB'
    });
    
    function linker(str){
    	$(str).hover(
    		function(){ $(this).fadeTo("fast", 0.7); },
    		function(){ $(this).fadeTo("fast", 1); });
    	$(str).click(
    		function(){ $(this).fadeTo("fast", 1); });
    }
    
    linker("#nav a");
    linker("#banners img");
    linker(".title a");
    linker("#side-banners img");
    linker("#foot-banners img");
    linker("#about a");
    linker(".photo img");
    linker("#go-header a");
    linker("#searchsubmit");
    linker(".view-detail");   
    linker(".view-all");    
    
});

//ポスト内の画像の横幅を制限
$(function(){
 var mw = 520; //最大幅を指定
 var sl = '.post img'; //jQueryセレクタ記述
 $(sl).each(function(){
  var w=$(this).width();
  if (w>mw) {
   $(this).height($(this).height()*(mw/w)).width(mw);
  }
 });
});

jQuery.event.add(window, "load", function(){
	
    $('#results .photo img').each(function(){
    	var l = 200;
        var w = $(this).width();
        var h = $(this).height();
        if (w < l) {
            $(this).css('margin-left',(l - w )/2);
        }
        if (h < l){
            $(this).css('padding-top',(l - h )/2);
        }
    });
    
    $('#photos .photo img').each(function(){
    	var l = 168;
        var w = $(this).width();
        var h = $(this).height();
        if (w < l) {
            $(this).css('margin-left',(l - w )/2);
        }
        if (h < l){
            $(this).css('padding-top',(l - h )/2);
        }
    });
    
    $('#random-gallery .photo img').each(function(){
    	var l = 168;
        var w = $(this).width();
        var h = $(this).height();
        if (w < l) {
            $(this).css('margin-left',(l - w )/2);
        }
        if (h < l){
            $(this).css('padding-top',(l - h )/2);
        }
    });

    $('#photos li:nth-child(odd)').css('margin-right','3px');
    
    //.pngFix();
    
}); 