//fontSize Defalut
var fontSize = 12;
//fontColorIndex Defalut(0Àº ±ÛÀÚ»ö)
var fontColorIndex = 0;
//fontColorIndex Defalut(0Àº ¹ÙÅÁ»ö)
var bgColorIndex = 0;

//±ÛÀÚ»ö ¹è¿­
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";

//¹è°æ»ö ¹è¿­
bgColor = new Array();
bgColor[0] = "";
bgColor[1] = "";
bgColor[2] = "#000000";
bgColor[3] = "#6666ff";
bgColor[4] = "#ff6666";
bgColor[5] = "#ff66ff";
bgColor[6] = "#66ff66";


/*----------------------------------------------------------------------------*/
/* NAME : f_playinput()                                                       */
/* DESC : ¼­ºêÆäÀÌÁö¿¡¼­ »ç¿ëÀÚ°¡ ÀÔ·ÂÇÑ ÅØ½ºÆ®¸¦ À½¼ºÀ¸·Î ÇÕ¼ºÇÏ¿© Àç»ýÇÑ´Ù. */
/*----------------------------------------------------------------------------*/
function f_playinput(inText){
     sRes = sBot.IsAvailable();
    if( sRes == 1 )
	{
		sBot.OnSendText(inText);
		//parent.frames[1].OnSendText(inText);
	}
}

/*----------------------------------------------------------------------------*/
/* NAME : f_playinput_d()													  */
/* DESC : ¼­ºêÆäÀÌÁö¿¡¼­ »ç¿ëÀÚ°¡ ÀÔ·ÂÇÑ ÅØ½ºÆ®¸¦ À½Àý´ÜÀ§·Î ÇÕ¼ºÇÏ¿© Àç»ýÇÑ´Ù*/
/*----------------------------------------------------------------------------*/
function f_playinput_d(inText){
	 sRes = sBot.IsAvailable();
    if( sRes == 1 )
	{
		sBot.OnSendText('<<' + inText + '>>');
	}
}
/*----------------------------------------------------------------------------*/
/* NAME : f_selectVoice2()													  */
/* DESC : ÄÞº¸¹Ú½º¿¡ onChangeµÆÀ» ¶§ À½¼º									  */
                                                 
/*----------------------------------------------------------------------------*/
function f_selectVoice2(obj) {
	var opts = obj.options;
	var strText  = "";

	for (var i=0; i<opts.length; i++) {
		if ( opts[i].selected ) strText = opts[i].text;
	}
	f_playinput(strText);
}

/*----------------------------------------------------------------------------*/
/* NAME : f_selectVoice()													  */
/* DESC : ¼¿·ºÆ® ¹Ú½º¿¡ onFocusµÆÀ» ¶§ À½¼º									  */
                                                        
/*----------------------------------------------------------------------------*/
function f_selectVoice(str, obj) {
	var opts = obj.options;
	var strText  = "";

	for (var i=0; i<opts.length; i++) {
		if ( opts[i].selected ) strText = (String)(str+ ". »óÇÏÈ­»ìÇ¥ Å°·Î ¼±ÅÃ. " + opts[i].text);
	}
	f_playinput(strText);
}


/*----------------------------------------------------------------------------*/
/* NAME : f_setVoice()                                                        */
/* DESC : È­¸éÀÌ Ã³À½ LoadµÇ¾úÀ» ¶§ ½ÇÇàµÇ´Â ÇÔ¼ö(À½¼º°ü·Ã)                   */

/*----------------------------------------------------------------------------*/
function f_setVoice()
{
	//if (readCookie("voiceStart").length == 0)
	//	setCookie("voiceStart", "stop", 1);
    //
	//if (readCookie("voiceSpeed").length == 0) 
	//	setCookie("voiceSpeed", 3, 1);
    //
	//if (readCookie("voiceVolum").length == 0)
	//	setCookie("voiceVolum", 3, 1);
    //
	//
    //
	//sRes = sBot.IsAvailable();
	//if( sRes == 1)
	//{	
	//	if(readCookie("voiceStart")=="start"  )
	//	{
//	//		f_voiceImg(); //À½¼º ¼³Á¤ ÀÌ¹ÌÁö º¯°æ
	//		f_voiceStart( "start" );
	//		f_setVoiceSpeed( "NO" );
	//		f_setVoiceVolume( "NO" );
	//	}
	//}
	//else f_popVoice();
    //
//	//f_setInit();
}

/*----------------------------------------------------------------------------*/
/* NAME : f_setInit()                                                         */
/* DESC : È­¸éÀÌ Ã³À½ LoadµÇ¾úÀ» ¶§ ½ÇÇàµÇ´Â ÇÔ¼ö(±ÛÀÚ°ü·Ã)                   */

