var timerID;
var posX,posY,opa;
var window_state=false;
var open_window=-1;

var url=new Array(
"list_seminar",
"list_exam",
"list_???"
);

var menuTitle=new Array(
"セミナー・集合研修",
"認定試験",
"list_???"
);

function CloseWindow()
{
	if(timerID!=null)
		window.clearInterval(timerID);

	$('popUpMainLayer').style.visibility="hidden";
	timerID=window.setInterval("ClosingWindow()",30);
	posX=600;
	posY=320;

	//IE 6対策
	if(getBrowser()=='IE6.0'){
		var elems = document.getElementsByTagName("select");
		for (var i = 0; i < elems.length; i++) {
			elems[i].style.display = "";
		}
	}
}
function ClosingWindow()
{
	posY-=64;
	opa-=0.075;
	if(IE){
		$('popUpWindow').style.top		=(posY-320)+'px';
	}else{
		$('popUpWindow').style.opacity=opa+"";
	}
	if(posY<=0){
		window.clearInterval(timerID);
		timerID=null;
		window_state=false;
		$('popUpWindow').style.visibility="hidden";
		$('NaviWindow').style.visibility="hidden";
	}
}

function OpenWindow(menuNo)
{
	if(timerID!=null)
		window.clearInterval(timerID);
	posX=0;
	posY=0;
	opa=0.01;
	if(IE){
		$('popUpWindow').style.top		=(-320)+'px';
	}else{
		$('popUpWindow').style.opacity	=opa+"";
	}
	$('popUpMainLayer').style.visibility="hidden";
	$('popUpWindow').style.visibility="visible";
	$('NaviWindow').style.visibility="visible";
	timerID=window.setInterval("OpeningWindow()",30);

	getFile(OpenedWindow,'/bin/LoadTopics.aspx?topics='+url[menuNo]);

	$('popUpTitle').setText('　'+menuTitle[menuNo]);

}
function OpenedWindow(obj)
{
	$('popUpMainLayer').innerHTML = obj.responseText;

	var p1_tag=$("popUpMenuBox");
	var p2_tag=p1_tag.getElementsByTagName("div");
	
	for(var i=0;i<p2_tag.length;i++){
		p2_tag[i].onmouseover	=function(){this.className="popUpInBtnOver";};
		p2_tag[i].onmouseout	=function(){this.className="popUpInBtnOut";};
	}
}

function OpeningWindow()
{
//	posX+=60;
	posY+=64;
	opa+=0.15;
	if(IE){
		$('popUpWindow').style.top=(posY-320)+'px';
	}else{
		$('popUpWindow').style.opacity=opa+"";
	}
	dd = new Date();
	debugPrint(dd.toLocaleString()+":"+posX+","+posY+","+opa);

	if((IE && posY>=320)||(!IE && opa>=0.75)){
		window.clearInterval(timerID);
		timerID=null;
		window_state=true;
		$('popUpMainLayer').style.visibility="visible";
	}

	//IE 6対策
	if(getBrowser()=='IE6.0'){
		var elems = document.getElementsByTagName("select");
		for (var i = 0; i < elems.length; i++) {
			elems[i].style.display = "none";
		}
	}
}

function topMenuInit()
{

	$('CloseBtn').onclick		=function(){CloseWindow();};

	$('up_menu_semiar').onmouseover	=function(){this.className='UpMenuBtn_OnMouse';};
	$('up_menu_semiar').onmouseout	=function(){this.className='UpMenuBtn';};

	$('up_menu_exam').onmouseover	=function(){this.className='UpMenuBtn_OnMouse';};
	$('up_menu_exam').onmouseout	=function(){this.className='UpMenuBtn';};

	$('up_menu_case').onmouseover	=function(){this.className='UpMenuBtn_OnMouse';};
	$('up_menu_case').onmouseout	=function(){this.className='UpMenuBtn';};

	$('up_menu_form').onmouseover	=function(){this.className='UpMenuBtn_OnMouse';};
	$('up_menu_form').onmouseout	=function(){this.className='UpMenuBtn';};

	$('up_menu_corp').onmouseover	=function(){this.className='UpMenuBtn_OnMouse';};
	$('up_menu_corp').onmouseout	=function(){this.className='UpMenuBtn';};

	$('up_menu_semiar').onclick=function(){
		if((!window_state) || open_window!=0){
			OpenWindow(0);
			open_window=0;
		}else{
			CloseWindow();
			open_window=-1;
		}
		return false;
	};

	$('up_menu_exam').onclick=function(){
		if((!window_state) || open_window!=1){
			OpenWindow(1);
			open_window=1;
		}else{
			CloseWindow();
			open_window=-1;
		}
		return false;
	};

	$('up_menu_case').onclick=function(){
		location.href='/report/example/';
		return false;
	};

	$('up_menu_form').onclick=function(){
		location.href='/corp/feedback.html';
		return false;
	};

	$('up_menu_corp').onclick=function(){
		location.href='/corp/';
		return false;
	};


	//トップメニューのAは機能させない
	var atag=$("UpMenu");
	atag=atag.getElementsByTagName("a");
	
	for(i=0;i<atag.length-1;i++){
//		if(atag[i].name=='' && atag[i].title=='' && atag[i].className!='n_a')
			if(!atag[i].onclick)
				atag[i].onclick=function(){return false;};
		debugPrint(i+":"+atag[i].name);
		debugPrint(i+":"+atag[i].href);
	}

	var i_tag=document.getElementsByTagName("input");
	
	for(i=0;i<i_tag.length-1;i++){
		if(i_tag[i].type=="text"){
			i_tag[i].style.backgroundColor="#ffffcc";
			i_tag[i].onfocus=function(){this.style.backgroundColor="#ffcccc";};
			i_tag[i].onblur =function(){this.style.backgroundColor="#ffffcc";};
		}
	}

	var t_tag=document.getElementsByTagName("textarea");
	
	for(i=0;i<t_tag.length-1;i++){
		t_tag[i].style.backgroundColor="#ffffcc";
		t_tag[i].onfocus=function(){this.style.backgroundColor="#ffcccc";};
		t_tag[i].onblur =function(){this.style.backgroundColor="#ffffcc";};
//		if(i_tag[i].type=="text"){
//			i_tag[i].onfocus=function(){this.style.backgroundColor="#ffffcc";};
//		}
	}

}