﻿var c_DaysExistCookie = 1;
var c_AllowSetLocation = false;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
window.onload = window_onload;
function window_onload() {
	PageLoad01();
	PageLoad();
	PageLoad02();
	UserControl_Top();
}
function PageLoad() {
	DownloadLinkRepair();
	LoadStyle();

	SetPageLoadTime();
	if (c_AllowSetLocation) {
		if (navigator.geolocation)
			navigator.geolocation.getCurrentPosition(SetLocation);
	}
	setInterval("SetPageUnloadTime();", 15000);

}
function PageLoad01() {
}
function PageLoad02() {
}
function UserControl_Top() {
}
function DownloadLinkRepair() {
	var v_RootUrl = document.getElementById(RootUrlID).href;
	var v_Links = document.getElementsByTagName("a");
	var i = 0;
	for (i = 0; i < v_Links.length; i++) {
		var v_IsDownload = v_Links[i].getAttribute("isdownload");
		if (v_IsDownload != null && v_IsDownload == "1") {
			var v_DownloadUrl = v_Links[i].href;
			v_DownloadUrl = v_DownloadUrl.replace(v_RootUrl, v_RootUrl + "Download.aspx?url=");
			v_Links[i].href = v_DownloadUrl;
		}
	}

}
function SetPageLoadTime() {
	if (typeof (c_RequestID) != 'undefined') {
		var v_CurrentTime = new Date();
		var v_CurrentTimeString = v_CurrentTime.getFullYear() + "-" + v_CurrentTime.getMonth() + "-" + v_CurrentTime.getDate()
		+ " " + v_CurrentTime.getHours() + ":" + v_CurrentTime.getMinutes() + ":" + v_CurrentTime.getSeconds();
		PageMethods.SetPageLoadTime(c_RequestID, v_CurrentTimeString);
	}
}
//██████████████████████████████████████████████████████████████████████████████
var IsPageUnload = false;
window.onunload = window_onunload;
window.onbeforeload = window_onbeforeunload;
function window_onunload() {
	if (IsPageUnload == false) {
		IsPageUnload = true;
		PageUnload();
	}
}
function window_onbeforeunload() {
	if (IsPageUnload == false) {
		IsPageUnload = true;
		PageUnload();
	}
}
function PageUnload() {
	SetPageUnloadTime();
}
function SetPageUnloadTime() {
	if (typeof (c_RequestID) != 'undefined') {
		var v_CurrentTime = new Date();
		var v_CurrentTimeString = v_CurrentTime.getFullYear() + "-" + v_CurrentTime.getMonth() + "-" + v_CurrentTime.getDate()
		+ " " + v_CurrentTime.getHours() + ":" + v_CurrentTime.getMinutes() + ":" + v_CurrentTime.getSeconds();
		PageMethods.SetPageUnloadTime(c_RequestID, v_CurrentTimeString);
	}
}
//██████████████████████████████████████████████████████████████████████████████
function SetLocation(position) {
	if (typeof (c_RequestID) != 'undefined') {
		PageMethods.SetLocation(c_RequestID, position.coords.latitude, position.coords.longitude);
	}
}
//██████████████████████████████████████████████████████████████████████████████
function GetScrollBarHeight() {
	var v_Body = document.getElementById("Body");
	return document.documentElement.clientHeight - v_Body.clientHeight;
}
function GetBrowserWidth() {
	var v_BrowserWidth = 0;
	if (typeof (window.innerWidth) == 'number') //Non-IE
		v_BrowserWidth = window.innerWidth;
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) //IE 6+ in 'standards compliant mode'
		v_BrowserWidth = document.documentElement.clientWidth;
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)) //IE 4 compatible
		v_BrowserWidth = document.body.clientWidth;
	return v_BrowserWidth;
}
function GetBrowserHeight() {
	var v_BrowserHeight = 0;
	if (typeof (window.innerWidth) == 'number')
		v_BrowserHeight = window.innerHeight;
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
		v_BrowserHeight = document.documentElement.clientHeight;
	else if (document.body && (document.body.clientWidth || document.body.clientHeight))
		v_BrowserHeight = document.body.clientHeight;
	return v_BrowserHeight;
}
function GetBodyWidth() {
	var v_Body = document.getElementById("Body");
	return v_Body.clientWidth;
}
function GetBodyHeight() {
	var v_Body = document.getElementById("Body");
	return v_Body.clientHeight;
}
//██████████████████████████████████████████████████████████████████████████████
function DisplayDialog(p_DialogHTML, p_FocusContolID) {
	HideAllDropDownList();
	var v_tdDialogContainer = document.getElementById("tdDialogContainer");
	v_tdDialogContainer.innerHTML = p_DialogHTML;

	var v_PageCover = document.getElementById("PageCover");
	v_PageCover.style.display = "block";

	var v_DialogContainer = document.getElementById("DialogContainer");
	v_DialogContainer.style.display = "block";

	var v_FocusContol = document.getElementById(p_FocusContolID);
	v_FocusContol.focus();
}
function CloseDialog() {
	ShowAllDropDownList();
	var v_PageCover = document.getElementById("PageCover");
	v_PageCover.style.display = "none";

	var v_DialogContainer = document.getElementById("DialogContainer");
	v_DialogContainer.style.display = "none";

	var v_tdDialogContainer = document.getElementById("tdDialogContainer");
	v_tdDialogContainer.innerHTML = "";
}
function HideAllDropDownList() {
	var allSelect = document.getElementsByTagName("select");
	for (var i = 0; i < allSelect.length; i++) {
		allSelect[i].style.display = "none";
	}
}
function ShowAllDropDownList() {
	var allSelect = document.getElementsByTagName("select");
	for (var i = 0; i < allSelect.length; i++) {
		allSelect[i].style.display = "inline-block";
	}
}

















//	document.getElementById("ct_Resizer").onmousedown = function() {
//		m_IsMouseDown = true;
//		document.getElementById("ct_ResizeSupport").style.display = "block";
//	}
//	document.body.onmouseup = function() {
//		m_IsMouseDown = false;
//		document.getElementById("ct_ResizeSupport").style.display = "none";
//	}
//	window.onresize = function() {
//		n_UpdatePanelSize();
//	}

//var m_IsMouseDown = false;
//var m_ResizerX = 0;

//function n_BodyMouseMove(mouse) {
//	if (m_IsMouseDown == true) {
//		if (mouse.clientX >= 100 && mouse.clientX <= GetBodyWidth() - 100) {
//			m_ResizerX = mouse.clientX;
//			n_UpdatePanelSize();
//		}
//	}
//}
//function n_UpdatePanelSize() {
//	if (m_ResizerX == 0) return;
//	document.getElementById('ct_Left').style.width = m_ResizerX - 3 + 'px';
//	document.getElementById('ct_Resizer').style.left = m_ResizerX - 3 + 'px';
//	document.getElementById('ct_Content').style.left = m_ResizerX + 2 + 'px';
//	document.getElementById('ct_Content').style.width = GetBodyWidth() - m_ResizerX + 2 + 'px';
//}
