/* エリアターゲティング 情報取得 */
/* initialize */
var citycode = "nagoya";
var blogCitycode = "nagoya";

try{
var city = SURFPOINT.getCityCode(); //どこどこＪＰから市区町村コードを取得する
var surfcf = SURFPOINT.getPrefCF(); //どこどこＪＰからＣＦ値を取得する
var cf = 40; //CF値設定　これよりＣＦ値が大きいことを条件とする
}catch(error){
	//console.log(error.number + "\n" + error.description);
}
// 以下条件式　どこどこＪＰで取得できた市区町村コードとＣＦ値の大きさで比較
if( surfcf > cf ){
	switch ( city ){
		case "23203":
		case "23208":
		case "23217":
		case "23220":
		case "23232":
		case "23233":
		case "23234":
		case "23421":
		case "23422":
		case "23423":
		case "23345":
		case "23424":
		case "23425":
			citycode='inazawa';
			blogCitycode='inazawa';
			break;
		case "23202":
		case "23211":
		case "23212":
		case "23213":
		case "23214":
		case "23225":
		case "23481":
		case "23482":
		case "23483":
		case "23501":
			citycode='okazaki';
			blogCitycode='okazaki';
			break;
		case "22130":
		case "22131":
		case "22132":
		case "22133":
		case "22134":
		case "22135":
		case "22136":
		case "22137":
		case "22211":
		case "22221":
		case "23201":
		case "23207":
		case "23221":
		case "23231":
		case "23561":
		case "23562":
		case "23563":
		case "23603":
			citycode='toyohashi';
			blogCitycode='toyohashi';
			break;
		case "23114":
		case "23116":
		case "23229":
		case "23230":
		case "23302":
		case "23304":
		case "23521":
			citycode='midori';
			blogCitycode='midori';
			break;
		case "21201":
		case "21202":
		case "21203":
		case "21205":
		case "21207":
		case "21208":
		case "21209":
		case "21213":
		case "21214":
		case "21215":
		case "21216":
		case "21217":
		case "21218":
		case "21219":
		case "21220":
		case "21221":
		case "21302":
		case "21303":
		case "21341":
		case "21361":
		case "21362":
		case "21381":
		case "21382":
		case "21383":
		case "21401":
		case "21403":
		case "21404":
		case "21421":
		case "21501":
		case "21502":
		case "21503":
		case "21504":
		case "21505":
		case "21506":
		case "21507":
		case "21521":
		case "21604":
			citycode='gifu';
			blogCitycode='yanaidu';
			break;
		case "24202":
		case "24203":
		case "24204":
		case "24207":
		case "24208":
		case "24209":
		case "24210":
		case "24211":
		case "24212":
		case "24215":
		case "24216":
		case "24341":
		case "24441":
		case "24442":
		case "24443":
		case "24461":
		case "24470":
		case "24471":
		case "24472":
		case "24543":
		case "24561":
		case "24562":
			citycode='tsukawage';
			blogCitycode='tsukawage';
			break;
		case "21202":
		case "21209":
		case "21216":
		case "21218":
		case "21221":
		case "21341":
		case "21361":
		case "21362":
		case "21381":
		case "21382":
		case "21383":
		case "21401":
		case "21403":
		case "21404":
		case "21421":
		case "25201":
		case "25202":
		case "25203":
		case "25204":
		case "25206":
		case "25207":
		case "25208":
		case "25209":
		case "25210":
		case "25211":
		case "25212":
		case "25213":
		case "25214":
		case "25381":
		case "25383":
		case "25384":
		case "25425":
		case "25441":
		case "25442":
		case "25443":
		case "25482":
		case "25483":
		case "25501":
		case "25502":
		case "25503":
		case "25504":
			citycode='oogaki';
			blogCitycode='oogaki';
			break;
		case "23206":
		case "23228":
		case "23215":
		case "23219":
		case "23342":
		case "23361":
		case "23362":
		case "21204":
		case "21206":
		case "21210":
		case "21211":
		case "21212":
			citycode='komaki';
			blogCitycode='komaki';
			break;
	}
}

//店舗情報出力
function writeTenpoInfo(){
	if( !citycode ){
		citycode="nagoya";
	}
	htmlText = '<a class="shopImg" href="/shop_info/' + citycode + '/"><img src="/image/areatargeting/' + citycode + '.gif" /></a>';
	htmlText += '<div class="shopBlog">';
	htmlText += '</div>';
	document.write(htmlText);
}



/* メイン画像のスライドショー */
slideData = [
	{img:"../image/banner/topmain/main1.jpg",URL:"/special/bargain/",target:"_self"},
	{img:"../image/banner/topmain/main2.jpg",URL:"/study_desk/",target:"_self"},
	{img:"../image/banner/topmain/main3.jpg",URL:"/close_up/close_up-0.html",target:"_self"},
	{img:"../image/banner/topmain/main4.jpg",URL:"/service/inetrior_coordinator/",target:"_self"}
];

// 現在表示している画像番号
currentImgNum = 0;
var slideShowTimer;

/* メイン画像切り替えボタン設定 */
$(function(){
	/* クリック処理 */
	$("#areaSpecialContents_menu a").click(function(){
		clearTimeout( slideShowTimer );
		var index = $("#areaSpecialContents_menu a").index(this);
		setSlide(index);
		$("img","#areaSpecialContents_menu a").each(function(){
			if( this.className == "current"){
				$(this).removeClass("current");
				this.src = this.src.replace("_on.","_off.");
			}
		});
		$("img",this).addClass("current");
	});
	/* マウスオーバー処理 */
	$("#areaSpecialContents_menu img").hover(function(){
		this.src=this.src.replace("_off.","_on.");
	},function(){
		if(this.className != "current"){
			this.src=this.src.replace("_on.","_off.");
		}
	});
});

$(function(){

	//スライドショーの要素を作成し表示を2秒後から始める
	setTimeout( function() {
		var div = $('<div></div>');
		var a = $('<a></a>');
		var img = $('<img></img>');
		div.attr("id","areaSpecialContents_main");
		div.css("visibility","visible");
		div.append(a);
		a.append(img);
		a.attr("href",slideData[currentImgNum]['URL']);
		a.attr("target",slideData[currentImgNum]['target']);
		img.attr("src", slideData[currentImgNum]['img']);
		 $("#areaSpecialContents_main").replaceWith(div);

		currentImgNum = (currentImgNum + 1) % slideData.length;

		//スライドショーの開始
		slideShowTimer = setInterval( function(){
			setSlide(currentImgNum);
			currentImgNum = (currentImgNum + 1) % slideData.length;
		} , 10000 );//スライドショーの間隔
	}, 2000);//Flashからスライドショーに切り替わる時間
});


function setSlide( num ){
		$("#areaSpecialContents_main img").attr("src", slideData[num]['img']);
		$("#areaSpecialContents_main img").parent().attr("href",slideData[num]['URL']);
		$("#areaSpecialContents_main img").parent().attr("target",slideData[num]['target']);
}
