/* ぴゅあどら基本JS */

var mono_flg = 0; //モノトーンフラグ 1:モノトーン

/* message ===================================================== */
/*** トップメッセージ ***/
function docTopMsg() {

	var flg = 0;// 出力フラグ
	document.write('<div id="topmsg">');
	if( flg==1 ) {

		document.write('<h1>ごあいさつ - 2011.03.19</h1><p>');
		document.write('3月11日（金）に発生した東日本大震災で亡くなられた方々のご冥福を心よりお祈り申し上げます。<br />あわせて私も含め被災地で過ごされる皆さんに励ましの意味も込めて応援を申し上げます。<br />');
		document.write('<br />');
		document.write('がんばろう、東北。<br />がんばろう、関東。<br />');
		document.write('<br />');
		document.write('</p>');

	}
	document.write('</div>');
}


/* header ====================================================== */

/*** ヘッダ ***/
function docHD() {
	docSearch();
	docHeadder();

/*
	if( mono_flg==1 ) {
		document.header.style.backgroundImage = "url(http://pyuadora.com/img/header_bg_m3.jpg)";
	} else {
		document.header.style.backgroundImage = "url(http://pyuadora.com/img/header_bg.jpg)";
	}
*/
	document.body.style.backgroundRepeat = "no-repeat";
	document.body.style.backgroundPosition = "right top";

}

function docHeadder() {

	document.write('<div id="site_identity">');
	document.write('	<div id="site_logo">');

	if( mono_flg==1 ) {

		// モノクロモード
		document.write('	<div onmouseover="document.site_logo1.src=\'http://pyuadora.com/img/PDPlogo_Gra.png\';" onmouseout="document.site_logo1.src=\'http://pyuadora.com/img/PDPlogo_Gra_m.png\';">');
		docHeadderSiteLogo(mono_flg);
		document.write('	</div>');
	} else {
		docHeadderSiteLogo(mono_flg);
	}
	document.write('	</div>');
	document.write('	<br class="cl" />');
	document.write('</div>');
}

function docHeadderSiteLogo(num) {
	document.write('<a href="http://pyuadora.com/">');
	if( num==1 ) {
		document.write('<img name="site_logo1" src="http://pyuadora.com/img/PDPlogo_Gra_m.png" alt="" class="logo" />');
	} else {
		document.write('<img name="site_logo1" src="http://pyuadora.com/img/PDPlogo_Gra.png" alt="" class="logo" />');
	}
	document.write('	<div id="site_name" />ぴゅあどら</div>');
	document.write('</a>');
	document.write('<div id="site_about">クルマを愛するすべての人へコラムを綴っています。<br />全ページ無断リンクOK。　');
	document.write('（管理人：<a href="http://pyuadora.com/about/index.htm#about_author">まさひろ</a>）</div>');
}

/*** キーワード検索 ***/
function docSearch() {
	/* 自前検索システム */
	document.write('<div id="srch">');
	document.write('	<form method="post" action="http://pyuadora.com/data/wwwsrch.cgi" class="srchbox" name="srchb"><div>');
	document.write('		<input type="text" placeholder="　Site Search" size="45" class="word" name="WORD" tabindex="1" accesskey="s" />');
	document.write('		<input type="submit" value="サイト内検索" class="btn" />');
	document.write('	</div></form>');
	document.write('</div>');
}


/* contents ==================================================== */

/**** 注意！ ****/
function docHardSign(){
	document.write('<!-- Hard Sign -->');
	document.write('<div id="hardsign">');
	document.write('	<h2>注意</h2><p>');
	document.write('	このコラムには挑戦的な表現が含まれています。<br /><br />');
	document.write('	他人を貶めたり故意に不快を与えるつもりではなく、あくまでも警告のつもりで書いておりますが、');
	document.write('	挑戦的な表現に不快感を感じる方は、読み飛ばすことを強くおすすめします。');
	document.write('	&gt; <a href="http://pyuadora.com/column/">コラム一覧</a><br />');
	document.write('	</p>');
	document.write('</div>');
}

