var _Common_ = {
	initRollovers:function(){
		if (!document.getElementById) return
		var aPreLoad = new Array();
		var sTempSrc;
		var aImages = document.getElementsByTagName('img');
		var img_Len = aImages.length;
		for (var i = 0; i < img_Len; i++) {		
			if (aImages[i].className == 'over') {
				var src = aImages[i].getAttribute('src');
				var ftype = src.substring(src.lastIndexOf('.'), src.length);
				var hsrc = src.replace(ftype, '_over'+ftype);
	
				aImages[i].setAttribute('hsrc', hsrc);
				aPreLoad[i] = new Image();
				aPreLoad[i].src = hsrc;
				aImages[i].onmouseover = function() {
					sTempSrc = this.getAttribute('src');
					this.setAttribute('src', this.getAttribute('hsrc'));
				}	
				aImages[i].onmouseout = function() {
					if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_x'+ftype, ftype);
					this.setAttribute('src', sTempSrc);
				}
			}
			
			if (aImages[i].className == 'imgover') {
				var src = aImages[i].getAttribute('src');
				var ftype = src.substring(src.lastIndexOf('.'), src.length);
				var hsrc = src.replace(ftype, '_o'+ftype);
	
				aImages[i].setAttribute('hsrc', hsrc);
				
				aPreLoad[i] = new Image();
				aPreLoad[i].src = hsrc;
				
				aImages[i].onmouseover = function() {
					sTempSrc = this.getAttribute('src');
					this.setAttribute('src', this.getAttribute('hsrc'));
				}	
				
				aImages[i].onmouseout = function() {
					if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
					this.setAttribute('src', sTempSrc);
				}
			}

		} 
		
		var aInputs = document.getElementsByTagName('input');
		var img_Len = aInputs.length;
		for (var i = 0; i < img_Len; i++) {		
			if (aInputs[i].className == 'over') {
				var src = aInputs[i].getAttribute('src');
				var ftype = src.substring(src.lastIndexOf('.'), src.length);
				var hsrc = src.replace(ftype, '_over'+ftype);
	
				aInputs[i].setAttribute('hsrc', hsrc);
				aPreLoad[i] = new Image();
				aPreLoad[i].src = hsrc;
				aInputs[i].onmouseover = function() {
					sTempSrc = this.getAttribute('src');
					this.setAttribute('src', this.getAttribute('hsrc'));
				}	
				aInputs[i].onmouseout = function() {
					if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_x'+ftype, ftype);
					this.setAttribute('src', sTempSrc);
				}
			}
		}   
		return;
	},
	rand:function(x){
		number = Math.floor(Math.random() * x);
		return number;
	},
	scrollInit:function(){
		$('a[href^=#]').click(function(){
			var href= this.hash;
			var $target = $(href == '#TOP' ? 'body' : href);
			if($target.size()){ 
				var top = $target.offset().top; 
				$($.browser.safari ? 'body' : 'html')
				.animate({scrollTop:top}, 1000, 'easeOutCubic',function(){
				
					location.href = href;
//					location.replace(href);				
				}); 
				return false;
			}
		})
		$('area[href^=#]').click(function(){
			var href= this.hash;
			var $target = $(href == '#TOP' ? 'body' : href);
			if($target.size()){ 
				var top = $target.offset().top; 
				$($.browser.safari ? 'body' : 'html')
				.animate({scrollTop:top}, 1000, 'easeOutCubic',function(){
				
					location.href = href;
//					location.replace(href);				
				}); 
				return false;
			}
		})
	
	},
	popupWindow:function(url, width, height, option, windowName){
		if (!width) width = window.innerWidth || document.documentElement.clientWidth;
		if (!height) height = window.innerHeight || document.documentElement.clientHeight;
		if (!option) option = 'menubar=yes, toolbar=yes, location=yes, status=yes, scrollbars=yes, resizable=yes';
		if (!windowName) windowName = "popup";
		var x = (screen.availWidth - width)/2;
		var y = (screen.availHeight - height)/3;
		var o = option+', width='+width+', height='+height+', left='+x+', top='+y;
		var win = window.open(url, windowName, o);
		
		if (win){
			win.focus();
			return false;
		} else {
			return true;
		}
	}

}
var Cookie = { //cookie
	read:function(CookieName){
		if(document.cookie){
			var cookie_Data = document.cookie;
			var Name =cookie_Data.indexOf(CookieName + "=",0);
			if(Name >= 0){
				var Data = cookie_Data.indexOf(";",Name + CookieName.length + 1);
				Data >= 0? Data = cookie_Data.substring(Name + CookieName.length + 1,Data): Data = cookie_Data.substring(Name + CookieName.length + 1,cookie_Data.length);
				return(Data);
			}
		}
		return(false);
	},
	set:function(CookieName,Value){
		var time =new Date();
		time.setTime(time.getTime() + (1000*365*60*60*24));
		var exptime =";expires=" + time.toGMTString();
		document.cookie = CookieName + "=" + Value + exptime + "; path=/";
	},
	Delete:function(CookieName){
		var time =new Date();
		time.setTime(time.getTime() - (1000*365*60*60*24));
		var exptime =";expires=" + time.toGMTString();
		document.cookie = CookieName + "=" + exptime + "; path=/";
	}
}


