var zoomRate = 30;			//
var maxRate = 210;			//
var minRate = 100;			//

var fontSize = 12;			//fontSize Default
var setfontsize = 12;		//setfontsize Default
var SetFont = strSetFont;	//SetFont Default "font";
var fontColorIndex = 0;		//fontColorIndex Defalut(0 )
var bgColorIndex = 0;		//fontColorIndex Defalut(0)
var ScreenSize = 100;		//ScreenSize Default
var VoiceSpeed = 3;			//VoiceSpeed Default
var VoiceVolum = 3;			//VoiceVolum Default




var beforeBgColor;
var beforeTag;
var beforeTableTag;

var afontSize = new Array();

var aVoice = new Array();
aVoice[1] = 1;
aVoice[2] = 2;
aVoice[3] = 3;
aVoice[4] = 4;
aVoice[5] = 5;

var aScreen = new Array();
aScreen[1] = 100;
aScreen[2] = 125;
aScreen[3] = 150;
aScreen[4] = 170;
aScreen[5] = 190;

var fontColor = new Array();
fontColor[0] = "";
fontColor[1] = "";
fontColor[2] = "#ffff00";
fontColor[3] = "#ffffff";
fontColor[4] = "#6666ff";
fontColor[5] = "#ff6666";
fontColor[6] = "#ff66ff";
fontColor[7] = "#66ff66";

var bgColor = new Array();
bgColor[0] = "";
bgColor[1] = "#ffffff";
bgColor[2] = "#000000";
bgColor[3] = "#6666ff";
bgColor[4] = "#ff6666";
bgColor[5] = "#ff66ff";
bgColor[6] = "#66ff66";






/*****************************************************************/
//
/*****************************************************************/
function readCookie( str ){
	var key = str + "=" ;
	var key_len = key.length;
	var cookie_len = document.cookie.length;
	var i = 0;

	while (i < cookie_len )	{
		var j = i + key_len;
		if ( document.cookie.substring( i, j ) == key ){
			var cookie_end = document.cookie.indexOf(";",j);

			if (cookie_end == -1){
				cookie_end = document.cookie.length;
			}
			return document.cookie.substring(j,cookie_end );
		}
		i++
	}
	return ""
}

/*****************************************************************/
//
/*****************************************************************/
function setCookie( key, value, term ){
	var expire = new Date();  
	expire.setDate( expire.getDate() + term );
	document.cookie = key + "=" + escape( value ) + "; path=/; expires=" + expire.toGMTString() + ";";

}




/*****************************************************************/
//
/*****************************************************************/
function bodyactive(){
	var sRes = "";	
	sRes = IsInstalled();
	if( sRes == true ){
		document.body.insertAdjacentHTML("BeforeEnd",objectTag);
	}else{
	}
}

/*****************************************************************/
/*PageInit()*/
/*****************************************************************/
//
function f_PageInit(){
	if( readCookie("VoiceStart").length == 0){
		setCookie("VoiceStart", VoiceStart , 1);
	}else VoiceStart = readCookie("VoiceStart");

	if( readCookie("VoiceVolum").length == 0 ){
		setCookie("VoiceVolum", VoiceVolum, 1);
	}else VoiceVolum = readCookie("VoiceVolum");

	if( readCookie("VoiceSpeed").length == 0 ){
		setCookie("VoiceSpeed", VoiceSpeed, 1);
	}else VoiceSpeed = readCookie("VoiceSpeed");

	var res = NetlightObjectType(NetLightCOM);
	if( res == true ){
	f_VoiceStart( readCookie("VoiceStart") )};

	if( typeof(DynamicNetLightCOM) != 'undefined' ){
		
		VoiceVolum = parseFloat(readCookie("VoiceVolum"));
		NetLightCOM.VoiceVolum=VoiceVolum;
		f_ImgChg(VoiceVolum, "volum");

		VoiceSpeed = parseFloat(readCookie("VoiceSpeed"));
		NetLightCOM.VoiceSpeed=VoiceSpeed;
		f_ImgChg(VoiceSpeed, "speed");
	}
	else{
		f_ImgChg("", "COM");
	}

	fontColorIndex = readCookie("fontColorIndex");
	bgColorIndex = readCookie("bgColorIndex");
	f_FontInit();
}


