var loaderImg2 = '<img src="image/ajax-loader2.gif" width="100" height="100" style="margin:0 auto;">';
var ar_bm = { 
"hatena" : "http://b.hatena.ne.jp/entry/image/large/#http://b.hatena.ne.jp/entry/" ,
"yahoo" : "http://num.bookmarks.yahoo.co.jp/image/small/#http://bookmarks.yahoo.co.jp/url?url=" ,
"ld" : "http://image.clip.livedoor.com/counter/medium/#http://clip.livedoor.com/page/" ,
"buz" : "http://api.buzzurl.jp/api/counter/v1/image?url=#http://buzzurl.jp/entry/" ,
"nifty" : "http://api.clip.nifty.com/api/v1/image/counter/#http://clip.nifty.com/entry?url=" ,
"fc2" : "http://bookmark.fc2.com/image/users/#http://bookmark.fc2.com/search/detail?url="
};

var ar_server2 = new Array(
"get/",
"http://seocheki.awe.jp/",
"http://seocheki.bex.jp/",
"http://seocheki.geo.jp/",
"http://seocheki.bulog.jp/",
//"http://seocheki.xrea.cc/",
"http://seocheki.xrea.bz/",
"http://seocheki.happy.nu/"
//"http://seocheki.xrea.jp/"
);


var show = false;

function kw_check(){

	var url = $("#url2").val();

	$("#kw-info").hide();
	$("#kw-frame").hide();
	$("#kw-loader").show();
	
	$.getJSON("get/get-parser2.php?url=" + encodeURIComponent(url), function(data){

		$("#gmo1kw,#gmo2kw,#gmo3kw").html(gmo_pbar);
		$("#kw-loader").hide();
		$("#kw-frame").show();
		$("#box-kw").html(data.table);
	
		//gmo-seo
		bar_len = 1;
		clearInterval(ti);
		ti = setInterval("bar()",800);

		for(i=0;i<=2;i++){
			if(data.word[i]) {
				url = "http://seo-airlines.com/api/keyword/chk.php?apikey=2a44e281dca2633e66126b5f924ed7c6&url=" + encodeURIComponent(url) + "&keyword=" + encodeURIComponent(data.word[i]);
				seo_air_request(url,i+1,"kw")
			}
		}

	});

}

