/*-------------------------------------------------

popup

-------------------------------------------------*/
//ポップアップ--（フォーカス機能追加）
//指定方法（DWのビヘイビアで設定）
function MM_openBrWindow(theURL,winName,features) { //v2.0
var winFocus;
winFocus=window.open(theURL,winName,features);
winFocus.focus();
}
/*-------------------------------------------------

smartRollover

-------------------------------------------------*/

function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].src.match("_off."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}
/*-------------------------------------------------

scroll

-------------------------------------------------*/
$(document).ready(function(){
  $('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;
        $('html,body')
        .animate({scrollTop: targetOffset}, 1000);
       return false;
      }
    }
  });
});
/*--------------------------------------------------------------------------*
 *  
 *  Easy Tab
 *  
 *  MIT-style license. 
 *  
 *  2008 Mk-T 
 *  http://mk-t-lab.com/
 *  
 *--------------------------------------------------------------------------*/
(function(){
	var init = function(){
		var tab = getElementsByClassName("tabMenu");
		if(!tab) return false;
		for(var i = 0, l = tab.length; i < l; i++){
			tab[i].menu = getElementsByClassName("tabIndex" , tab[i]);
			tab[i].contents = getElementsByClassName("tabContents" , tab[i]);
			if(tab[i].menu.length != 1) return false;
			tab[i].menu[0].li = tab[i].menu[0].getElementsByTagName("li");
			if(tab[i].menu[0].li.length == tab[i].contents.length){
				for(var j = 0, jl = tab[i].contents.length; j < jl; j++){
					tab[i].menu[0].li[j].key1 = i;
					tab[i].menu[0].li[j].key2 = j;
					tab[i].menu[0].li[j].onclick = function(){
						openFn(this.key1, this.key2);
						return false;
					}
					if(tab[i].menu[0].li[j].className != "active0"){
						tab[i].contents[j].style.display = "none";
					}
				}
			}
		}
		function openFn(key1,key2){
			for(var i = 0, l = tab[key1].contents.length; i < l; i++){
				tab[key1].menu[0].li[i].className = "disable"+i;
				tab[key1].contents[i].style.display = "none";
			}
			tab[key1].menu[0].li[key2].className = "active"+key2;
			tab[key1].contents[key2].style.display = "block";
		}
			
	}
	var addEvent = (function() {
		if ( window.addEventListener ) {
			return function(el, type, fn) {
				el.addEventListener(type, fn, false);
			};
		} else if ( window.attachEvent ) {
			return function(el, type, fn) {
				var f = function() {
					fn.call(el, window.event);
				};
				el.attachEvent("on"+type, f);
			};
		} else {
			return function(el, type, fn) {
				el["on"+type] = fn;
			};
		}
	})();
	var getElementsByClassName = (function(){
		if(document.getElementsByClassName){
			return function(className, pElement){
				return (pElement||document).getElementsByClassName(className);
			};
		}else{
			return function(className, pElement){
				var d = document, nodes = [], item;
				var cls, items = (pElement || d).getElementsByTagName("*");
				for(var i = 0, l = items.length; i < l; i++){
					item = items[i];
					if(item.className){
						cls = item.className.split(/\s+/);
						for(var k = 0, kl = cls.length; k < kl; k++){
							if(cls[k]==className){
								nodes[nodes.length] = item; break;
							}
						}
					}
				}
				return nodes.length > 0 ? nodes : null;
			};
		}
	})();
	addEvent(window,"load",init);
})();

