(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 expLimit=new Date();
		//expLimit.setTime(expLimit.getTime()+(1000*60*10));
		expLimit.setTime(expLimit.getTime()+(1000*10));
		var expTime=expLimit.toGMTString();
		document.cookie="hitsTmpWords="+encodeURI(hintsWord)+";+expires="+expTime;
	}
}
)();

var FromSearchEngine = false;
(function(){
	var ref = document.referrer;
	if (/^http:\/\/search\.livedoor\.com\/search/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/sf\.livedoor\.com\/search/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/www\.google\.(co\.jp|com)\/search/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/images\.google\.(co\.jp|com)/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/blogsearch\.google\.co\.jp\/blogsearch/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/search\.yahoo\.co\.jp\/search/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/blog-search\.yahoo\.co\.jp\/search/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/search\.goo\.ne\.jp\/web.jsp/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/blog\.search\.goo\.ne\.jp\/search_goo\/result/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/search\.live\.com\/results\.aspx/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/search\.msn\.co\.jp/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/www\.excite\.co\.jp\/search.gw/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/www\.baidu\.jp/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/blog\.baidu\.jp/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/www\.bing\.com\.search/.test(ref)) FromSearchEngine = true;


	if (/^http:\/\/search\.nifty\.com\/websearch\/search/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/search\.nifty\.com\/blogsearch\/search/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/search\.www\.infoseek\.co\.jp\/Web/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/blogsearch\.fc2\.com/.test(ref)) FromSearchEngine = true;
	if (/^http:\/\/ask\.jp\/web\.asp/.test(ref)) FromSearchEngine = true;
})();



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 linkAmebaSearch(str){
	var link="http://search.ameba.jp/search.html?q="+encodeURI(str);
	location.href=link;


}


var styleBottomObj = {
    generalTitle : {
        fontsize : "14px",
        fontweight : "bold",
        textdecoration : "underline",
        color : "",
        padding : "",
		letterSpacing : "0.4em"
    },
    generalDescription : {
        fontsize : "",
        fontweight : "",
        textdecoration : "",
        color : "",
        padding : "8px 0 2px",
		letterSpacing : ""
    },
    generalUrl : {
        fontsize : "12px",
        fontweight : "",
        textdecoration : "",
        color : "",
        padding : "",
		letterSpacing : "0.4em"
    },
    mouseoverTitle : {
        fontsize : "14px",
        fontweight : "bold",
        textdecoration : "underline",
        color : "#0066CC",
        padding : "",
		letterSpacing : "0.4em"
    },
    mouseoverDescription : {
        fontsize : "",
        fontweight : "",
        textdecoration : "",
        color : "#666666",
        padding : "8px 0 2px",
		letterSpacing : ""
    },
    mouseoverUrl : {
        fontsize : "12px",
        fontweight : "",
        textdecoration : "underline",
        color : "#0066CC",
        padding : "",
		letterSpacing : "0.4em"
    }
};

function gadBottomChangeStyle(gadobj, styleArg){
    gadobj.style.fontSize = styleArg.fontsize;
    gadobj.style.fontWeight = styleArg.fontweight;
    gadobj.style.textDecoration = styleArg.textdecoration;
    gadobj.style.color = styleArg.color;
    gadobj.style.padding = styleArg.padding;
    gadobj.style.letterSpacing = styleArg.letterSpacing;
}

