// Tooltip
var tooltip=function(){
	var id = 'tt';
	var top = -73;
	var left = -36;
	var maxw = 232;
	var speed = 10;
	var timer = 20;
	var endalpha = 85;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();

/*
 * yuga.js 0.7.1
 * Copyright (c) 2009 Kyosuke Nakamura (kyosuke.jp)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Since:     2006-10-30
 * Modified:  2009-01-27
 *
 * jQuery 1.3.1
 */

(function($) {

	$(function(){
    var $targetElement = '.wordBreak';
    if($.browser.msie) {
        $($targetElement).css('word-break', 'break-all');
    } else {
        $($targetElement).each(function(){
            if(navigator.userAgent.indexOf('Firefox/2') != -1) {
                $(this).html($(this).text().split('').join('<wbr />'));
            } else {
                $(this).html($(this).text().split('').join(String.fromCharCode(8203)));
            }
        });
    }
});
	
$(function() {
	$.yuga.rollover();
	$.yuga.scroll();
	$.yuga.tab();
	$.yuga.stripe();
	$.yuga.css3class();
});

//---------------------------------------------------------------------

$.yuga = {
	// URIを解析したオブジェクトを返すfunction
	Uri: function(path){
		var self = this;
		this.originalPath = path;
		//絶対パスを取得
		this.absolutePath = (function(){
			var e = document.createElement('span');
			e.innerHTML = '<a href="' + path + '" />';
			return e.firstChild.href;
		})();
		//絶対パスを分解
		var fields = {'schema' : 2, 'username' : 5, 'password' : 6, 'host' : 7, 'path' : 9, 'query' : 10, 'fragment' : 11};
		var r = /^((\w+):)?(\/\/)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#]+)?\??([^#]+)?#?(\w*)/.exec(this.absolutePath);
		for (var field in fields) {
			this[field] = r[fields[field]];
		}
		this.querys = {};
		if(this.query){
			$.each(self.query.split('&'), function(){
				var a = this.split('=');
				if (a.length == 2) self.querys[a[0]] = a[1];
			});
		}
	},
	//ロールオーバー
	rollover: function(options) {
		var c = $.extend({
			hoverSelector: '.imgover, .allimg img',
			groupSelector: '.imggroup',
			postfix: '_on'
		}, options);
		//ロールオーバーするノードの初期化
		var rolloverImgs = $(c.hoverSelector).filter(isNotCurrent);
		rolloverImgs.each(function(){
			this.originalSrc = $(this).attr('src');
			this.rolloverSrc = this.originalSrc.replace(new RegExp('('+c.postfix+')?(\.gif|\.jpg|\.png)$'), c.postfix+"$2");
			this.rolloverImg = new Image;
			this.rolloverImg.src = this.rolloverSrc;
		});
		//グループ内のimg要素を指定するセレクタ生成
		var groupingImgs = $(c.groupSelector).find('img').filter(isRolloverImg);
			//通常ロールオーバー
		rolloverImgs.not(groupingImgs).hover(function(){
			$(this).attr('src',this.rolloverSrc);
		},function(){
			$(this).attr('src',this.originalSrc);
		});
		//グループ化されたロールオーバー
		$(c.groupSelector).hover(function(){
			$(this).find('img').filter(isRolloverImg).each(function(){
				$(this).attr('src',this.rolloverSrc);
			});
		},function(){
			$(this).find('img').filter(isRolloverImg).each(function(){
				$(this).attr('src',this.originalSrc);
			});
		});
		//フィルタ用function
		function isNotCurrent(i){
			return Boolean(!this.currentSrc);
		}
		function isRolloverImg(i){
			return Boolean(this.rolloverSrc);
		}
		},
	//ページ内リンクはするするスクロール
	scroll: function(options) {
		//ドキュメントのスクロールを制御するオブジェクト
		var scroller = (function() {
			var c = $.extend({
				easing:100,
				step:30,
				fps:60,
				fragment:''
			}, options);
			c.ms = Math.floor(1000/c.fps);
			var timerId;
			var param = {
				stepCount:0,
				startY:0,
				endY:0,
				lastY:0
			};
			//スクロール中に実行されるfunction
			function move() {
				if (param.stepCount == c.step) {
					//スクロール終了時
					setFragment(param.hrefdata.absolutePath);
					window.scrollTo(getCurrentX(), param.endY);
				} else if (param.lastY == getCurrentY()) {
					//通常スクロール時
					param.stepCount++;
					window.scrollTo(getCurrentX(), getEasingY());
					param.lastY = getEasingY();
					timerId = setTimeout(move, c.ms); 
				} else {
					//キャンセル発生
					if (getCurrentY()+getViewportHeight() == getDocumentHeight()) {
						//画面下のためスクロール終了
						setFragment(param.hrefdata.absolutePath);
					}
				}
			}
			function setFragment(path){
				location.href = path
			}
			function getCurrentY() {
				return document.body.scrollTop  || document.documentElement.scrollTop;
			}
			function getCurrentX() {
				return document.body.scrollLeft  || document.documentElement.scrollLeft;
			}
			function getDocumentHeight(){
				return document.documentElement.scrollHeight || document.body.scrollHeight;
			}
			function getViewportHeight(){
				return (!$.browser.safari && !$.browser.opera) ? document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight : window.innerHeight;
			}
			function getEasingY() {
				return Math.floor(getEasing(param.startY, param.endY, param.stepCount, c.step, c.easing));
			}
			function getEasing(start, end, stepCount, step, easing) {
				var s = stepCount / step;
				return (end - start) * (s + easing / (100 * Math.PI) * Math.sin(Math.PI * s)) + start;
			}
			return {
				set: function(options) {
					this.stop();
					if (options.startY == undefined) options.startY = getCurrentY();
					param = $.extend(param, options);
					param.lastY = param.startY;
					timerId = setTimeout(move, c.ms); 
				},
				stop: function(){
					clearTimeout(timerId);
					param.stepCount = 0;
				}
			};
		})();
		$('a[href^=#], area[href^=#]').not('a[href=#], area[href=#]').each(function(){
			this.hrefdata = new $.yuga.Uri(this.getAttribute('href'));
		}).click(function(){
			var target = $('#'+this.hrefdata.fragment);
			if (target.length == 0) target = $('a[name='+this.hrefdata.fragment+']');
			if (target.length) {
				scroller.set({
					endY: target.offset().top,
					hrefdata: this.hrefdata
				});
				return false;
			}
		});
	},
	//タブ機能
	tab: function(options) {
		var c = $.extend({
			tabNavSelector:'.tabNav',
			activeTabClass:'active'
		}, options);
		$(c.tabNavSelector).each(function(){
			var tabNavList = $(this).find('a[href^=#], area[href^=#]');
			var tabBodyList;
			tabNavList.each(function(){
				this.hrefdata = new $.yuga.Uri(this.getAttribute('href'));
				var selecter = '#'+this.hrefdata.fragment;
				if (tabBodyList) {
					tabBodyList = tabBodyList.add(selecter);
				} else {
					tabBodyList = $(selecter);
				}
				$(this).unbind('click');
				$(this).click(function(){
					tabNavList.removeClass(c.activeTabClass);
					$(this).addClass(c.activeTabClass);
					tabBodyList.hide();
					$(selecter).show();
					return false;
				});
			});
			tabBodyList.hide()
			tabNavList.filter(':first').trigger('click');
		});
	},
	//奇数、偶数を自動追加
	stripe: function(options) {
		var c = $.extend({
			oddClass:'odd',
			evenClass:'even'
		}, options);
		$('ul, ol').each(function(){
			//JSでは0から数えるのでevenとaddを逆に指定
			$(this).children('li:odd').addClass(c.evenClass);
			$(this).children('li:even').addClass(c.oddClass);
		});
		$('table, tbody').each(function(){
			$(this).children('tr:odd').addClass(c.evenClass);
			$(this).children('tr:even').addClass(c.oddClass);
		});
	},
	//css3のクラスを追加
	css3class: function() {
		//:first-child, :last-childをクラスとして追加
		$('body :first-child').addClass('firstChild');
		$('body :last-child').addClass('lastChild');
		//css3の:emptyをクラスとして追加
		$('body :empty').addClass('empty');
	}
};
})(jQuery);



/*company_message_nenga*/
function nengawinopen(){
    var NewWin = window.open("nenga/index.html",
                    "nenga",
                    'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=950,height=650');
    NewWin.moveTo(window.screen.availWidth/2 - (1024/2) ,window.screen.availHeight/2 - 369)
    NewWin.focus();
}

/*company_history*/
function historyopen(url,name) {
  str = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=480,height=360';
  var newW = window.open(url,name,str);
  newW.focus();
}

/*photocanvas*/
function photocanvas(){
	NewWin=window.open("http://www.cdn-tera.co.jp/recruit/photocanvas/index.html","photocanvas",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=740,height=550');
}

/*solution_index*/
function caseopen(url,name) {
  str = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=765,height=520';
  var newW = window.open(url,name,str);
  newW.focus();
}

/*solution_employment*/
function saiyouopen(url,name) {
  str = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=700,height=550';
  var newW = window.open(url,name,str);
  newW.focus();
}

/*product_dpanpf*/
function dpanphopen(url,name) {
  str = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=815,height=650';
  var newW = window.open(url,name,str);
  newW.focus();
}


/*googlemap*/
function writeGMap( intCLat, intCLon ) {

	if (GBrowserIsCompatible()) { 

		var map = new GMap( document.getElementById( "gmap" ) );		// Division Object - Google Maps
		var lon  = intCLon ;
		var lat  = intCLat ;
		var myoffice = new GPoint(lon,lat);
		map.centerAndZoom(myoffice , 3);
		map.addControl(new GSmallMapControl());
		var baseIcon = new GIcon();
		/*baseIcon.shadow = 'http://www.google.com/mapfiles/shadow50.png';*/
		baseIcon.iconSize = new GSize(118, 63);
		/*baseIcon.shadowSize = new GSize(37, 34);*/
		baseIcon.iconAnchor = new GPoint(51, 55);
		baseIcon.infoWindowAnchor = new GPoint(9, 2);
		baseIcon.infoShadowAnchor = new GPoint(18, 25);
		var icon = new GIcon(baseIcon);
		icon.image = 'images/teralogo.png';
		var marker = new GMarker(myoffice,icon);
		map.addOverlay(marker);
	}
}

/*photocanvas*/
function photocanvas(){
	NewWin=window.open("http://www.cdn-tera.co.jp/recruit/photocanvas/index.html","photocanvas",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=740,height=550');
}

//フルスクリーン
// --- vvv --- Which your Browser --- vvv ---
var myBrowser;
if(navigator.platform){
	myBrowser=new myBrowser((document.getElementById != null),(navigator.platform.indexOf('Win32') != -1),(navigator.appName.indexOf('Microsoft') != -1));
}
function myBrowser(version,platform,type){
	this.version=version;	//trueかfalse,DOM使用可能ブラウザ(IE4以上,NN6以上)ならtrue
	this.platform=platform;	//trueかfalse,Win32ならtrue
	this.type=type;		//trueかfalse,IEならtrue
}
// --- ^^^ --- Which your Browser --- ^^^ ---
//--------------モニタ解像度に合わせてフルスクリーンでウィンドウを開きます。
function openOutputFullScr(myUrl){

	//if(MM_FlashCanPlay){//Flash Player Ver.6を持っていればウィンドウを開く

		//var myUrl = "index.html";

		if(myBrowser.type){ //IEの場合
			if(myBrowser.platform){ //WIN IEの場合
				var thisWinWidth=screen.width;
				var thisWinHeight=screen.availHeight;
				newwin=window.open(myUrl,"_blank","scrollbars=0,resizable=no,location=no,menubar=no,status=no,left=0,top=0");
				newwin.resizeTo(thisWinWidth,thisWinHeight);
			}
			else{ //Mac IEの場合
				var thisWinWidth=screen.width-12;
				var thisWinHeight=screen.availHeight;
				newwin=window.open(myUrl,"_blank","scrollbars=0,resizable=no,location=no,menubar=no,status=no,left=0,top=0");
				newwin.resizeTo(thisWinWidth,thisWinHeight);
			}
		}
		else{

			if( navigator.userAgent.indexOf("Safari") != -1){
				//Safari
				var thisWinWidth=screen.width;
				var thisWinHeight=screen.height-46;
				window_size = "width=" + thisWinWidth + ",height=" + thisWinHeight +",innerWidth=" + thisWinWidth + ",innerHeight=" + thisWinHeight;
				newwin=window.open(myUrl,"_blank","scrollbars=0,resizable=no,location=no,menubar=no,status=no," + window_size);
				newwin.moveTo(0,0);
				
			}else{
				//NS
				var thisWinWidth=screen.availWidth-12;
				var thisWinHeight=screen.availHeight-30;
				window_size = "width=" + thisWinWidth + ",height=" + thisWinHeight +",innerWidth=" + thisWinWidth + ",innerHeight=" + thisWinHeight;
			newwin=window.open(myUrl,"_blank","scrollbars=0,resizable=no,location=no,menubar=no,status=no," + window_size);
				newwin.moveTo(0,0);
			}
		}
	}
	
	function getWindowHeight(){
		if(usr.Mac && (usr.checkObj == 1 || usr.OPERA)){
			return window.innerHeight;
		}else if(usr.Win && usr.checkObj == 1){
			return window.innerHeight - 16;
		}else if(usr.checkObj == 4){
			return window.innerHeight - 15;
		}else if(usr.OPERA || usr.checkObj == 2 || usr.checkObj == 3){
			return d.body.clientHeight;
		}
	}

	function getWindowXOffset(){
		if(usr.checkObj == 2 || usr.checkObj == 3){
			return d.body.scrollLeft;
		}else if(usr.checkObj == 1 || usr.checkObj == 4){
			return window.pageXOffset;
		}
	}
	function getWindowYOffset(){
		if(usr.checkObj == 2 || usr.checkObj == 3){
			return d.body.scrollTop;
		}else if(usr.checkObj == 1 || usr.checkObj == 4){
			return window.pageYOffset;
		}
	}

	function getDocHeight(){
		if(usr.checkObj == 1){
			return getTagTop('end') + 1;
		}else if(usr.checkObj == 2 || usr.checkObj == 3 || usr.checkObj == 4){
			return getTagTop('end');
		}
	}

	function getDistanceMaxY(){
		if(usr.allObj){
			return (getDocHeight() - getWindowHeight());
		}
	}

	function setObj(idName){
		return d.all ? d.all(idName) : d.getElementById ? d.getElementById(idName) : d.layers[idName];
	}

	function getTagTop(idName) {
		var obj = setObj(idName);
		var tagCoords = new Object();

		if((usr.checkObj == 2) || (usr.checkObj == 3) || (usr.checkObj == 4)) {
			tagCoords.y = obj.offsetTop;
			while ((obj = obj.offsetParent) != null) {
				tagCoords.y += obj.offsetTop;
			}if(usr.Mac && usr.Moz){
				return tagCoords.y - 12;
			}else if((usr.Win && usr.Moz) || (usr.Mac && usr.SAFARI)){
				return tagCoords.y - 9;
			}else{
				return tagCoords.y;
			}
		} else if(usr.checkObj == 1) {
			tagCoords.y = d.anchors[idName].y;
			return tagCoords.y;
		}return idName;
	}

	/*PageScroller*/
	var pageScrollTimer;
	function pageScroll(toX,toY,frms,frX,frY) {
		if(pageScrollTimer) clearTimeout(pageScrollTimer);
		var spd = usr.Mac ? 14 :16;
		var actX = getWindowXOffset();
		var actY = getWindowYOffset();
		if(!toX || toX < 0) toX = 0;
		if(!toY || toY < 0) toY = 0;
		if(!frms) frms = usr.NN ? 10 :usr.Mac ? 4 :5;
		if(!frX) frX = 0 + actX;
		if(!frY) frY = 0 + actY;

		frX += (toX - actX) / frms;
		if (frX < 0) frX = 0;
		frY += (toY - actY) / frms;
		if (frY < 0) frY = 0;
		var posX = Math.ceil(frX);
		var posY = Math.ceil(frY);
		window.scrollTo(posX, posY);
		if((Math.floor(Math.abs(actX - toX)) < 1) && (Math.floor(Math.abs(actY - toY)) < 1)){
			clearTimeout(pageScrollTimer);
			window.scroll(toX,toY);
		}else if(posX != toX || posY != toY){
			pageScrollTimer = setTimeout("pageScroll("+toX+","+toY+","+frms+","+frX+","+frY+")",spd);
		}else{
			clearTimeout(pageScrollTimer);
		}
	}

	function jumpToAnchor(idName) {
		if(usr.allObj){
			if(!!idName){
				var anchorY = getTagTop(idName);
				var dMaxY = getDistanceMaxY();
				var setY = (anchorY<1)?0:(anchorY>dMaxY)?dMaxY:anchorY;
				if(anchorY>1){
					pageScroll(0,setY);
				}else if(anchorY<=1){
					pageScroll(0,0);
				}else{
					location.hash = idName;
				}
			}else{
				pageScroll(0,0);
			}
		}else{
			!!idName ? location.hash = idName : location.hash = "top";
		}
	}
	function jumpToPageTop() {
		if(usr.allObj){
			pageScroll(0,0);
		}else{
			!!idName ? location.hash = idName : location.hash = "top";
		}
	}

var Mac = navigator.appVersion.indexOf('Mac',0) != -1;
var Win = navigator.appVersion.indexOf('Win',0) != -1;
var IE  = navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1;
var NN  = navigator.appName.indexOf("Netscape",0) != -1;
var Moz = navigator.userAgent.indexOf("Gecko") != -1;
var Vmajor = parseInt(navigator.appVersion); // ex. 3
var Vminor = parseFloat(navigator.appVersion); // ex. 3.01
var WinIE = (Win && IE);
var MacIE5 = ((Mac && navigator.appVersion.indexOf('MSIE 5',0) != -1) || (Mac && IE && VER > 4));


var MacIE4 = ((Mac && navigator.appVersion.indexOf('MSIE 4.',0) != -1));
var MacIE3 = ((Mac && navigator.appVersion.indexOf('MSIE 3.',0) != -1));

var bAgent = navigator.userAgent;
var d = document;
function sniffer(){
this.Win = bAgent.indexOf("Win",0) != -1 ? 1 :0;
this.Mac = bAgent.indexOf("Mac",0) != -1 ? 1 :0;
this.Moz = ((bAgent.indexOf("Gecko") != -1) && (bAgent.indexOf("Safari",0) == -1)) ? 1 :0;
this.OPERA = bAgent.indexOf("Opera",0) != -1 ? 1 :0;
this.SAFARI = bAgent.indexOf("Safari",0) != -1 ? 1 :0;
this.checkObj = d.all?(d.getElementById?3:2):(d.getElementById?4:(d.layers?1:0));
this.allObj = ((this.checkObj == 1) || (this.checkObj == 2) || (this.checkObj == 3) || (this.checkObj == 4));
return this;
}
var usr = new sniffer;

