/* ======================================================================

ホーム 各コンテンツ呼び出しローディング処理

呼び出しファイル
 - おしらせ（キャンペーン・サービス情報）
 - おしらせ（メンテナンス情報）
 - 提携店舗一覧

====================================================================== */
/* 読み込み実行 */
function loadCtsData(id1,url1){
	var tgt1 = '#' + id1;
	$(tgt1).load(url1, function(){
		//	ローディングが完了したときに実行したい処理をここへ記述
	});
}

/* 読み込み指定 */
$(function(){
	//提携店舗一覧
	loadCtsData('partnerlist','/c/home/partner.htm');
	//おしらせ（キャンペーン・サービス情報）
	loadCtsData('othernews','/c/news/data/home/other.htm');
	//おしらせ（メンテナンス情報）
	loadCtsData('maintenews','/c/news/data/home/mainte.htm');
});

/* ======================================================================

	ホーム読み込み順 指定
	- ページの読み込み後に表示するコンテンツの指定

====================================================================== */
$(function(){

	//ページ読み込み後に下記を表示
	$('#collect').css('display', 'block');
	$('#spend').css('display', 'block');
	$('#news').css('display', 'block');

	//ページ読み込み後にローディングを終了
	$('#main').css('background', 'none');
	$('#sub .subbox').css('background', 'none');


	//even指定
	$("#thisweekinfo .pickup li:odd").addClass("odd");
	$("#netcollect .bnr li:odd").addClass("odd");
	$("#netuse .bnr li:odd").addClass("odd");
	$("#netuse .shoplist li:odd").addClass("odd");

	//last設定
	$("#sub #nearbystore .newcompany li:last-child").addClass("last");
	//$("#sub #nearbystore .company li:last-child").addClass("last");
	$("#sub #pickup ul li:last-child").addClass("last");


	/* リンク設定 画像と対
	----------------------------------------------------------------- */

			/* 今週のおトクリンク設定
			----------------------------------------------------------------- */
				$("#thisweekinfo .pickup li").click(function() {
					var targeturl = $(this).children("p").children("a").attr("href");
					location.href = targeturl;
				});
				$("#thisweekinfo .pickup li").hover(function(){
					$(this).addClass("box_hover");
					},
					function(){
					$(this).removeClass("box_hover");
				});

			/* ネットでためよう！注目ショップ
			----------------------------------------------------------------- */
				$("#pointmall .attentionshop li").click(function() {
					var targeturl = $(this).children("p.txt").children("a").attr("href");
					location.href = targeturl;
				});
				$("#pointmall .attentionshop li").hover(function(){
					$(this).addClass("box_hover");
					},
					function(){
					$(this).removeClass("box_hover");
				});

			/* ネットで使おう！ ポイントつかってお買物
			----------------------------------------------------------------- */
				$("#shoping .shoplist li").click(function() {
					var targeturl = $(this).children("p.txt").children("a").attr("href");
					location.href = targeturl;
				});
				$("#shoping .shoplist li").hover(function(){
					$(this).addClass("box_hover");
					},
					function(){
					$(this).removeClass("box_hover");
				});

			/* 近くのお店でためよう！つかおう！
			----------------------------------------------------------------- */
				$("#nearbystore li").click(function() {
					var targeturl = $(this).children("p.txt").children("a").attr("href");
					location.href = targeturl;
				});
				$("#nearbystore li").hover(function(){
					$(this).addClass("box_hover");
					},
					function(){
					$(this).removeClass("box_hover");
				});

			/* 注目ピックアップ
			----------------------------------------------------------------- */
				$("#pickup li").click(function() {
					var targeturl = $(this).children("p.txt").children("a").attr("href");
					location.href = targeturl;
				});
				$("#pickup li").hover(function(){
					$(this).addClass("box_hover");
					},
					function(){
					$(this).removeClass("box_hover");
				});

	/* 高さ揃え
	----------------------------------------------------------------- */

			/* 今週のおトクリンク設定
			----------------------------------------------------------------- */
			var pickuph = 0;
			$("#thisweekinfo .pickup li").each(function (pickupi) {
				var pickupi = pickupi+1;
				$(this).addClass("heightLine-pickup" + pickuph);
				if(pickupi % 2 == 0){
					pickuph = pickuph + 1;
				}
			});

			/* ポイントをつかってお買物
			----------------------------------------------------------------- */
			var shoplisth = 0;
			$("#shoping .shoplist li").each(function (shoplisti) {
				var shoplisti = shoplisti+1;
				$(this).addClass("heightLine-shoplist" + shoplisth);
				if(shoplisti % 2 == 0){
					shoplisth = shoplisth + 1;
				}
			});





	/* 指定最大数から2枚以上をランダムで表示
	----------------------------------------------------------------- */


//------------------------データセット
//最大値
numMax = 14;

//表示数
numShow = 5;

bnrAry = new Array();

//HTMLタグ
bnrAry[0] = '							<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_geo.gif" alt="GEO" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/geo/index.htm"><span>GEO</span>レンタル、リサイクル、新品で200円(税抜)につき1ポイントたまる。</a></p>'
					+'							</li>';

bnrAry[1] = '							<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_shell.gif" alt="シェル" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/shell/index.htm"><span>シェル</span>サービスステーションにて現金のお支払いで燃料油1Lにつき1ポイントたまる</a></p>'
					+'							</li>';

bnrAry[2] = '							<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_lawson.gif" alt="ローソン" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/lawson/index.htm"><span>ローソン</span>マチのほっとステーション。様々なシーンでポイントがたまる！</a></p>'
					+'							</li>';

bnrAry[3] = '							<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_ims.gif" alt="株式会社アイ・エム・エス" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/ims/index.htm"><span>株式会社アイ・エム・エス</span>プリントシール機プレイ代1回400円ごとに2ポイントたまる！</a></p>'
					+'							</li>';

bnrAry[4] = '							<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_orix.gif" alt="オリックスのレンタカーネットワーク" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/orix/index.htm"><span>オリックスのレンタカーネットワーク</span>レンタカーご利用金額100円（税込）につき2ポイントたまる！</a></p>'
					+'							</li>';

bnrAry[5] = '							<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_geocafe.gif" alt="GEOCAFE" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/geo_cafe/index.htm"><span>GEOCAFE</span>インターネット＆まんが喫茶。座席ご利用料金　200円(税抜)につき1ポイントたまる。</a></p>'
					+'							</li>';

bnrAry[6] = '							<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_sakai.gif" alt="サカイ引越センター" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/hikkoshi-sakai/index.htm"><span>サカイ引越センター</span>「マイスタークオリティー」の引越しでポイントがたまる。</a></p>'
					+'							</li>';

bnrAry[7] = '							<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_taiyakan.gif" alt="タイヤ館" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/taiyakan/index.htm"><span>タイヤ館</span>タイヤ館のお買い物100円（税込）ごとに1ポイントたまる！</a></p>'
					+'							</li>';

bnrAry[8] = '							<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_travelrentacar.gif" alt="トラベルレンタカー" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/travelrentacar/index.htm"><span>トラベルレンタカー</span>沖縄行くならトラベルレンタカー。100円（税込）ごとに1ポイントたまる！</a></p>'
					+'							</li>';

bnrAry[9] = '							<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_nittsu.gif" alt="引越しは日通" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/nittsu/index.htm"><span>引越しは日通</span>0120-154022（ひっこしはにっつう）でポイントがたまる。</a></p>'
					+'							</li>';

bnrAry[10] = '						<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_jrs.gif" alt="日本ロードサービス（JRS）" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/jrs/index.htm"><span>日本ロードサービス（JRS）</span>ロードサービス新規ご入会で100Pがもらえる！</a></p>'
					+'							</li>';

bnrAry[11] = '						<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_iric.gif" alt="保険クリニック" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/hoken_clinic/index.htm"><span>保険クリニック</span>来店型保険ショップ。初回来店相談で500ポイントたまる。</a></p>'
					+'							</li>';

bnrAry[12] = '						<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_lifenet.gif" alt="Life Net" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/lifenet/index.htm"><span>Life Net</span>暮らしのことで「困ったとき」の相談窓口♯9990番でポイントがたまる。</a></p>'
					+'							</li>';

bnrAry[13] = '						<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_rootinn.gif" alt="ルートインホテルズ" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/routeinn_hotels/index.htm"><span>ルートインホテルズ</span>ホテルに泊まって、ご宿泊代金100円（税抜）ごとに3ポイントたまる！</a></p>'
					+'							</li>';


/* 現在停止中企業
bnrAry[14] = '							<li class="cfx">'
					+'								<p class="vis"><img src="/c/home/img/partner/logo_s_kfc.gif" alt="KFC（千葉県内のみ）" width="50" height="35" border="0" /></p>'
					+'								<p class="txt"><a href="http://www.ponta.jp/c/partner/kfc/index.htm"><span>KFC（千葉県内のみ）</span>カーネル・サンダースがこだわり続けた“本当のおいしさ”でポイントがたまる。</a></p>'
					+'							</li>';
*/

//------------------------処理開始
var rdmAry = new Array();
var numCnt = 0;
var numShowFix = numShow -1;

var rdmVal = getRdm();
rdmAry[0] = rdmVal;

setData();

//表示数に満たすまでループ
function setData(){
	rdmVal = getRdm();
	
	if(checkNum()){
		
		numCnt++;
		rdmAry[numCnt] = rdmVal;
		
		if(numCnt != numShowFix){
			setData();
		}
	}else{
		setData();
	}
}

//数字が重複していないかチェック
function checkNum(){
	var checkCnt = 0;
	for(var i=0; i<=numCnt; i++){
		//alert(numCnt);
		if(rdmVal != rdmAry[i]){
			checkCnt++;
		}
	}
	
	if(checkCnt > numCnt){
		return true;
	}else{
		return false;
	}
}

//ランダムな数字を取得
function getRdm(){
	var rdm = Math.floor( Math.random()*numMax );
	return rdm;
}

//HTMLセット
var bnrlist = '';
var bnrlistFix;

var bnrlist = '';
for(var i=0; i<=numShowFix; i++){
	num = rdmAry[i];
	bnrlist += bnrAry[num];
//	bnrlist += '<li>'+bnrAry[num]+'</li>';
}
//alert(bnrlist);

var bnrlistFix = '';
//bnrlistFix += '<ul>';
bnrlistFix += bnrlist;
//bnrlistFix += '</ul>';

//HTML書き出し
//jQuery(function($){
	$("#sidebnrlist").html(bnrlistFix);
	$("#sub #nearbystore .company li:last-child").addClass("last");
//});





















});
