/*////////////////////////////////////////////////

NRI Network Communications official site
creation date 2010.7
Copyright (c) NRI Network Communications, Ltd. All Rights Reserved.
	
////////////////////////////////////////////////*/
/*------------------------------
font size
------------------------------*/
$(function(){
	 $('.fontSize').html('<div><dl>'+
	'<dt><img src="/shared/image/ttl_fontsize.gif" alt="文字サイズ変更" width="84" height="13"></dt>'+
	'<dd id="fontS"><span>小</span></dd>'+
	'<dd id="fontM"><span>中</span></dd>'+
	'<dd id="fontL"><span>大</span></dd>'+
	'</dl></div>');
});		 
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
$(function(){//common function start
					 
	
    $(function(){
			var ChildElements=$('#wrapper'+','+'footer');
			var fontSizeSet =100;
			
			if($.cookie('fontSize') == null) { 
				$(ChildElements).css('font-size',fontSizeSet+"%");
				$('#fontS').addClass('current');
			}
			else if($.cookie('fontSize')){
				fontSizeSet = $.cookie('fontSize');
				$(ChildElements).css('font-size',fontSizeSet+"%");
				
				switch(fontSizeSet){
				case '100':
					$('#fontM,#fontL').removeClass('current');
					$('#fontS').addClass('current');
					break;
				case '117':
					$('#fontS,#fontL').removeClass('current');
					$('#fontM').addClass('current');
					break;
				case '134':
					$('#fontS,#fontM').removeClass('current');
					$('#fontL').addClass('current');
					break;
				};
			}
			$('.fontSize dd').click(function(){
				var size =$(this).attr('id');		
				switch(size){
				case 'fontS':
					$(fontSizeSet = 100);
					break;
				case 'fontM':
					$(fontSizeSet = 117);
					break;
				case 'fontL':
					$(fontSizeSet = 134);
					break;
				};
				$(ChildElements).css('font-size',fontSizeSet+"%");
				$('.fontSize dd').removeClass('current');
				$(this).toggleClass('current');
				$.cookie('fontSize', fontSizeSet,{ expires: 7 , path:'/'});
			});
		});
/*------------------------------
noscript
------------------------------*/
		$('#wrapper').css('padding-top','0');
/*------------------------------
roll over
------------------------------*/
    $.fn.rollover = function(postfix) {
        postfix = postfix || '_on';
        return this.not('[src*="'+ postfix +'."]').each(function() {
            var img = $(this);
            var src = img.attr('src');
            var src_on = [
                src.substr(0, src.lastIndexOf('.')),
                src.substring(src.lastIndexOf('.'))
            ].join(postfix);
            img.hover(
                function() {
                    img.attr('src', src_on);
                },
                function() {
                    img.attr('src', src);
                }
            );
        });
    };
		$('.on').rollover();
/*----------------------------
add class
----------------------------*/
		var lastchild = [
				'footer li:last-child',
				'.news dl:last-child '		
				];
				for(i=0; i<lastchild.length; i++){
				$($(lastchild)[i]).addClass('lastChild'); 
		}
		var odd = [
				'tr:nth-child(odd)',
				'th:nth-child(odd)',
				'.mailForm li:nth-child(odd)'
				];
				for(i=0; i<odd.length; i++){
				$($(odd)[i]).addClass('odd'); 
		}
		var even = [
				'td:nth-child(even)',
				'tr:nth-child(even)'
				];
				for(i=0; i<odd.length; i++){
				$($(even)[i]).addClass('even'); 
		}
		var nth3 = [
				'td:nth-child(3)'
				];
				for(i=0; i<odd.length; i++){
				$($(nth3)[i]).addClass('nth3'); 
		}
		var nth4 = [
				'td:nth-child(4)'
				];
				for(i=0; i<odd.length; i++){
				$($(nth4)[i]).addClass('nth4'); 
		}
		var iptTxt = [
				'.mailForm input[type="text"]'
				];
				for(i=0; i<odd.length; i++){
				$($(iptTxt)[i]).addClass('iptTxt'); 
		}
		var iptEmail = [
				'.mailForm input[type="email"]'
				];
				for(i=0; i<odd.length; i++){
				$($(iptEmail)[i]).addClass('iptEmail'); 
		}
		var iptTel = [
				'.mailForm input[type="tel"]'
				];
				for(i=0; i<odd.length; i++){
				$($(iptTel)[i]).addClass('iptTel'); 
		}
/*------------------------------
gnav
------------------------------*/
		$('nav li ul').hide();
		var currentPath = location.pathname.replace(/\/index.html/,'/');
		var pathSlash = currentPath.split('/');
		
		var path1 = '/'+pathSlash[1]+'/';
		var path2 = path1+pathSlash[2]+'/';
		
		$('nav li').each(function(){
			var dir = $(this).find	('a').attr('href').replace(/\/index.html/,'/').replace('http://www.nri-net.com/','/');
			if(dir == path1){
				$(this).children().show();
				$(this).children('a').toggleClass('current');
			}else if(dir == path2){
				$(this).children().toggleClass('current');
				$(this).parent().prev().toggleClass('current');
			}
		});
/*------------------------------
scrollto
------------------------------*/
		$('a[href*=#wrapper]').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 = 30;
					var scldurat = 1200;
					var targetOffset = target.offset().top - sclpos;
					$('html,body')
						.animate({scrollTop: targetOffset}, {duration: scldurat, easing: "easeOutExpo"});
					return false;
				}
			}
		});

