/* 플래시 함수 start */

function Flash(id,url,w,h,bg,t){

document.write("\
<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width="+w+" height="+h+" id="+id+">\
<param name='movie' value="+url+" />\
<param name='wmode' value="+t+" />\
<param name='bgcolor' value="+bg+" />\
<param name='allowScriptAccess' value='sameDomain' />\
<param name='quality' value='high' />\
<param name='menu' value='false' />\
<embed src="+url+" wmode="+t+" width="+w+" height="+h+" name="+id+" bgcolor="+bg+" allowScriptAccess='sameDomain' quality='high' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />\
</object>\
");
}

/* 플래시 함수 end */



/* 퀵메뉴 움직임 start */

var stmnLEFT = 0; // 스크롤메뉴의 좌측 위치 690
var stmnGAP1 = 30; // 페이지 헤더부분의 여백 (이보다 위로는 올라가지 않음) 
var stmnGAP2 = 130; // 스크롤시 브라우저 상단과 약간 띄움. 필요없으면 0으로 세팅 
var stmnBASE = 230; // 스크롤메뉴 초기 시작위치 (아무렇게나 해도 상관은 없지만 stmnGAP1과 약간 차이를 주는게 보기 좋음) 
var stmnActivateSpeed = 200; // 움직임을 감지하는 속도 (숫자가 클수록 늦게 알아차림) 
var stmnScrollSpeed = 10; // 스크롤되는 속도 (클수록 늦게 움직임) 
var mainScroll = document.getElementsByTagName('html')[0];
//var mainScroll = document.body.scrollTop;


function RefreshStaticMenu() { 
	var stmnStartPoint, stmnEndPoint, stmnRefreshTimer; 
	stmnStartPoint = parseInt(document.getElementById('quick_menu').style.top, 10); 
	stmnEndPoint = mainScroll.scrollTop + stmnGAP2 - 180; 
	if (stmnEndPoint < stmnGAP1) stmnEndPoint = stmnGAP1; 
	
	if ( stmnStartPoint != stmnEndPoint ) { 
	stmnScrollAmount = Math.ceil( Math.abs( stmnEndPoint - stmnStartPoint ) / 20); 
	document.getElementById('quick_menu').style.top = parseInt(document.getElementById('quick_menu').style.top, 10) + ( ( stmnEndPoint<stmnStartPoint ) ? -stmnScrollAmount : stmnScrollAmount ); 
	stmnRefreshTimer = stmnScrollSpeed; 

	} 
	
	else { 
		stmnRefreshTimer = stmnActivateSpeed; 
	}
	setTimeout ("RefreshStaticMenu();", stmnRefreshTimer); 

	}

function InitializeStaticMenu() { 
	document.getElementById('quick_menu').style.top = mainScroll.scrollTop + stmnBASE; 
	RefreshStaticMenu(); 
	document.getElementById('quick_menu').style.left = stmnLEFT; 
} 

/* 퀵메뉴 움직임 end */


/*div 게시판 레이어로 보이기 제어 */

function clickshow(num) {
	var str=0
	for (i=1; i<=10; i++) {
		if(document.all["Layer"+i]){
			menu=eval("document.all.Layer"+i+".style");
			if (num==i) {
				if (menu.display=="block") {
					menu.display="none";
					str=1
					//document.getElementById('title').style.color="#777777";
					//document.getElementById('title').style.fontWeight="normal";
					}else {
					menu.display="block";
					//document.getElementById('title').style.color="#21a1b8";
					//document.getElementById('title').style.fontWeight="bold";
					}
				}
			}
		}
	}



/*div 보이기 제어 : 탭메뉴 */

function tab_menu(index) {
	for(i=1; i<5; i++){
		if (index == i) {
			document.getElementById('p'+i).style.display = "";
			}else {
			document.getElementById('p'+i).style.display = "none";
			}
		}
	}

/* iframe 높이 자동 조절 */

function calcHeight(FrameName) 
{
  var the_height= document.getElementById(FrameName).contentWindow.document.body.scrollHeight; 
document.getElementById(FrameName).height=the_height; 
} 

/* popup */
function popup(u,w,h,s,n)
{
    var url = u;
    var width = w;
    var height = h;
    var left = 0;
    var top = 0;

    var toolbar = 'no';
    var menubar = 'no';
    var status = 'no';
    var scrollbars = s;
    var resizable = 'no';
    var help = window.open( u, n, 'left='+left+', top='+top+', width='+width+', height='+height+', toolbar='+toolbar+', menubar='+menubar+', status='+status+', scrollbars='+scrollbars+', resizable='+resizable);
	help.focus();
}

/* popup2 */
function popup2() 
{ 
window.open('http://220.149.163.79/pop.html', 'new_win','width=350,height=300 ,left=0, top=0,toolbar=0, menubar=0, statusbar=0, scrollbar=0, resizable=0');
}

