/*--------------------------------------------------------------------------*
*
*	default js
*
*	(C) Remixpoint, Inc. All Rights Reserved.
*	
*	2009 Remixpoint, Inc.
*	http://www.remixpoint.co.jp
*
*	Last Modified: 2010-12-07
*	Last Editor: Toshiyuki Hara
*
*	jQuery 1.4.4
/*--------------------------------------------------------------------------*/
(function($){

	$(function(){

		//ブラウザ判別 IE6,7,8
		if(!jQuery.support.opacity){
			// IE6,7,8
			if(!jQuery.support.style){
			
				if (typeof document.documentElement.style.maxHeight != "undefined") {
					// IE7
				}
				else {
					// IE6
					$('li:first-child', '#nav_foot').addClass("first-child");
				
				}
				
			}else{
				// IE8
			}
		}

		//imgのマウスオーバープラグイン
		$.fn.mouseHover = function(){

			$(this).hover(
				function(){
					if($(this).attr("src").match(/_active/)){
					} else {
						$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));
					}
				},
				function(){
					if($(this).attr("src").match(/_active/)){
					} else {
						$(this).attr("src",$(this).attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1$2"));
					}
				}
			).each(function(){
				$("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));
			});
			

		}

		/* $(".anchor img, #btn_cls").mouseHover(); */

		//pageScrollerプラグイン
		$.fn.pageScroller = function(options) {
		
			var c = $.extend({
				sclpos: 0
			},options);
		
			$(this).click(function() {
					if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
						var target = $(this.hash);
						target = target.length && target;
						if (target.length) {
							var sclpos = c.sclpos;
							var scldurat = 600;
							var targetOffset = $(this.hash).offset().top - sclpos;
							$('html,body')
								.animate({scrollTop: targetOffset}, {duration: scldurat, easing: "easeOutExpo"});
							return false;
						}
					}
				});
		}

		// class="anchor"でpageScrollerを適用させる
		$(".anchor[href*=#]").pageScroller({
			sclpos: 0
		});


		//ウィンドウで開く
		$("a[rel='blank'],area[rel='blank']").live("click" , function(){
			this.target = "_blank";
		});

		//ウィンドウを閉じる
		$("#btn_cls").click(function(){
			window.close();
		});


		//高さを測るプラグイン
		$.fn.heightMeasures = function(){
			$(this).each(function(){
			
				$(this)
					.next('.slide')
					.css("height",$(this).next('.slide').height());

				if($(this).hasClass('active')){

				} else {
				
					$(this)
						.next('.slide')
						.css({'display':'none'});
				
				}
			});
		}


		//開閉メニュープラグイン
		$.fn.slideMotion = function() {
			
			$(this).heightMeasures();
			$(this).click(function(){
				var th = $(this);
				var next = $(this).next('.slide');
				if(next.css('display')=='none'){
					th
						.addClass('active')
						.next('.slide')
						.slideDown(function(){
							$('div' , this).fadeIn(250);
						});
						
				
				} else if(next.css('display')=='block') {
					th.removeClass('active').next('.slide')
						.find('div')
						.fadeOut(250 , function(){
							$(this).parent('.slide').slideUp();
						});
				}
			});
		}


		// 主な実績 > クライアント別,事業カテゴリー別に「年代」を追加する
		$.fn.yearDisplay = function() {
			
			if($(this).length) {
			
				var fYear = $("div:first" , this).attr("class").replace(/^entry(.+)$/,'$1')-0;
				var lYear = $("div:last" , this).attr("class").replace(/^entry(.+)$/,'$1')-0;
				var i;
				
				for (i = lYear; i <= fYear; i = i +1){
					var ey = "entry"+String(i);
					if($("div."+ ey +"").length) {
						var y = $("div."+ ey +"").attr("class").replace(/^entry(.+)$/,'$1')-0;
						$("div."+ey+"" , this).wrapAll('<div class="nav_local"><div class="slide"></div></div>');
						
					}
				}
				
				$('<h2><span></span></h2>').prependTo('.nav_local');
		
				$('.nav_local').each(function(){
				
					var localYear = $('.slide > div:first' , this).attr("class").replace(/^entry(.+)$/,'$1')-0;
					
					if(fYear == localYear) {
						$('h2', this).addClass('active');
					}
					
					$('h2 > span', this).text(localYear);
				});
				
			
			}
		}


	});

})(jQuery);