/**** PRリンク ****/
function docPrClmAfter() {
	var now = new Date();
	var tm = now.getSeconds();
	document.write('<div id="affili">');

	document.write('	<!-- PR -->');
	document.write('	[PR] <a href="http://www.zubat.net/car-hoken/promo/?ID=abeaw00048" target="_top">ズバット自動車保険比較</a>：満期が近づいたら、一気に見積りましょう！<br />');

	document.write('</div>');
}


/**** ツイッターウィジェット関連 ****/
function docTwBtnParts(){
	var strurl = window.location.href;

	document.write('<div style="float:left;padding-right:5px;margin-right:5px;" class="icon_twitter">');
	document.write('<span onmouseover="document.site_Twittericon11.src=\'http://pyuadora.com/img/ico_twi.png\';" onmouseout="document.site_Twittericon11.src=\'http://pyuadora.com/img/ico_twi_mono3.png\';">');
	document.write('	<a href="http://twitter.com/share?count=horizontal&amp;original_referer='+strurl+'&amp;url='+strurl+'&amp;via=masahiro_pdp">');
	document.write('	<img name="site_Twittericon11" alt="" width="16" height="16" style="vertical-align:middle;" src="http://pyuadora.com/img/ico_twi_mono3.png"></a> ');
	document.write('</span>');
	document.write('<span onmouseover="document.site_Twittericon11.src=\'http://pyuadora.com/img/ico_twi.png\';" onmouseout="document.site_Twittericon11.src=\'http://pyuadora.com/img/ico_twi_mono3.png\';">');
	document.write('	<a href="http://twitter.com/share?count=horizontal&amp;original_referer='+strurl+'&amp;url='+strurl+'&amp;via=masahiro_pdp" target="_blank">ツイートする</a>');
	document.write('</span>');
	document.write('</div>');
}

/**** Facebookウィジェット関連 ****/
function docFBBtnParts(){
	var strurl = window.location.href;

//	document.write('<iframe src="http://www.facebook.com/plugins/like.php?app_id=124576220974076&amp;href='+strurl+'&amp;send=false&amp;layout=button_count&amp;width=450&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:20px;"></iframe>');

	document.write('<div style="float:left;padding-right:5px;margin-right:5px;" class="icon_facebook">');
	document.write('<span onmouseover="document.site_facebookicon11.src=\'http://pyuadora.com/img/ico_facebook.png\';" onmouseout="document.site_facebookicon11.src=\'http://pyuadora.com/img/ico_facebook_mono.png\';">');
	document.write('	<a href="http://www.facebook.com/share.php?u='+strurl+'">');
	document.write('	<img name="site_facebookicon11" alt="" width="16" height="16" style="vertical-align:middle;" src="http://pyuadora.com/img/ico_facebook_mono.png"></a> ');
	document.write('</span>');
	document.write('<span onmouseover="document.site_facebookicon11.src=\'http://pyuadora.com/img/ico_facebook.png\';" onmouseout="document.site_facebookicon11.src=\'http://pyuadora.com/img/ico_facebook_mono.png\';">');
	document.write('	<a href="http://www.facebook.com/share.php?u='+strurl+'">シェア（いいね！）</a>');
	document.write('</span>');
	document.write('</div>');


}


/**** メッセージ送信 ****/
function docMsg(){
	document.write('<div id="docMessageFrame">');
	document.write('<h3>管理人にメッセージを送る</h3>');

	document.write('	<form method="post" action="http://pyuadora.com/data/wwwmail.cgi">');
	document.write('		<table>');
	document.write('			<tr><td class="right">name:</td><td colspan="2"><input type="text" size="50" name="name" placeholder="　Your name"></td></tr>');
	document.write('			<tr><td class="right">mail:</td><td><input type="email" size="50" name="email" placeholder="　Your Email"></td><td style="font-size:100%;"> (未入力時は返答を避けます)</td></tr>');
	document.write('			<tr><td class="right">message:</td><td colspan="2"><textarea cols="50" rows="3" name="message" placeholder=" Your messages"></textarea></td></tr>');
	document.write('			<tr><td>&nbsp;<input type="hidden" name="url" value="' + document.URL + '"></td><td colspan="2"><input type="submit" class="btn" value=" 送信 "></td></tr>');
	document.write('		</table>');
	document.write('	</form>');

	document.write('</div><br class="cl" />');
}


