(function(){
	if(wordsFromReferrer&&wordsFromReferrer!=""){
		var word= wordsFromReferrer.replace(/%e3%80%80/g,"\+");
		word= word.replace(/%E3%80%80/g,"\+");
		word= word.replace(/%e3%80%81/g,"\+");
		word= word.replace(/%E3%80%81/g,"\+");
		word= word.replace(/%81%40/g,"\+");
		word= word.replace(/%20/g,"\+");
		word= word.replace(/%2C/g,"\+");
		word= word.replace(/%2B/g,"\+");
		if(word.slice(-1)=="+"){
			word=word.slice(0, -1);
		}
		word=decodeURI(word);
		while (word.search(/\+\+/i) != -1) {
			word= word.replace(/\+\+/g,"\+");
		}
		if(word.slice(-1)=="+"){
			word=word.slice(0, -1);
		}
		if(word.slice(0,1)=="+"){
			word=word.slice(1);
		}
		hintsWord=word.split("+").join(", ");
	}
}
)();


function showArrow(el){
	var iconRnd = Math.floor(Math.random() * 5);
	el.className = "showAdsArrow"+iconRnd;
}


function blockhover(el){
	el.className="blockhoverGeneral";

//el.style.backgroundColor="#eee";
}

function block(el){
	el.className="blockGeneral";
//el.style.backgroundColor="";
}


function hideArrow(el){
	el.className="hideAdsArrow";
}
function jumpAd(url){
	window.location.href=url;
}

function highlight(adCount){
	var replaceTags=Array();
	for (i = 0; i < adCount; i++) {
		replaceTags.push("gAdTitle"+i);
		replaceTags.push("gAdDesc"+i);
	}
	if(replaceTags.length>0){
		for (i = 0; i < replaceTags.length; i++) {
			var gAdUnit=replaceTags[i];
			var adSrc=document.getElementById(gAdUnit);
			var adReplaseHTML=adSrc.innerHTML;
			var hintsWordsCount=hintsWord.split(", ");
			var hintsHighlight=Array();
			for (j = 0; j < hintsWordsCount.length; j++) {
				hintsHighlight[j]='<span style="background-color:#ffff66;color:#333333;border-bottom:1px dotted #333333;">'+hintsWordsCount[j]+'</span>';
				var Replasetag=adReplaseHTML.split(hintsWordsCount[j]);
				var tag="";
				for (k = 0; k < Replasetag.length; k++) {
						if (hintsHighlight[j] !=null) {
							tag = Replasetag.join(hintsHighlight[j]);
						}

				}
				adReplaseHTML=tag;
			}
		adSrc.innerHTML=adReplaseHTML;
		}
	}
}

function google_ad_request_done(google_ads) {

    //if(hintsWord!=""){
    	//	var gadTitle = '<h4>【' + hintsWord + '】に関するスポンサーリンク</h4>';
    	//	document.write(gadTitle);
    	//}

	var s = '';
	var i;

	if (google_ads.length == 0) {
		return;
	}

	if (google_ads[0].type="text" && google_ads.length > 0) {
		s='';
		s += '<div id="adList" class="gadBox">';
		for(i=0; i < google_ads.length; ++i) {
			s += '<div class="hideAdsArrow" id="adCount'+i+'" onmouseover="blockhover(this);" onmouseout="block(this);" onclick="jumpAd(\''+ google_ads[i].url+'\');"><a class="genAnch" onclick="return false;" href="javascript:void(0)">';
			var gad_title ='<span id="gAdTitle'+i+'" class="gadTitle" onclick="return false;" href="javascript:void(0)">'+ google_ads[i].line1+'</span>';
			var gad_url ='<span class="gadDisplayURL">'+google_ads[i].visible_url+'</span>';
			var gad_des ='<span id="gAdDesc'+i+'" class="gadDescription">' + google_ads[i].line2 + google_ads[i].line3 +'</span>';
			s += gad_title + gad_des + gad_url;
			s += '</a></div>';

		}

		s +='</div>';
		s += '<p id="gadLogo">Ads by Google</p>';
	}

    document.write(s);
    if(hintsWord!=""){
		highlight(google_ads.length);
	}
    return;

}

if ( parent==self ){
	google_ad_channel='opt2';
	google_max_num_ads='2';
	if(hintsWord!=""){
	google_hints = hintsWord;
	google_ad_channel='opt1';
	google_max_num_ads='2';
	}
	google_ad_client='ca-cyberagent-ameblo_js';
	google_ad_output='js';
	google_ad_type='text';
	google_language='ja';
	google_encoding ='utf8';
	google_safe='high';
	google_ad_section='s1 s2';
//google_adtest = 'on';

}

