/*
 * general.js - for www.haruyama.jp
 * @requires jQuery v1.3.2
 *
 * Copyright (c) 2010 cyclops.co.,ltd.
 * $Date: 2010.01.15
 *
 */


 
/**
 *	Initialization
 */
$(function(){
	$.cyc.init();
});

$(window).load(function () {
	$.cyc.load();
 });

/**
 *	Initialization
 */

$.cyc = {
	init: function() {
		for (module in $.cyc) {
			if ($.cyc[module].init){
				$.cyc[module].init();
			}
		}
	},
	load:function(){
		for (module in $.cyc) {
			if ($.cyc[module].load){
				$.cyc[module].load();
			}
		}
	}
};





/**
 *	externalLinks (add target _blank)
 */
$.cyc.externalLinks = {
	init: function() {
		$('a[rel=external]').attr("target","_blank").filter(':not(:has("img"))').addClass("external");
	}
};


/**
 *	swap img
 */
$.cyc.swap = {
	init: function() {
		$('img.swap')
			.bind('mouseover', this.enter)
			.bind('mouseout', this.exit)
			.each(this.preload);
		$('input[type=image]')
			.bind('mouseover', this.enter)
			.bind('mouseout', this.exit)
			.each(this.preload);
	},
	preload: function() {
		this.preloaded = new Image;
		this.preloaded.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1-o$2");
	},
	enter: function() {
		this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1-o$2");
	},
	exit: function() {
		this.src = this.src.replace(/^(.+)-o(\.[a-z]+)$/, "$1$2");
	}
};


/**
 *	pagetop
 */
 $.cyc.pagetop = {
	init: function() {
		$('#footer a[href*=#]').click(function() {
			if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')&& location.hostname == this.hostname.replace(/:.*$/,'')) {
				var $target = $(this.hash);
				$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
				if ($target.length) {
					var targetOffset = $target.offset().top;
					$('html,body').animate({scrollTop: targetOffset}, 500);
					return false;
				}
			}
		});	
	 }
 };
 


/**
 *	table-zebra
 */
$.cyc.zebra = {
	init:function(){
		$('tbody','table.zebra').each(function(){
				$("tr",this).removeClass("odd").filter(':odd').addClass("odd");
		});
	}
};


/**
 *	table-trHover
 */
$.cyc.trHover = {
	init:function(){
		//hover
		$("tr","table.trhover tbody").hover(function() {
			$(this).addClass("hover");
		},
		function() {
		$(this).removeClass("hover");
		} ); 
	}
};




/**
 *	thumbnails list height fix
 */
 

 $.cyc.thumbnails = {
 	init:function(){
	 	$("li",".thumbnails").css('height','auto');
	 },
	load:function(){
		//list height even
		$(".thumbnails").autoHeight(true);
	}
};




/**
shadowboxの設定
*/

Shadowbox.init({
	language:   "ja",
	players:    ["img","flv","html","iframe"]
});



/**
shadowbox option
target="_parent"
*/
$.cyc.parentLinks = {
	init: function() {
		$('#parentlink','#cart').attr("target","_parent");
		$('a[rel=parentlink]').attr("target","_parent");
	}
};




/**
lavaLamp
 */
 $.cyc.lavaLamp = {
 	init:function(){
		$("#contents-navigation").lavaLamp({
			fx: "backout", 
			speed: 800,
			click: function(event, menuItem) {
				return true;
			}
		});
	}
};


/**
Groject.ImageSwitch.js
http://www.skuare.net/test/jImageSwitch.html
*/
/*
$.cyc.lmageSwitch = {
	init:function(){
		$("#item-thumbs a").click(function(){
		$(".slash").ImageSwitch({Type:$(this).attr("class"), 
			NewImage:$(this).attr("rel"),	
			Direction:"DownTop"
			});
		});
	}
};
*/


/**
jquery.galleriffic.js
http://www.twospy.com/galleriffic/
*/