/*------------------------------
mailto
------------------------------*/
	  var isMac = (navigator.appVersion.indexOf("Macintosh") != -1) ? true : false;
	  var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
	  var mailSer = '';
		var mailRec = '';
		var mailInf = '';
		var mailCar = '';

	  if (isMac) {
	  	mailSer = "<a href='mailto:info@nri-net.com?subject=【サービスに関するお問い合わせ】&body=質問事項をご記入ください。%0d%0a%0d%0a%0d%0a貴社名：%0d%0a部署名：%0d%0aご担当者様 氏名：%0d%0aフリガナ：%0d%0a電話番号：%0d%0aメールアドレス：' class='modMail'>info@nri-net.com</a>";
	  	mailRec = "<a href='mailto:recruit@nri-net.com?subject=【新卒採用に関するお問い合わせ】&body=質問事項をご記入ください。%0d%0a%0d%0a%0d%0a氏名：%0d%0aフリガナ：%0d%0a電話番号：%0d%0aメールアドレス：' class='modMail'>recruit@nri-net.com</a>";
	  	mailCar = "<a href='mailto:career_entry@nri-net.com?subject=【キャリア採用に関するお問い合わせ】&body=質問事項をご記入ください。%0d%0a%0d%0a%0d%0a氏名：%0d%0aフリガナ：%0d%0a電話番号：%0d%0aメールアドレス：' class='modMail'>career_entry@nri-net.com</a>";
	  	mailInf = "<a href='mailto:info@nri-net.com?subject=【お問い合わせ】&body=質問事項をご記入ください。%0d%0a%0d%0a%0d%0a氏名：%0d%0aフリガナ：%0d%0a電話番号：%0d%0aメールアドレス：' class='modMail'>info@nri-net.com</a>";
	  }
		else {
	  	mailSer = "<a href='mailto:info@nri-net.com?subject=%81y%83T%81%5b%83r%83X%82%c9%8a%d6%82%b7%82%e9%82%a8%96%e2%82%a2%8d%87%82%ed%82%b9%81z&body=%8e%bf%96%e2%8e%96%8d%80%82%f0%82%b2%8bL%93%fc%82%ad%82%be%82%b3%82%a2%81B%0d%0a%0d%0a%0d%0a%8bM%8e%d0%96%bc%81F%0d%0a%95%94%8f%90%96%bc%81F%0d%0a%82%b2%92S%93%96%8e%d2%97l%20%8e%81%96%bc%81F%0d%0a%83t%83%8a%83K%83i%81F%0d%0a%93d%98b%94%d4%8d%86%81F%0d%0a%83%81%81%5b%83%8b%83A%83h%83%8c%83X%81F' class='modMail'>info@nri-net.com</a>";
	  	mailRec = "<a href='mailto:recruit@nri-net.com?subject=%81y%90V%91%b2%8d%cc%97p%82%c9%8a%d6%82%b7%82%e9%82%a8%96%e2%82%a2%8d%87%82%ed%82%b9%81z&body=%8e%bf%96%e2%8e%96%8d%80%82%f0%82%b2%8bL%93%fc%82%ad%82%be%82%b3%82%a2%81B%0d%0a%0d%0a%0d%0a%8e%81%96%bc%81F%0d%0a%83t%83%8a%83K%83i%81F%0d%0a%93d%98b%94%d4%8d%86%81F%0d%0a%83%81%81%5b%83%8b%83A%83h%83%8c%83X%81F' class='modMail'>recruit@nri-net.com</a>";
	  	mailCar = "<a href='mailto:career_entry@nri-net.com?subject=%81y%83L%83%83%83%8a%83A%8d%cc%97p%82%c9%8a%d6%82%b7%82%e9%82%a8%96%e2%82%a2%8d%87%82%ed%82%b9%81z&body=%8e%bf%96%e2%8e%96%8d%80%82%f0%82%b2%8bL%93%fc%82%ad%82%be%82%b3%82%a2%81B%0d%0a%0d%0a%0d%0a%8e%81%96%bc%81F%0d%0a%83t%83%8a%83K%83i%81F%0d%0a%93d%98b%94%d4%8d%86%81F%0d%0a%83%81%81%5b%83%8b%83A%83h%83%8c%83X%81F' class='modMail'>career_entry@nri-net.com</a>";
	  	mailInf = "<a href='mailto:info@nri-net.com?subject=%81y%82%a8%96%e2%82%a2%8d%87%82%ed%82%b9%81z&body=%8e%bf%96%e2%8e%96%8d%80%82%f0%82%b2%8bL%93%fc%82%ad%82%be%82%b3%82%a2%81B%0d%0a%0d%0a%0d%0a%8e%81%96%bc%81F%0d%0a%83t%83%8a%83K%83i%81F%0d%0a%93d%98b%94%d4%8d%86%81F%0d%0a%83%81%81%5b%83%8b%83A%83h%83%8c%83X%81F' class='modMail'>info@nri-net.com</a>";
	  }

		$('.modMailSer').html(mailSer);
		$('.modMailRec').html(mailRec);
		$('.modMailCar').html(mailCar);
		$('.modMailInf').html(mailInf);

});//common function end
/*------------------------------
 *  heightLine JavaScript Library beta4
 *  
 *  MIT-style license. 
 *  
 *  2007 Kazuma Nishihata 
 *  http://www.webcreativepark.net
------------------------------*/
new function(){
	
	function heightLine(){
	
		this.className="heightLine";
		this.parentClassName="modBoxCol3"
		reg = new RegExp(this.className+"-([a-zA-Z0-9-_]+)", "i");
		objCN =new Array();
		var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
		for(var i = 0; i < objAll.length; i++) {
			var eltClass = objAll[i].className.split(/\s+/);
			for(var j = 0; j < eltClass.length; j++) {
				if(eltClass[j] == this.className) {
					if(!objCN["main CN"]) objCN["main CN"] = new Array();
					objCN["main CN"].push(objAll[i]);
					break;
				}else if(eltClass[j] == this.parentClassName){
					if(!objCN["parent CN"]) objCN["parent CN"] = new Array();
					objCN["parent CN"].push(objAll[i]);
					break;
				}else if(eltClass[j].match(reg)){
					var OCN = eltClass[j].match(reg)
					if(!objCN[OCN]) objCN[OCN]=new Array();
					objCN[OCN].push(objAll[i]);
					break;
				}
			}
		}
		
		//check font size
		var e = document.createElement("div");
		var s = document.createTextNode("S");
		e.appendChild(s);
		e.style.visibility="hidden"
		e.style.position="absolute"
		e.style.top="0"
		document.getElementById("wrapper").appendChild(e);
		var defHeight = e.offsetHeight;
		
		changeBoxSize = function(){
			for(var key in objCN){
				if (objCN.hasOwnProperty(key)) {
					//parent type
					if(key == "parent CN"){
						for(var i=0 ; i<objCN[key].length ; i++){
							var max_height=0;
							var CCN = objCN[key][i].childNodes;
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j] && CCN[j].nodeType == 1){
									CCN[j].style.height="auto";
									max_height = max_height>CCN[j].offsetHeight?max_height:CCN[j].offsetHeight;
								}
							}
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j].style){
									var stylea = CCN[j].currentStyle || document.defaultView.getComputedStyle(CCN[j], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight -= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight -= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","");
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									CCN[j].style.height =newheight+"px";
								}
							}
						}
					}else{
						var max_height=0;
						for(var i=0 ; i<objCN[key].length ; i++){
							objCN[key][i].style.height="auto";
							max_height = max_height>objCN[key][i].offsetHeight?max_height:objCN[key][i].offsetHeight;
						}
						for(var i=0 ; i<objCN[key].length ; i++){
							if(objCN[key][i].style){
								var stylea = objCN[key][i].currentStyle || document.defaultView.getComputedStyle(objCN[key][i], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight-= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight-= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","")
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									objCN[key][i].style.height =newheight+"px";
							}
						}
					}
				}
			}
		}
		
		checkBoxSize = function(){
			if(defHeight != e.offsetHeight){
				changeBoxSize();
				defHeight= e.offsetHeight;
			}
		}
		changeBoxSize();
		setInterval(checkBoxSize,1000)
		window.onresize=changeBoxSize;
	}
	
	function addEvent(elm,listener,fn){
		try{
			elm.addEventListener(listener,fn,false);
		}catch(e){
			elm.attachEvent("on"+listener,fn);
		}
	}
	addEvent(window,"load",heightLine);
}