function adjustImage(target_img,maxWidth,maxHeight)
{
    var newX, newY;
    var newHeight, newWidth;
    var newImg;

    newImg = new Image();
    newImg.src = target_img.src;
    imgw = newImg.width;
    imgh = newImg.height;
    maxHeight=imgh;
    
	if (imgw > maxWidth || imgh > maxHeight)
	{
        if(imgw > maxWidth)
        {
            if(imgw > maxWidth)
                newWidth = maxWidth;
            else
                newWidth = imgw;
            newHeight = Math.round((imgh*newWidth)/imgw);
        }
        else
        {
            if(imgh > maxHeight)
                newHeight = maxHeight;
            else
                newHeight = imgh;
            newWidth = Math.round((imgw*newHeight)/imgh);
        }
    }else{
        newWidth = imgw;
        newHeight = imgh;        
    }

    newX = maxWidth/2 - newWidth/2;
    newY = maxHeight/2 - newHeight/2;

  if(newWidth>0){
    target_img.onload = null;
    target_img.src = newImg.src;
    target_img.width = newWidth;
    target_img.height = newHeight;
  }

}


//DIV 컨트롤 스크립트

var old_answer = "";

function toggle(now_question,now_answer) {


	if(old_answer != now_answer) {
		if(old_answer != "") {
			old_answer.style.display = "none";
			old_question.className = ""
		}
		now_answer.style.display = "block";
		now_question.className = "now"
		old_answer = now_answer;
		old_question = now_question;
	} else {
		now_answer.style.display = "none";
		old_question.className = "over"
		old_answer = "";
		old_question = "";
	}
}

function over(now_answer,e) {
	if(now_answer.style.display != "block") {
		e.className = "over"
	}
}

function out(now_answer,e) {
	if(now_answer.style.display != "block") {
		e.className = ""
	}
}

//아이프레임탭메뉴 0

function clickMouse(idx) //this, 1
{
    var menuimg = [
                    {off:"../research/propessor/images/tab_01_off.gif", on:"../research/propessor/images/tab_01_on.gif"},
					{off:"../research/propessor/images/tab_01_off.gif", on:"../research/propessor/images/tab_01_on.gif"},
                    {off:"../research/propessor/images/tab_02_off.gif", on:"../research/propessor/images/tab_02_on.gif"},
                    {off:"../research/propessor/images/tab_03_off.gif", on:"../research/propessor/images/tab_03_on.gif"},
                    {off:"../research/propessor/images/tab_04_off.gif", on:"../research/propessor/images/tab_04_on.gif"},
					{off:"../research/propessor/images/tab_05_off.gif", on:"../research/propessor/images/tab_05_on.gif"}
                  ];

    var count = document.getElementById("parent_tabmenu").getElementsByTagName("img").length;

    for(var i=0; i<count; i++){

        var ii = i + 1;
        var ig = document.getElementById("ig" + ii);

        if(ii == idx){
            ig.setAttribute("src", menuimg[ii].on);
            ig.blur(); // 클릭시 이미지 테두리 점선 제거
        }
        else{
            ig.setAttribute("src", menuimg[ii].off);
        }
    }
}


//아이프레임탭메뉴1

function clickMouse1(idx) //this, 1
{
    var menuimg = [
                    {off:"../research/propessor/images/physics_tab01_off.gif", on:"../research/propessor/images/physics_tab01_on.gif"},
					{off:"../research/propessor/images/physics_tab01_off.gif", on:"../research/propessor/images/physics_tab01_on.gif"},
                    {off:"../research/propessor/images/physics_tab02_off.gif", on:"../research/propessor/images/physics_tab02_on.gif"},
                    {off:"../research/propessor/images/physics_tab03_off.gif", on:"../research/propessor/images/physics_tab03_on.gif"},
                    {off:"../research/propessor/images/physics_tab04_off.gif", on:"../research/propessor/images/physics_tab04_on.gif"},
					{off:"../research/propessor/images/physics_tab05_off.gif", on:"../research/propessor/images/physics_tab05_on.gif"},
					{off:"../research/propessor/images/physics_tab06_off.gif", on:"../research/propessor/images/physics_tab06_on.gif"},
					{off:"../research/propessor/images/physics_tab07_off.gif", on:"../research/propessor/images/physics_tab07_on.gif"}


                  ];

    var count = document.getElementById("parent_tabmenu").getElementsByTagName("img").length;

    for(var i=0; i<count; i++){

        var ii = i + 1;
        var ig = document.getElementById("ig" + ii);

        if(ii == idx){
            ig.setAttribute("src", menuimg[ii].on);
            ig.blur(); // 클릭시 이미지 테두리 점선 제거
        }
        else{
            ig.setAttribute("src", menuimg[ii].off);
        }
    }
}


//아이프레임탭메뉴2