/*** コラム後 ***/
function docAF() {
}

/*** コンテンツフッタ ***/
function docFT() {
}


/* sidebar ===================================================== */
function docSidemenu1() {
	docProfile();
}
function docSidemenu2() {
	docCurrentClm(2);
	docCateLinkAfterClm(2);
	docToolLink(2);
	docLink();	//リンク
	docTwbar();	//twitterブログパーツ
}

function docProfile(){
	document.write('<div id="docProfile">');
	document.write('	<h3 class="about">管理人</h3>');
	document.write('	<ul class="aboutauthor">');
	document.write('		<li class="prof">');
	document.write('			<a href="http://pyuadora.com/about/index.htm#about_author">');

	if( mono_flg==1 ) {
		document.write('				<img src="http://pyuadora.com/img/profile_pleo_m2.jpg" alt="管理人近影" />');
	} else {
		document.write('				<img src="http://pyuadora.com/img/profile_pleo_m1.jpg" alt="管理人近影" />');
	}
	document.write('			</a>');
	document.write('		</li>');

	document.write('		<li class="prof">管理人：');
	document.write('			<a href="http://pyuadora.com/about/index.htm#about_author">まさひろ</a>');
	document.write('		</li>');
	document.write('		<li>『ドライビングで魅了せよ』をコンセプトに「運転技術だけでなく人生でも他人を魅了できる人間を目指そう」という想いをこめてコラムを綴っています。</li>');
	document.write('	</ul>');
	document.write('	<ul class="icons1">');
	docIconsList1(1);
	document.write('	</ul>');
	document.write('</div>');
}

/*** カテゴリ別リンク ***/
function docCateLinkAfterClm(num) {
	document.write('<div class="docCateLinkAfterClm">');
	document.write('	<h3>カテゴリ</h3>');

	document.write('	<div class="CateLinkArea">');
	document.write('		<ul class="">');
		docRelLink(18);	// 人間
		docRelLink(11);	// 精神
		docRelLink(9);	// 言葉
		docRelLink(17);	// 時間
		docRelLink(1);	// お金
		docRelLink(0);	// すべて
	document.write('		</ul>');
	document.write('	</div>');
	document.write('</div>');
}

/*** コラムカテゴリイメージ表示 ***/
function docCateImg(k,strCat) {
	switch (k) {
		case  0:
		case  3:
		case 10:
		case 12:
		case 13:
		case 15:
			break;
		default:

			/* イメージ画像統合 */
			switch (k) {
				case  6:
				case  7:
				case  14:
					k = 17;	break;
				case  1:
				case  2:
				case  4:
				case  5:
				case  8:
				case  9:
				case  11:
				case  16:
					k = 18;	break;
			}

			var num = ('00' + k).slice(-2);
			document.write('<div class="catelnk">');
			document.write('	<div id="cateimg1">');
			document.write('		<a href="http://pyuadora.com/column/index_cat.htm?c=' + k + '" title="「' + strCat + '」カテゴリ">');
			document.write('			<div class="cateimgset">');
			document.write('				<img src="http://pyuadora.com/img/cate_img/'+num+'_m.jpg" alt="" class="cateimg" />');
			document.write('				<img src="http://pyuadora.com/img/cate_img/'+num+'.jpg" alt="" class="cateimg_z" />');
			document.write('			</div>');
			document.write('		</a>');
			document.write('	</div>');
			document.write('	<div class="catelnktext">');
			document.write('		<img src="http://pyuadora.com/img/ico_list.png" alt="" />&nbsp;');
			document.write('		<a href="http://pyuadora.com/column/index_cat.htm?c=' + k + '">「'+ strCat + '」カテゴリ</a>');
			document.write('	</div>');
			document.write('</div>');
			break;
	}
}