/**
slide pan js
*/
/*
$.cyc.lmagePan = {
	init:function(){
		
		$('#fig-zoom').hide();
		$('#fig-zoom').fadeIn(1500);
		
		var x = 0;
		var y = 0;
		
		$('#fig-zoom').mousedown(function(e) {
			$(this).css('cursor', 'move');
			var bx = e.pageX;
			var by = e.pageY;
			$().bind('mousemove.move', function(e) {
				x += bx - e.pageX;
				bx = e.pageX;
				if (x < 0) x = 0;
				if (x > 263) x = 263;
				y += by - e.pageY;
				by = e.pageY;
				if (y < 0) y = 0;
				if (y > 350) y = 350;
				$('#fig-zoom').css('backgroundPosition', '-' + x + 'px -' + y + 'px');
				return false;
			}).one('mouseup', function() {
			$('#fig-zoom').css('cursor', 'auto');
			$().unbind('mousemove.move');
		});
		return false;
		}),
		
		$("#item-thumbs a").click(function(){
			var link = 'url(' + $(this).attr('rel') +')';
			$('#fig-zoom').css('background-image',link);
			$('#fig-zoom').css('background-position','top left');
			x = 0;
			y = 0;
			$('#fig-zoom').hide();
			$('#fig-zoom').fadeIn(1500);
		});
	}
};
*/






/**
#order
スーツのスタイルによりタックの選択を変化させる
*/

$.cyc.orderForm = {
	init:function(){
		var bodyID = $('body').attr('id');
		
		function offradio(){
			$('#slacks01-unit input').removeAttr('checked');
			$('#slacks02-unit input').removeAttr('checked');
			$('#slacks03-unit input').removeAttr('checked');
		}
		
		function efx(t1,t2,t3){
			$('#slacks01-unit').fadeTo('slow',t1);
			$('#slacks02-unit').fadeTo('slow',t2);
			$('#slacks03-unit').fadeTo('slow',t3);
		}
		
		if(bodyID =='order'){
			$("#input-jacket-silhouette .left input").click(function(){  
				
				efx(1,0.5,0.5);
				
				$('#slacks01-unit input').removeAttr('disabled');
				$('#slacks02-unit input').attr('disabled','true');
				$('#slacks03-unit input').attr('disabled','true');
				
				offradio();
			});
			
			$("#input-jacket-silhouette .right input").click(function(){
				
				efx(1,1,1);
				
				$('#slacks01-unit input').removeAttr('disabled');
				$('#slacks02-unit input').removeAttr('disabled');
				$('#slacks03-unit input').removeAttr('disabled');
				
				offradio();
			});  
		}
	}
};


/**
#login
会員登録の選択を変化させる
*/

$.cyc.loginForm = {
	init:function(){
		var bodyID = $('body').attr('id');
		
		if(bodyID =='login'){
			$("input#user-year").click(function(){
				$('#input-year label').fadeTo("slow",1);
				$('#input-tel label').fadeTo("slow",0.5);
				
				$('#input-tel input#user-tel1').attr('disabled','false');
				$('#input-tel input#user-tel2').attr('disabled','false');
				$('#input-tel input#user-tel3').attr('disabled','false');
				
				$('#input-year select').removeAttr('disabled');
			});
			
			$("input#user-tel").click(function(){
				$('#input-tel label').fadeTo("slow",1);
				$('#input-year label').fadeTo("slow",0.5);
				
				$('#input-year select').attr('disabled','false');
				
				$('#input-tel input#user-tel1').removeAttr('disabled');
				$('#input-tel input#user-tel2').removeAttr('disabled');
				$('#input-tel input#user-tel3').removeAttr('disabled');
			});
		}
	}
};



/**
item.html
input#user-remake
詳細ページでのお直しの選択の変化
*/

