	var this_directory = window.location.href.split("/");
	var cnt_url = this_directory.length - 2;
	this_directory = this_directory[cnt_url];
	var feed_url = null;
	var display_cat = null;
	var display_catlink = null;
	var array_page = [
		{page: "topics", getnum: 1, category: "トピックス（新商品・イベント等）", catdir: "http://santabike.blog102.fc2.com/blog-category-1.html"},	//トピックス
		{page: "owner", getnum: 0, category: "", catdir: "http://nice11jp.blog93.fc2.com/"},	//店主ブログページ
		{page: "rentalbike", getnum: 1, category: "レンタルバイク情報", catdir: "http://santabike.blog102.fc2.com/blog-category-3.html"},	//レンタルバイク情報
		{page: "arrival", getnum: 1, category: "車輌入荷情報", catdir: "http://santabike.blog102.fc2.com/blog-category-2.html"},	//新入荷情報ページ
		{page: "custom", getnum: 1, category: "カスタム車両", catdir: "http://santabike.blog102.fc2.com/blog-category-4.html"}	//過去の製作車輌
	];
	var cnt_array_page = array_page.length;
	var array_php_address = [
		"http://www.santabike.com/php/blog01.php?u=0",	//中年バイク屋店主のしがない毎日
		"http://www.santabike.com/php/blog01.php?u=1"	//サンタバイクインフォメーション
	];
	var j = 0;	//tmpArray[j]で0から配列に値を入れるのに使用する
	
	for(var i = 0; i < cnt_array_page; i++){
		if(this_directory == array_page[i].page) {
			feed_url = array_php_address[array_page[i].getnum];
			display_cat = array_page[i].category
			display_catlink = array_page[i].catdir
			if(display_cat == "") {
				display_cat = "all"
			}
		}
	}
	var aaa = true;
	if(feed_url === null) {
		aaa = false;
	}

