//------------- Window control js -------------------------------------
//
//	v@
//															 by kechap
//---------------------------------------------------------------------


//------------- open window ()-------------------------------------
//
OpenWin = false;

function winOpen(Url,winW,winH,Scroll,Resize){

//	if(OpenWin) {
//			if(!OpenWin.closed){
//				OpenWin.resizeTo(winW,winH);
//			}
//	}

	var winUrl = Url;
	var windowW = ",width=" + winW;
	var windowH = ",height=" + winH;
	var winScroll = ",scrollbars=" + Scroll;
	var winResiz = ",resizable=" + Resize;
	var winStat = "fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0"+ winScroll + winResiz + windowW + windowH;
	OpenWin = window.open(winUrl,"myWin",winStat);

//	var winX = Math.ceil( (window.screen.width  - winW) / 2 );
//	var winY = Math.ceil( (window.screen.height - winH) / 2 );
//	OpenWin.moveTo(winX,winY);

	if(OpenWin && !OpenWin.closed) OpenWin.resizeTo(winW,winH);
	OpenWin.focus();
	}



//
//------------- open window ()---------------------------------
//
function winClose(){
		OpenWin.close();
	}
//
//------------- resize window (ړTCY)-------------------------
//

function resizeWin(maxX,maxY,speed,delay){
	this.maxX = maxX;
	this.maxY = maxY;
	this.speed = speed;
	this.delay = delay;
	this.doResize = (document.all || document.getElementById);
	this.focus();
	this.initWin();
	}

function initWin(){
	if (this.doResize){
		this.zoomW = this.zoomH = true;
		this.zoomWin();
	}else{
		this.resizeTo(this.maxX + 10, this.maxY - 20);
		this.centerWin();
	}
	}

function zoomWin(){
	var W = getW();
	var H = getH();
	if ((this.maxX - W)>1){ var tmpW = Math.ceil((maxX - W)*this.speed)}else{ this.zoomW = false}
	if ((this.maxY - H)>1){ var tmpH = Math.ceil((maxY - H)*this.speed)}else{ this.zoomH = false}
	this.resizeBy(tmpW,tmpH);
	this.centerWin();
	if(this.zoomW || this.zoomH){
		setTimeout(zoomWin(),this.delay);
	}
	}

function centerWin(){
	var x = Math.ceil((window.screen.width  - getW()) / 2);
	var y = Math.ceil((window.screen.height - getH()) / 2);
	this.moveTo(x,y);
	}

function getW(){
	if (document.all){	//IE
		return (this.document.body.clientWidth + 10);
	}else if (document.getElementById){	//Netscape
		return this.outerWidth;
	}else{
		return this.outerWidth - 12;
	}
	}
	
function getH(){
	if (document.all){	//IE
		return (this.document.body.clientHeight + 29)
	}else if (document.getElementById){	//Netscape
		return this.outerHeight;
	}else{
		return this.outerHeight - 31; 
	}
	}

//---------------------------------------------------------------------









