
(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(", ");
	}
}
)();

var FromSearchEngineFooter = false;
(function(){
	var ref = document.referrer;
	if (/^http:\/\/search\.livedoor\.com\/search/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/sf\.livedoor\.com\/search/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/www\.google\.(co\.jp|com)\/search/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/images\.google\.(co\.jp|com)/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/blogsearch\.google\.co\.jp\/blogsearch/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/search\.yahoo\.co\.jp\/search/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/blog-search\.yahoo\.co\.jp\/search/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/search\.goo\.ne\.jp\/web.jsp/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/blog\.search\.goo\.ne\.jp\/search_goo\/result/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/search\.live\.com\/results\.aspx/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/search\.msn\.co\.jp/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/www\.excite\.co\.jp\/search.gw/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/www\.baidu\.jp/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/blog\.baidu\.jp/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/www\.bing\.com\.search/.test(ref)) FromSearchEngineFooter = true;


	if (/^http:\/\/search\.nifty\.com\/websearch\/search/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/search\.nifty\.com\/blogsearch\/search/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/search\.www\.infoseek\.co\.jp\/Web/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/blogsearch\.fc2\.com/.test(ref)) FromSearchEngineFooter = true;
	if (/^http:\/\/ask\.jp\/web\.asp/.test(ref)) FromSearchEngineFooter = true;
})();


function showArrow(el){
	var iconRnd = Math.floor(Math.random() * 5);
		el.className = "showAdsArrow"+iconRnd;
}


