$(document).ready(function(){

/* 
2011.10.19 
チラシが３件未満の場合、自動スクロールをOFFにするため
この部分をテンプレートへ移動します。
	$('#slider_box').bxSlider({
		nextText: '次へ',
		nextImage:'../images/top/handbill_right.gif',
		nextSelector: '#next',
		prevText: '前へ',
		prevImage:'../images/top/handbill_left.gif',
		prevSelector: '#prev',
		auto:true,
		speed: 2000,
		pause: 5000,
		displaySlideQty:3,
		moveSlideQty:3
	});
*/
//Examples of how to assign the ColorBox event to elements
val = $(".colorbox").colorbox( {maxWidth:650, maxHeight:650});
$(".search_category").colorbox({innerWidth:620, innerHeight:420, onComplete:cate_load, iframe:true, inline:true, href:"#category"});
$(".search_area"    ).colorbox({innerWidth:620, innerHeight:420, onComplete:area_load, iframe:true, inline:true, href:"#area"});
$(".search_station" ).colorbox({innerWidth:620, innerHeight:420, onComplete:stat_load, inline:true, href:"#station"});

$("a[rel='example']").colorbox({title: function(){
    var url = $(this).attr('href');
    return '<a href="'+url+'" target="_blank">Open In New Window</a>';
}});
});

function toBig(){$('#s_stin').animate({opacity:0},300,function(){$('#s_stin').css('display','none');$('#s_st').css('display','block').animate({opacity:1},300);});}
function bigToLittle(name,id,train){$.ajax({type: "GET",url: "/json_data.php",dataType: "json",data:"mode=setTrainLittlePC&id="+id,success: function(ds){$('#s_st').animate({opacity:0},300,function(){$('#s_st').css('display','none');var htm='<h5>'+train+'</h5>';htm+='<p class="mb10">駅名を選択してください。</p><ul>';for( i=0;i<ds.length;i++ ){htm+='<li><a href="index.php?mode=pc_search&station[]='+ds[i]["cate2_id"]+'">'+ds[i]["name2"]+'</a></li>';}htm+='</ul><p>&gt;&gt;<a href="/shop/" onclick="toBig();return false;">路線選択に戻る</a></p>';$('#s_stin').html(htm);$('#s_stin ul li:nth-child(5n+1)').css('margin-left','0px');$('#s_stin').css('display','block').animate({opacity:1},300);});}});}

function changeAreaSelect(type){
	if (type==1) {//mapを見せる
		$("#sort").css("display","none");
		$("#map").css("display","block");
	} else if (type==2) {// ソート順を見せる
		$("#map").css("display","none");
		$("#sort").css("display","block");
	}
}

function cate_load(){

	//表示を切り替える
	$("#category_big").css("display","block");
	for( i=10; i<50; i++ ){
		$("#category_little_"+i).css("display","none");
	}
}

function area_load(){

	//表示を切り替える
	$("#area_big").css("display","block");
	for( i=10; i<50; i++ ){
		$("#area_little_"+i).css("display","none");
	}
}

function stat_load(){

	//表示を切り替える
	$("#station_big").css("display","block");
	//for( i=10; i<50; i++ ){
	//	$("#station_little_"+i).css("display","none");
	//}
	$("#station_little").css("display","none");
}

function disp_remind(){

	//表示を切り替える
	$("#pc_remind_form").slideToggle(1000);
}


  var pos = 0;
  function toPrev( max_cnt ){
      $('#slider_box').animate({"left": "+=197px"}, "slow");
  };
  function toNext( max_cnt ){
      $('#slider_box').animate({"left": "-=197px"}, "slow");
  };

$(function(){
     $("#page_top a").click(function(){
     $('html,body').animate({ scrollTop: $($(this).attr("href")).offset().top }, 'slow','swing');
     return false;
     })
});



	// IDを指定したチェックをはずす
	function delete_check( target_id ) {
		$("#"+target_id+" input:checkbox").attr("checked", false);
		
		//路線検索の場合
		if( target_id == "station" ){
			$("#train").val('');
			$("#station").html('');
			//alert(t);
		}
	}
	
	// クラスを指定してチェックをはずす
	function delete_check_class( target_id ) {
		$("."+target_id+" input:checkbox").attr("checked", false);
	}
	
	// IDを指定してチェックする
	function add_check( target_id ) {
		$("#"+target_id+" input:checkbox").attr("checked", true);
	}
	
	// クラスを指定してチェックをはずす
	function add_check_class( target_id ) {
		$("."+target_id+" input:checkbox").attr("checked", true);
	}



    $(function(){  
        $('div.link_box').biggerlink();  
    });  



    function banner_click(b_id){
	
		var now = new Date();
		var sec = now.getSeconds(); // 秒
	
		//データを取得する
		$.ajax({
			type: "GET",
			url: "/json_data.php",
			dataType: "json",
			data:"mode=setBannerCnt&b_id="+b_id+"&time="+sec,
			success: function(ds){	
				if( ds.error ){
	
				}else{

				}
			}
		});
	}



    function banner_click2(b_id,link_url,new_win_flg){
	
		var now = new Date();
		var sec = now.getSeconds(); // 秒
		
		//alert(b_id);
	
		//データを取得する
		$.ajax({
			type: "GET",
			url: "/json_data.php",
			dataType: "json",
			data:"mode=setBannerCnt&b_id="+b_id+"&time="+sec,
			success: function(ds){	
				if( ds.error ){
					
				}else{
					
				}
				
				//新規ウィンドウ
				if( new_win_flg ){
					window.open(link_url,null);
				}
				//同一ウィンドウ
				else{
					location.href=link_url;
				}
			}
		});
	}

