function showUserMenu(ename)
{
	if(window.document.getElementById(ename).style.display == "none")
		window.document.getElementById(ename).style.display = "block";
	else
		window.document.getElementById(ename).style.display = "none";
}

function disRow(ename)
{
//	alert(ename+" priv");
	if (ename=="uname")
	{
		window.document.getElementById("uname").style.display = "block";
		window.document.getElementById("priv").style.display = "none";
	}
	if (ename == "priv")
	{
		window.document.getElementById("uname").style.display = "none";
		window.document.getElementById("priv").style.display = "block";
	}
}

function chkPassword(frmObj)
{
	if(frmObj.userpwd.value=="" || frmObj.userpwd.value==null)
	{
		alert("Please fill Password");
		frmObj.userpwd.focus();
		return false;
	}
	if(frmObj.conpwd.value=="" || frmObj.conpwd.value==null)
	{
		alert("Please fill Confirm Password");
		frmObj.conpwd.focus();
		return false;
	}
	if(frmObj.userpwd.value!=frmObj.conpwd.value)
	{
		alert("Password and Confirm Password not matching\nPlease Enter Again!");
		frmObj.conpwd.select();
		return false;
	}
	
	return true;
}

function chkPriv(ename)
{
	if (ename.value == "TLR")
	{
		showUserMenu("TDetails");
	}
	else
	{
		window.document.getElementById("TDetails").style.display = "none";
	}
	if (ename.value == "EDT")
	{
		showUserMenu("EDetails");
	}
	else
	{
		window.document.getElementById("EDetails").style.display = "none";
	}
}

function conDel(memno)
{
	var x = confirm("Do you really wish to delete this record?");
	if (x==true)
		window.location="delmemcust.jsp?mno="+memno;
	else 
		return false;
}

function conBODel(id)
{
	var x = confirm("Do you really wish to delete this record?");
	if (x==true)
		window.location="delbouser.jsp?uid="+id;
	else 
		return false;
}
function chgAction(frmObj, type)
{
	if (type=="details")
	{
		frmObj.action = 'viewmemcust.jsp';
	}
	else if (type=="transactions")
	{
		frmObj.action = 'transmemcust.jsp';
	}
	frmObj.submit();
}

function updateAction(frmObj, type)
{
	if (type=="details")
	{
		frmObj.action = 'viewmemcust.jsp';
	}
	else if (type=="transactions")
	{
		frmObj.action = 'transmemcust.jsp';
	}
}

var gAutoPrint = true; // Tells whether to automatically call the print function

function printSpecial()
{
	if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';

		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}

		html += '\n</HEAD>\n<BODY>\n';

		var printReadyElem = document.getElementById("printReady");

		if (printReadyElem != null)
		{
			html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady function");
			return;
		}
		
		html += '\n</BODY>\n</HTML>';

		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();

		//setTimeout('printWin.close();',180000); 
	}
	else
	{
		alert("The print ready feature is only available if you are using an browser. Please update your browser.");
	}
}

function displayCurrentDate()
{
	var fullDate = calcTime('Singapore', '+8');
	return fullDate;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function replaceString(sString, sReplaceThis, sWithThis) { 
    if (sReplaceThis != "" && sReplaceThis != sWithThis) {
      var counter = 0;
      var start = 0;
      var before = "";
      var after = "";
      while (counter<sString.length) {
        start = sString.indexOf(sReplaceThis, counter);
        if (start == -1){
         break;
         } else {
           before = sString.substr(0, start);
           after = sString.substr(start + sReplaceThis.length, sString.length);
           sString = before + sWithThis + after;
           counter = before.length + sWithThis.length;
          }
        }
      }
   return sString;
  }
  
  
 function UpFirstChar(word) { 
  upper = word.toUpperCase() 
  normal = upper.substring(0,1) + word.substring(1,word.length) 
  return normal;
} 