/*****************************************************************/
/*Init()*/
/*****************************************************************/
function f_FontInit(){
	
	if (readCookie("setfontsize").length == 0 ){
		setCookie("setfontsize", setfontsize, 1);
	}else setfontsize = readCookie("setfontsize");	//

	if( readCookie("fontSize").length == 0 ){
		setCookie("fontSize", fontSize, 1);
	}else fontSize = readCookie("fontSize");		//
	
	if (readCookie("SetFont").length == 0 ){
		setCookie("SetFont", SetFont, 1);
	}else SetFont = readCookie("SetFont");			//

	if( readCookie("fontColorIndex").length == 0 ){
		setCookie("fontColorIndex", 0, 1);
	}else fontColorIndex = readCookie("fontColorIndex");	
		
	if ( readCookie("bgColorIndex").length == 0 ){
		setCookie("bgColorIndex", 0, 1);
	}else bgColorIndex = readCookie("bgColorIndex");

	if ( readCookie("zoomVal").length == 0 ){
		setCookie("zoomVal", "100%", 7);
	}else currZoom = readCookie("zoomVal")+"%";		//

	zoomInOut("");
	
	setFontSize(setfontsize);
	f_setFace();
	

	
	
}

/*****************************************************************/
/**/
/*****************************************************************/
function setFontSize(val){
	afontSize[1] = val;
	for( var i=2; i<6; i++ ){
		val = parseInt(val) + 3;
		afontSize[i] = val;
	}
}


/*****************************************************************/
/**/
/*****************************************************************/
function f_objectInsert(mode){
	var sRes = "";
	sRes = IsInstalled();
	if( sRes == true ){
		document.body.insertAdjacentHTML("BeforeEnd", objectTag);
	}else{
		/*var com = confirm("음성서비스를 받으시려면 프로그램을 설치하셔야 합니다.\n\n설치하시겠습니까?");

		if( com == true ){*/
			top.location.href="/home/NetLight2/ActiveX.jsp?NetURL="+NetURLPath;
		//}
	}
}


/*****************************************************************/
/**/
/*****************************************************************/
function f_VoiceStart(str){
	//-setTimeout("", 2000);
	
	if( typeof(DynamicNetLightCOM) != 'undefined' ){
		if( str == "start" ){
			f_ImgChg('', "VoiceStart");
			if( FrameLength == 2 ){
			
				if( typeof(eval(FrameMainName +"document.all['VoiceLink']")) == 'object' ){
					//eval(FrameMainName +"document.all['VoiceLink']").href = "JavaScript:NetReader('VoiceStop');";
                    eval(FrameMainName +"document.all['VoiceLink']").onclick = function() { NetReader('VoiceStop'); return false;}  //추가
					eval(FrameMainName +"document.all['VoiceLink']").title="음성 켜기 버튼";
					
				}
			}else{
				if( typeof(document.all['VoiceLink']) == 'object' ){
					//document.all['VoiceLink'].href="JavaScript:NetReader('VoiceStop');";
                    document.all['VoiceLink'].onclick = function() { NetReader('VoiceStop'); return false;}				//추가
					document.all['VoiceLink'].title="음성 켜기 버튼";

				}
			}

			DynamicNetLightCOM.VoiceActive=true;
		}
		else if( str == "stop"){
			f_ImgChg('', "VoiceStop");
			if( FrameLength == 2 ){
				if( typeof(eval(FrameMainName +"document.all['VoiceLink']")) == 'object' ){
					//eval(FrameMainName +"document.all['VoiceLink']").href="JavaScript:NetReader('VoiceStart');";
                    eval(FrameMainName +"document.all['VoiceLink']").onclick = function() { NetReader('VoiceStart'); return false;}		//추가
					eval(FrameMainName +"document.all['VoiceLink']").title="음성 끄기 버튼";
				}
			}else{
				if( typeof(document.all['VoiceLink']) == 'object' ){
					//document.all['VoiceLink'].href="JavaScript:NetReader('VoiceStart');";
                    document.all['VoiceLink'].onclick = function() { NetReader('VoiceStart'); return false;}			//추가
					document.all['VoiceLink'].title="음성 끄기 버튼";
				}
			}
		
			
			DynamicNetLightCOM.VoiceActive=false;
			
		}
		setCookie("VoiceStart", str, 1);
	}else{
		//alert("NetLight 음성모듈이 존재하지 않습니다");
		f_objectInsert("voice");
	}	
}

