text: var template = "";
  var role = "";
  var username = "";
  var pattern_filter = "";
  var column_filter = null;
  var column_sort = "EID"
  var order_sort = "ascending";
  var xmlDoc;
  var xslDoc;
  var detailsDoc;
  
  init();
  Tooltip.init();
  
  function init()
  {
  	if (window.ActiveXObject)
  	{
  		loadTemplate("css/template.tpl");
  		checkAuthorizedUser();
  	}
  	else
  	{
  		getElement("page").innerHTML = "";
  		alert("Your browser can not display this page!");
  	}
  }
  
  function loadTemplate(url)
  {
  	var templateDoc = new ActiveXObject("Microsoft.XMLHTTP");
  	templateDoc.onreadystatechange = function()
  	{
  		if (templateDoc.readyState == 4)
  		{
  			template = templateDoc.responseText;
  		}
  	}
  	templateDoc.open("GET", url, false);
  	templateDoc.send(null);
  }
  
  function getTemplate(name, args)
  {
  	var i = template.indexOf("<" + name + ">");
  	var j = template.indexOf("</" + name + ">", i);
  	var text = template.substring(i + name.length + 2, j);
  	while (text.indexOf("![") != -1)
  	{
  		var i = text.indexOf("![");
  		var j = text.indexOf("]", i);
  		text = text.substring(0, i) + args[text.substring(i + 2, j)] + text.substring(j + 1);
  	}
  	return text;
  }
  
  function checkAuthorizedUser()
  {
  	role = getCookie("role");
  	username = getCookie("username");
  	if ((role.length == 0) || (username.length == 0))
  	{
  		getElement("header").innerHTML = "";
  		getElement("menu").innerHTML = "";
  		getElement("main").innerHTML = getTemplate("login", null);
  	}
  	else
  	{
  		var args = {
  			"username" : username
  		};
  		loadData();
  		getElement("header").innerHTML = getTemplate("system_header", args);
  		hide_add_data();
  	}
  }
  
  function loadData()
  {
  	loadEmployees();
  	xslDoc = new ActiveXObject("Microsoft.XMLDOM");
  	xslDoc.async = false;
  	xslDoc.load("db/employees.xsl");
  	detailsDoc = new ActiveXObject("Microsoft.XMLDOM");
  	detailsDoc.async = false;
  	detailsDoc.load("db/details.xsl");
  }
  
  function loadEmployees()
  {
  	xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  	xmlDoc.async = false;
  	xmlDoc.load("http://localhost/NewAge/?sql=exec+getEmployeesList&root=EMPLOYEES");
  }
  
  function checkLoginForm(form)
  {
  	form.username.value = trim(form.username.value);
  	if (form.username.value.length == 0)
  	{
  		alert("Please provide your username to login.");
  		form.username.focus();
  		return;
  	}
  	form.password.value = trim(form.password.value);
  	if (form.password.value.length == 0)
  	{
  		alert("Please provide your password to login.");
  		form.password.focus();
  		return;
  	}
  	var xmlUsersDoc = new ActiveXObject("Microsoft.XMLDOM");
  	xmlUsersDoc.async = false;
  	xmlUsersDoc.load("db/user.xml");
  	var users = xmlUsersDoc.documentElement.childNodes;
  	for (var i=0; i<users.length; i++)
  	{
  		if ((form.username.value == users[i].getAttribute("username")) &&
  			(form.password.value == users[i].getAttribute("password")))
  		{
  			role = users[i].tagName;
  			username = users[i].getAttribute("username");
  			document.cookie = "role=" + role;
  			document.cookie = "username=" + username;
  			checkAuthorizedUser();
  			return;
  		}
  	}
  	alert("Wrong username or password!");
  }
  
  function logout()
  {
  	role = "";
  	username = "";
  	document.cookie = "role=" + role;
  	document.cookie = "username=" + username;
  	checkAuthorizedUser();
  }