/* ---------------------------------------------------------------- */
/* JavaScript add-on modules for Internet Explorer                  */
/* scripting by Northernland.net           http://northernland.net  */
/* copyright(c) 2008 Northernland.net      info@northernland.net    */
/* ---------------------------------------------------------------- */

var zSpan  = 0.1;  // ズーム倍率の変化量
var zMax   = 4.0;  // 最大ズーム時の倍率（超えると1.0倍に戻る)
var zmin   = 0.2;  // 最小ズーム時の倍率（下回ると1.0倍に戻る）

var delta  = 0;    // ホイール移動量の初期値

function jsRst(){
	delta = 0;
}

function jsZoom(event){
	if( !event ){
		event = window.event;
		delta = 0;
	}
	ctrl = null;
	ctrl = event.ctrlKey;
	keycode = event.keyCode;
	if((ctrl)&&(keycode == 107)){ // [ctrl][＋] 同時押し
		delta = 100;
		event.keyCode = 0;
		event.returnValue = false;
		event.cancelBubble = true;
		jsExpand();
		return false;
	}else if((ctrl)&&(keycode == 109)){ // [ctrl][−] 同時押し
		delta = -100;
		event.keyCode = 0;
		event.returnValue = false;
		event.cancelBubble = true;
		jsExpand();
		return false;
	}
	if((event.wheelDelta)&&(ctrl)){
		delta = parseInt( event.wheelDelta );
		event.returnValue = false;
		event.cancelBubble = true;
		jsExpand();
		return false;
	}else{
		delta = 0;
		jsRst();
	}
}

function jsExpand(){
	if(delta != 0){
		zoomRatio = parseFloat( window.document.body.style.zoom );
		if( !zoomRatio ){
			zoomRatio = 1.0;
		}
		if( delta >= 1 ){
			zoomRatio += zSpan;
		}else if( 0 > delta ){
			zoomRatio -= zSpan;
		}
		if((zoomRatio >= zMax)||( zmin >= zoomRatio)){
			zoomRatio = 1.0;
		}
		window.document.body.style.zoom = zoomRatio;
	}
}
window.document.onkeydown    = jsZoom;
window.document.onmousewheel = jsZoom;
window.document.onkeyup      = jsRst;
window.document.onmouseup    = jsRst;

