
/**
 *
 * 共通JS
 * 前ページ共通のJS設定
 *
 */
 
	jQuery.easing.def = "string";
 
	/*
	 *
	 * 外部ファイル読み込み
	 ***************************************************************************************************/
	jQuery.require = (function(){
	 	var jspath = "/_commons/baseDir/js/";
		var csspath = "/_commons/baseDir/css/";
		var loadFile = function(obj){
			if(obj.type=='js'){
				document.write('<script type="text/javascript" src="' + jspath + obj.file + '"></script>');
			}else{
				document.write('<link rel="stylesheet" type="text/css" media="all" href="' + csspath + obj.file + '" />');
			}
		}
		var rfunc = function(exfiles){
			if(exfiles.join){
				for(var i=0,l=exfiles.length;i<l;i++){
					loadFile(exfiles[i]);
				}
			}else{
				loadFile(exfiles);
			}
		
		}
		return rfunc;
	})();
			
	//外部読み込みファイルリスト
	var exfilelist = [
		{type:"js",file:"jquery.easing.1.3.js"},
		{type:"js",file:"xlargeblog_jq.js"},
		{type:"js",file:"jquery.dropshadow.js"},
		{type:"js",file:"jquery.dimensions.min.js"},
		{type:"js",file:"jquery.rollover.js"},
		{type:"js",file:"easySlider1.7.js"}
	];
		
	$.require(exfilelist);
		
	/*
	 *
	 * 起動
	 ***************************************************************************************************/
	$(document).ready(function(e){
			
		/**
		 * サーチフォーム
		 */	
		$("input","#search").mouseover(function(){
			$(this).addClass("input-over");
		}).mouseout(function(){
			$(this).removeClass("input-over");
		}).focusin(function(){
			$(this).removeClass("input-over");
			$(this).addClass("input-focusin");
		}).focusout(function(){
			$(this).removeClass("input-over");
			$(this).removeClass("input-focusin");
		});
			
			
		/*
		 * ボック マウスアクションの適応
		 */
		 
		 	//store index
		 	
		 	var ibc = 0;
			$('.indexbox').each(function(){
					
				var _href = $("a",this).attr("href");
				var _target = $("a",this).attr("target");
				_target = _target == "" ? "_self" : _target;

				$(this).css("cursor","pointer");
				$(this).click(function(){
					window.open(_href, _target);
					//location.href = $("a",this).attr("href");
				});

				//Store名縦位置修正
				var ntopp = Number($($(".storename",this)[0]).css("top").split("px")[0]) - ($($(".storename",this)[0]).height() / 2)
				$($(".storename",this)[0]).css("top",ntopp + "px");
					
				$(this).mouseenter(function(){
					//$(this).addClass('over');
					
					$(this).css("backgroundColor",$(".og",this).css("backgroundColor"))
				});
				$(this).mouseleave(function(){
					//$(this).removeClass('over');
					$(this).css("backgroundColor","#FFFFFF")
				});
				$(".storename",this).append($("a",this).html());
				$("a",this).html("");
					
				ibc++;
					
			});
		 
		 
		 	//ENTRY
		 	
			$('.entrybox').each(function(){
					
				$(this).css("cursor","pointer");
				$(this).click(function(){
					location.href = $("a",this).attr("href");
				});
					
				var type = "entry";
			
				$(this).mouseover(function(){
					_clearTimer()
					$(this).addClass(type + 'box-over');
					$(".title",this).addClass(type + 'title-over');
				});
				$(this).mouseout(function(){
					_clear();
				});
				$(".title",this).append($("a",this).html());
				$("a",this).html("");
				
				var _this = this;
				var stid;
				function _clear(){
					_clearTimer()
					if(jQuery.browser.msie){
						stid = setTimeout(_clearExe,0)
					}else{
						_clearExe();
					}
				}
				//
				function _clearExe(){
					trg = _this;
					$(trg).removeClass(type + 'box-over');
					$(".title",trg).removeClass(type + 'title-over');					
				}
					
				function _clearTimer(){
					clearTimeout(stid)
				}	
					
			});

			
		 	//Entry index
			
			$('.entryindexbox').each(function(){
				
				
				$(this).css("cursor","pointer");
				$(this).click(function(){
					location.href = $("a",this).attr("href");
				});
					
				var type = "entryindex";
			
				$(this).mouseover(function(){
					_clearTimer();
					$(this).addClass(type + 'box-over');
					$(".title",this).addClass('title-over');
					$(".description",this).addClass('description-over');
					$(".info",this).addClass('info-over');
				}).
				mouseout(function(){
					_clear();
				});
					
				$(".title",this).append($("a",this).html());
				$("a",this).html("");
				
				var _this = this;
				var stid;
				function _clear(){
					_clearTimer()
					if(jQuery.browser.msie){
						stid = setTimeout(_clearExe,0)
					}else{
						_clearExe();
					}
				}
				//
				function _clearExe(){
					trg = _this;
					$(trg).removeClass(type + 'box-over');
					$(".title",trg).removeClass('title-over');					
					$(".description",trg).removeClass('description-over');
					$(".info",trg).removeClass('info-over');
				}
					
				function _clearTimer(){
					clearTimeout(stid)
				}	
					
			});
					
		 
			//Search index
			$('.searchindexbox').each(function(){
			
				var _href = $("a",this).attr("href");
				var _target = $("a",this).attr("target");
				_target = _target == "" ? "_self" : _target;
				
				$(this).
				mouseenter(function(){
					$(this).addClass('searchindexbox-over');				
					$('.title',this).addClass('title-over');
					$('.date',this).addClass('date-over');
				}).
				mouseleave(function(){
					$(this).removeClass('searchindexbox-over');
					$('.title',this).removeClass('title-over');
					$('.date',this).removeClass('date-over');
				}).
				click(function(){
					window.open(_href, _target);
				}).
				css("cursor","pointer")
					
				$(".title",this).append($("a",this).html());
				$("a",this).html("");
						
			});

		
			//News Detail
			//レイアウト調整
			$('#entrydetailmain').each(function(){
					$(".detailcontent",this).each(function(){
					var i= 0;
					$("p",this).each(function(){
						
						if(i == 0){
						
							var imgc = 0;
							$("img",this).each(function(){
							if(imgc >= 1) return;
							$(this).css("margin","0px");
							$(this).css("padding","0px");
							imgc++;
							})
							}
							
							i++;

							//Pタグ内か空だった場合スペースを入れてエリアをとる
							if($(this).html() == ""){
								$(this).html("&nbsp;");
							}
								
						})
					});
			});


			//Entry Dettail タイトル：複数行対応
			$('#entrydetailmain').each(function(){
				var h = $(".title",this).height() + 15;
				h = h < 40 ? 40 : h;
				h = h + 20;
				$(".detailtitle",this).css("height",h + "px");
				$(".storename",this).css("height",h + "px");
				$(".storename th",this).css("height",h + "px");

				if($(".newicon-s",this).size() == 0) return;
				var imatop = (h - $(".newicon-s",this).height()) / 2 - 1;
				$(".newicon-s",this).css("margin-top",imatop + "px");
				
			});
		 
		 
		 


		/*
	 	 * navi
 		 */

		
			//開閉式リスト
			$('.expandlist').expandlist({multiopen:true}); 		

 			//左袖バナー（ロールオーバで透過する）処理
 			$('.imgbanner,.imgbannerrect').bannerButton({});
			
			
		/*
		 * 共通：ボックスへシャドウの適応
		 * ※最後に適応すること
		 */

			if ($.browser.msie && $.browser.version < 5)
			{			
				$('.shadowbox,.whbtn,.shadowbutton').dropShadow(
				{
					left : 0 ,
					top : 0 ,
					blur : 3 ,
					color : "#c0c0c0",
					swap:false
				}
				);
			}

						
	});
	
	
	/**
	 * 指定の要素位置までスクロールする
	 * @trgid	対象要素名
	 */	
	function scrollTo(trgid){
		$('html, body').animate(
							{ scrollTop: $(trgid).position().top }, 
							{ duration:500, easing:"easeInOutExpo" });
		return false;
	}
	