/*----------------------------------------------------------------------------*/
function f_setInit(){
	
	if (readCookie("fontSize").length == 0)
		setCookie("fontSize", 12, 1);
	else
		fontSize = readCookie("fontSize");
		
	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("fontSize")== 12 && readCookie("fontColorIndex")==0 && readCookie("bgColorIndex") == 0){
	}
	else
	{
		f_setFace();
	}
}

/*----------------------------------------------------------------------------*/
/* NAME : f_fontPlus()                                                        */
/* DESC : ±ÛÀÚÅ©±â¸¦ Å©°Ô                                                     */

/*----------------------------------------------------------------------------*/
function f_fontPlus() 
{
	if (fontSize < 20) 
	{
		fontSize = parseInt(fontSize) + 2;		
		f_setFace();
		f_playinput("±ÛÀÚ Å©±â "+fontSize);
	}
}

/*----------------------------------------------------------------------------*/
/* NAME : f_fontMinus()                                                       */
/* DESC : ±ÛÀÚÅ©±â¸¦ ÀÛ°Ô                                                     */

/*----------------------------------------------------------------------------*/
function f_fontMinus() {
	if (fontSize > 11) {
		fontSize = parseInt(fontSize) - 2;		
		f_setFace();
		f_playinput("±ÛÀÚ Å©±â "+fontSize);
	}
}

/*----------------------------------------------------------------------------*/
/* NAME : f_setFontColor1()                                                   */
/* DESC : ±ÛÀÚ»ö º¯°æ(key Event½Ã)                                            */

/*----------------------------------------------------------------------------*/
function f_setFontColor1(param){
	var keyCode = window.event.keyCode;
	if( keyCode == 13 )
	{
		if ( param >= 0 && param <= 7 )
		{
			fontColorIndex = param;
			f_setFace();
		}		
	}
}

/*----------------------------------------------------------------------------*/
/* NAME : f_setFontColor2()                                                   */
/* DESC : ±ÛÀÚ»ö º¯°æ                                                         */

/*----------------------------------------------------------------------------*/
function f_setFontColor2(param){
	if ( param >= 0 && param <= 7 ) 
	{
		fontColorIndex = param;
		f_setFace();
	}
}

/*----------------------------------------------------------------------------*/
/* NAME : f_setBgColor1()                                                     */
/* DESC : ¹è°æ»ö º¯°æ(key Event½Ã)                                            */

/*----------------------------------------------------------------------------*/
function f_setBgColor1(param) {
	var keyCode = window.event.keyCode;
	if( keyCode == 13 )
	{
		if ( param >= 0 && param <= 6 ) 
		{
			bgColorIndex = param;
			f_setFace();		
		}
	}
}	

/*----------------------------------------------------------------------------*/
/* NAME : f_setBgColor2()                                                     */
/* DESC : ¹è°æ»ö º¯°æ                                                         */

/*----------------------------------------------------------------------------*/
function f_setBgColor2(param) {
	if ( param >= 0 && param <= 6 ) {
		bgColorIndex = param;
		f_setFace();		
	}
}

/*----------------------------------------------------------------------------*/
/* NAME : f_setFace()                                                         */
/* DESC : ±ÛÀÚÅ©±â, ±ÛÀÚ»ö, ¹è°æ»ö ¼³Á¤                                       */
                                                   
/*----------------------------------------------------------------------------*/
function f_setFace(){
	var objs_td		= new Array();
	var	objs_a		= new Array();
	var	ogjs_span	= new Array();
	var objs_p		= new Array();
/*
	var iCntFrames = parent.frames.length;


	if (iCntFrames == 0 )
	{
		iCntFrames = 1;
	}

	for(a=0; a<iCntFrames; a++)
	{
		// mainÈ­¸é frame ¼ö : 3, subÈ­¸é frame ¼ö :3, bottom(¸Þ´º¹Ù·Î°¡±â) È¯°æº¯È­ ¾ÈÇÔ
		if(iCntFrames >= 3)
		{
			objs_td = parent.frames[a].document.getElementsByTagName("td");
			objs_a = parent.frames[a].document.getElementsByTagName("a");
			ogjs_span = parent.frames[a].document.getElementsByTagName("span");
			objs_p = parent.frames[a].document.getElementsByTagName("p");
		}
		else
		{*/
			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.color=fontColor[fontColorIndex];
		} 
		for (i=0;i<ogjs_span.length;i++) 
		{
			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];
		}
	//}

	// mainÈ­¸é frame ¼ö : 3, subÈ­¸é frame ¼ö :4, bottom(¸Þ´º¹Ù·Î°¡±â) È¯°æº¯È­ ¾ÈÇÔ
	/*if( iCntFrames >= 3)
	{
		if ( parent.frames[0].document.all['select2'] == "[object]" )
		{
			parent.frames[0].document.frmMain.select2.selectedIndex = parseInt(fontColorIndex);
			parent.frames[0].document.frmMain.select.selectedIndex = parseInt(bgColorIndex);
		}
	}
	else
	{*/
		if ( document.all['select2'] == "[object]" )
		{
			document.all['select2'].selectedIndex = parseInt(fontColorIndex);
			document.all['select'].selectedIndex = parseInt(bgColorIndex);
		}
	//}

	setCookie("fontSize", fontSize, 1);
	setCookie("fontColorIndex", fontColorIndex, 1);
	setCookie("bgColorIndex", bgColorIndex, 1);	
}



