
	alphaS      = false;
	alphaLast   = 100;
	alphaOver   = 100;
	DivLocationX = 0;
	DivLocationY = 0;
	timerIDtiming = 200;
	moveIDtiming  = 30;
	drawCount = 0.15;
	XEnable = 0;
	YEnable = 1;
	LRmode       = 0;
	UDmode       = 1;



	var VarUsrAgt = navigator.userAgent.toLowerCase();
	isMac = (navigator.appVersion.indexOf("Mac") != -1);
	isWin = (navigator.appVersion.indexOf("Win") != -1);
	isX11 = (navigator.appVersion.indexOf("x11") != -1);
	isNS4 = (document.layers) ? 1 : 0;
	isNS6 = VarUsrAgt.indexOf("netscape6") != -1;
	isNS7 = VarUsrAgt.indexOf("netscape/7.") != -1;
	isIE5 = VarUsrAgt.indexOf("msie 5.") != -1;
	isIE6 = VarUsrAgt.indexOf("msie 6.") != -1;
	isIE7 = VarUsrAgt.indexOf("msie 7.") != -1;
	isOP6 = VarUsrAgt.indexOf("opera 6.") != -1 || VarUsrAgt.indexOf("opera/6.") != -1;
	isOP7 = VarUsrAgt.indexOf("opera 7.") != -1 || VarUsrAgt.indexOf("opera/7.") != -1;
	isMZ1 = navigator.appName.indexOf("Netscape") != -1 && navigator.appVersion.charAt(0)   == 5;

	isJS = ( (isIE5 && !isMac) || (isIE6 && !isMac) || isIE7 || isNS6 || isNS7 || isMZ1 || isOP7)


	if (isOP7) isNS4 = isNS6 = isNS7 = isIE5 = isIE6 = isMZ1 = false;


var div_data = "" , div_mini="" , divcheck=false;
var divW , divH , MouseToDiv;
var ScriptStart = false;


var MozillaState =0;
if (isNS6 || isNS7 || isMZ1) MozillaState = 0;

//////////////////////////////////
function divPreset(){
	alphaState();

	if ( (DivLocat("X") - DivNow("X")) !=0 && XEnable || (DivLocat("Y") - DivNow("Y")) !=0 && YEnable){
		clearInterval(timerID); timerID = 0;
		timerID = setInterval("moveDiv()",moveIDtiming);
	}
}


function moveDiv(){
	alphaState();

	tempX = DivLocat("X") - DivNow("X"); tempY = DivLocat("Y") - DivNow("Y"); 
	tx = parseInt((tempX - Math.abs(tempX)) / (Math.abs(tempX) * 2));
	ty = parseInt((tempY - Math.abs(tempY)) / (Math.abs(tempY) * 2));
	if (tx==0) tx=1;    if (ty==0) ty=1;
	if (isNaN(tx) || drawCount==1) tx=0;if (isNaN(ty) || drawCount==1) ty=0 ;


	div_data.style.top  = DivNow("Y") + Math.ceil(tempY * drawCount) + ty + "px";
	div_data.style.left = DivNow("X") + Math.ceil(tempX * drawCount) + tx + "px";

	if (tx == 0 && ty == 0){
		clearInterval(timerID); timerID = 0;
		timerID = setInterval("divPreset()",timerIDtiming);
	}
}


//////////////////////////////////

function DivLocat(ordinate){
	var LRstate=0,UDstate=0;
	if (isIE5 || isIE6 || isIE7 || isOP7){
		mouseXm = document.documentElement.scrollLeft;
		mouseYm = document.documentElement.scrollTop;
	} else if (isNS6 || isNS7 || isMZ1) {
		mouseXm = self.pageXOffset;
		mouseYm = self.pageYOffset;
	}
	if (ordinate.toUpperCase() == "X"){
		if(LRmode==1){
			return parseInt(WinSize("X") - DivSize("W") - DivLocationX + mouseXm - MozillaState);
		}   return DivLocationX + mouseXm;
	} else if (ordinate.toUpperCase() == "Y"){
		if (UDmode==1){
			return parseInt(WinSize("Y") - DivSize("H") - DivLocationY + mouseYm - MozillaState);
		}   return DivLocationY + mouseYm;
	}
}


//////////////////////////////////

