var newlocation;
var count, intervel;
var wait_time;
var have_submit = false;

function countdown()
{
	var board = document.getElementById("progress_bar");
	count --;
	if (count < 0)
	{
		parent.window.location = newlocation;
		//alert("Redirect to " + newlocation);
	}
	else
	{
		board.value = board.value + "|";
		setTimeout("countdown()", intervel);
	}
}


// switch the static IP settings between enable or disabled by input
function disableStaticIPSetting(input)
{
	netForm=document.NetworkSetting;
	netForm.network_ipaddress.disabled = input;
	netForm.network_subnet.disabled = input;
	netForm.network_router.disabled = input;
	netForm.network_dns1.disabled = input;
	netForm.network_dns2.disabled = input;
}

// switch the pppoe settings between enable or disabled by input
function disablePPPoESetting(input)
{
	netForm=document.NetworkSetting;
	netForm.network_pppoeuser.disabled = input;
	netForm.network_pppoepass.disabled = input;
	netForm.network_pppoeconfirmpass.disabled = input;
}

function disableLANSetting(input)
{
	disableStaticIPSetting(input);
	netForm=document.NetworkSetting;
	netForm.network_resetip[0].disabled = input;
	netForm.network_resetip[1].disabled = input;
	netForm.enable_upnp.disabled = input;
	netForm.enable_upnpfor.disabled = input;
}

function checkNetType()
{
	var netForm=document.NetworkSetting;
	if (netForm.network_type[1].checked) 
	{ // PPPoE mode
		// disable upnp first
		netForm.upnp_enable.value = false;
		netForm.enable_upnp.checked = false;
		disablePPPoESetting(false);
		disableLANSetting(true);
	} else { // LAN mode
		if (netForm.network_resetip[0].checked) 
		{ // dhcp
			disableLANSetting(false);
			disablePPPoESetting(true);
			disableStaticIPSetting(true);
		} else { //static ip
			disableLANSetting(false);
			disablePPPoESetting(true);
		}
	}
}