//-->

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 ""
}

/*------------------------------------------------------------------*/
/*  Æã¼Ç¸í   : setCookie                                            */
/*  ³»¿ë¼³¸í : ÄíÅ°°ªÀ» ¼³Á¤ÇÑ´Ù.                                   */
/*  È£Ãâ ¸ðµâ¸í                                                     */
/*      1) html        :                                            */
/*      2) JSP/servlet :                                            */
/*      3) script func.:                                            */
/*  ¸Å°³º¯¼ö  : key°ª, value°ª, ÄíÅ° À¯È¿ÀÏÀÚ-1                     */
/*  Æ¯ÀÌ»çÇ×  :                                                     */
/*------------------------------------------------------------------*/
function setCookie( key, value, term ){
	var expire = new Date();  
	expire.setDate( expire.getDate() + term );
//	document.cookie = key + "=" + escape( value ) + "; path=/; expires="+expire.toGMTString().substring(0,17)+"15:00:00"+expire.toGMTString().substring(25)+";";
	document.cookie = key + "=" + escape( value ) + "; path=/; expires=" + expire.toGMTString() + ";";

}

/*----------------------------------------------------------------------------*/
/* NAME : f_setBasic()                                                        */
/* DESC : ÆäÀÌÁö È¯°æ¼³Á¤ ÃÊ±âÈ­                                              */

/*----------------------------------------------------------------------------*/
function f_setBasic(mode, load)
{


	setCookie("fontSize", 12, 1);
	fontSize = readCookie("fontSize");
		
	setCookie("fontColorIndex", 0, 1);
	fontColorIndex = readCookie("fontColorIndex");
	
	setCookie("bgColorIndex", 0, 1);
	bgColorIndex = readCookie("bgColorIndex");

	f_setFace();
	

	setCookie("voiceStart", "stop", 1);
	f_voiceStart( readCookie("voiceStart") );

	setCookie("voiceSpeed", 3, 1);
	f_setVoiceSpeed( "NO" );

	setCookie("voiceVolum", 3, 1);
	f_setVoiceVolume( "NO" );
}

/*----------------------------------------------------------------------------*/
/* NAME : f_setVoiceSpeed()                                                   */
/* DESC : À½¼º¼Óµµ ¼³Á¤                                                       */
/*----------------------------------------------------------------------------*/
function f_setVoiceSpeed(mode)
{
	var sSpeed;
	var strPlay = "";
	if ( readCookie("voiceSpeed").length == 0 ) sSpeed = 3;
	else sSpeed = readCookie("voiceSpeed");

	if (sRes != 0)
	{
		if( mode == "up" ){
			if( sSpeed < 5 ) sSpeed = parseInt(sSpeed) + 1;
			f_playinput("À½¼º ¼Óµµ"+ sSpeed);

		}else if( mode == "down" ){
			if( sSpeed > 1 ) sSpeed = parseInt(sSpeed) - 1;
			f_playinput("À½¼º ¼Óµµ "+ sSpeed);

		}else{
			//NO JOBS
		}

		//Cookie Àç¼³Á¤
		setCookie( "voiceSpeed", sSpeed, 1 );	
		sBot.OnSetSpeed(sSpeed);		

	}
}

/*----------------------------------------------------------------------------*/
/* NAME : f_setVoiceSpeed()                                                   */
/* DESC : À½¼ºº¼·ý ¼³Á¤                                                       */
/*----------------------------------------------------------------------------*/
function f_setVoiceVolume(mode)
{
	var sVol;
	if ( readCookie("voiceVolum").length == 0 ) sVol = 3;
	else sVol = readCookie("voiceVolum");

	if ( sRes != 0 )
	{
		if( mode == "up" ){
			if( sVol < 5 ){
				sVol = parseFloat(sVol) + 1;
			}
			f_playinput("À½¼º º¼·ý "+ sVol);

		}else if( mode == "down" ){
			if( sVol > 1 ){
				sVol = parseFloat(sVol) - 1;
			}
			f_playinput("À½¼º º¼·ý "+ sVol);

		}else{
			//NO JOBS
		}
		
		//Cookie Àç¼³Á¤
		setCookie( "voiceVolum", sVol, 1 );	
		sBot.OnSetVolume(sVol);

	}
}
/*----------------------------------------------------------------------------*/
/* NAME : f_voiceImg()                                                     */
/* DESC : À½¼º°ü·Ã ÀÌ¹ÌÁö º¯°æ(ÆäÀÌÁö ·ÎµåµÉ¶§ ½ÇÇàµÊ)                        */