function site_check(){

    var i = ar_server2.length;
    while(i){
        var j = Math.floor(Math.random()*i);
		i--;
        var tmp = ar_server2[i];ar_server2[i] = ar_server2[j]; ar_server2[j] = tmp;
    }


	if(show) clear_form();
	show = true;
	
	var url = $("#url0").val();
	if(url=="") return;

	$("#td-url").html('<a href="' + url + '" target=\"_blank\">' + url + '</a>');
	$("#url1,#url2").val(url);

	$("#td-siteimg").html('<a href="' + url + '" target="_blank"><img src="http://capture.heartrails.com/200x200/cool?' + url + '" width="200" height="200" border="0"></a>');

	$("#td-pr,#td-alexa,#td-title,#td-desc,#td-host,#td-whois,#td-ycate,#td-jlist,#td-slist,#td-emachi,#td-title,#td-desc,#td-kw,#td-h1,#td-outlink,#td-lm,#td-fs,#td-bm-hatena,#td-bm-yahoo,#td-bm-ld,#td-bm-buz,#td-bm-nifty,#td-bm-fc2").html(loaderImg);
	$("#td-gl,#td-gi").html(loaderImgG);
	$("#td-yl,#td-yi").html(loaderImgY);

	$("#css-check").attr("href","http://jigsaw.w3.org/css-validator/validator?uri=" + encodeURIComponent(url) +"&profile=css21&usermedium=all&warning=1&lang=ja");
	$("#html-check").attr("href","http://validator.w3.org/check?uri=" + encodeURIComponent(url) +"&charset=%28detect+automatically%29&doctype=Inline&group=0");
	$("#whois").attr("href","whois.php?w-url=" + url);
	$("#http-header").attr("href","http-header.php?url=" + url);
	$("#outlink").attr("href","outlink.php?url=" + url);
	$("#bl-check").attr("href","backlink.php?url=" + url);
	$("#archive").attr("href","http://web.archive.org/web/*/" + url);
	$("#gad").attr("href","https://www.google.com/adplanner/planning/site_profile#siteDetails?identifier=" + url + "&lp=true");


	//サイトタイトルなど
	$.getJSON("get/get-siteinfo.php?url=" + encodeURIComponent(url) ,function(res){
	
			if(res.stat) {  location.href='./forbidden.php'; return; }

			$("#td-title").html(res.title);
			$("#td-desc").html(res.desc);
			$("#td-kw").html(res.kw);
			$("#td-h1").html(res.h1);
			if(res.inlink) $("#td-outlink").html("外部リンク：" + res.outlink + "　内部リンク：" + res.inlink + '　<a href="outlink.php?url=' + url + '" target="_blank" style="font-size:12px;">全ての発リンクを見る</a>');
				else $("#td-outlink").html("&nbsp;");
			if(res.lastm) $("#td-lm").html(res.lastm + '　<a href="http-header.php?url=' + url + '" target="_blank" style="font-size:12px;">HTTPヘッダを見る</a>');
				else $("#td-lm").html("&nbsp;");
			$("#td-fs").html(res.fsize);
				
			ar_kw = res.kw.split(",");
			$("#word1").val(ar_kw[0]);
			
    });	
	
	//ペイジランク
	$.ajax({
		dataType: "jsonp",
		url: ar_server2[0] + "get-pralexa.php?m=pr&url=" + encodeURIComponent(url),
		success: function(data) {
			$("#td-pr").html(data.val); 
			$("#fakepr").html('<a href="javascript:fakepr_check();">ページランク偽装チェック</a>');

			//ソーシャルブックマーク
			for(key in ar_bm){
				var ar = ar_bm[key].split("#");
				$("#td-bm-" + key).html('<a href="' + ar[1] + url + '" target="_blank"><img src="' + ar[0] + url + '" border="0"></a>');
			}

		},
		error: function(){ $("#td-pr").html("failed"); }
	});

	//アレクサ
	$.ajax({
		dataType: "jsonp",
		url: ar_server2[1] + "get-pralexa.php?m=alexa&url=" + encodeURIComponent(url),
		success: function(data) { $("#td-alexa").html('<a href="http://www.alexa.com/siteinfo/' + url + '" target="_blank">' + data.val + '</a>'); }
	});


	//被リンク・インデックス　グーグル
	$.ajax({
		dataType: "jsonp",
		url: ar_server2[2] + "get-idxlink.php?se=g&url=" + encodeURIComponent(url),
		success: function(data) { 
			var p = encodeURIComponent("link:" + url);
			$("#td-gl").html('<a href="http://www.google.co.jp/search?hl=ja&q=' + p + '&num=20" target="_blank">' + data.link + '</a>');

			p = encodeURIComponent("site:"+url);
			$("#td-gi").html('<a href="http://www.google.co.jp/search?hl=ja&q=' + p + '&num=20" target="_blank">' + data.idx + '</a>');
		}
	});

	//被リンク・インデックス　ヤッホー
	$.ajax({
		dataType: "jsonp",
		url: ar_server2[3] + "get-idxlink.php?se=y&url=" + encodeURIComponent(url),
		success: function(data) { 
			var p = encodeURIComponent("link:" + url);
			$("#td-yl").html('<a href="http://search.yahoo.co.jp/search?p=' + p + '&n=20" target="_blank">' + data.link + '</a>');

			p = encodeURIComponent("site:"+url);
			$("#td-yi").html('<a href="http://search.yahoo.co.jp/search?p=' + p + '&n=20" target="_blank">' + data.idx + '</a>');
		}
		
	});

	//ディレクトリ
	$.ajax({
		dataType: "jsonp",
		url: "get/get-dir.php?url=" + encodeURIComponent(url),
		success: function(data) { 
			$("#td-ycate").html(data.yahoo);
			$("#td-jlist").html(data.jlist);
			$("#td-slist").html(data.slist);
			$("#td-emachi").html(data.emachi);

			//ホスト
			$.ajax({
				dataType: "jsonp",
				url: "http://seocheki.bulog.jp/get-host.php?url=" + encodeURIComponent(url),
				//url: "http://seocheki.net/get/get-host.php?url=" + encodeURIComponent(url),
				success: function(data) { 
					$("#td-host").html(data.host);
					$("#td-whois").html(data.whois);
				}
				
			});
		}
		
	});

}


function clear_form(){

	for(i=1;i<=3;i++){
		$("#kw"+i).html("&nbsp;");
	
		$("#grank"+i).html("&nbsp;");
		$("#yrank"+i).html("&nbsp;");
		$("#word"+i).val("")
	}
	$("#box-kw").html("&nbsp;");
	$("#fakepr").html('&nbsp;');

}

function fakepr_check(){
	var url = $("#url0").val();
	
	$.ajax({
		dataType: "jsonp",
		url: "get/get-fakepr.php?url=" + encodeURIComponent(url),
		success: function(data) { 
			$("#fakepr").html(data.res);
		}
		
	});

}

function show_jpartner(){
	$("#jpartner div").html("<img src='image/jpartner2.jpg'>");
    wx = $(window).scrollLeft() + Math.floor(($(window).width() - $('#jpartner').outerWidth()) / 2);
    wy = $(window).scrollTop() + Math.floor(($(window).height() - $('#jpartner').outerHeight()) / 2);
    $("#jpartner").css({ "top": wy, "left": wx }).fadeIn("fast");
}

function close_jpartner(){
    $("#jpartner").fadeOut("fast");
}