/*****************************************************************/
/*네비게이션 설정*/
/*****************************************************************/
function f_NaviStart(str){
	//-setTimeout("", 2000);
	if( typeof(DynamicNetLightCOM) != 'undefined' ){
		if( str == "start" ){
			f_ImgChg('', "NaviStart");
			if( FrameLength == 2 ){
			
				if( typeof(eval(FrameMainName +"document.all['NaviLink']")) == 'object' ){
					eval(FrameMainName +"document.all['NaviLink']").href = "JavaScript:NetReader('NaviStop');";
					eval(FrameMainName +"document.all['NaviLink']").title="네비게이션 켜기 버튼";
					
				}
			}else{
				if( typeof(document.all['NaviLink']) == 'object' ){
					document.all['NaviLink'].href="JavaScript:NetReader('NaviStop');";
					document.all['NaviLink'].title="네비게이션 켜기 버튼";

				}
			}
			
			DynamicNetLightCOM.NavigationActive=true;
			f_VoiceStart("start");
		}
		else if( str == "stop"){
			f_ImgChg('', "NaviStop");
			if( FrameLength == 2 ){
				if( typeof(eval(FrameMainName +"document.all['NaviLink']")) == 'object' ){
					eval(FrameMainName +"document.all['NaviLink']").href="JavaScript:NetReader('NaviStart');";
					eval(FrameMainName +"document.all['NaviLink']").title="네비게이션 끄기 버튼";
				}
			}else{
				if( typeof(document.all['NaviLink']) == 'object' ){
					document.all['NaviLink'].href="JavaScript:NetReader('NaviStart');";
					document.all['NaviLink'].title="네비게이션 끄기 버튼";
				}
			}
		
			
			DynamicNetLightCOM.NavigationActive=false;
			
		}
		setCookie("NaviStart", str, 1);
	}else{
		//alert("NetLight 음성모듈이 존재하지 않습니다");
		f_objectInsert("voice");
	}	
}


//음성모듈 볼륨설정
function f_VoiceVolume(mode)
{
	var sVol;
	sVol = readCookie("VoiceVolum");
	for( var i=0; i<aVoice.length; i++){
	
		if(sVol == aVoice[i]){
			sVol = i;
			break;
		}
	}

	if( mode == "up" ){
		if( sVol < 5 ){
			sVol = parseInt(sVol) + 1;
		}

	}else if( mode == "down" ){
		if( sVol > 1 ){
			sVol = parseInt(sVol) - 1;
		}
	}else{
		//NO JOBS
	}

	if( typeof(DynamicNetLightCOM) != 'undefined' ){
		//Cookie 재설정
		setCookie( "VoiceVolum", aVoice[sVol], 1 );
		//NetLight Voice Setting
		NetLightCOM.VoiceVolum = readCookie("VoiceVolum");		 
	}else{//alert("NetLight 음성모듈이 존재하지 않습니다");
	}
}

//음성모듈 스피드 설정
function f_VoiceSpeed(mode)
{
	var sSpeed;
	sSpeed = readCookie("VoiceSpeed");
	for( var i=1; i<aVoice.length; i++){
		if(sSpeed == aVoice[i]){
			sSpeed = i;
			break;
		}
	}

	if( mode == "up" ){
		if( sSpeed < 5 ){
			sSpeed = parseInt(sSpeed) + 1;
		}

	}else if( mode == "down" ){
		if( sSpeed > 1 ){
			sSpeed = parseInt(sSpeed) - 1;
		}
	}else{
		//NO JOBS
	}	

	
	if( typeof(DynamicNetLightCOM) != 'undefined' ){
		//Cookie 재설정
		setCookie( "VoiceSpeed", aVoice[sSpeed], 1 );
		//NetLight Speed Setting
		NetLightCOM.VoiceSpeed = readCookie("VoiceSpeed");		
		//DynamicNetLightCOM.VoiceSpeed = readCookie("VoiceSpeed");
	}else{//alert("NetLight 음성모듈이 존재하지 않습니다");
	}
}

/*********************************************************/
//글자 크게
/*********************************************************/
function f_fontPlus(){
	if (fontSize < 20){
		fontSize = parseInt(fontSize) + 3;
		//f_ImgChg(fontSize, "font");
		f_setFace();
	}
}
/*********************************************************/
//글자 작게
/*********************************************************/
function f_fontMinus() {
	if (fontSize > 13) {
		fontSize = parseInt(fontSize) - 3;
		f_setFace();
	}
}
/*********************************************************/
//폰트컬러
/*********************************************************/
function f_setFontColor(val){
	if ( val >= 0 && val <= 7 ) 
	{
		fontColorIndex = val;
		f_setFace();
	}
}