/*----------------------------------------------------------------------------*/
function f_voiceImg()
{
	var voiceStart = readCookie("voiceStart");
	var voiceSpeed = readCookie("voiceSpeed");
	var voiceVolum = readCookie("voiceVolum");

	if( voiceStart == "start" ){

		document.all['voice_link'].href = "javascript:f_voiceStart('stop');";
		document.all['voice_start'].src = "/image/tts_images/tts_sound_on.gif";

		document.all['voice_start'].alt = "À½¼º ÁßÁö";
		document.all['voice_start'].title = "À½¼º ÁßÁö";

		//Cookie Àç¼³Á¤
		setCookie( "voiceStart", "start", 1 );	

	}else if( voiceStart == "stop" ){
		document.all['voice_link'].href = "javascript:f_voiceStart('start');";
		document.all['voice_start'].src = "/image/tts_images/tts_sound_off.gif";

		document.all['voice_start'].alt = "À½¼º ½ÃÀÛ";
		document.all['voice_start'].title = "À½¼º ½ÃÀÛ";

		//Cookie Àç¼³Á¤
		setCookie( "voiceStart", "stop", 1 );
		//startFlag = false;
	}



}

var sRes;
var sBot = window.parent.frames['1'];
var sBot0 = window.parent.frames['0'];



/*----------------------------------------------------------------------------*/
/* NAME : f_voiceStart()                                                      */
/* DESC : À½¼º½ÃÀÛ or À½¼ºÁßÁö ¹öÆ°À» ´­·¶À» °æ¿ì¿¡ ½ÇÇàµÊ                    */

/*----------------------------------------------------------------------------*/
function f_voiceStart(val)
{
	if( val == "start" ){
		sRes = sBot.OnStart();
		if ( sRes == 0 ) //sRes = 0ÀÌ¸é ¸ðµâÀÌ ¶°ÀÖÁö¾ÊÀ» ¶§
		{
			f_popVoice();
			return;
		}
		else 
		{
			document.all['voice_link'].href = "javascript:f_voiceStart('stop');";
			document.all['voice_start'].src = "/image/tts_images/tts_sound_on.gif";

			document.all['voice_start'].alt = "À½¼º ÁßÁö";
			document.all['voice_start'].title = "À½¼º ÁßÁö";
			
			displayOn(2);
			
			//Cookie Àç¼³Á¤
			setCookie( "voiceStart", "start", 1 );	
		}
	}else if( val == "stop" ){
		sBot.OnStop();
		document.all['voice_link'].href = "javascript:f_voiceStart('start');";
		document.all['voice_start'].src = "/image/tts_images/tts_sound_off.gif";

		document.all['voice_start'].alt = "À½¼º ½ÃÀÛ";
		document.all['voice_start'].title = "À½¼º ½ÃÀÛ";

		displayOn(1);
		
		//Cookie Àç¼³Á¤
		setCookie( "voiceStart", "stop", 1 );
		//startFlag = false;
	}
}

function displayOn(val){

	if(val==1){
		
		 for ( i = 1; i <=7; i++){		
			if( document.all['tts_tool_on_'+i] == '[object]' ){
				
				var temp = eval('document.all.tts_tool_on_'+i+'.style');
				temp.display='none';
			}
		}
		document.all.tts_tool_off_1.style.display='block';
	} else {
		 for ( i = 1; i <=7; i++){		 
				var temp = eval('document.all.tts_tool_on_'+i+'.style');
				temp.display = 'block';
		}
		document.all.tts_tool_off_1.style.display='none';
	}

}

/*----------------------------------------------------------------------------*/
/* NAME : f_popVoice()                                                        */
/* DESC : À½¼º¸ðµâÀÌ °ø»çÁßÀÏ¶§ ¶ß´Â ÆË¾÷                                     */
/*----------------------------------------------------------------------------*/
function f_popVoice()
{
//	var voiceCheck = readCookie( 'noti_voice' );
//	if ( voiceCheck == 'noti_voice' ){
//		return;
//	}
//	else
//	{
		window.open("/noti_voice.html","noti_voice", "top=0,left=391,width=390,height=250,toolbar=no,scrollbars=no,resizable=no,status=no,titlebar=no,menubar=no,location=no");
//	}
}