// ログイン判定
//------------------------------------------------------------------------------
var login ={};

login.init = function(loca){
	var name = "accnm";
	var src = "";
	src += '<ul>';
	if(Cookie.read(name)){
		//src += '<li><a href="http://www.longyong.jp/cart/cart.php"><img src="../common/img/navi_cart_' + loca + '.png" alt="カートを見る" /></a></li>';
		src += '<li><a href="https://www.longyong.jp/mypage/memberpage.php"><img src="/common/img/navi_mypage_' + loca + '.png" alt="マイページ" /></a></li>';
		src += '<li><a href="https://www.longyong.jp/mypage/login.php?cmd=logout"><img src="/common/img/navi_logout_' + loca + '.png" alt="ログアウト" /></a></li>';
		src += '</ul>';
		src += '<p>ようこそ' + decodeURIComponent(Cookie.read(name)) + 'さん</p>';
	}else{
		src += '<li><a href="https://www.longyong.jp/mypage/login.php"><img src="/common/img/navi_login_' + loca + '.png" alt="ログイン" /></a></li>';
		src += '</ul>';
	}

	document.write(src);
	
/*

		<ul>
			<li><a href="http://www.longyong.jp/cart/cart.php"><img src="../common/img/navi_cart_middle.png" alt="カートを見る" /></a></li>
			<li><a href="https://www.longyong.jp/mypage/memberpage.php"><img src="../common/img/navi_mypage_middle.png" alt="マイページ" /></a></li>
			<li><a href="https://www.longyong.jp/mypage/login.php?cmd=logout"><img src="../common/img/navi_logout_middle.png" alt="ログアウト" /></a></li>
			<li><a href="https://www.longyong.jp/mypage/login.php"><img src="../common/img/navi_login_middle.png" alt="ログイン" /></a></li>
		</ul>
		<p>ようこそ〇〇〇さん</p>

*/
	
};