$.cyc.remakeForm = {
	init:function(){
		$('#user-remake1','fieldset#input-user-gocart').click(function(){
			/*$('#input-remake1 label').fadeTo("slow",1);
			$('#input-remake2 label').fadeTo("slow",0.5);*/
			
			$('#input-remake2 label.chagename').fadeTo("slow",0.5);
			
			$('#input-remake2 select').attr('disabled','false');
		});
		
		$('#user-remake2').click(function(){
			$('#input-remake2 label.chagename').fadeTo("slow",1);
			
			$('#input-remake2 select').removeAttr('disabled');
		});
	}
};



/*サイドメニューのli:hover実装*/

/**
li:hoverを実装する
*/
$.cyc.lihover = {
	init:function(){
		$('li','#content-sub-navigation .category').hover(function(){
			$(this).addClass('hover');
		},function(){
			$(this).removeClass('hover');
		});
	}
};



/**
swfobject
*/
$.cyc.swfobjects = {
	init:function(){
		var bodyID = $('body').attr('id');
		
		if (window.location.pathname == "/"){
			
var swfURL = '/flashbanner/flashBanner.swf';
var so = new SWFObject(swfURL, "flashbanner", "528", "232", "6.0.65");

	so.addVariable("playlist", "/flashbanner/list.xml");
	
	//so.addVariable("loopTime", "2");

	so.addVariable("areaBorderWidth", "1");
	//so.addVariable("areaBorderColor", "0x000000");
	//so.addVariable("areaBackgroundColor", "0xFFFFFF");
	so.addVariable("areaBorderEdge", "true");

	//so.addVariable("bannerWidth", "170");
	//so.addVariable("bannerHeight", "40");
	so.addVariable("bannerMargin", "10");
	so.addVariable("bannerPadding", "2");

	//so.addVariable("bannerColorNormal", "0xc9E4F2");
	so.addVariable("bannerColorHover", "0xCC0000");
	so.addVariable("bannerColorCurrent", "0x0A2F61");
	
	so.addVariable("bannerAreaPadding", "7");
	//so.addVariable("bannerAreaMarginBottom", "0");
	
	so.addVariable("bannerAreaBackgroundColor", "0xFFFFFF");
	so.addVariable("bannerAreaBackgroundAlpha", "40");
	//so.addVariable("bannerAreaBackgroundImage", "/flashbanner/gui/bg-comp.jpg");

	so.addVariable("bannerAccelAreaWidth", "30");
	so.addVariable("bannerArwImage", "/flashbanner/gui/arw.swf");
	so.addVariable("bannerArwAlphaNormal", "50");
	//so.addVariable("bannerArwAlphaHover", "80");

	//so.addVariable("bannerSpeed", "-2");
	so.addVariable("bannerAccel", "5");

	//so.addVariable("displaySelectable", "false");
	//so.addVariable("areaResizable", "false");

so.write("flash-banner");
			
		}
		
		if (window.location.pathname == "/label01/"){
var swfURL = '/flashbanner/flashBanner.swf';
var so = new SWFObject(swfURL, "flashbanner", "526", "232", "6.0.65");

	so.addVariable("playlist", "/flashbanner/label01.xml");
	
	//so.addVariable("loopTime", "2");

	so.addVariable("areaBorderWidth", "1");
	//so.addVariable("areaBorderColor", "0x000000");
	//so.addVariable("areaBackgroundColor", "0xFFFFFF");
	so.addVariable("areaBorderEdge", "true");

	//so.addVariable("bannerWidth", "170");
	//so.addVariable("bannerHeight", "40");
	so.addVariable("bannerMargin", "10");
	so.addVariable("bannerPadding", "2");

	//so.addVariable("bannerColorNormal", "0xc9E4F2");
	so.addVariable("bannerColorHover", "0xCC0000");
	so.addVariable("bannerColorCurrent", "0x0A2F61");
	
	so.addVariable("bannerAreaPadding", "7");
	//so.addVariable("bannerAreaMarginBottom", "0");
	
	so.addVariable("bannerAreaBackgroundColor", "0xFFFFFF");
	so.addVariable("bannerAreaBackgroundAlpha", "40");
	//so.addVariable("bannerAreaBackgroundImage", "/flashbanner/gui/bg-comp.jpg");

	so.addVariable("bannerAccelAreaWidth", "30");
	so.addVariable("bannerArwImage", "/flashbanner/gui/arw.swf");
	so.addVariable("bannerArwAlphaNormal", "50");
	//so.addVariable("bannerArwAlphaHover", "80");

	//so.addVariable("bannerSpeed", "-2");
	so.addVariable("bannerAccel", "5");

	//so.addVariable("displaySelectable", "false");
	//so.addVariable("areaResizable", "false");

so.write("flash-banner");
		}
		
		if (window.location.pathname == "/label02/"){
var swfURL = '/flashbanner/flashBanner.swf';
var so = new SWFObject(swfURL, "flashbanner", "526", "232", "6.0.65");
	so.addVariable("playlist", "/flashbanner/label02.xml");
	so.addVariable("areaBorderWidth", "1");
	so.addVariable("areaBorderEdge", "true");
	so.addVariable("bannerMargin", "10");
	so.addVariable("bannerPadding", "2");
	so.addVariable("bannerColorHover", "0xCC0000");
	so.addVariable("bannerColorCurrent", "0x0A2F61");
	so.addVariable("bannerAreaPadding", "7");
	so.addVariable("bannerAreaBackgroundColor", "0xFFFFFF");
	so.addVariable("bannerAreaBackgroundAlpha", "40");

	so.addVariable("bannerAccelAreaWidth", "30");
	so.addVariable("bannerArwImage", "/flashbanner/gui/arw.swf");
	so.addVariable("bannerArwAlphaNormal", "50");
	so.addVariable("bannerAccel", "5");
	
so.write("flash-banner");
		}
		
		if (window.location.pathname == "/label03/"){
var swfURL = '/flashbanner/flashBanner.swf';
var so = new SWFObject(swfURL, "flashbanner", "526", "232", "6.0.65");

	so.addVariable("playlist", "/flashbanner/label03.xml");
	
	//so.addVariable("loopTime", "2");

	so.addVariable("areaBorderWidth", "1");
	//so.addVariable("areaBorderColor", "0x000000");
	//so.addVariable("areaBackgroundColor", "0xFFFFFF");
	so.addVariable("areaBorderEdge", "true");

	//so.addVariable("bannerWidth", "170");
	//so.addVariable("bannerHeight", "40");
	so.addVariable("bannerMargin", "10");
	so.addVariable("bannerPadding", "2");

	//so.addVariable("bannerColorNormal", "0xc9E4F2");
	so.addVariable("bannerColorHover", "0xCC0000");
	so.addVariable("bannerColorCurrent", "0x0A2F61");
	
	so.addVariable("bannerAreaPadding", "7");
	//so.addVariable("bannerAreaMarginBottom", "0");
	
	so.addVariable("bannerAreaBackgroundColor", "0xFFFFFF");
	so.addVariable("bannerAreaBackgroundAlpha", "40");
	//so.addVariable("bannerAreaBackgroundImage", "/flashbanner/gui/bg-comp.jpg");

	so.addVariable("bannerAccelAreaWidth", "30");
	so.addVariable("bannerArwImage", "/flashbanner/gui/arw.swf");
	so.addVariable("bannerArwAlphaNormal", "50");
	//so.addVariable("bannerArwAlphaHover", "80");

	//so.addVariable("bannerSpeed", "-2");
	so.addVariable("bannerAccel", "5");

	//so.addVariable("displaySelectable", "false");
	//so.addVariable("areaResizable", "false");

so.write("flash-banner");

		}
		
	}
}
