//form error セッティング
$(document).ready(function() {
	$('tr.error').children('td').children('input, textarea').focus(function(){
		$(this).each(function(){		  
			$(this).parent('td').parent('tr').removeClass("error")
			return true;
		});
	});
	
	$('p.error input').click(function(){
		$(this).each(function(){		  
			$(this).parent('p').removeClass("error")
			return true;
		});
	});
});



//concept innerfade セッティング
$(document).ready(function(){
	$('#sec_vi ul').innerfade ({
		animationtype: 'fade',
		speed: 1500,
		timeout: 5000,
		containerheight: '560px'
	});
});


//top equalHeights セッティング
$(document).ready(function(){
	$('.heightFix').equalHeightColumns();
});



//window可変レイアウト セッティング

$(window).bind("load resize", function(){
	layoutSet(); //windowサイズが変わったら再レイアウト
});

$(document).ready(function() {
	layoutSet(); //レイアウト
});

function layoutSet(){

	var w = Math.floor(($(window).width()));
	var h = Math.floor(($(window).height()));

	if(navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPhone/i)) {
		//ipad ihone
		$("#container").css({ "min-height": h - 182 });	
		$("#contents").css({ "min-height": h - 182 });
	} else {
		$("#container").css({ "min-height": h - 152 });	
		$("#contents").css({ "min-height": h - 152 });
	}
		
	$("#collection_index #contents").css({ "min-height": h - 132 });
	
	if(w > 1000){	
		$("#shop #contents #main_col").css({ "width": w - 496 });
		$("#news_index #contents #main_col").css({ "width": w - 193 });
		$("#news #contents #main_col").css({ "width": w - 350 });
		$("#form #contents #main_col").css({ "width": w - 217 });
	} else {
		$("#shop #contents #main_col").css({ "width": 504 });
		$("#news_index #contents #main_col").css({ "width": 782 });
		$("#news #contents #main_col").css({ "width": 665 });
		$("#form #contents #main_col").css({ "width": 783 });
	}

	var wrapperHeight = Math.floor(($("#wrapper").height()));
	if(wrapperHeight > (h - 305)){		
		$("#wrapper.middle").css({ "padding-top": 85 });
	} else {
		$("#wrapper.middle").css({ "padding-top": (h - wrapperHeight -182)/2 +25 });
	}
	
	if(h < 732){		
		$("#concept #sec_vi").css({ "padding-top": 20 });
		$("#concept #conceptFlash").css({ "height": 600 });
	} else {
		$("#concept #sec_vi").css({ "padding-top": (h - 560 -132)/2 });
		$("#concept #conceptFlash").css({ "height": h - 132 });
	}
	
	if(h < 645){		
		$("#shop_index #main_col div#map_wrap").css({ "padding-top": 40 });
		$("#shop_index #shopFlash").css({ "height": 513 });
		$("#collection_index #external_collectionFlash").css({ "height": 513 });
		$("#top #topFlash").css({ "height": 600 });
	} else {
		$("#shop_index #main_col div#map_wrap").css({ "padding-top": (h - 432 -132)/2 });
		$("#shop_index #shopFlash").css({ "height": h - 132 });
		$("#collection_index #external_collectionFlash").css({ "height": h - 132 });
		$("#top #topFlash").css({ "height": h - 45 });
	}
	
	if(h > 19.2/14* w){
		$("#top #bg img").css({ "height": h });
		$("#top #bg img").css({ "width": 'auto'});
	} else {
		$("#top #bg img").css({ "width": w });
		$("#top #bg img").css({ "height": 'auto' });
	}
	
};


//news masonry セッティング
jQuery.event.add(window, "load", function() {	
	$('#entries').masonry({
		columnWidth: 260, 
		animate: true,
		animationOptions: {
		duration: 300,
		easing: 'easeOutCirc',
		queue: false
	  	}
	});

});