function DivNow(ordinate){
	if(!ScriptStart) return;
	if (ordinate.toUpperCase()=="X"){
		return parseInt(div_data.style.left);
	} else if (ordinate.toUpperCase()=="Y"){
		return parseInt(div_data.style.top);
	}
}


//////////////////////////////////

function WinSize(ordinate){
	if (ordinate.toUpperCase()=="X"){
		if(isIE5 || isIE6 || isIE7 || isOP7){
			return document.documentElement.clientWidth;
		} else if (isNS6 || isNS7 || isMZ1) {
			return innerWidth;
		}
	} else if (ordinate.toUpperCase()=="Y"){
		if(isIE5 || isIE6 || isIE7 || isOP7){
			return document.documentElement.clientHeight;
		} else if (isNS6 || isNS7 || isMZ1) {
			return innerHeight;
		}
	}
}


function DivSize(ordinate){
	if (ordinate.toUpperCase()=="W"){
		return div_data.offsetWidth;
	} else if (ordinate.toUpperCase()=="H"){
		return div_data.offsetHeight;
	}
}

//////////////////////////////////

function alphaState(){
	if(!alphaS) return;
	a_state = alphaLast;
	if(MouseToDiv) a_state=alphaOver;
	if (isIE5 || isIE6 || isIE7 ){
		div_data.style.filter = "alpha(opacity="+a_state+",style=0)";
	} else if (isNS6 || isNS7 || isMZ1){
		div_data.style.MozOpacity= a_state/100;
	} else if (isOP7){

	}
}


//////////////////////////////////

var LastDivMode = false;
function mousemove(myEvents){
	if(!ScriptStart) return;
	if (isIE5 || isIE6 || isIE7 || isOP7){
		mouseX  = window.event.clientX + document.documentElement.scrollLeft; 
		mouseY  = window.event.clientY + document.documentElement.scrollTop; 
	} else if (isNS6 || isNS7 || isMZ1) {
		mouseX  = myEvents.pageX; mouseY  = myEvents.pageY;
	}

	DivSize("W");DivSize("H");
	if ( mouseX >= DivNow("X") && ( DivNow("X") + DivSize("W") ) >= mouseX && mouseY >= DivNow("Y") && ( DivNow("Y")+DivSize("H") ) >= mouseY){
		if (LastDivMode == false) DivContents(maxMenu)
		MouseToDiv = LastDivMode = true;
	} else {
		if (LastDivMode == true) DivContents(minMenu)
		MouseToDiv = LastDivMode = false;
	}
}

//////////////////////////////////

test1=0;
function DivContents(menu_mode){
	if(!div_mini) return;
	if (menu_mode != div_data.innerHTML){
		div_data.innerHTML = menu_mode;
		test1++;
	}
	status = test1;
}

var minMenu,maxMenu;
//////////////////////////////////

function startwindow(){
	if ( !document.getElementById("MoveDiv") || !isJS ) return;

	enq = "";
	name = "topenq=";
	cookie = document.cookie+";";
	start = cookie.indexOf(name);
	if (start != -1) {
		end = cookie.indexOf(";",start);
		enq = unescape(cookie.substring(start+name.length,end));
	}

	if(enq == "1"){clearMovie();return;}
	if(enq == "2"){endMovie();return;}

	if(document.getElementById){
		document.getElementById("MoveDiv").style.display = 'block';
		document.getElementById("OpenDiv").style.display = 'none';
	} else if(document.all) {
		document.all("MoveDiv").style.display = 'block';
		document.all("OpenDiv").style.display = 'none';
	} else if(document.layers) {
	document.layers["MoveDiv"].display = 'block';
	document.layers["OpenDiv"].display = 'none';
	}

	div_data = document.getElementById("MoveDiv");
	div_data.style.position="absolute";
	divcheck=true;



	DivSize("W");
	DivSize("H");


	for (i = 0 ; i <= 500; i ++){
		div_check = document.getElementsByTagName('div')[i];
		if (div_check){
			if(div_check.id.substr(0,8) =="setM_ID@"){
				ComponentsDivData(div_check.id);
			}
		} else {
			break;
		}
	}

	div_data.style.top  = DivLocat("Y") + "px";
	div_data.style.left = DivLocat("X") + "px";

	alphaState();
	ScriptStart = true;

	timerID = setInterval("divPreset()",timerIDtiming);


	if (isJS) document.onmousemove = mousemove;
}

