window.onresize = function()
{
	GetMainContentHeight(BUTTON_TOP_NO_MENU, NO_BUTTON_CHANGE);
}

$(document).ready(function()
{
	GetMainContentHeight(BUTTON_TOP_NO_MENU, NO_BUTTON_CHANGE);
});

function cancelDefault()
{
	$.modal.close();
}

function confirmWindow()
{
	var confirmPrompt;
	if(language == ENGLISH)
	{
		confirmPrompt = "Are you sure to reset factory settings?";
	}
	else if(language == CHINESE)
	{
		confirmPrompt = "确定要恢复出厂设置吗？";
	}
	if(window.confirm(confirmPrompt))
	{
		$("#confirm").modal();
	}
}
/*************************************************
Function: 		confirmApply
Description: 	用于恢复出厂密码保护确认
Input: 			无
Output:			无
Return: 		无
Others: 		无
*************************************************/
function confirmApply()
{
	var data;
	var xmlHttp = GetHTTPObject();
	var response;

	data = "type=" + DEFAULT_CONFIG + "&cmd=" + SET + "&language=" + language + "&slotNo=" + slotNo + "&setString=";		
	data += $("#user").val() + FIRST_DELIMITER + $("#password").val();
	
	xmlHttp.open("POST", "/goform/formEMR30", true)
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", data.length);
	xmlHttp.onreadystatechange = function()
	{
		if((xmlHttp.readyState == 4) && (xmlHttp.status == 200))
		{
			response = parseInt(AjaxStrDeal(xmlHttp.responseText), 10);
			if(response == RETURN_OK)
			{
				cancelDefault();
				parent.resetDefaultFlag = 1;
			}
			else
			{
				alert(returnError[language][response]);
			}
		}
	}
	xmlHttp.send(data);
}

function uploadParam()
{
	var ieFlag;
	var fileSize;
	var fileName = document.getElementById("uploadFileName");
	var path = fileName.value.split("\\");
	var strVal = new String(path[path.length - 1]);
	var dat   = strVal.split(".");
	if(dat[dat.length - 1] != "dat")
	{
		if(language == ENGLISH)
		{
			alert("Please make sure to upload the configuration file!");
		}
		else
		{
			alert("请确保正确的配置文件！");
		}
		return;
	}
	if(navigator.userAgent.indexOf("MSIE")>0)
	{
		ieFlag = true;
	}
	else
	{
		ieFlag = false;
	}
	if(ieFlag == false)
	{
		fileSize = fileName.files[0].size;
		if(fileSize > 2097152)
		{
			if(language == ENGLISH)
			{
				alert("The size of configuration file can not be larger than 2M!");
			}
			else
			{
				alert("配置文件的大小不得超过2M！");
			}
			return;
		}
	}
	if(language == ENGLISH)
	{
		var confirmPrompt = "Your device will be rebooted! Are you sure to restore your configuration?";
	}
	else
	{
		var confirmPrompt = "设备将被重启！确定要重新配置参数？";
	}
	
	if(window.confirm(confirmPrompt))
	{
		$("#uploadForm").submit();
	}
}

function downloadParam()
{
	$("#downloadForm").submit();
}