//-----clouds--------------//
var cloudspace=new Array();
var stagespace=1000;
cloudspace[1]=new Array(); cloudspace[1]['w']=219; cloudspace[1]['p']=630;
cloudspace[2]=new Array(); cloudspace[2]['w']=128; cloudspace[2]['p']=350;
cloudspace[3]=new Array(); cloudspace[3]['w']=51; cloudspace[3]['p']=900;
cloudspace[4]=new Array(); cloudspace[4]['w']=88; cloudspace[4]['p']=120;
cloudspace[5]=new Array(); cloudspace[5]['w']=219; cloudspace[5]['p']=130;
function volllresize() {
  d=document.body.clientWidth;
  if(d && d>1000) {
    stagespace=d;
  }
}
function initCloud() {
  volllresize();
  window.onresize=volllresize;
  for(i=1;i<cloudspace.length;i++) {
   cloudspace[i]['p']*=d/1000;
  }
  window.int_TJPfloat=setInterval("TJPfloat();",50);
}
window.paused=0;
function TJPmovecloud(cid,pos) {
     if(pos > stagespace && window.paused>0 ) {
      return;
     }
     if(pos+cloudspace[cid]['w']>stagespace) {
     document.getElementById('s_cloud'+cid).style.width=stagespace-pos+'px';
     } else {
     document.getElementById('s_cloud'+cid).style.width=cloudspace[cid]['w']+'px';
     }
     document.getElementById('s_cloud'+cid).style.left=pos+'px';
}
function TJPfloat() {
 if(document.getElementById('inter1')) {
  for(i=1;i<cloudspace.length;i++) {
   if(cloudspace[i]['p'] >= stagespace) {cloudspace[i]['p']=-cloudspace[i]['w'];}
   else if(cloudspace[i]['p'] <= -cloudspace[i]['w']) {cloudspace[i]['p']=stagespace;}
   cloudspace[i]['p']-=1+cloudspace[i]['w']/200;
   TJPmovecloud(i,cloudspace[i]['p']);
  }
 }
}
jQuery(document).ready(function(){
  if (window.isIE6){return;}
  initCloud();
  if($j.browser.msie){return;}
  $j('div.clouds div').hover(
   function(){ $j(this).stop(true, true).animate({opacity:'0',top:'+=10'},1000); return false;},
   function(){ $j(this).stop(true, true).animate({opacity:'1',top:'-=10'},1000); return false;}
  );
});
//------------translate_me-------------------//
function replaceText(elm,oldtext,newtext) {
  jQuery(elm).html(jQuery(elm).html().replace(oldtext,newtext));
}
jQuery(document).ready(function(){
  if(jQuery("#comment_title").html()){
    replaceText("#comment_title","Comments","留言：");
  }
  if(jQuery("#comment_form_title").html()){
    replaceText("#comment_form_title","Add comment","添加留言：");
  }
  if(jQuery("#comments").html()){
    replaceText("#comments",">There are no comments for this post.<",">还没有人留言呢~<");
  }
  if(jQuery(".submit_wrapper input","#comment_form").val()){
    jQuery(".submit_wrapper input").val("我要留言");
  }

  jQuery(".post_read_more","#location_0").each(function(){
    replaceText(this,">Read more<",">阅读全文<");
  });
  jQuery(".archived","#location_0").each(function(){
    replaceText(this,"View older posts","查看更多");
  });
  jQuery(".metadata","#location_0").each(function(){
    replaceText(this," comments<","条留言<");
    replaceText(this," comment<","条留言<");
    replaceText(this,">Posted in <",">分类：<");
    replaceText(this,">Tagged as <",">标签：<");
  });
  jQuery(".input_wrapper","#comment_form").each(function(){
    replaceText(this,"Name: ","你的名字：");
    replaceText(this,"Website: ","你的网站：");
    replaceText(this,"Comment: ","你的留言：");
  });
  jQuery(".blog_component h2","#location_0").each(function(){
    replaceText(this,"Blog posts in ","显示文章分类在：");
    replaceText(this,"Blog search: ","搜索结果：");
    replaceText(this,"and","+");
    replaceText(this,"and","+");
    replaceText(this,"and","+");
    replaceText(this,"and","+");
  });
  jQuery(".paging","#location_0").each(function(){
    replaceText(this,">Displaying posts <",">当前显示 <");
    replaceText(this,">Displaying comments <",">显示留言第 <");
    replaceText(this,"> of <","> 条，共 <");
    replaceText(this,"> in total<","> 条<");
    replaceText(this,"Newer<","上一页<");
    replaceText(this,">Older",">下一页");
    replaceText(this,"No comments found"," ");
    replaceText(this,/Displaying.*all.*comments/,"");
    replaceText(this,/Displaying.*all.*posts/,"");
  });
  jQuery(".recent_comment","#location_1").each(function(){
    replaceText(this," commented on "," 留言在 ");
  });
  jQuery(".archive_links li","#location_1").each(function(){
    replaceText(this,">January ",">一月 ");
    replaceText(this,">February ",">二月 ");
    replaceText(this,">March ",">三月 ");
    replaceText(this,">April ",">四月 ");
    replaceText(this,">May ",">五月 ");
    replaceText(this,">June ",">六月 ");
    replaceText(this,">July ",">七月 ");
    replaceText(this,">August ",">八月 ");
    replaceText(this,">September ",">九月 ");
    replaceText(this,">October ",">十月 ");
    replaceText(this,">November ",">十一月 ");
    replaceText(this,">December ",">十二月 ");
  });
  jQuery(".blog_archive_show_all_link","#location_1").each(function(){
    replaceText(this,"Show all...","列出全部...");
  });
});
//-------post_type--------//
$j(document).ready(function(){
if (window.isIE6){return;}
$j(".post_wrapper").each(function(){
    if($j(this).children(".metadata").children(".category").text().indexOf("Blog")!=-1){
      $j(this).children(".date").css("background","url(/assets/snowpink/post-icons.png) no-repeat left top");
    }else if($j(this).children(".metadata").children(".category").text().indexOf("相册")!=-1){
      $j(this).children(".date").css("background","url(/assets/snowpink/post-icons.png) no-repeat left -38px");
    }else if($j(this).children(".metadata").children(".category").text().indexOf("音乐")!=-1){
      $j(this).children(".date").css("background", "url(/assets/snowpink/post-icons.png) no-repeat left -194px");
    }else if($j(this).children(".metadata").children(".category").text().indexOf("留言")!=-1){
      $j(this).children(".date").css("background", "url(/assets/snowpink/post-icons.png) no-repeat left -156px");
    }
});

});
//-----defaultvalue------//
(function($) {
  $.fn.defaultvalue = function() {
    var elements = this;
    var args = arguments;
    var c = 0;
    return(
      elements.each(function() {
        var el = $(this);
        var def = args[c++];
        el.val(def).focus(function() {
          if(el.val() == def) {
            el.val('');
          }
          el.blur(function() {
            if(el.val() == '') {
              el.val(def);
            }
          });
        });
      })
    );
  }
})(jQuery);
jQuery(document).ready(function(){jQuery('#blog_search,#new_comment_email').defaultvalue('搜索...','用做与您联系')});
//-------ddtips-----//
$j(document).ready(function(){
  $j('.ddtip').mouseover(function(){
    var tipcontent=$j(this).children('.tipcontent');
    var thisht=tipcontent.css('max-height');
    tipcontent.stop().animate({height:thisht},{queue:false, duration:500, easing: 'easeOutBounce'})
  });
  $j('.ddtip').mouseout(function(){
    $j(this).children('.tipcontent').stop().animate({height:'0'},{queue:false, duration:500, easing: 'easeOutBounce',complete:function(){$j(this).css('display','none')}})
  });
});
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend( jQuery.easing,
{  
  easeOutBounce: function (x, t, b, c, d) {
    if ((t/=d) < (1/2.75)) {
      return c*(7.5625*t*t) + b;
    } else if (t < (2/2.75)) {
      return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
    } else if (t < (2.5/2.75)) {
      return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
    } else {
      return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
    }
  }
});
//---lightBox------//
$j(document).ready(function(){
   $j("a[rel^='prettyPhoto']").prettyPhoto({
     animationSpeed:'fast',
     padding:30,
     showTitle:false,
     theme:'light_rounded',
     showDescription:false });
});
//---scrollTo----//
(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
jQuery(function($){
    $('#backtop').click(function(){
        $.scrollTo(0,2500,{easing:'easeOutBounce'});
        return false;
    });
    $('#gotocomment').click(function(){
        $.scrollTo('#comment_form_area',2500,{easing:'easeOutBounce'});
        return false;
    });
});
//-----Color-----//
(function(jQuery){jQuery.each(['backgroundColor','borderBottomColor','borderLeftColor','borderRightColor','borderTopColor','color','outlineColor'],function(i,attr){jQuery.fx.step[attr]=function(fx){if(fx.state==0){fx.start=getColor(fx.elem,attr);fx.end=getRGB(fx.end);}
fx.elem.style[attr]="rgb("+[Math.max(Math.min(parseInt((fx.pos*(fx.end[0]-fx.start[0]))+fx.start[0]),255),0),Math.max(Math.min(parseInt((fx.pos*(fx.end[1]-fx.start[1]))+fx.start[1]),255),0),Math.max(Math.min(parseInt((fx.pos*(fx.end[2]-fx.start[2]))+fx.start[2]),255),0)].join(",")+")";}});function getRGB(color){var result;if(color&&color.constructor==Array&&color.length==3)
return color;if(result=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
return[parseInt(result[1]),parseInt(result[2]),parseInt(result[3])];if(result=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
return[parseFloat(result[1])*2.55,parseFloat(result[2])*2.55,parseFloat(result[3])*2.55];if(result=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
return[parseInt(result[1],16),parseInt(result[2],16),parseInt(result[3],16)];if(result=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
return[parseInt(result[1]+result[1],16),parseInt(result[2]+result[2],16),parseInt(result[3]+result[3],16)];return colors[jQuery.trim(color).toLowerCase()];}
function getColor(elem,attr){var color;do{color=jQuery.curCSS(elem,attr);if(color!=''&&color!='transparent'||jQuery.nodeName(elem,"body"))
break;attr="backgroundColor";}while(elem=elem.parentNode);return getRGB(color);};var colors={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]};})(jQuery);
$j(document).ready(function(){
    var ua=navigator.userAgent;
    var isWebkit=$j.browser.safari&&/Safari\/[5-9]/.test(ua);
    var isOpera=$j.browser.opera;
    if(isWebkit||window.isIE6||isOpera){return;}
    var contentlink=$j('.post_wrapper .content p a');
    contentlink.animate({backgroundColor:'#181818',color:'#009FCC'},100);
    contentlink.hover(
        function(){$j(this).stop(true,true).animate({backgroundColor:'#2580a2',color:'white'},600);},
        function(){$j(this).stop(true,true).animate({backgroundColor:'#181818',color:'#009FCC'},600);}
    );
});
//----feed hover----/
$j(document).ready(function(){
  var feedhover=$j('#feedhover');
  feedhover.animate({top:'20'},100);
  $j('#feed').hover(
      function(){feedhover.stop(true, true).animate({top:'27'},{queue:false,duration:400}).fadeIn(400)},
      function(){feedhover.stop(true, true).animate({top:'20'},{queue:false,duration:400}).fadeOut(400)}
  );
});
