/**
 *
 * IE判定
 *
 */
function is_MSIE() {
    if (window.opera) { //Opera
        return false;
    } else if (document.all) {
        return true;
    } else {
        return false;
    }
}

/**
 *
 * 画像切り替え
 *
**/
function smartRollover(base, flip) {
  var imgs = document.images;
  if (!document.images) {
    return false;
  }
  var pre = new Array();
  for (var i = 0; i < imgs.length; i++) {
    var src = imgs[i].src;
    if (src.match(base)) {
      // 画像先読み
      pre[i] = new Image();
      pre[i].src = src.replace(base, flip);

      // ロールオーバー設定
      imgs[i].onmouseover = function() {
        this.src = this.src.replace(base, flip);
      }
      imgs[i].onmouseout = function() {
        this.src = this.src.replace(flip, base);
      }
    }
  }
}

/**
 *
 * イベント追加
 *
**/
function addEvent(elm, eventName, func) {
  if (elm.addEventListener) {
    elm.addEventListener(eventName, func, false);
    return true;

  } else if (elm.attachEvent) {
    elm.attachEvent("on"+eventName, func);
    return true;

  } else {
    return false;

  }
}


/**
 *
 * 別窓オープン
 *
**/
function external() {
	if (!document.getElementsByTagName) {
		return;
	}
	var anchors = document.getElementsByTagName('a');
	for (var i = 0; i < anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute('class') == 'external' || anchor.getAttribute('className') == 'external') {
			anchor.setAttribute('target', '_blank');
		}
	}
}

/**
 *
 * OS判定
 *
**/
function get_os() {
	var os;
	var ua = navigator.userAgent;

	if (ua.match(/Win(dows )?NT 6\.1/)) {
		// Windows 7
		os = "Windows 7";  

	} else if (ua.match(/Win(dows )?NT 6\.0/)) {
		// Windows Vista
		os = "Windows Vista";

	} else if (ua.match(/Win(dows )?NT 5\.2/)) {
		// Windows Server 2003
		os = "Windows Server 2003";

	} else if (ua.match(/Win(dows )?(NT 5\.1|XP)/)) {
		// Windows XP
		os = "Windows XP";

	} else if (ua.match(/Win(dows)? (9x 4\.90|ME)/)) {
		// Windows ME
		os = "Windows ME";

	} else if (ua.match(/Win(dows )?(NT 5\.0|2000)/)) {
		// Windows 2000
		os = "Windows 2000";

	} else if (ua.match(/Win(dows )?98/)) {
		// Windows 98
		os = "Windows 98";

	} else if (ua.match(/Win(dows )?NT( 4\.0)?/)) {
		// Windows NT
		os = "Windows NT";

	} else if (ua.match(/Win(dows )?95/)) {
		// Windows 95
		os = "Windows 95";

	} else if (ua.match(/Mac|PPC/)) {
		// Macintosh
		os = "Mac OS";

	} else if (ua.match(/Linux/)) {
		// Linux
		os = "Linux";

	} else if (ua.match(/(Free|Net|Open)BSD/)) {
		// BSD 系
		os = RegExp.$1 + "BSD";

	} else if (ua.match(/SunOS/)) {
		// Solaris
		os = "Solaris";

	} else {
		// 上記以外 OS
		os = "N/A";

	}

	return os;
}

/**
 *
 * フォントセット
 *
**/
function set_fontfamily()  {
	switch (get_os()) {
		case "Windows Server 2003":
		case "Windows XP":
		case "Windows 2000":
		case "Windows ME":
		case "Windows NT":
		case "Windows 98":
		case "Windows 95":
		//case "Windows Vista":
			//$("body").css("font-family", "'ＭＳ Ｐゴシック', 'MS PGothic', 'sans-serif;'").css("font-size", "14px");
			if ($("#ChargeMenu")) {
				$("#ChargeMenu > ul > li").css('padding-bottom', '5px');
			}
			break;
		default:
			break;
	}
}

/**
 *
 * IE6判定
 *
**/
function is_IE6() {
	if (typeof document.documentElement.style.maxHeight == "undefined") {
		return true;
	}
	return false;
}

/**
 *
 * iPhone用
 *
**/
function load_picture() {
	$("#Flash").css({
		'background-image':'url(/images/topimage.jpg)',
		'background-repeat':'no-repeat'
	});
}
