var VoiceStart = "stop";	//VoiceStart Default 

//ÄíÅ°°ª ÀÐ±â
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().substring(0,17)+"15:00:00"+expire.toGMTString().substring(25)+";";
	document.cookie = key + "=" + escape( value ) + "; path=/; expires=" + expire.toGMTString() + ";";
}

//Object Tag Insert
setTimeout( "bodyactive()", 1000);

function bodyactive(){
	var sRes = "";
	sRes = IsInstalled();
	if( sRes == true ){
		//setCookie("SetupFlag", "Setup", 365);
		document.body.insertAdjacentHTML("BeforeEnd",objectTag);
	}else{
		//alert("Not Setup");
		//f_objectInsert("");
	}
	//alert("ASF");
	/*
	else{
		f_objectInsert('');
	}
	*/
}

function f_objectInsert(mode){
	var sRes = "";
	sRes = IsInstalled();
	if( sRes == true ){
		//setCookie("SetupFlag", "Setup", 365);
		document.body.insertAdjacentHTML("BeforeEnd", objectTag);
	}else{
		var com = confirm("À½¼º¼­ºñ½º¸¦ ¹ÞÀ¸½Ã·Á¸é ÇÁ·Î±×·¥À» ¼³Ä¡ÇÏ¼Å¾ß ÇÕ´Ï´Ù.\n\n¼³Ä¡ÇÏ½Ã°Ú½À´Ï±î?");

		if( com == true ){
			//setCookie("SetupFlag", "Setup", 365);
			//if( mode == "voice" ) setCookie("VoiceStart", "start", 365);
			//else if( mode == "navi" ) setCookie("NaviStart", "start", 365);

			//top.location.reload();
			top.location.href="/netmate/ActiveX.asp";
		}
	}
}

function f_PageInit(){
	if( readCookie("VoiceStart").length == 0){
		setCookie("VoiceStart", VoiceStart , 1);
	}else VoiceStart = readCookie("VoiceStart");

	if( typeof(DynamicNetLightCOM) != 'undefined' ){
		if( readCookie("VoiceStart") == "start"){
			f_VoiceStart("start");
		}
	}else{
	//	f_ImgChg("", "COM");
	}
}

function f_VoiceStart(str){
	setTimeout("", 2000);

	if( typeof(DynamicNetLightCOM) != 'undefined' ){
		if( str == "start" ){
			f_ImgChg('', "start");
			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']").title="À½¼º ÄÑ±â ¹öÆ°";
				}
			}else{
				if( typeof(document.all['VoiceLink']) == 'object' ){
					//document.all['VoiceLink'].href="javascript:f_VoiceStart('stop');";
					document.all['VoiceLink'].href="JavaScript:NetReader('VoiceStop');";
					document.all['VoiceLink'].title="À½¼º ÄÑ±â ¹öÆ°";
				}
			}

			DynamicNetLightCOM.VoiceActive=true;
		}
		else if( str == "stop"){
			f_ImgChg('', "stop");
			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']").title="À½¼º ²ô±â ¹öÆ°";
				}
			}else{
				if( typeof(document.all['VoiceLink']) == 'object' ){
					document.all['VoiceLink'].href="JavaScript:NetReader('VoiceStart');";
					document.all['VoiceLink'].title="À½¼º ²ô±â ¹öÆ°";
				}
			}
			DynamicNetLightCOM.VoiceActive=false;
			//f_NaviStart("stop");
		}
		setCookie("VoiceStart", str, 1);
	}else{
		//f_ImgChg('', "stop");
		//alert("NetLight À½¼º¸ðµâÀÌ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù");
		f_objectInsert("voice");
	}	
}

//·¹º§ ÀÌ¹ÌÁö º¯°æ
function f_ImgChg(val, flag){

	//Font
	if( flag == "font"){
//		for( var i=1; i<=5;i++){
//			if(afontSize[i] == val){
//				document.all['fSizeImg'].src = "/image/main/page_view0"+ i +".gif";
//				break;
//			}
//		}
	}
	//Start
	else if(flag == "start"){
		if( FrameLength == 2 ){
			if( typeof(eval(FrameMainName +"document.all['VoiceStart']")) == 'object' ){
				eval(FrameMainName +"document.all['VoiceStart']").alt="À½¼º²ô±â ¹öÆ°";
				eval(FrameMainName +"document.all['VoiceStart']").title="À½¼º²ô±â ¹öÆ°";
				//parent.frames[1].document.all['voiceImg'].src = "/netmate/image/control/icon01_on.gif";
				eval(FrameMainName +"document.all['VoiceStart']").src = "/image/main/page02_sound_on.gif";
			}
		}else{
			if( typeof(document.all['VoiceStart']) == 'object' ){
				document.all['VoiceStart'].alt="À½¼º²ô±â ¹öÆ°";
				document.all['VoiceStart'].title="À½¼º²ô±â ¹öÆ°";
				document.all['VoiceStart'].src = "/image/main/page02_sound_on.gif";
			}
		}
	}
	//Stop
	else if(flag == "stop"){
		if( FrameLength == 2 ){
			if( typeof(eval(FrameMainName +"document.all['VoiceStart']")) == 'object' ){
				eval(FrameMainName +"document.all['VoiceStart']").alt="À½¼ºÄÑ±â ¹öÆ°";
				eval(FrameMainName +"document.all['VoiceStart']").title="À½¼ºÄÑ±â ¹öÆ°";
				eval(FrameMainName +"document.all['VoiceStart']").src = "/image/main/page02_sound_off.gif";
			}
		}else{
			if( typeof(document.all['VoiceStart']) == 'object' ){
				document.all['VoiceStart'].alt="À½¼ºÄÑ±â ¹öÆ°";
				document.all['VoiceStart'].title="À½¼ºÄÑ±â ¹öÆ°";
				document.all['VoiceStart'].src = "/image/main/page02_sound_off.gif";
			}
		}
	}
	//Not NetLightCOM
	else if( flag == "COM" ){
	//	if( typeof(document.all['voiceImg']) == 'object' ) document.all['voiceImg'].src = "/images/netmate/<%//=oneOrder%>sound_off2.gif";
	}
	//No Job
	else ;
}