/*********************************************************/
//바탕색
/*********************************************************/
function f_setBgColor(val){
	if ( val >= 0 && val <= 6 ) 
	{
		bgColorIndex = val;
		f_setFace();
	}
}
/*********************************************************/
//화면확대
/*********************************************************/
/*
function zoomInOut(how){
	var sValue;
	//-setTimeout("", 1000);
	if(readCookie("zoomVal") != null && readCookie("zoomVal") != ""){
			if( FrameLength == 2 ){
				eval(FrameMainName +"document.body").style.zoom = readCookie("zoomVal")+"%";			
			}else{
				 document.body.style.zoom = readCookie("zoomVal")+"%";
			}
			currZoom=readCookie("zoomVal");
	}else{
			if( FrameLength == 2 ){
				eval(FrameMainName +"document.body").style.zoom = "100%"; 
			}else{
				document.body.style.zoom = "100%"; 
			}
			currZoom = "100%";
	}

	

	if ( ((how == "in") && (parseInt(currZoom) >= maxRate)) || ((how == "out") && (parseInt(currZoom) <= minRate)) ) {
		return; 
	}
	if (how == "in") {
		if( FrameLength == 2 )
			eval(FrameMainName +"document.body").style.zoom = parseInt(eval(FrameMainName +"document.body").style.zoom)+zoomRate+"%";
		else
			document.body.style.zoom = parseInt(document.body.style.zoom)+zoomRate+"%";
			

	}else if( how == "out" ){
		if( FrameLength == 2 )
			eval(FrameMainName +"document.body").style.zoom = parseInt(eval(FrameMainName +"document.body").style.zoom)-zoomRate+"%";
		else
			document.body.style.zoom = parseInt(document.body.style.zoom)-zoomRate+"%";
			 //alert(parseInt(currZoom)-zoomRate+"%");
			 //for (var d = 0; d < document.all.tags('DIV').length; d++)
			 //{
				
			//	document.all.tags('DIV')[d].style.zoom=parseInt(currZoom)-zoomRate+"%";
			
			// }
	}
	if( FrameLength == 2 ){
		sValue = parseInt(eval(FrameMainName +"document.body").style.zoom);		
	}else{
		sValue = parseInt(document.body.style.zoom);
	}

	setCookie("zoomVal", sValue, 365);



	
}
*/

/*********************************************************/
//화면확대
/*********************************************************/
function zoomInOut(how){
 var sValue;
 //-setTimeout("", 1000);
 if(readCookie("zoomVal") != null && readCookie("zoomVal") != "" && readCookie("zoomVal") != "NaN"){
	   if( FrameLength == 2 ){
			//eval(FrameMainName +"document.getElementById('zoomCtrl')").style.zoom = readCookie("zoomVal")+"%";   
			eval(FrameMainName +"document.getElementById('zoomCtrl')").style.zoom = readCookie("zoomVal")+"%";  	

	   }else{
			document.getElementById("zoomCtrl").style.zoom = readCookie("zoomVal")+"%";
	   }
	   currZoom=readCookie("zoomVal");
 }else{
	   if( FrameLength == 2 ){
			eval(FrameMainName +"document.getElementById('zoomCtrl')").style.zoom = "100%"; 
	   }else{
			document.getElementById("zoomCtrl").style.zoom = "100%"; 
	   }
	   currZoom = "100%";
 }

 if ( ((how == "in") && (parseInt(currZoom) >= maxRate)) || ((how == "out") && (parseInt(currZoom) <= minRate)) ) {
	  return; 
 }
 if (how == "in") {
	  if( FrameLength == 2 )
			eval(FrameMainName +"document.getElementById('zoomCtrl')").style.zoom = parseInt(eval(FrameMainName +"document.getElementById('zoomCtrl')").style.zoom)+zoomRate+"%";
	  else
			document.getElementById("zoomCtrl").style.zoom = parseInt(document.getElementById("zoomCtrl").style.zoom)+zoomRate+"%";


 }else if( how == "out" ){
	  if( FrameLength == 2 )
			eval(FrameMainName +"document.getElementById('zoomCtrl')").style.zoom = parseInt(eval(FrameMainName +"document.getElementById('zoomCtrl')").style.zoom)-zoomRate+"%";
	  else
			document.getElementById("zoomCtrl").style.zoom = parseInt(document.getElementById("zoomCtrl").style.zoom)-zoomRate+"%";
 }
 if( FrameLength == 2 ){
			sValue = parseInt(eval(FrameMainName +"document.getElementById('zoomCtrl')").style.zoom);  
 }else{
			sValue = parseInt(document.getElementById("zoomCtrl").style.zoom);
 }
	 setCookie("zoomVal", sValue, 365);
}


