

/*メールマガジン登録・解除
----------------------------------------------------*/
function mailmag_window( type ){
/*
if(document.mailmag.email.value == ""){
  alert("メールアドレスを入力してください。");
  return;
}
*/
if( type == 1 ){
	document.mailmag.regist.value = 1;
	document.mailmag.release.value = 0;
}else{
	document.mailmag.regist.value = 0;
	document.mailmag.release.value = 1;
}
	window.open('','mailmag','width=450,height=150,menubar=no,titlebar=no,toolbar=no,scrollbars=no');
	document.mailmag.submit();
}


/*e-book
----------------------------------------------------*/
function MM_openBrWindow(theURL,winName,features) {
  obj = window.open(theURL,winName,features);
  obj.focus(); 
}


/*アクションセット
----------------------------------------------------*/
$(function () {
	$.actionSet.pngfix();
	$.actionSet.tickerLoad();
	$.actionSet.copyright();
	$.actionSet.naviHover();
	$.actionSet.blanklink();
	//$.actionSet.pageScroll();
	$.actionSet.popUpWindow();
	$.actionSet.windowClose();
	$.actionSet.equalHeight();
});

$.actionSet = {
	
	copyright:function(options){
		var data = new Date();
		var now_year = data.getFullYear();
		//var now_year = "getFullYear";
		$("#NowYear").text(now_year);
	},
	
	tickerLoad:function(options){
		$.getScript("/csm/js/jquery.li-scroller.1.0.js", function(){
			//$("#ticker").jStockTicker({interval:20});
			$("ul#ticker").liScroll({travelocity: 0.05}); 
		});
	},
		
	pngfix:function(options){
		/*if (typeof document.documentElement.style.maxHeight == "undefined") {
			$.getScript("/csm/js/DD_belatedPNG.js", function(){
			//$.getScript("http://css-eblog.com/js/common/DD_belatedPNG_0.0.7a.js", function(){
				DD_belatedPNG.fix('img');
			});
		}*/
		$(document).pngFix();
	},
	
	naviHover: function(options) {
		$("#navGlobal ul a img.hover , #navLocal a img.hover, ul.navInfo a img,#navAssistFooter a img,.sectionFrameC ul li img,#knowIndex img,#navTrd img,#navTwitter img,#navFacebook img,#infoMailmag .btn input").each(function() {
			var off = this.src;
			var dot = this.src.lastIndexOf('.');
			var on = this.src.substr(0, dot) +
				'_on' + this.src.substr(dot, 4);
			$(this).hover(
				function() { this.src = on; },
				function() { this.src = off; });
		});		
	},
	
	blanklink: function(options) {
		$('a.external,a.pdf').click(function(){
			window.open(this.href, '_blank');
			return false;
		});
	},
	
	pageScroll: function(options) {
		jQuery.easing.quart = function (x, t, b, c, d) {
			return -c * ((t=t/d-1)*t*t*t - 1) + b;
		};
		$('a[href*=#]').click(function() {
			if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
				&& location.hostname == this.hostname) {
				var $target = $(this.hash);				
				$target = $target.length && $target
				|| $('[name=' + this.hash.slice(1) +']');
				if ($target.length) {
					var targetOffset = $target.offset().top;
					var moveTime =500;
					var thisOffset = $("html").scrollTop();//
					var movePage = Math.abs(thisOffset-targetOffset)/3000;
					movePage = movePage.toFixed(1);
					if(1>=movePage)movePage=1;
					moveTime = moveTime * movePage;
					$('html,body')
					.animate({scrollTop: targetOffset}, moveTime, "quart");
					return false;
				}
			}
		});
	},
	
	popUpWindow: function(options) {
		//memo:.html?name=popupName&scroll=1&width=555&height=555
		$('a.popup,area.popup').click(function(){
			var defwinScroll = 1;			
			var defWinWidth = 650;
			var defwinHeight = 500;
			
			var queryString = this.href.replace(/^[^\?]+\??/, "");
			var params = tb_parseQuery(queryString);
			var url = this.href.split("?")[0];
			var winName = String(params["name"]);
			var winScroll = Number(params["scroll"]);
			var winWidth = Number(params["width"]);
			var winHeight = Number(params["height"]);
			if(isNaN(winWidth)) {
					winWidth = defWinWidth;
			}
			if(isNaN(winHeight)) {
					winHeight = defwinHeight;
			}
			if(isNaN(winScroll)) {
					winScroll = defwinScroll;
			}
		
			var centerW = (window.screen.width-winWidth)/2;
			var centerH = (window.screen.height-winHeight)/2;
			var newWindow;
			newWindow = window.open(url, winName, "toolbar=0, location=0, directories=0, status=0, menubar=1, resizable=yes, scrollbars=" + winScroll + ", width=" + winWidth + ", height=" + winHeight + ", left=" + centerW + ", top=" + centerH + "");
			newWindow.focus();
			return false; 
		});
		function tb_parseQuery ( query ) {
		   var Params = {};
		   if ( ! query ) {return Params;}// return empty object
		   var Pairs = query.split(/[;&]/);
		   for ( var i = 0; i < Pairs.length; i++ ) {
			 var KeyVal = Pairs[i].split('=');
			 if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
			 var key = unescape( KeyVal[0] );
			 var val = unescape( KeyVal[1] );
			 val = val.replace(/\+/g, ' ');
			 Params[key] = val;
		   }
		   return Params;
		}
	},
	
	windowClose: function(options) {
		$("a.close").click(function(){
			window.close();
		});
	},
	equalHeight : function(options) {
			
			$(document).ready(function() {
				equalHeight($("#areaInfo .unit3Col .sectionBox"));
			});
			
			function equalHeight(group) {
				tallest = 0;
				group.each(function() {
					thisHeight = $(this).height()+0;
					if(thisHeight > tallest) {
						tallest = thisHeight;
					}
				});
				group.height(tallest);
			}
	}
	
}




