/* ------------------------------------
*
*	Since : 2007-11-19
*	Editor : BBmedia Inc. D_sasaki
*	update : 2008-07-09
*
-------------------------------------*/

jQuery(function(){
				
	var checkBox = {
		check : function(node){
			node.attr("checked","checked");
		},
		cancel : function(node){
			node.removeAttr("checked");
		}	
	}
	
	var catimg = jQuery(".categories li img:not(:last)");
	var lastImg = jQuery("#cat99").next("label").children("img");
	var inp = jQuery(".categories li input");
	var radioImg = $(".area ul img, .date ul img")
	
	var ua = navigator.userAgent;
	var ie = (ua.indexOf("MSIE") >= 0);
	var safari = (ua.indexOf("Safari") >= 0);
	
	//----------------------------------------------------
			
	catimg.click(function() {
		var target = jQuery(this).parent().prev("input")
						  
		if(!(target.attr("checked"))) {
			checkBox.check(target);
			return false;
		} else {
			checkBox.cancel(target);
			jQuery("#cat99").removeAttr("checked");
			return false;
		}
	});
	
	lastImg.click(function() {
		var target = jQuery(this).parent().prev("input")
		
		if(!(target.attr("checked"))) {
			checkBox.check(inp);
			return false;
		} else {
			checkBox.cancel(inp);
			return false;
		}
	});
	
	radioImg.click(function(){
		var target = jQuery(this).parent().prev("input")
		checkBox.check(target)
	})	
	
	//---------------------------------------------------

	$(".area ul input").each(function(i){
		$(this).click(function(){
			$("#areaMap img").attr("src","../images/img_map_area_00" + (i +1) + ".gif");
		})
		.next()
		.children("img")
		.click(function(){
			$("#areaMap img").attr("src","../images/img_map_area_00" + (i +1) + ".gif");			
		})
	});

	$(".area map area").each(function(i){
		
		if(safari){
			$(this).click(function(){
				$("#areaMap img").attr("src","../images/img_map_area_00" + (i +1) + ".gif");
				$("#area0"+(i +1)).attr("checked","checked");
				
			})			
		}
		else {
			$(this).focus(function(){
				$("#areaMap img").attr("src","../images/img_map_area_00" + (i +1) + ".gif");
				$("#area0"+(i +1)).attr("checked","checked");
				if(ie) this.blur();
			})
		}
		
	});

	
});



