/**
 * リファラを取得し、Yahoo、Googleからやってきた場合は個人のURLに
 * 変換するスクリプト
 */

function check21(){
 var url = location.href;       //現在のURL
 var refa = document.referrer;  //リファラ
 
 if(refa=="") return; //リファラが取れないときは処理しない
 //googleかyahooか？
 if(refa.match(/^http:\/\/www\.google\.co\.jp\//)!=null) jump(url);
 if(refa.match(/^http:\/\/www\.google\.com\//)!=null) jump(url);
 if(refa.match(/^http:\/\/www\.yahoo\.co\.jp\//)!=null) jump(url);
 if(refa.match(/^http:\/\/search\.yahoo\.co\.jp\//)!=null) jump(url);
}

function jump(url){
 var sitehref = "http://www.japanknowledge.com";
 if(url.match(sitehref)==null){
   var nefa = url.replace(/.*\.([a-zA-Z0-9\-]+\.)(com|co\.jp|ne\.jp)/, sitehref);
   location.href=nefa;
 }
}