function blockhover(el){
	//el.className="blockhoverGeneral";
	el.className="blockGeneral blockGeneralHover";

//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 replaceTitleTags=Array();
	var replaceDescTags=Array();
	for (i = 0; i < adCount; i++) {
		replaceTitleTags.push("gAdTitle"+i+"_footer");
		replaceDescTags.push("gadDescription");
	}
	if(replaceTitleTags.length>0){
		for (i = 0; i < replaceTitleTags.length; i++) {
			var gAdUnit=replaceTitleTags[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;">'+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;
		}
	}
	if(replaceDescTags.length>0){
		for (i = 0; i < replaceDescTags.length; i++) {
			function elementsByClassName(className){
				 var d = document, nodes = [], item;
				 try { // XPathをサポートしているならこれを使う
				 var xp = d.evaluate(
				   './/'+'*'+'[contains(concat(" ", @class, " "), " '+className+' ")]',
				    d, null, XPathResult.ANY_TYPE, null
				  );
				  for (item = xp.iterateNext(); item; item = xp.iterateNext()){
				   nodes.push(item);
				  }
				 } catch(e){ // そうでなければ地道にDOM解析
				 var cls, items = d.getElementsByTagName('*');
				  for(var i = 0, l = items.length; i < l; i++){
				   item = items[i];
				   if(item.className){
				    cls = item.className.split(/¥s+/);
				    for(var j = 0, k = cls.length; j < k; j++){
				     if(cls[j]==className){
				      nodes[nodes.length] = item; break;
				     }
				    }
				   }
				  }
				 }
				 return nodes.length > 0 ? nodes : null;
			}

			var descClass = elementsByClassName("gadDescription");
			var adSrc= descClass[descClass.length-1];
			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;">'+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 highlight2(adCount){

	var replaceTitleTags=Array();
	var replaceDescTags=Array();
	for (i = 0; i < adCount; i++) {
		replaceTitleTags.push("gAdTitle"+i+"_footer");
		replaceDescTags.push("gadDescription");
	}
	if(replaceTitleTags.length>0){
		for (i = 0; i < replaceTitleTags.length; i++) {
			var gAdUnit=replaceTitleTags[i];
			var adSrc=document.getElementById(gAdUnit);
			var adReplaseHTML=adSrc.innerHTML;
			var hintsWordsCount=tmpHintsWord.split(", ");
			var hintsHighlight=Array();
			for (j = 0; j < hintsWordsCount.length; j++) {
				hintsHighlight[j]='<span style="background-color:#ffff66;color:#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;
		}
	}
	if(replaceDescTags.length>0){
		for (i = 0; i < replaceDescTags.length; i++) {
			function elementsByClassName(className){
				 var d = document, nodes = [], item;
				 try { // XPathをサポートしているならこれを使う
				 var xp = d.evaluate(
				   './/'+'*'+'[contains(concat(" ", @class, " "), " '+className+' ")]',
				    d, null, XPathResult.ANY_TYPE, null
				  );
				  for (item = xp.iterateNext(); item; item = xp.iterateNext()){
				   nodes.push(item);
				  }
				 } catch(e){ // そうでなければ地道にDOM解析
				 var cls, items = d.getElementsByTagName('*');
				  for(var i = 0, l = items.length; i < l; i++){
				   item = items[i];
				   if(item.className){
				    cls = item.className.split(/¥s+/);
				    for(var j = 0, k = cls.length; j < k; j++){
				     if(cls[j]==className){
				      nodes[nodes.length] = item; break;
				     }
				    }
				   }
				  }
				 }
				 return nodes.length > 0 ? nodes : null;
			}

			var descClass = elementsByClassName("gadDescription");
			//var adSrc= descClass[descClass.length-1];
			var adSrc= descClass[descClass.length-1-i];
			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;">'+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) {
	var s = '';
	var i;

	if (google_ads.length == 0) {
		return;
	}

	if (google_ads[0].type="text" && google_ads.length > 0) {
		var dat_title_class = '';

		if(hintsWord!=""){
			gad_title_class ='gadTitle_s';
		}else{
			gad_title_class ='gadTitle';
		}

		s += '<div class="gadBox">';

		for(i=0; i < google_ads.length; ++i) {
			var google_ad = google_ads[i];

			var gad_title = '<a class="gadTitle" href="'+google_ad.url+'">';
			gad_title    += '<span id="gAdTitle'+i+'_footer" class="' + gad_title_class + '">'+ google_ad.line1 +'</span>';
			gad_title    += '</a>';

			var gad_des ='<span class="gadDescription">' + google_ad.line2 + google_ad.line3 +'</span>';

			var gad_url ='<span class="gadDisplayURL">';
			gad_url    +='<a class="gadTitle_footer" href="'+google_ad.url+'">'+google_ad.visible_url+'</a>'
			gad_url    +='</span>';

			s += '<div class="blockGeneral" onmouseover="blockhover(this);" onmouseout="block(this);">';
			s += gad_title + gad_des + gad_url;
			s += '</div>';
		}

		s += '<p class="gadLogo"><a href="'+google_info.feedback_url+ '">Ads by Google</a></p>';
		s +='</div>';
	}

        //ieだとfooterCss内でdocument.writeした<style>がここで消える
	//document.getElementById("advertising3").innerHTML += s;
	document.write(s);
    if(hintsWord!=""){
		highlight(google_ads.length);
	}
    else if(tmpHintsWord!=""){
		highlight2(google_ads.length);
	}
    return;
}

//function makeAd_channel(){
//
//	var channel="ameblo";
//	var pageURL=location.href;
//	if(/ameblo.jp\//.test(pageURL)){
//	//if(/kariblo.jp\//.test(pageURL)){
//			var pageURLtail=pageURL.split("ameblo.jp\/")[1].split("/")[1];
//			//var pageURLtail=pageURL.split("kariblo.jp\/")[1].split("/")[1];
//
//			if(/day/.test(pageURLtail)||/theme/.test(pageURLtail)||/archive/.test(pageURLtail)){channel="opt9";
//			}else if(/page-/.test(pageURLtail)){
//				channel="opt11";
//			}else if(/entry-/.test(pageURLtail)){
//				channel="opt12";
//			}else{
//				channel="opt8";
//			}
//	}
//	return channel;
//}

function google_hints_cookie(){
	var savedHintsWord="";
	var cookieStr=document.cookie+";";
	var cookieName="hitsTmpWords=";
	var start=cookieStr.indexOf(cookieName);
	if(start>-1){
		var end=cookieStr.indexOf(";",start);
		savedHintsWordEn=cookieStr.substring(start+cookieName.length,end);
		savedHintsWord=decodeURI(savedHintsWordEn);
	}

	return savedHintsWord;
}

var tmpHintsWord=google_hints_cookie();


if ( parent==self ){

	google_ad_channel='opt3';
//	google_ad_channel=makeAd_channel();
//	google_max_num_ads='3';
	if(hintsWord!=""){
		google_hints = hintsWord;
		google_ad_channel='opt6';
//		google_ad_channel='opt1';
//		google_max_num_ads='4';

	}else if(tmpHintsWord!=""){
		google_hints = tmpHintsWord;
		google_ad_channel='opt7';
//		google_ad_channel='opt10';
//		google_max_num_ads='3';
//
//	}else if(google_ad_channel=='opt12'){
//
//		if(meta_words){
//			google_hints =meta_words.replace(",ブログ,アメブロ,アメーバ,ameba","");
//		}
//
//
//	}else if("entryLeaveFlg" in window && entryLeaveFlg){
//
//			google_max_num_ads='5';
//			google_ad_channel='opt5';
//
//	}else if(google_ad_channel=='opt8'||google_ad_channel=='opt11'){
//
//		if(theme_words){
//			google_hints =meta_words.replace(",ブログ,アメブロ,アメーバ,ameba","");
//			var theme_word2="";
//			for (i = 0; i < theme_words.length; i++) {
//				if(theme_words[i]!="ブログ"){
//					theme_word2 +=theme_words[i]+",";
//				}
//			}
//			google_hints=theme_word2;
//		}
//
//
//
//	}else if("adEntryIndex" in window && adEntryIndex > 0){
//		google_ad_channel='opt11';
//


	}else if(FromSearchEngineFooter){

			google_ad_channel='opt3';
//			google_max_num_ads='4';
//			google_ad_channel='opt4';


	}




//	google_ad_channel='opt3';
	google_max_num_ads='2';
	//google_skip = '3';
	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_feedback = 'on';
//google_adtest = 'on';
}

function footerCss(){

var cssStart='<style type="text/css">';
var cssEnd='</style>'


var css0='#gadFooter.gadBox{width:95%;font-size:1.2em;}';
var css1=".gadDescription_footer{text-underline:none;}";
//var css2='#gadFooter.gadBox .gadDisplayURL_footer{display:block;font-size:0.85em;text-align:right;}';
var css2='';
var css3='.gadTitle{font-weight:bold;letter-spacing:0.4em;text-decoration:underline;}';
var css4='.gadTitle_s{font-weight:bold;letter-spacing:0.4em;text-decoration:underline;}';
var css5='.gadDescription{padding:8px 0 2px;}';
var css6='.gadDisplayURL_footer{text-align:left;padding:0;}';
var css7='.gadTitle_footer{letter-spacing:0.4em;}';

//document.write(cssStart+css0+css1+css2+cssEnd);
document.write(cssStart+css0+css1+css2+css3+css4+css5+css6+css7+cssEnd);

}

footerCss();

