
// ロールオーバー
function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

// ポップアップウィンドウのソース
function openwin (url,name,w,h) {
    w = window.open(url,name,"width="+w+",height="+h+",left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,favorites=no,resizable=no");
    w.focus();
}


// ポップアップ 画像クリックで閉じる（印刷・閉じるボタン付き）
function windowOpen(url,w,h) {
  var winFig;
  var width = parseInt(w);
  var height = parseInt(h);

  st = "toolbar=no,location=no,directories=no,status=no,menubar=yes,scrolbars=auto,resizable=yes,";
  winFig = window.open("", "OpenWin", st+"width="+width+",height="+height);

  winFig.document.open();
  winFig.document.writeln("<html>");
  winFig.document.writeln("<head><title>大関株式会社</title></head>");
  winFig.document.writeln('<body style="margin:0px auto;text-align:center;">');
  winFig.document.writeln('<script type="text/javascript">');
  winFig.document.writeln('<!--');
  winFig.document.writeln('function setScreenSize()');
  winFig.document.writeln('{');
  winFig.document.writeln('window.moveTo(0,0);');
  winFig.document.writeln('window.resizeTo(window.screen.availWidth, window.screen.availHeight);');
  winFig.document.writeln('}');
  winFig.document.writeln('//-->');
  winFig.document.writeln('</script>');
  winFig.document.writeln('<img src="'+url+'" align="center" />');
  winFig.document.writeln('<div style="margin-top:15px;" align="center">');
  winFig.document.writeln('<input type="button" onclick="javascript:print()" value="印刷する">');
  winFig.document.writeln('<input type="button" onclick="setScreenSize();this.style.display=\'none\'" value="最大化">');
  winFig.document.writeln('<input type="button" onclick="self.window.close()" value="閉じる">');
  winFig.document.writeln('</div>');
  winFig.document.writeln("</body>");
  winFig.document.writeln("</html>");
  winFig.document.close();

  var Win   = navigator.userAgent.indexOf("Win") != -1   ? true : false;
  var Mac   = navigator.userAgent.indexOf("Mac") != -1   ? true : false;

  if(Win) {
    if(navigator.userAgent.indexOf("Gecko")!=-1){
      winFig.location.reload();
    }
  }
}


// ポップアップ 画像クリックで閉じる
function openwin (url,name,w,h) {
w = window.open(url,name,"width="+w+",height="+h+",left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,favorites=no,resizable=no");w.focus();
}
// JavaScript Document
function winOpen(url,w,h) {
  var winFig;
  var width = parseInt(w);
  var height = parseInt(h);

  st = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrolbars=no,resizable=no,";
  winFig = window.open("", "OpenWin", st+"width="+width+",height="+height);

  winFig.document.open();
  winFig.document.writeln("<html>");
  winFig.document.writeln("<head><title>image window</title></head>");
  winFig.document.writeln('<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">');
  winFig.document.writeln('<a href="javascript:void(0);" onClick="self.window.close()"><img src="'+url+'" border="0" /></a>');
  winFig.document.writeln("</body>");
  winFig.document.writeln("</html>");
  winFig.document.close();

  var Win   = navigator.userAgent.indexOf("Win") != -1   ? true : false;
  var Mac   = navigator.userAgent.indexOf("Mac") != -1   ? true : false;

  if(Win) {
    if(navigator.userAgent.indexOf("Gecko")!=-1){
      winFig.location.reload();
    }
  }
}


/* ------------------------------------------------
  ページトップへ戻る
------------------------------------------------ */
function go_toppage() {
    window.scrollTo(0, 0);
}


/* ------------------------------------------------
  イベント追加関数
------------------------------------------------ */
function add_event(object, event_type, func) {
    if (object.addEventListener) {
        object.addEventListener(event_type, func, false);
        return true;
    }
    else if (object.attachEvent) {
        var result = object.attachEvent("on"+event_type, func);
        return result;
    }
    else {
        return false;
    }
}


/* ------------------------------------------------
  各オブジェクトへのイベント追加
------------------------------------------------ */
add_event(window,
		  'load',
		  initRollovers);


/*
<!--
function OpenWin(){
    win=window.open("window.htm","new","width=350,height=*");
}
// -->

<!--
function openw(){
var win1=window.open("","newwin1","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,width=150,height=150");
win1.document.write("<h1>hello new window</h>");
win1.document.close();
}
//-->
*/