/*** 便利ツールリンク ***/
function docToolLink(num) {
	var intCnt = defCateCnt(19);
	document.write('<div class="ToolLink">');
	document.write('<h3>シミュレータ</h3>');

	document.write('<div class="CateLinkArea">');
	document.write('<ul class="">');
		document.write('<li><a href="http://pyuadora.com/about/buycarsim.htm">自動車購入費用</a></li> ');
		document.write('<li><a href="http://pyuadora.com/about/ijisim.htm">自動車維持費</a></li> ');
		document.write('<li><a href="http://pyuadora.com/about/loansim.htm">自動車ローン</a></li> ');
		document.write('<li><a href="http://pyuadora.com/about/gearratiosim.htm">ギアレシオ</a></li> ');
		document.write('<li><a href="http://pyuadora.com/about/tools.htm">すべて ('+intCnt+')</a></li> ');
	document.write('</ul>');
	document.write('</div>');

	document.write('</div>');
}

/*** メニューリンク ***/
function docMenuLink(num) {
	document.write('<div class="MenuLink">');
	document.write('<h3>menu</h3>');

	document.write('<div class="CateLinkArea">');
	document.write('<ul class="">');
		document.write('<li><a href="http://pyuadora.com/">トップ</a></li> ');
		document.write('<li><a href="http://pyuadora.com/column/">コラム</a></li> ');
		document.write('<li><a href="http://pyuadora.com/about/tools.htm">便利ツール</a></li> ');
		document.write('<li><a href="http://pyuadora.com/about/">サイト概要</a></li> ');
		document.write('<li><a href="http://pyuadora.com/about/mail.htm">メール</a></li> ');
	document.write('</ul>');
	document.write('</div>');

	document.write('</div>');
}

/*** アイコン ***/
function docIconsList1(num) {

	/* Facebook */
	document.write('<li class="icon_facebook">');
	document.write('<span onmouseover="document.site_facebookicon'+num+'.src=\'http://pyuadora.com/img/ico_facebook.png\';" onmouseout="document.site_facebookicon'+num+'.src=\'http://pyuadora.com/img/ico_facebook_mono.png\';">');
	document.write('	<a href="http://www.facebook.com/profile.php?id=100001016525220" target="_blank">');
	document.write('	<img name="site_facebookicon'+num+'" alt="" width="16" height="16" src="http://pyuadora.com/img/ico_facebook_mono.png"></a> ');
	document.write('</span>');
	document.write('<span onmouseover="document.site_facebookicon'+num+'.src=\'http://pyuadora.com/img/ico_facebook.png\';" onmouseout="document.site_facebookicon'+num+'.src=\'http://pyuadora.com/img/ico_facebook_mono.png\';">');
	document.write('	<a href="http://www.facebook.com/profile.php?id=100001016525220" target="_blank">facebook</a>');
	document.write('</span>');
	document.write('</li>');

	/* twitter */
	document.write('<li class="icon_twitter">');
	document.write('<span onmouseover="document.site_Twittericon'+num+'.src=\'http://pyuadora.com/img/ico_twi.png\';" onmouseout="document.site_Twittericon'+num+'.src=\'http://pyuadora.com/img/ico_twi_mono3.png\';">');
	document.write('	<a href="http://twitter.com/#!/masahiro_pdp" target="_blank">');
	document.write('	<img name="site_Twittericon'+num+'" alt="" width="16" height="16" src="http://pyuadora.com/img/ico_twi_mono3.png"></a> ');
	document.write('</span>');
	document.write('<span onmouseover="document.site_Twittericon'+num+'.src=\'http://pyuadora.com/img/ico_twi.png\';" onmouseout="document.site_Twittericon'+num+'.src=\'http://pyuadora.com/img/ico_twi_mono3.png\';">');
	document.write('	<a href="http://twitter.com/#!/masahiro_pdp" target="_blank">twitter</a>');
	document.write('</span>');
	document.write('</li>');

	/* RSS */
	document.write('<li class="icon_rss">');
	document.write('<span onmouseover="document.site_RSSicon'+num+'.src=\'http://pyuadora.com/img/ico_rss_orange.png\';" onmouseout="document.site_RSSicon'+num+'.src=\'http://pyuadora.com/img/ico_rss_mono.png\';">');
	document.write('	<a href="http://pyuadora.com/about/rss.htm" target="_blank">');
	document.write('	<img name="site_RSSicon'+num+'" alt="" width="16" height="16" src="http://pyuadora.com/img/ico_rss_mono.png"></a> ');
	document.write('</span>');
	document.write('<span onmouseover="document.site_RSSicon'+num+'.src=\'http://pyuadora.com/img/ico_rss_orange.png\';" onmouseout="document.site_RSSicon'+num+'.src=\'http://pyuadora.com/img/ico_rss_mono.png\';">');
	document.write('	<a href="http://pyuadora.com/about/rss.htm" target="_blank">RSS</a>');
	document.write('</span>');
	document.write('</li>');
}

