﻿var helloStr=new Array;
helloStr[0]=["不想<a href=\"#commentform\">说几句</a>吗？","来<a href=\"#commentform\">砸砖</a>吧！"];
helloStr[1]=["做个<a href=\"http://www.xij.cn/blog/?page_id=49#commentform\">友情链接</a>吧:)","公司<a href=\"http://www.xij.cn/blog/?page_id=35#commentform\">招人</a>哦！"];
helloStr[2]=["你<a href=\"http://feeds.feedburner.com/leexij\">订阅</a>了吗？","翻啊翻啊翻出一块砖！"];
helloStr[3]=["你<a href=\"http://feeds.feedburner.com/leexij\">订阅</a>了吗？","抽烟吗？玩dota不？","欢迎加入产品易用性QQ群:14408580"];

function msg(ref,id1,id2){
  $("#msg").html("<em>"+ref+"</em><span>"+helloStr[id1][parseInt(Math.random()*id2)]+"</span>");
}

$(function(){
//随机问候
if($.cookie("ref")==null){
  var ref=document.referrer;
  if(ref){
    ref=ref.replace("http://","");
    ref=ref.indexOf("/")==-1 ? ref : ref.substring(0,ref.indexOf("/"));
	if(ref!=="www.xij.cn"){ref="欢迎来自"+ref+"的朋友:)";$.cookie("ref",ref);}else{ref="欢迎再次光临:)";}
  }else{
    ref="欢迎再次光临:)";
  }
}else{
  var ref=$.cookie("ref");
}
var page=window.location.search;
page=page.substring(1,page.indexOf("="));
switch(page){
  case "p":
  msg(ref,0,helloStr[0].length);
  break;
  case "page_id":
  msg(ref,1,helloStr[1].length);
  break;
  case "paged":
  msg(ref,2,helloStr[2].length);
  break;
  case "cat":
  msg(ref,2,helloStr[2].length);
  break;
  default:
  msg(ref,3,helloStr[3].length);
}

//评论效果
$(".commentlist li").hover(
  function(){
    $(this).addClass("li2");
  },
  function(){
    $(this).removeClass("li2");
  }
);

//内容代码效果
$("code").hover(
  function(){
    $(this).addClass("code2");
  },
  function(){
    $(this).removeClass("code2");
  }
);
 
});