// /index.html トップページ用クローズアップ処理用

var closeup = function() {
	this.activeCloseupType = "Thumb";
}
closeup.prototype = {
	
	init : function() {
	
		$("#closeup li ul").addClass("type-thumb");		
		$("#closeup li ul li:odd").addClass("mr00");
		$("#closeup").show();
		
		$("#closeup").innerfade({type:"btnClick", btnNext:"#btnBnrNext", btnPrev:"#btnBnrPrev" , ico_channel_active:"images/index/ico_bnr_channel_on.gif" , ico_channel_normal:"images/index/ico_bnr_channel.gif"});
		$("#btnCloseupThumb img , #btnCloseupList img").css("cursor" , "pointer");
		
		this.setChangeBtn();
		
		this.fitCloseupHeight(-20);
		
		//サムネイルの場合は、バナーのロールオーバーでウインク効果
		/*
		$("#closeup li ul.type-thumb a").hover(
			function() {
				$("img" , this)
						.animate({ opacity:0.7 } , 400)
						.animate({ opacity:1 } , 500);
			},
			function() {
				$("img" , this).animate({ opacity:1 } , 100);
			}
		);
		*/
	},
	
	setChangeBtn : function() {
		
		$("#btnCloseupThumb img").click(function() {
			closeupObj.changeCloseupType("Thumb");
		});
		$("#btnCloseupList img").click(function() {
			closeupObj.changeCloseupType("List");
		});
		
	},
	
	changeCloseupType : function(type) {
		
		if(type == "Thumb" && type != this.closeupThumb){	
			
			this.closeupThumb = type;
			$("#closeup li ul").removeClass("type-list");	
			$("#closeup li ul").addClass("type-thumb");	
			
			this.fitCloseupHeight(-20);
			
			this.btnImageChange ("#btnCloseupThumb img" , "#btnCloseupList img");
			
			
		}else if(type == "List" && type != this.closeupThumb) {
				
			this.closeupThumb = type;
			
			$("#closeup li ul").removeClass("type-thumb");
			$("#closeup li ul").addClass("type-list");		
			
			this.fitCloseupHeight(0);
			
			this.btnImageChange ("#btnCloseupList img" , "#btnCloseupThumb img");
			
		}
	},
	
	//高さ調整
	fitCloseupHeight : function(adjust) {
		
		var maxheight = 0;
		$("#closeup li").each(function() {
			if($(this).height() > maxheight) {
				maxheight = $(this).height();	
			}
		});
		$("#closeup").css("height" , maxheight+adjust);
		
	},
	
	//切り替えボタンの差し替え
	btnImageChange : function(selecter_on , selecter_off) {
		
		var imgsrc = $(selecter_on).attr("src");
		var dot = imgsrc.lastIndexOf('.');
		var imgsrc_ro = imgsrc.substr(0, dot) + '_active' + imgsrc.substr(dot, 4);
		$(selecter_on).attr("src" , imgsrc_ro);
		
		var imgsrc_off = $(selecter_off).attr("src");
		var dot_off = imgsrc_off.lastIndexOf('.');
		var imgsrc_nonro = imgsrc_off.substr(0, dot_off).replace("_active" , "") + imgsrc_off.substr(dot_off, 4);
		$(selecter_off).attr("src" , imgsrc_nonro);
		
	}
};


var closeupObj = new closeup();