// トップモーション
//------------------------------------------------------------------------------
var index = {};
index.lock = false;
index.time = 600;
index.easing = 'easeOutExpo';
index.next = function(){
	if(!this.lock){
		this.lock = true;
		$("#Index .mainImg ul").animate({"marginLeft":"0px"},index.time,index.easing,function(){
											  
			$("#Index .mainImg li:last").insertBefore("#Index .mainImg li:first");
			$("#Index .mainImg ul").css("marginLeft","-700px");
			index.lock = false;
		});
	}
	return false;
	
};
index.prev = function(){
	if(!this.lock){
		this.lock = true;
		$("#Index .mainImg ul").animate({"marginLeft":"-1400px"},index.time,index.easing,function(){
											  
			$("#Index .mainImg ul").append($("#Index .mainImg li:first"));
			$("#Index .mainImg ul").css("marginLeft","-700px");
			index.lock = false;
		});
	}
	return false;
};
index.clear = "";
index.init = function(){
	$("#Index .mainImg").hover(function(){
		clearInterval(index.clear)		
	},function(){
		index.clear = setInterval(function(){
			index.next();
		},5000);
	});

	$("#Index .mainImg li").shuffle();
	
	$("#Index .mainImg ul").css("marginLeft","-700px");
	 
	$("#Index .mainImg ul a").each(function(i){
		$(this).mouseover(function(){
			$(this).stop()
			.css("opacity",0.3)
			.animate({
				opacity: 1
			},800,"easeOutCubic");
		});
	});
	
	index.clear = setInterval(function(){
			    
		index.next();
	
	},5000);
	
	
};

/*

	footerBn

======================================================== */
function footerBn(){
	var src ="";
	src +='<div class="middleBnList">';
	src +='<div class="bn">';
	src +='<ul>';
	src +='<li><a href="/user/"><img src="/common/img/m_bn_01.jpg" alt="ユニフォーム　ユーザー紹介" /></a></li>';
	src +='<li><a href="/longyong_magazine/index.html"><img src="/common/img/m_bn_02.jpg" alt="ロンヨンMAGAZINE" /></a></li>';
	src +='<li><a href="http://ameblo.jp/longyong/" target="_blank"><img src="/common/img/m_bn_03.jpg" alt="フットサルブログ" /></a></li>';
	src +='<li><a href="/event/"><img src="/common/img/m_bn_04.jpg" alt="イベント情報" /></a></li>';
	src +='</ul>';
	src +='<br class="clear" />';
	src +='</div>';
	src +='</div>';
	document.write(src);
}

/*

	widget

======================================================== */
var widget = {};
widget.clear = [];
widget.init = function(){
	$("#Widget").fadeIn(500);
	$("#Widget .simulator").hover(function(){
		clearTimeout(widget.clear[0]);
		$(this).stop().animate({width:"100%"},400,"easeOutExpo",function(){
										 
			$(this).find("li,form").fadeIn(100);
			$(this).find("li").mouseover(function(){
			$(this).stop()
			.css("opacity",0.3)
			.animate({
				opacity: 1
			},800,"easeOutCubic");
		});

		});
	},
	function(){
		var obj = this;
		widget.clear[0] = setTimeout(function(){
			$(obj).find("li,form").hide();							 
			$(obj).stop().animate({width:"40px"},400,"easeOutExpo");
		},500);
		
	});
	$("#Widget .login").hover(function(){
		clearTimeout(widget.clear[1]);
		$(this).stop().animate({width:"100%"},400,"easeOutExpo",function(){
										 
			$(this).find("li,form").fadeIn(100);
			$(this).find("li").mouseover(function(){
			$(this).stop()
			.css("opacity",0.3)
			.animate({
				opacity: 1
			},800,"easeOutCubic");
		});

		});
	},
	function(){
		var obj = this;
		widget.clear[1] = setTimeout(function(){
			$(obj).find("li,form").hide();							 
			$(obj).stop().animate({width:"40px"},400,"easeOutExpo");
		},500);
		
	})
	
	
};


/*

	loading

======================================================== */
$(document).ready(function(){ 
        $(document).pngFix(); 
	with(_Common_){
		initRollovers();
		scrollInit();
	}
	widget.init();
	$("#Item .spec .material a").colorbox({transition:"fade"});
	
	if($("#Index").length){
	//	index.init();
	}	 
	 
}); 
    
    
/*

	検索

======================================================== */
function uniformSearch(){
		
		
		
		
		

	return true;
}
    
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuart',
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	}

});


