/* 
 * func.js - Function Define.
 *
 * Copyright (c) U-Media Communications, Inc. All Rights Reserved.
 *
 * $Id: v1.0 12-Dec-2007 Jacky.Yang Exp $
 */

var totalWaitTime=7; //second
var renewTime=100; //millisecond, progress reflash clock.
//var renewClock=100 / ((totalWaitTime*1000)/renewTime);
var renewClock;
var percent=0;
var redirectURL;
var currectIP;

function wait_page()
{	
	if (percent == 0)
	{
		renewClock=100 / ((totalWaitTime*1000)/renewTime);
		//redirectURL = ".." + location.pathname;
		document.getElementById("mainform").style.display = "none";
		document.getElementById("waitform").innerHTML = "<table bolder=\"0\"><tr><td colspan=\"2\"><font color=white>Processing, Please wait......</font></td></tr><tr><td width=\"95%\"><table align=\"left\" bgcolor=\"#ffffff\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#FFFFFF\" style=\"border-style: solid; border-width: 1px\"><tr><td width=480 align=\"left\"><table id=\"progress\" bgcolor=\"blue\" height=\"25\"><tr><td></td></tr></table></td></tr></table></td><td width=\"95%\"><font color=white><span id=\"progressValue\">&nbsp;</span></font></td></tr></table>";
	}
	percent+=renewClock;
	if (percent > 100) {
		location.href = redirectURL;
		return;
	}
	document.getElementById("progress").style.width = Math.round(percent) + "%";
	document.getElementById("progressValue").innerHTML = Math.round(percent) + "%";
	window.setTimeout("wait_page()", renewTime);
}

function reboot_page()
{	
	if ((Math.round(percent) > 70) && (Math.round(percent)%5) == 0) {
		if (currectIP != "")
			rebootRedirect.location.href="http://" + currectIP +"/rebootredirect.asp";
	}
		
	if (percent == 0)
	{
		renewClock=100 / ((totalWaitTime*1000)/renewTime);
		//redirectURL = ".." + location.pathname;
		document.getElementById("mainform").style.display = "none";
		document.getElementById("waitform").innerHTML = "<table bolder=\"0\"><tr><td colspan=\"2\"><font color=red>Rebooting, Please wait......</font></td></tr><tr><td width=\"95%\"><table align=\"left\" bgcolor=\"#ffffff\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#FFFFFF\" style=\"border-style: solid; border-width: 1px\"><tr><td width=480 align=\"left\"><table id=\"progress\" bgcolor=\"blue\" height=\"25\"><tr><td></td></tr></table></td></tr></table></td><td width=\"95%\"><font color=white><span id=\"progressValue\">&nbsp;</span></font></td></tr></table>";
	}
	percent+=renewClock;
	if (percent > 100) {
		location.href = redirectURL;
		return;
	}
	document.getElementById("progress").style.width = Math.round(percent) + "%";
	document.getElementById("progressValue").innerHTML = Math.round(percent) + "%";
	window.setTimeout("reboot_page()", renewTime);
}
