function showWEPKey(F)
{
	if (document.forms[0].WEPMode[1].checked) {
		if ( window.confirm('Do you want to enable the WEP encryption ? ') ) {
			document.forms[0].WEPMode[0].checked = true;
			window.open ( 'WepKeySetting.htm' , 'WEPKeySetting' , 'width=780,height=420,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,left=0,top=0', true);
			return true;
		} else {
			return false;
		}
	} else {
		window.open ( 'WepKeySetting.htm' , 'WEPKeySetting' , 'width=780,height=420,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,left=0,top=0', true);
		return true;
	}
}
function showWEPKey5G(F)
{
	if (document.forms[0].WEPMode_5G[1].checked) {
		if ( window.confirm('Do you want to enable the WEP encryption ? ') ) {
			document.forms[0].WEPMode_5G[0].checked = true;
			window.open ( 'WepKeySetting5G.htm' , 'WEPKeySetting5G' , 'width=780,height=420,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,left=0,top=0', true);
			return true;
		} else {
			return false;
		}
	} else {
		window.open ( 'WepKeySetting5G.htm' , 'WEPKeySetting5G' , 'width=780,height=420,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,left=0,top=0', true);
		return true;
	}
}

function SelD11GMode(passForm,str,d11gmode)
{
	if (str == "init") 
	{
		if (d11gmode==0)
			passForm.wl_mode.selectedIndex = 0;		
		else if (d11gmode==1)
			passForm.wl_mode.selectedIndex = 1;
		else if (d11gmode==2)
			passForm.wl_mode.selectedIndex = 2;
		else if (d11gmode==3)
			passForm.wl_mode.selectedIndex = 3;
		else
			passForm.wl_mode.selectedIndex = 0;
	}
	return 1;
}

function SelChannel_5G(passForm, channel, turbomode)
{
	var	i;
	var	ObjOption;
	var bTurbo;
	var TurboChannel = new Array("42","42", "50", "58");
	var NonTurboChannel = new Array("36", "36", "40", "44", "48", "52", "56", "60", "64");
//	var TurboChannel = new Array("42", "42", "50", "58", "152", "160");
//	var NonTurboChannel = new Array("36", "36", "40", "44", "48", "52", "56", "60", "64", "149", "153", "157", "161", "165");
	var TurboText = new Array("Auto (DFS)", "42 - 5.21GHz", "50 - 5.25GHz", "58 - 5.29GHz  ");
	var NonTurboText = new Array("Auto (DFS)", "36 - 5.18GHz", "40 - 5.20GHz", "44 - 5.22GHz", "48 - 5.24GHz", "52 - 5.26GHz", "56 - 5.28GHz", "60 - 5.30GHz", "64 - 5.32GHz  ");
//	var channel = '<!--#set_get path="setup/wl_channel_5G" -->';
	var bselect;

	for ( i = 0 ; i < 14 ; i++ ) {
		passForm.wl_channel_5G.remove(0);
	}

	if (turbomode == '1')
	{

		for (var i=0;i<TurboChannel.length;i++)
		{	
			ObjOption = new Option ( TurboText[i], TurboChannel[i], false, bselect=(channel==TurboChannel[i])?true:false);
			passForm.wl_channel_5G.options[passForm.wl_channel_5G.options.length] =   ObjOption;
		}
	}
	else 
	{
		for (var i=0;i<NonTurboChannel.length;i++)
		{
			ObjOption = new Option ( NonTurboText[i], NonTurboChannel[i], false, bselect=(channel==NonTurboChannel[i])?true:false );
			passForm.wl_channel_5G.options[passForm.wl_channel_5G.options.length] =   ObjOption;
		}
	}
	if (passForm.wl_autochannel_5G.value == '1')
		passForm.wl_channel_5G.selectedIndex = 0;			
}

function SelWEP(passForm)
{
	if (passForm.WEPMode[1].checked) 
	{
	 	passForm.wl_wep.value = "0";
//	 	passForm.wl_auth.value = "0";
	}
	else
	{
		var key1 = '<!--#set_get path="wireless/wl_key1_24G" -->';
		var key2 = '<!--#set_get path="wireless/wl_key2_24G" -->';
		var key3 = '<!--#set_get path="wireless/wl_key3_24G" -->';
		var key4 = '<!--#set_get path="wireless/wl_key4_24G" -->';
		if (passForm.wlkey.value != '1')
		if ((key1=="") &&(key2=="") &&(key3=="") &&(key4==""))
		{
			alert(mavis_str(Alert_Msg_89));
			//alert("Please edit WEP settings first!");
			passForm.WEPMode[1].checked;
			return 0;
		}
		
	 	passForm.wl_wep.value = "1";
//	 	passForm.wl_auth.value = "1";	 	
	}
	return 1;
}