function google_ad_request_done(google_ads) {
	var s ='';
    if(hintsWord!=""){
		var gadTitle = '<h4  onclick="linkAmebaSearch(hintsWord);" style="font-size:1em;cursor:pointer;"><span>【' + hintsWord + '】</span>をアメーバで検索</h4>';

		s += gadTitle;
	}


	var i;

	if (google_ads.length == 0) {
		return;
	}

	if (google_ads[0].type="text" && google_ads.length > 0) {
		s += '<div class="general" class="gadBox">';
		for(i=0; i < google_ads.length; ++i) {
			var gad_title ="";
			var gad_des ='<span class="gadDescription">' + google_ads[i].line2 + google_ads[i].line3 +'</span>';

 			if(hintsWord!=""){

				s += '<div class="blockGeneral" id="gadCount'+i+'" onmouseover="blockhover(this);" onmouseout="block(this);">';
				gad_title ='<a class="genAnch" href="'+ google_ads[i].url+'"><span id="gAdTitle'+i+'" class="gadTitle_s">'+ google_ads[i].line1+'</span></a>';
				var gad_url ='<span class="gadDisplayURL"><a class="genAnch" href="'+ google_ads[i].url+'">'+google_ads[i].visible_url+'</a></span>';
				s += gad_title + gad_des + gad_url;
				s += '</div>';

			}else{

				s += '<div class="blockGeneral" id="gadCount'+i+'" onmouseover="blockhover(this);" onmouseout="block(this);">';
				gad_title ='<a class="genAnch" href="'+ google_ads[i].url+'"><span class="gAdTitle'+i+'" class="gadTitle">'+ google_ads[i].line1+'</span></a>';
				var gad_url ='<span class="gadDisplayURL"><a class="genAnch" href="'+ google_ads[i].url+'">'+google_ads[i].visible_url+'</a></span>';
				s += gad_title + gad_des + gad_url;
				s += '</div>';

			}
		}

		s +='</div>';
		s += '<p class="gadLogo_footer"><a href="'+google_info.feedback_url+ '">Ads by Google</a></p>';
	}
    document.write(s);

    if (google_ads[0].type="text" && google_ads.length > 0) {
        for(j=0; j < google_ads.length; j++){
			var gadHoverCount = document.getElementById("gadCount"+j);
			var spanTagsStyle = gadHoverCount.getElementsByTagName("span");
			for(var n=0; n < spanTagsStyle.length; n++){
				if(spanTagsStyle[n].className == "gadTitle_s"){
					gadBottomChangeStyle(spanTagsStyle[n], styleBottomObj.generalTitle);
				}
				if(spanTagsStyle[n].className == "gAdTitle0"){
					gadBottomChangeStyle(spanTagsStyle[n], styleBottomObj.generalTitle);
				}
                if(spanTagsStyle[n].className == "gadDescription"){
                    gadBottomChangeStyle(spanTagsStyle[n], styleBottomObj.generalDescription);
                }
				var gadATagStyle = gadHoverCount.getElementsByTagName("a");

				var gadUrlSpanTag = gadATagStyle[1].parentNode;
				gadUrlSpanTag.style.textAlign = "left";

				gadBottomChangeStyle(gadATagStyle[1], styleBottomObj.generalUrl);
			}
			gadHoverCount.onmouseover = function(){
				this.style.background = "#EAEFFF";
				var spanTags = this.getElementsByTagName("span");
				for(var k=0; k < spanTags.length; k++){
					if(spanTags[k].className == "gadTitle_s"){
						gadBottomChangeStyle(spanTags[k], styleBottomObj.mouseoverTitle);
					}
					if(spanTags[k].className == "gAdTitle0"){
						gadBottomChangeStyle(spanTags[k], styleBottomObj.mouseoverTitle);
					}
					if(spanTags[k].className == "gadDescription"){
						gadBottomChangeStyle(spanTags[k], styleBottomObj.mouseoverDescription);
					}
				}
				var gadATag = this.getElementsByTagName("a");
				gadBottomChangeStyle(gadATag[1], styleBottomObj.mouseoverUrl);
			}
			gadHoverCount.onmouseout = function(){
				this.style.background = "";
				var spanTags = this.getElementsByTagName("span");
				for(var k=0; k < spanTags.length; k++){
					if(spanTags[k].className == "gadTitle_s"){
						gadBottomChangeStyle(spanTags[k], styleBottomObj.generalTitle);
					}
					if(spanTags[k].className == "gAdTitle0"){
						gadBottomChangeStyle(spanTags[k], styleBottomObj.generalTitle);
					}
					if(spanTags[k].className == "gadDescription"){
						gadBottomChangeStyle(spanTags[k], styleBottomObj.generalDescription);
					}
				}
				var gadATag = this.getElementsByTagName("a");
				gadBottomChangeStyle(gadATag[1], styleBottomObj.generalUrl);
			}
        }
    }

    return;
}




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 ){
	if(article_length==13){
		google_ad_channel="1-3-3";
	}else if(article_length==15){
		google_ad_channel="1-5-5";
	}else if(article_length==110){
		google_ad_channel="1-10-10";
	}
	google_max_num_ads='1';
	if(hintsWord!=""){
		google_hints = hintsWord;

	}else if(tmpHintsWord!=""){
		google_hints = tmpHintsWord;
	}

	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 page1_bCss(){

var cssStart='<style type="text/css">';
var cssEnd='</style>'

var css0='.general .blockGeneral a.genAnch .gAdTitle0{background:url("http://stat100.ameba.jp/blog/ucs/img/char/char2/131.gif") no-repeat right center !important;}';
var css00='.general .blockhoverGeneral a.genAnch .gAdTitle0{background:url("http://stat100.ameba.jp/blog/ucs/img/char/char2/131.gif") no-repeat right center !important;}';

var css1='.general .blockGeneral a.genAnch .gAdTitle1{background:url("http://stat100.ameba.jp/blog/ucs/img/char/char2/131.gif") no-repeat right center !important;}';
var css11='.general .blockhoverGeneral a.genAnch .gAdTitle1{background:url("http://stat100.ameba.jp/blog/ucs/img/char/char2/131.gif") no-repeat right center !important;}';

var css2='.general .blockGeneral a.genAnch .gAdTitle2{background:url("http://stat100.ameba.jp/blog/ucs/img/char/char2/131.gif") no-repeat right center !important;}';
var css22='.general .blockhoverGeneral a.genAnch .gAdTitle2{background:url("http://stat100.ameba.jp/blog/ucs/img/char/char2/131.gif") no-repeat right center !important;}';

var css3='.general .blockGeneral a.genAnch .gAdTitle3{background:url("http://stat100.ameba.jp/blog/ucs/img/char/char2/131.gif") no-repeat right center !important;}';
var css33='.general .blockhoverGeneral a.genAnch .gAdTitle3{background:url("http://stat100.ameba.jp/blog/ucs/img/char/char2/131.gif") no-repeat right center !important;}';

//document.write(cssStart+css0+css00+css1+css11+css2+css22+css3+css33+cssEnd);
}
page1_bCss();