function startwindow2(){
	if ( !document.getElementById("OpenDiv") || !isJS ) return;

	div_data = document.getElementById("OpenDiv");
	div_data.style.position="absolute";
	divcheck=true;



	DivSize("W");
	DivSize("H");


	for (i = 0 ; i <= 500; i ++){
		div_check = document.getElementsByTagName('div')[i];
		if (div_check){
			if(div_check.id.substr(0,8) =="setM_ID@"){
				ComponentsDivData(div_check.id);
			}
		} else {
			break;
		}
	}

	div_data.style.top  = DivLocat("Y") + "px";
	div_data.style.left = DivLocat("X") + "px";

	alphaState();
	ScriptStart = true;

	timerID = setInterval("divPreset()",timerIDtiming);


	if (isJS) document.onmousemove = mousemove;
}

checkData="";
function ComponentsDivData(data){
	for (di = 0 ; di <= data.length ; di++){
		if ( data.substr(di,1) == "@" || data.substr(di,1) == "," || data.substr(di,1) == ";"){
			checkData = data.substr(di+1,2);
			for (dk = di+1 ; dk <= data.length ; dk++){
				if ( data.substr(dk,1) == "=" || data.substr(dk,1) == ":" ) break;
				if ( data.substr(dk,1) == "@" || data.substr(dk,1) == "," || data.substr(dk,1) == ";"){
					 dk=0;break;
				}
			}
			numberData = parseInt(data.substr(dk+1,8))
			if (!isNaN(numberData)){
				switch (checkData){
					case "aS":alphaS       = numberData;break;
					case "aL":alphaLast   = numberData;break;
					case "aO":alphaOver   = numberData;break;
					case "Dx":DivLocationX = numberData;break;
					case "Dy":DivLocationY = numberData;break;
					case "T1":timerIDtiming= numberData;break;
					case "T2":moveIDtiming = numberData;break;
					case "Xe":XEnable     = numberData;break;
					case "Ye":YEnable     = numberData;break;
					case "LR":LRmode      = numberData;break;
					case "UD":UDmode      = numberData;break;
					case "cD":
						drawCount   = numberData/10;
						if (drawCount>1) drawCount=1;
						break;
					default:break;
				}
			}
		}
	}
}


//////////////////////////////////

function showMovie(){
	document.cookie = "topenq=; domain=.nhk.or.jp; path=/nhkworld; expires=Wed, 16-Dec-2009 15:00:00 GMT";

	if(document.getElementById){
		document.getElementById("MoveDiv").style.display = 'block';
		document.getElementById("OpenDiv").style.display = 'none';
	} else if(document.all) {
		document.all("MoveDiv").style.display = 'block';
		document.all("OpenDiv").style.display = 'none';
	} else if(document.layers) {
	document.layers["MoveDiv"].display = 'block';
	document.layers["OpenDiv"].display = 'none';
	}
	startwindow();
	}


function clearMovie(){
	document.cookie = "topenq=1; domain=.nhk.or.jp; path=/nhkworld; expires=Wed, 16-Dec-2009 15:00:00 GMT";

	if(document.getElementById){
		document.getElementById("MoveDiv").style.display = 'none';
		document.getElementById("OpenDiv").style.display = 'block';
	} else if(document.all) {
		document.all("MoveDiv").style.display = 'none';
		document.all("OpenDiv").style.display = 'block';
	} else if(document.layers){
		document.layers["MoveDiv"].display = 'none';
		document.layers["OpenDiv"].display = 'block';
	}
	startwindow2();
}

function endMovie(){
	document.cookie = "topenq=2; domain=.nhk.or.jp; path=/nhkworld; expires=Wed, 16-Dec-2009 15:00:00 GMT";

	if(document.getElementById){
		document.getElementById("MoveDiv").style.display = 'none';
		document.getElementById("OpenDiv").style.display = 'none';
	} else if(document.all) {
		document.all("MoveDiv").style.display = 'none';
		document.all("OpenDiv").style.display = 'none';
	} else if(document.layers){
		document.layers["MoveDiv"].display = 'none';
		document.layers["OpenDiv"].display = 'none';
	}
}