function SelWEP_5G(passForm)
{
	if (passForm.WEPMode_5G[1].checked) 
	{
	 	passForm.wl_wep_5G.value = "0";
//	 	passForm.wl_auth_5G.value = "0";
	}
	else
	{
		var key1 = '<!--#set_get path="wireless/wl_key1_5G" -->';
		var key2 = '<!--#set_get path="wireless/wl_key2_5G" -->';
		var key3 = '<!--#set_get path="wireless/wl_key3_5G" -->';
		var key4 = '<!--#set_get path="wireless/wl_key4_5G" -->';
		if (passForm.wlkey5G.value != '1')		
		if ( (key1=="") &&(key2=="") &&(key3=="") &&(key4==""))
		{
			alert(mavis_str(Alert_Msg_89));
			//alert("Please edit WEP settings first!");
			passForm.WEPMode_5G[1].checked;
			return 0;
		}	
	 	passForm.wl_wep_5G.value = "1";
//	 	passForm.wl_auth_5G.value = "1";	 	
	}
	return 1;
}
function SelTurboMode(passForm)
{
	var	i;
	var	ObjOption;
	var bTurbo;
	var bselect;
	var TurboChannel = new Array("42","42", "50", "58");
	var NonTurboChannel = new Array("36","36", "40", "44", "48", "52", "56", "60", "64");
//	var TurboChannel = new Array("42", "42", "50", "58", "152", "160");
//	var NonTurboChannel = new Array("36", "36", "40", "44", "48", "52", "56", "60", "64", "149", "153", "157", "161", "165");
	var TurboText = new Array("Auto (DFS)", "42 - 5.21GHz", "50 - 5.25GHz", "58 - 5.29GHz  ");
	var NonTurboText = new Array("Auto (DFS)", "36 - 5.18GHz", "40 - 5.20GHz", "44 - 5.22GHz", "48 - 5.24GHz", "52 - 5.26GHz", "56 - 5.28GHz", "60 - 5.30GHz", "64 - 5.32GHz  ");

	
	for ( i = 0 ; i < 14 ; i++ ) {
		passForm.wl_channel_5G.remove(0);
	}

	if (passForm.wl_TurboMode_5G.selectedIndex == 1)
	{
		for (var i=0;i<TurboChannel.length;i++)
		{
			ObjOption = new Option ( TurboText[i], TurboChannel[i], false, bselect = (TurboChannel[i]=="50")?true:false);
			passForm.wl_channel_5G.options[passForm.wl_channel_5G.options.length] =   ObjOption;
		}
	}
	else 
	{
		for (var i=0;i<NonTurboChannel.length;i++)
		{
			ObjOption = new Option ( NonTurboText[i], NonTurboChannel[i], false, bselect = (NonTurboChannel[i]=="52")?true:false );
			passForm.wl_channel_5G.options[passForm.wl_channel_5G.options.length] =   ObjOption;
		}
	}
}

function SelAutoChannel_5G(passForm)
{
	if (passForm.wl_channel_5G.selectedIndex == 0)
		passForm.wl_autochannel_5G.value = 1;
	else
		passForm.wl_autochannel_5G.value = 0;
}

function GetChangedValue( varstring, SSIDnum )
{
	var find_result = "";
	stringArray = varstring.split(";");
	
	if ( stringArray[SSIDnum].length == 0 )
		find_result = "";
	else
		find_result = stringArray[SSIDnum];

	return find_result;
}

function SetChangedValue( varstring, SSIDnum, value)
{
	var bind_result = "";
	stringArray = varstring.split(";");

//	for( i=0; i<4; i++ )
	for( i=0; i<3; i++ )
	{
		if ( i == SSIDnum )
			bind_result += value ;
		else
			bind_result += stringArray[i] ;

//		if ( i < 3 )
		if ( i < 2 )
			bind_result += ";"
	}

//alert(varstring+"'s bind result is : "+ bind_result);

	return bind_result;
}