/*********************************************************/
//레벨 이미지 변경
/*********************************************************/
function f_ImgChg(val, flag){
	//Start
	if(flag == "VoiceStart"){
		if( FrameLength == 2 ){
			if( typeof(eval(FrameMainName +"document.all['VoiceStart']")) == 'object' ){
				eval(FrameMainName +"document.all['VoiceStart']").alt="voice off";
				eval(FrameMainName +"document.all['VoiceStart']").title="voice off";
				eval(FrameMainName +"document.all['VoiceStart']").src = "/home/english/images/control/btn_on.jpg";
			}
		}else{
			if( typeof(document.all['VoiceStart']) == 'object' ){
				document.all['VoiceStart'].alt="voice off";
				document.all['VoiceStart'].title="voice off";
				document.all['VoiceStart'].src = "/home/english/images/control/btn_on.jpg";
			}
		}
	}
	//Stop
	else if(flag == "VoiceStop"){
		if( FrameLength == 2 ){
			if( typeof(eval(FrameMainName +"document.all['VoiceStart']")) == 'object' ){
				eval(FrameMainName +"document.all['VoiceStart']").alt="voice on";
				eval(FrameMainName +"document.all['VoiceStart']").title="voice on";
				eval(FrameMainName +"document.all['VoiceStart']").src = "/home/english/images/control/off.gif";
			}
		}else{
			if( typeof(document.all['VoiceStart']) == 'object' ){
				document.all['VoiceStart'].alt="voice on";
				document.all['VoiceStart'].title="voice on";
				document.all['VoiceStart'].src = "/home/english/images/control/off.gif";
			}
		}
	}




	
	//Not NetLightCOM
	else if( flag == "COM" ){
	}
}

/*********************************************************/
//글자크기 설정
/*********************************************************/
function f_setFace(){
	var objs_td		= new Array();
	var	objs_a		= new Array();
	var	ogjs_span	= new Array();
	var objs_p		= new Array();

	objs_td		= document.getElementsByTagName("td");
	objs_a		= document.getElementsByTagName("a");
	ogjs_span	= document.getElementsByTagName("span");
	objs_p		= document.getElementsByTagName("P");

	for (i=0;i<objs_td.length;i++){
		objs_td[i].style.fontSize=fontSize+'px';
		objs_td[i].style.color=fontColor[fontColorIndex];
		objs_td[i].style.backgroundColor=bgColor[bgColorIndex];
	}

	for (i=0;i<objs_a.length;i++){
		objs_a[i].style.fontSize=fontSize+'px';
		objs_a[i].style.color=fontColor[fontColorIndex];
	}

	for (i=0;i<ogjs_span.length;i++){
		ogjs_span[i].style.fontSize=fontSize+'px';
		ogjs_span[i].style.color=fontColor[fontColorIndex];
	}

	for (i=0;i<objs_p.length;i++){
		objs_p[i].style.fontSize=fontSize+'px';
		objs_p[i].style.color=fontColor[fontColorIndex];
	}

	if ( document.all['fontSelect'] == '[object]' && document.all['bgSelect'] == '[object]' ){
		document.all['fontSelect'].selectedIndex	= parseInt(fontColorIndex);
		document.all['bgSelect'].selectedIndex		= parseInt(bgColorIndex);
	}

	setCookie("fontSize", fontSize, 1);					//폰트저장
	setCookie("fontColorIndex", fontColorIndex, 1);		//폰트색상저장	
	setCookie("bgColorIndex", bgColorIndex, 1);			//배경색저장
}


/*********************************************************/
//Object 유/무
/*********************************************************/
function NetlightObjectType(netlight){
	if(netlight.object){
		return true;
	}else{
		return false;
	}
}

/*
function zoomIn() {
	var newZoom;
  newZoom= parseInt(top-area.style.zoom)+10+'%'
      top-area.style.zoom =newZoom; 
  }

function zoomOut() {
  newZoom= parseInt(top-area.style.zoom)-10+'%'
      top-area.style.zoom =newZoom;
  } 
*/

