
/* ロールオーバー処理 */

/*
 Btn Class v1.1
 update 2007.12.10
 create K.Kubonaka 
*/

function Btn(elm) {
	var me = this;
	this.elm = elm;
	this.over = function() { me.changeImage(true); };
	this.out = function() {	me.changeImage(false); };
	this.init();
}

var _Btn = Btn.prototype;

_Btn.init = function() {
	var me = this;
	var img_on = new Image();
	var img_str = this.elm.getAttribute("src");
	img_on.src = img_str.replace("_off", "_on");
	this.setEvent();
};


_Btn.doSelect = function() {
	this.deleteEvent();
	this.changeImage(true);
};


_Btn.setEvent = function() {
	try {
		this.elm.addEventListener("mouseover", this.over, false);
		this.elm.addEventListener("mouseout", this.out, false);
	} catch(e) {
		this.elm.attachEvent("onmouseover", this.over);
		this.elm.attachEvent("onmouseout", this.out);
	}
};


_Btn.deleteEvent = function() {
	try {
		this.elm.removeEventListener("mouseover", this.over, false);
		this.elm.removeEventListener("mouseout", this.out, false);
	} catch(e) {
		this.elm.detachEvent("onmouseover", this.over);
		this.elm.detachEvent("onmouseout", this.out);
	}
};


_Btn.changeImage = function(flag) {
	var img = this.elm.getAttribute("src");
	this.elm.setAttribute("src", (flag) ? img.replace("_off", "_on") : img.replace("_on", "_off"));
};


/*
 roSetter v1.1
 update 2007.12.10
 create K.Kubonaka 
*/

(function(func) {
	try {
		window.addEventListener("load", func, false);
	} catch(e) {
		window.attachEvent("onload", func);
	}
})(function() {
	var btnArray01 = document.getElementsByTagName("img");
	var btnArray02 = document.getElementsByTagName("input");
	for (var i = 0, ln = btnArray01.length; i < ln; i++) {
		if (btnArray01[i].getAttribute("src").indexOf("_off.") >= 0) new Btn(btnArray01[i]);
	}
	for (var i = 0, ln = btnArray02.length; i < ln; i++) {
		try{
			if (btnArray02[i].getAttribute("src").indexOf("_off.") >= 0) new Btn(btnArray02[i]);
		} catch(e){
		}
	}	
});

/* ジャンプメニュー */

function jump(targ,selObj,restore){ 
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

function goToURL() { //v3.0
  var i, args=goToURL.arguments; document.returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function initRollOvers() {
	if (!document.getElementById){
		return;
	}
	if(!document.getElementById("puttlabBoxBtn")){
		return;
	}
	
	var imageSrc = document.images["puttlabBoxBtn"].src;
	var strNum = imageSrc.indexOf("/common/img",0);
	var DOMAIN = imageSrc.substring(0,strNum);

	var preLoads = new Array();
	var banners = new Array();
	var urls = new Array();
	var btns = new Array();
	
	banners[0] = document.getElementById("seminar2Box");
	btns[0] = document.getElementById("seminar2BoxBtn");
	urls[0] = DOMAIN  + "/rental/index.html";
	banners[1] = document.getElementById("puttlabBox");
	btns[1] = document.getElementById("puttlabBoxBtn");
	urls[1] = DOMAIN  + "/putt_lab/index.html";
	
	
	if(document.getElementById("assetAcce")){
		banners[2] = document.getElementById("assetAcce");
		btns[2] = document.getElementById("assetAcceBtn");
		urls[2] = DOMAIN  + "/accessories/index.html";
		banners[3] = document.getElementById("assetBusin");
		btns[3] = document.getElementById("assetBusinBtn");
		urls[3] = "http://www.callawaygolf.jp/business/index.html";
	}

	for (var i = 0; i < banners.length; i++) {
		var src = btns[i].getAttribute('src');
		banners[i].setAttribute('num', i);
		var ftype = src.substring(src.lastIndexOf('.'), src.length);
		var oSrc = src.replace(ftype, '_on'+ftype);

		//-- スワップ元、スワップ先画像の登録
		btns[i].setAttribute('pSrc', src);
		btns[i].setAttribute('oSrc', oSrc);
		
		//Aリンク削除
		//alert(banners[i].childNodes[1].childNodes[0].nodeName);
		banners[i].childNodes[1].childNodes[0].removeAttribute('href');

		//-- イメージのプリロード
		preLoads[i] = new Image();
		preLoads[i].src = oSrc;

		//-- イベントの設定
		banners[i].onmouseover = function() {
			btns[this.getAttribute('num')].setAttribute('src', btns[this.getAttribute('num')].getAttribute('oSrc'));
		}
		banners[i].onmouseout = function() {
			btns[this.getAttribute('num')].setAttribute('src', btns[this.getAttribute('num')].getAttribute('pSrc'));
		}
		banners[i].onclick = function () {
			if(urls[this.getAttribute('num')].slice(0,23) == "http://www.callawaygolf") {
				openBrWindow(urls[this.getAttribute('num')],'_blank','');
			}else {
				goToURL('parent',urls[this.getAttribute('num')]);return document.returnValue;
			}
		}
	}
}

function addOnload(func){
	if ( typeof window.addEventListener != "undefined" ){
		window.addEventListener( "load", func, false );
	}else if ( typeof window.attachEvent != "undefined" ) {
		window.attachEvent( "onload", func );
	}else{
		if ( window.onload != null ){
			var oldOnload = window.onload;
			window.onload = function ( e ) {
			oldOnload( e );
			window[func]();
		};
	}else
		window.onload = func;
	}
}
addOnload(initRollOvers);

function subWin(theURL,winName,features) {
  var winFocus;
  winFocus = window.open(theURL,winName,features);
  winFocus.focus();
}

//WEBカタログPOP UP TOPへ
function catalogPopupWindow() {
	var url = "/catalog/index.html#01";
	popupWindow = window.open(url,"wisebook","width=1024,height=710");
	popupWindow.focus();
	
	if (typeof document.documentElement.style.maxHeight != "undefined") {
	if(typeof popupWindow.data != "undefined")
	{
		popupWindow.location.reload(true);
	}}
	else
	{
	}
}
