/* common.js ver1.1 */

//ブラウザのバージョン取得
function getBrowser() {
	var userAgent = window.navigator.userAgent;

	var browser = {
		safari: /applewebKit.+version/i.test(userAgent),
		chrome: /applewebKit.+chrome/i.test(userAgent),
		firefox: /firefox/i.test(userAgent),
		msie: /msie/i.test(userAgent),
		opera: /opera/i.test(userAgent),
		version: userAgent.match(/(version\/|chrome\/|firefox\/|msie\s|opera\/)([\d\.]+)/i)[2] || ""
	}

	return browser;

}

//モニターサイズの取得
function getMonitorSize() {
	var monitorSize = {
		width: window.screen.width,
		height: window.screen.height,
		availWidth: window.screen.availWidth,
		availHeight: window.screen.availHeight
	}
	return monitorSize;
}

window.onload = function(){
	windowClose();
	windowPrint();
	txtAttr();
}

function windowClose() {
	var cls = document.getElementById('close');
	if(cls){
		cls.onclick = function() {
			self.close();
		}
	}
}
function windowPrint() {
	var prt = document.getElementById('print');
	if(prt) {
		prt.onclick = function() {
			self.print();
		}
	}
}
function Winopen_raw(url,windowname) {
	window.open(url, windowname);
}

//サイズ指定、中央にポップアップ
function windowOpen(targetUrl) {
	var scrollbarWidth = 17;//スクロールバーの幅分をあらかじめ追加
	
	var windowWidth = 670 + scrollbarWidth;
	var windowHeight = 970;
	
	var monitorSize = getMonitorSize();
	
	var screenWidth = window.screen.availWidth;
	var screenHeight = window.screen.availHeight;
	
	var top = Math.round((screenHeight / 2) - (windowHeight / 2));
	var left = Math.round((screenWidth / 2) - (windowWidth / 2));
	
	
	//ウインドウサイズ縦が表示領域より大きい場合そのサイズに合わせる
	if(monitorSize.availHeight < windowHeight) {
		windowHeight = monitorSize.availHeight;
	}
	
	var wo = window.open(targetUrl, "_blank", "width="+windowWidth+", height="+windowHeight+", top="+top+", left="+left+", location=no, scrollbars=no, resizable=yes, scrollbars=yes");
	
	//chromeのみ縦が画面からはみ出るのを防ぐ為open後、位置をずらしてからサイズ調整をする。
	var browser = getBrowser();//ブラウザ判定
	if(browser.chrome == true) {
		wo.moveTo(left,top);
		wo.resizeTo(windowWidth,windowHeight);
	}
}

//ロールオーバーで透明度変更
$(function(){
	$(".rolla").hover(function(){
		$(this).fadeTo(0,0.75);
	},function(){
		$(this).fadeTo(0,1);
	});
});
/*function Winopen(url,windowname,width,height) {
	var features="location=no, menubar=no, status=no, scrollbars=yes, resizable=yes, toolbar=no";
	var isWin = (navigator.appVersion.indexOf("Win") != -1);
	if (width){
		if (window.screen.width > width){
			features+=", left="+(window.screen.width-width)/2;
		}else{
			width=window.screen.width;
		}
		if(isWin){
				features+=", width="+(width+17);
		}else{
		features+=", width="+(width+17);
		}
	}
	if (height) {
		if (window.screen.height > height){
			if (isWin){
				features+=", top="+((window.screen.height-70)-height)/2;
			}else{
				features+=", top="+(window.screen.height-height)/2;
			}
		}else{
			if (isWin){
			height=window.screen.height-70;
			}else{
			height=window.screen.height;
			}
		}
		features+=", height="+height;
	}
	window.open(url,windowname,features);
}*/
function txtAttr() {
	var node = document.getElementById('wrapFooterNavi');
	if(node){
		var a = node.getElementsByTagName('a');
		for (var i=0, af=a.length; i<af; i++){
			var h = a[i];
			var prevClass = h.className;
			if(i < af-1){
				h.className = prevClass + ' ' + 'txtBarX';
			}else{
				h.className = prevClass + ' ' + 'txtBarXend';
			}
		}
	}
}