function clickMouse2(idx) //this, 1
{
    var menuimg = [
                    {off:"../research/propessor/images/materials_tab01_off.gif", on:"../research/propessor/images/chemical_tab01_on.gif"},
					{off:"../research/propessor/images/chemical_tab01_off.gif", on:"../research/propessor/images/chemical_tab01_on.gif"},
                    {off:"../research/propessor/images/chemical_tab02_off.gif", on:"../research/propessor/images/chemical_tab02_on.gif"},
                    {off:"../research/propessor/images/chemical_tab03_off.gif", on:"../research/propessor/images/chemical_tab03_on.gif"},
                    {off:"../research/propessor/images/chemical_tab04_off.gif", on:"../research/propessor/images/chemical_tab04_on.gif"},
					{off:"../research/propessor/images/chemical_tab05_off.gif", on:"../research/propessor/images/chemical_tab05_on.gif"},
					{off:"../research/propessor/images/chemical_tab06_off.gif", on:"../research/propessor/images/chemical_tab06_on.gif"}
                  ];

    var count = document.getElementById("parent_tabmenu").getElementsByTagName("img").length;

    for(var i=0; i<count; i++){

        var ii = i + 1;
        var ig = document.getElementById("ig" + ii);

        if(ii == idx){
            ig.setAttribute("src", menuimg[ii].on);
            ig.blur(); // 클릭시 이미지 테두리 점선 제거
        }
        else{
            ig.setAttribute("src", menuimg[ii].off);
        }
    }
}


//아이프레임탭메뉴3

function clickMouse3(idx) //this, 1
{
    var menuimg = [
                    {off:"../research/propessor/images/materials_tab01_off.gif", on:"../research/propessor/images/materials_tab01_on.gif"},
					{off:"../research/propessor/images/materials_tab01_off.gif", on:"../research/propessor/images/materials_tab01_on.gif"},
                    {off:"../research/propessor/images/materials_tab02_off.gif", on:"../research/propessor/images/materials_tab02_on.gif"},
                    {off:"../research/propessor/images/materials_tab03_off.gif", on:"../research/propessor/images/materials_tab03_on.gif"},
                    {off:"../research/propessor/images/materials_tab04_off.gif", on:"../research/propessor/images/materials_tab04_on.gif"},
					{off:"../research/propessor/images/materials_tab05_off.gif", on:"../research/propessor/images/materials_tab05_on.gif"},
					{off:"../research/propessor/images/materials_tab06_off.gif", on:"../research/propessor/images/materials_tab06_on.gif"},
					{off:"../research/propessor/images/materials_tab07_off.gif", on:"../research/propessor/images/materials_tab07_on.gif"},
                    {off:"../research/propessor/images/materials_tab08_off.gif", on:"../research/propessor/images/materials_tab08_on.gif"}
				  ];

    var count = document.getElementById("parent_tabmenu").getElementsByTagName("img").length;

    for(var i=0; i<count; i++){

        var ii = i + 1;
        var ig = document.getElementById("ig" + ii);

        if(ii == idx){
            ig.setAttribute("src", menuimg[ii].on);
            ig.blur(); // 클릭시 이미지 테두리 점선 제거
        }
        else{
            ig.setAttribute("src", menuimg[ii].off);
        }
    }
}


//아이프레임탭메뉴4

function clickMouse4(idx) //this, 1
{
    var menuimg = [
                    {off:"../research/propessor/images/mechatronics_tab01_off.gif", on:"../research/propessor/images/mechatronics_tab01_on.gif"},
					{off:"../research/propessor/images/mechatronics_tab01_off.gif", on:"../research/propessor/images/mechatronics_tab01_on.gif"},
                    {off:"../research/propessor/images/mechatronics_tab02_off.gif", on:"../research/propessor/images/mechatronics_tab02_on.gif"},
                    {off:"../research/propessor/images/mechatronics_tab03_off.gif", on:"../research/propessor/images/mechatronics_tab03_on.gif"},
                    {off:"../research/propessor/images/mechatronics_tab04_off.gif", on:"../research/propessor/images/mechatronics_tab04_on.gif"},
					{off:"../research/propessor/images/mechatronics_tab05_off.gif", on:"../research/propessor/images/mechatronics_tab05_on.gif"},
					{off:"../research/propessor/images/mechatronics_tab06_off.gif", on:"../research/propessor/images/mechatronics_tab06_on.gif"}
                  ];

    var count = document.getElementById("parent_tabmenu").getElementsByTagName("img").length;

    for(var i=0; i<count; i++){

        var ii = i + 1;
        var ig = document.getElementById("ig" + ii);

        if(ii == idx){
            ig.setAttribute("src", menuimg[ii].on);
            ig.blur(); // 클릭시 이미지 테두리 점선 제거
        }
        else{
            ig.setAttribute("src", menuimg[ii].off);
        }
    }
}


function clickMouse10(idx) //this, 1
{
    var menuimg = [
                    {off:"../Graduate/images/aca_tab1.gif", on:"../Graduate/images/aca_tab1over.gif"},
					{off:"../Graduate/images/aca_tab1.gif", on:"../Graduate/images/aca_tab1over.gif"},
                    {off:"../Graduate/images/aca_tab2.gif", on:"../Graduate/images/aca_tab2over.gif"}
                    
                  ];

    var count = document.getElementById("parent_tabmenu").getElementsByTagName("img").length;

    for(var i=0; i<count; i++){

        var ii = i + 1;
        var ig = document.getElementById("ig" + ii);

        if(ii == idx){
            ig.setAttribute("src", menuimg[ii].on);
            ig.blur(); // 클릭시 이미지 테두리 점선 제거
        }
        else{
            ig.setAttribute("src", menuimg[ii].off);
        }
    }
}