function docAccessReport(){
	document.write('<img src="http://pyuadora.com/data/report/report.cgi?'+document.referrer+'" width="1" height="1">');
}

function docLink() {
	document.write('<div id="docLink">');
	document.write('<h3>リンク</h3>');
	document.write('<ul class="">');
	document.write('	<li><a href="http://dir.yahoo.co.jp/Recreation/Automotive/Media_and_News/Columns_and_Columnists/?q=R">Yahoo! コラムとコラムニスト</a></li> ');
	document.write('	<li><a href="http://www.dmoz.org/World/Japanese/%E3%83%AC%E3%82%AF%E3%83%AA%E3%82%A8%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3/%E8%87%AA%E5%8B%95%E8%BB%8A/%E9%81%8B%E8%BB%A2/">DMOZ</a></li>');
	document.write('</ul>');
	document.write('</div>');
}


/**** ツイッター関連 ****/
// twitter blogparts
function docTwbar(){
	document.write('<div id=\"twbar\">');
	document.write('<script>');
	document.write('new TWTR.Widget({');
	document.write('  version: 2,');
	document.write('  type: \'profile\',');
	document.write('  rpp: 4,');
	document.write('  interval: 6000,');
	document.write('  width: \'auto\','); // 'auto'を数値にすることも可能
	document.write('  height: \'auto\','); // 'auto'を数値にすることも可能
	document.write('  theme: {');
	document.write('    shell: {');
	document.write('      background: \'#ffffff\',');
	document.write('      color: \'#000000\'');
	document.write('    },');
	document.write('    tweets: {');
	document.write('      background: \'#ffffff\',');
	document.write('      color: \'#000000\',');
	document.write('      links: \'#000000\'');
	document.write('    }');
	document.write('  },');
	document.write('  features: {');
	document.write('    scrollbar: false,');
	document.write('    loop: false,');
	document.write('    live: true,');
	document.write('    hashtags: true,');
	document.write('    timestamp: false,');
	document.write('    avatars: false,');
	document.write('    behavior: \'all\'');
	document.write('  }');
	document.write('}).render().setUser(\'masahiro_pdp\').start();');
	document.write('</script>');
	document.write('</div>');
}


/* footer ====================================================== */
function docUnderMenu(){
	docCateLinkAfterClm(1);
	docToolLink(1);
	docCurrentClm(1);
	docMenuLink(1);

	document.write('<br class="cl" /> ');//footer枠のために必要
	document.write('<div id="docFooterFinal" />');
	docCopyRight();
	docTxtcnt();
	docAccessReport();
	document.write('</div>');
}

function docCopyRight(){
	var myDate = new Date();
	var myYear = myDate.getYear();
	var myYear4 = (myYear < 2000) ? myYear+1900 : myYear ;
	document.write('<span id="copyright_main">');
	document.write('Copyright &#169; 2000-', myYear4, ' <a href="http://pyuadora.com/about/index.htm#about_author">まさひろ</a>,');
	document.write('<a href="http://pyuadora.com/">ぴゅあどら</a>(PureDrivingPleasure)');
	document.write('</span>');
}



/* other   ===================================================== */

/*** テキストカウンタ ***/ // CSSで制御できないためIEのみ非表示
function docTxtcnt() {
	var msie=chkBrowser();
	if(msie!=5){
		document.write('<span id="txtcounter">');
		document.write('<script type="text/javascript" src="http://pyuadora.com/data/txtcount/txtcount-bg.cgi"></script>');
		document.write('</span>');
	}
}

/**** BackScrollイベント処理 ****/

