// JavaScript Document

function resizeBlock(varID,varID2){
	var windowH = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	var windowW = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
	if(windowH>600){
		var varH = (windowH - 600)/2;
		varH = varH + "px";
		document.getElementById(varID).style.marginTop = varH;
		if(varID2!="") document.getElementById(varID2).style.marginBottom = varH;
	}
	if(windowW<900){
		document.getElementById('menu').style.fontSize = "100%";
		document.getElementById('foot').style.padding = "20px 2px";
	}
}
var flg = "b";
function blockDisplay(varID){
	if(flg=="a"){
		flg = "b";
		document.getElementById(varID).style.display = "none";
	} else {
		flg = "a";
		document.getElementById(varID).style.display = "block";
	}
}

function initRollOvers() {
    if (!document.getElementById){
        return;
    }
    var preLoads = new Array();
    var allImages = document.getElementsByTagName('img');
    for (var i = 0; i < allImages.length; i++) {       
        if (allImages[i].className == 'rollover') {
            var src = allImages[i].getAttribute('src');
            var ftype = src.substring(src.lastIndexOf('.'), src.length);
            var oSrc = src.replace(ftype, '_on'+ftype);
            //-- スワップ元、スワップ先画像の登録
            allImages[i].setAttribute('pSrc', src);
            allImages[i].setAttribute('oSrc', oSrc);
            //-- イメージのプリロード
            preLoads[i] = new Image();
            preLoads[i].src = oSrc;
            //-- イベントの設定
            allImages[i].onmouseover = function() {
                this.setAttribute('src', this.getAttribute('oSrc'));
            }
            allImages[i].onmouseout = function() {
                this.setAttribute('src', this.getAttribute('pSrc'));
            }
        }
    }
}
 
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(){
   // #で始まるアンカーをクリックした場合に処理
   $('a[href^=#]').click(function() {
      // スクロールの速度
      var speed = 400;// ミリ秒
      // アンカーの値取得
      var href= $(this).attr("href");
      // 移動先を取得
      var target = $(href == "#" || href == "" ? 'html' : href);
      // 移動先を数値で取得
      var position = target.offset().top;
      // スムーススクロール
      $($.browser.safari ? 'body' : 'html').animate({scrollTop:position}, speed, 'swing');
      return false;
   });
});