$(document).ready(function(){
	//RSSが同じドメインにある場合
if(aaa) {
	$.ajax({
		url: feed_url,
		//非同期通信
		async: true,
		//通信結果をキャッシュしない
		cache: false,
		dataType: "xml",
		success: function(xml){
			var tmpArray = new Array();
			var htmlStr = '';
			var maxNum = $(xml).find('item').length;
			var displayNum = 11;
			var flag = false;
			var blog_title = $(xml).find('channel > title').text();
			
			$(xml).find('item').each(function(i){
				if (i == maxNum) {
					return false;
				}
				var title = $(this).find('title').text();
				if(title.length > 10) {
					title = title.substring(0,10)+"…　";
				} else {
					title = title;
				}
				var url = $(this).find('link').text();
				var description = $(this).find('description').text();
				if(description.length > 35) {
					description = description.substring(0,35) + '…　<a href="' + url + '" title="' + title + '">続きを読む<\/a>';
				} else {
					description = description;
				}

				var subject = $(this).find('dc\\:subject').text();
				if(subject == '') {
					subject = $(this).find('subject').text();
				}
				var date = $(this).find('dc\\:date').text();
				if(date == '') {
					date = $(this).find('date').text();
				}
				var category = $(this).find('category').text();
				
				date = dateChanger(date);
				
				if(subject == display_cat) {
				tmpArray[j] = '<dt><a href="' + url + '" title="' + title + '">' + title + '<\/a><\/dt><dd><div>' + description + '<\/div><\/dd>';
				j++;
				} else if(display_cat == "all") {
				tmpArray[j] = '<dt><a href="' + url + '" title="' + title + '">' + title + '<\/a><\/dt><dd><div>' + description + '<\/div><\/dd>';
				j++;
				}
				
				/*if (url == "") {
					tmpArray[i] = '<dt>' + date[0] + '<\/dt><dd><div><p class="updateTitle"><em>' + title + '<\/em><\/p>' + description + '<\/div><\/dd>';
				} else {
					tmpArray[i] = '<dt>' + date[0] + '<\/dt><dd><div><p class="updateTitle"><em><a href="' + url + '" title="' + title + '">' + title + '<\/a><\/em><\/p>' + description + '<a href="' + url + '" title="' + title + '">続きを読む<\/a><\/div><\/dd>';
				}*/
			});
			
			if ($('#Blog').size() > 0) {
				if (maxNum < displayNum) {
					displayNum = maxNum;
				} else {
					displayNum;
				}
			} else {
				flag = true;
				displayNum = maxNum;
			}
			
			htmlStr = '<dl>';
			for (j = 0; j < displayNum; j++) {
				if(tmpArray[j] != undefined){
				htmlStr += tmpArray[j];
				}
			}
			htmlStr += '<\/dl>';
			if(display_cat == "all") {
				display_cat = blog_title;
			}
			htmlStr += '<p class="catlink"><a href="' + display_catlink + '" title="外部リンク:' + display_cat + '">' + display_cat + '一覧<\/a><\/p>';
			
			if (flag) {
				$('#CPTopics noscript').replaceWith(htmlStr);
			} else {
				//htmlStr += '<p class="detail"><a href="" title="リンク:お知らせページ">お知らせページへ<\/a><\/p>';
				$('#Blog noscript').replaceWith(htmlStr);
			}
			
			// open new window
			$(function() {
				$('a[href^="http://"]').click(function() {
					if (!(location.hostname == this.hostname)) {
						this.target = "_blank";
					}
				});
			});
			
		},
		//エラー表示
		error: function(xml){
			$('#Blog noscript').replaceWith('<p>更新情報の読み込みに失敗しました。<\/p>');
			
			// open new window
			$(function() {
				$('a[href^="http://"]').click(function() {
					if (!(location.hostname == this.hostname)) {
						this.target = "_blank";
					}
				});
			});
		}
	
	});
}
	//月表示を数字表示に変換する
    var dateChanger = function(str) {
        var strdate = str.split('\+')[0].replace('T',' ').replace('-','\/').replace('-','\/');//strdate==YYYY/mm/dd hh:mm:ss
        //return Date.parse(strdate);
        var mydate = new Date(strdate);
        yy = mydate.getFullYear();
        mm = mydate.getMonth() + 1;
        dd = mydate.getDate();
        if (mm < 10) { mm = "0" + mm; }
        if (dd < 10) { dd = "0" + dd; }
        var datestr = new Array();
        datestr[0] = yy + "年" + mm + "月" + dd + "日";
        datestr[1] = yy + "-" + mm + "-" + dd;
        return datestr;
    }
	
	// table hover background color change.
	$(function(){
		$('.basicTable table tbody tr').hover(function(){
			$(this).addClass("select");
		},function(){
			$(this).removeClass("select");
		});
	});
	
	// open new window
	$(function() {
		//$('a[href^="http://"]').not('a[href^="http://jigsaw.w3.org/"]').not('a[href^="http://validator.w3.org/"]').click(function() {
		$('a[href^="http://"]').click(function() {
			if (!(location.hostname == this.hostname)) {
				this.target = "_blank";
				//window.open(this.href, '');
				//return false;
			}
		});
		$('a[href^="pdf/"]', 'a[href^="../pdf"]').click(function() {
			window.open(this.href, '');
			return false;
		});
		$('a[href^="blog/"]', 'a[href^="../blog"]').click(function() {
			window.open(this.href, '');
			return false;
		});
	});

	// easing
	$(function() {
		$('area[href*=#], a[href*=#]').click(function() {
			if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
				var target = $(this.hash);
				target = target.length && target;

				if (target.length) {
					var sclpos = 6;	//スクロール後のtopからの距離　初期値：30
					var scldurat = 2400;	//スクロールスピードの調整ミリ秒　初期値：1200
					var targetOffset = target.offset().top - sclpos;
					$($.browser.opera ? $.support.boxModel == false ? 'body' : 'html' :'html,body')
						.animate({scrollTop: targetOffset});
					return false;
				}
			}
		});
	});

	// web catalog image change
	$(function(){
		$(".catNavi li").click(function(){
			if( $('.catNavi li').hasClass("select") ) {
				$('.catNavi li').removeClass("select");
			}
			$(this).addClass("select")
			
			$("#main img").attr("src",$(".catNavi li.select a").attr("href"));
			return false;
		});
	});

});