function doBackScroll() {
	var Doc=document;
	//横スクロール位置取得,このスクリプトでは使いません
	//var Scr_x=Doc.body.scrollLeft || Doc.documentElement.scrollLeft || Doc.scrollX || 0;
	//縦スクロール位置取得
	var Scr_y=Doc.body.scrollTop || Doc.documentElement.scrollTop || Doc.scrollY || 0;
	Scr_y= Math.ceil(Scr_y*0.1);//Math.ceil()は値を切り上げ（7.24なら8）となります。
	scrollBy(0,-Scr_y);//スクロール位置を、現在位置から指定距離だけ移動します。

	// 画面最上部に移動するまで繰り返す
	if(Scr_y>0){// 変数 Scr_y が 0 になったら停止します。
		var Tout=setTimeout("doBackScroll()", 20);
	} else {
		clearTimeout(Tout);
	}
}



/*** ツリーメニュー ***/
flag = false;
function treeMenu(tName) {
	if(document.getElementById(tName).style.display == 'none') {
		document.getElementById(tName).style.display = "block";
	} else {
		document.getElementById(tName).style.display = "none";
	}
}

/**** ブラウザ判定 ****/
function chkBrowser(){
	var strUA = "";
	var intB = 0;
	strUA = navigator.userAgent.toLowerCase();

	if     (strUA.indexOf("safari") != -1){		intB = 1 ;} //Safari,GoogleChrome
	else if(strUA.indexOf("firefox") != -1){	intB = 2 ;} //Firefox
	else if(strUA.indexOf("opera") != -1){		intB = 3 ;} //Opera
	else if(strUA.indexOf("netscape") != -1){	intB = 4 ;} //Netscape
	else if(strUA.indexOf("msie") != -1){		intB = 5 ;} //InternetExplorer
	else if(strUA.indexOf("mozilla/4") != -1){	intB = 6 ;} //Netscape.4
	return (intB);
}

/**** パラメタ取得 ****/
function getPara(){
	var a = location.href.split("=");
	var b = eval(a[1]);
	if( b == undefined ) b = 0;
	return(b);
}

/**** フェードアウト ****/
function setFade(str){
	var nav = $(str);
	nav.hover(
		function(){nav.stop().fadeTo(700,0.5);},
		function(){nav.stop().fadeTo(700,1);}

	//【参考】マウスオーバー以外の画像（要素）をフェードアウトで透明にする
	//	function(){nav.not(this).stop().fadeTo(700,0.5);},
	//	function(){nav.not(this).stop().fadeTo(700,1);}

	);
}

$(function() {
	setFade('#site_identity');
});
$(function() {
	setFade('header .logo-navi');
});
$(function() {
	setFade('#contents h1');
});
$(function() {
	setFade('#contents h2');
});
$(function() {
	setFade('#contents #docMessageFrame h3');
});
$(function() {
	setFade('#contents #clmPageLink');
});
$(function() {
	setFade('#contents #clmSiteLink');
});
$(function() {
	setFade('#contents article a');
});
$(function() {
	setFade('#contents article #end');
});
$(function() {
	setFade('#contents #affili a');
});
$(function() {
	setFade(' .MenuLink');
});
$(function() {
	setFade(' .menulist');
});
$(function() {
	setFade(' .ToolLink');
});
$(function() {
	setFade(' .docCateLinkAfterClm');
});
$(function() {
	setFade(' #docLink');
});
$(function() {
	setFade(' .docCurrentClm');
});
$(function() {
	setFade('aside #docProfile h3');
});
$(function() {
	setFade('aside #docProfile .aboutauthor');
});
$(function() {
	setFade(' .icon_facebook');
});
$(function() {
	setFade(' .icon_twitter');
});
$(function() {
	setFade('aside #docProfile .icon_rss');
});
$(function() {
	setFade('aside #twbar');
});
$(function() {
	setFade('footer #docFooterFinal');
});

/* フェードイン・フェードアウトで切り替わるカテゴリ画像 */
$(function(){
	$("img.cateimg").hover(
		function() {$(this).stop().animate({"opacity": "0"}, "slow");},
		function() {$(this).stop().animate({"opacity": "1"}, "slow");}
	);
});

