// ---- disable right-click
//document.oncontextmenu = disableRightClick;

var submitForm = "yes";
 
function checkIfSubmitted()
{
   if (submitForm=="yes")
   {
      submitForm="no";
      return true;
   }
   else {
      return false;
   }
}

function resetSubmittedForm() {
	submitForm="yes";
	return true;
}

function disableRightClick()
{
  return false;
  //return true;
}
// ---- end of disable right-click


function dispMonth(mon) 
{
	 
  switch (mon) 
  {
    case 1:  return "Jan";
    case 2:  return "Feb";
    case 3:  return "Mar";
    case 4:  return "Apr";
    case 5:  return "May";
    case 6:  return "Jun";
    case 7:  return "Jul";
    case 8:  return "Aug";
    case 9:  return "Sep";
    case 10: return "Oct";
    case 11: return "Nov";
    case 12: return "Dec";
  }	      
}


function fmtCurrency(amount)
{
	a = fmtDecimal(amount);
	
	if (a.substr(a.indexOf('.')).length = 3 && a.substr(a.indexOf('.')) == '.00'){
	amountResult = a.substr(0, a.indexOf('.'));
	}
	else 
	amountResult = a;
	
	return amountResult;
}


function fmtDecimal(amount)
{
  return fmtNumber(amount/100);
}


function fmtNumber(amount)
{
  var textFormat = "";	
  s = new String(amount);	
  decimalPt = s.indexOf('.');
  if ( decimalPt>0 && decimalPt==(s.length - 2)) { s += '0'; }
  //if ( decimalPt<0 ) s += ".00";
  
  if ( decimalPt < 0 ) {
     beforeDecimal = s;
     //afterDecimal = "";  // by William 20040521  
     afterDecimal = ".00";
  }
  else {
     beforeDecimal = s.substr(0,s.indexOf('.'));
     afterDecimal = "." + s.substr(s.indexOf('.')+1);
  }
     
  //if ( afterDecimal.indexOf(".00") >= 0 ) // by William 20040521
  //  afterDecimal = "";   // by William 20040521
       
  for (var t=0,k=beforeDecimal.length-1; k>=0; k--) {
    t++;
    
    if (t % 3 == 0)
       textFormat = "," + beforeDecimal.substr(k,1) + textFormat; 
    else 
       textFormat =  beforeDecimal.substr(k,1) + textFormat;
    //document.write("<br>" + textFormat);   
  } 

  if (textFormat.substr(0,1) == ",") 
     return textFormat.substr(1,textFormat.length-1) + afterDecimal;
 
  return textFormat + afterDecimal;
}

function leadingZero(nr)
{
	if (nr < 10) nr = "0" + nr;
	return nr;
}


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function popHelp(msg) 
{
    var win = window.open("","Help","width=350,height=180,status=no,resizable=no,top=200,left=300");
    win.document.write("<html><title>Help Window</title>");
    win.document.write("<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"../Style.css\">");
    win.document.write("<body>");
    win.document.write("<BR><p><font class=font14>"+msg+"</p>");
    win.document.write("<center><a href=javascript:window.close();>close</a></center>");
    win.document.write("</body></html>");
}

function popWinSB(url) 
{
    window.open(url,"InternetPPS","width=850,height=520,status=no,resizable=yes,scrollbars=yes,top=0,left=0");
}

function popWin(url) 
{
    window.open(url,"InternetPPS","width=780,height=520,status=no,resizable=yes,top=0,left=0");
}


function popUp(url)
{
    windowprops = "top=0,left=0,location=no,resizable=yes,status=yes,scrollbars=yes," + ",width=" + screen.width + ",height=" + (screen.height-80);
    window.open(url, "popupPage", windowprops);
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v2.0
  var i, visStr, args, theObj;
  args = MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=4) { //with arg triples (objNS,objIE,visStr)
    visStr   = args[i+3];
    if (navigator.appName == 'Netscape' && document.layers != null) {
      theObj = eval(args[i]);
      if (theObj) theObj.visibility = visStr;
    } else if (document.all != null) { //IE
      if (visStr == 'show') visStr = 'visible'; //convert vals
      if (visStr == 'hide') visStr = 'hidden';
      theObj = eval(args[i+1]);
      if (theObj) theObj.style.visibility = visStr;
    } else if (!document.all && document.getElementById) {
       if (visStr == 'show') visStr = 'visible'; //convert vals
       if (visStr == 'hide') visStr = 'hidden';
       theObj = eval(args[i+2]);
       if (theObj) theObj.style.visibility = visStr;
    }
  }

}


function DisplayError(err)
{
	alert("JavaScript Exception: " +err + "\n\nIf the problem cannot be resolved after several retries, please contact PPS Hotline for assistance.");
	MM_showHideLayers('document.layers[\'Layer1\']','document.all[\'Layer1\']','document.getElementById("Layer1")','hide','document.layers[\'Layer2\']','document.all[\'Layer2\']','document.getElementById("Layer2")','hide','document.layers[\'Layer3\']','document.all[\'Layer3\']','document.getElementById("Layer3")','show');
	return true;
}

// trim the input string
function trim(theString) {
	return (theString.replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') ); 
}

// add escape char for symbols
function addEscapeChar(orgStr, specChar)
{
  chkpt = 0;

  while(orgStr.indexOf(specChar, chkpt) != -1) {

    var front = orgStr.substring(0, orgStr.indexOf(specChar, chkpt));
    chkpt = orgStr.indexOf(specChar, chkpt)+1;
    var back = orgStr.substring(chkpt, orgStr.length);
    chkpt = chkpt + 1;
									 		
    orgStr = front + "\\" + specChar + back;
  }

  return orgStr;
}

// change continuous spaces to &ndsp;
function convertSpaces(orgStr)
{
	while (orgStr.indexOf("  ") != -1) {
		orgStr=orgStr.replace(" ", "&nbsp;");
	}
	return orgStr;
}

// function to disable pre-set key-stoke in funDown + Backspace;
function funDownInAck(evt) {
	var ret = true;
	// disable any checking in Macintosh Machine
	if (navigator.userAgent.indexOf("Macintosh;") != -1) {
		document.onkeydown = null;
		return true;
	}
	checkBrowserInAck(navigator.appName);

	evt = (evt) ? evt : ((event) ? event : null);
    if (evt) {
        if (evt.keyCode == 8) { // Backspace
			ret = cancelKey(evt);
        }
	}
	if (ret) ret = funDown(evt);
	return ret;
}

function checkBrowserInAck(browserName) {
	if (browserName=="Netscape") {
	    document.addEventListener("keypress",funDownInAck,true);
		document.onkeydown = null;
	}
}


function resetBrowserInAck() {
	if (navigator.appName=="Netscape") {
	    document.removeEventListener("keypress",funDownInAck,true);
	}
}

// function to disable pre-set key-stoke;
function funDown(evt) {
	// disable any checking in Macintosh Machine
	if (navigator.userAgent.indexOf("Macintosh;") != -1) {

		document.onkeydown = null;
		return true;
	}

	//checkBrowser(navigator.appName);
	evt = (evt) ? evt : ((event) ? event : null);
    if (evt) 
	{
        if (evt.keyCode == 116) // F5
		{
			if (location.pathname != "/hkt/revamp2/English/LoginPage.html" && location.pathname != "/hkt/revamp2/Chinese/LoginPage.html")
				cancelKey(evt);
        }
		else if (evt.keyCode == 122) // F11 = 122
		{
			cancelKey(evt);
		}
		else if (evt.altKey)
		{
			if (evt.keyCode == 37 || evt.keyCode == 39 || evt.keyCode == 36) //capture alt+left = 37arrow, alt+right = 39, alt + home = 36
			{
				if (navigator.appName=="Netscape")
					cancelKey(evt); // for NS
				else if (navigator.appName=="Microsoft Internet Explorer")
					return false; // for IE
			}
		}
		else if ((evt.shiftKey && evt.keyCode == 117) || evt.keyCode == 117 || evt.keyCode == 114) // F3 = 114, F6=117
		{
			//if (navigator.appName == "Microsoft Internet Explorer")
				cancelKey(evt);
		}
		else if (evt.shiftKey && evt.ctrlKey)
		{
			if (navigator.appName == "Microsoft Internet Explorer")
				if (evt.keyCode == 9) // tab = 9
					cancelKey(evt);
			if (navigator.appName == "Netscape")
				if (evt.charCode == 82) // after push shifKey R charCode == 82
					if (location.pathname != "/hkt/revamp2/English/LoginPage.html" && location.pathname != "/hkt/revamp2/Chinese/LoginPage.html")
						cancelKey(evt);	
		}
		else if (evt.ctrlKey)
		{
			if (navigator.appName=="Netscape") 
			{
				if (evt.charCode == 114) //capture R=114
				{
					if (location.pathname != "/hkt/revamp2/English/LoginPage.html" && location.pathname != "/hkt/revamp2/Chinese/LoginPage.html")
						cancelKey(evt);
				}
				else if (evt.charCode == 98 || evt.charCode == 100 || evt.charCode == 101 || evt.charCode == 105)
						cancelKey(evt);	 // capture  B=98, D=100, E=101,  I=105
				else if (evt.charCode == 102 || evt.charCode == 103 || evt.charCode == 108 || evt.charCode == 110) 
						cancelKey(evt); // capture F = 102, G = 103, L = 108, N=110
				else if (evt.charCode == 117 || evt.charCode == 111) 
						cancelKey(evt); // capture U = 117, O = 111
			}
			else if (navigator.appName=="Microsoft Internet Explorer") 
			{
				if (evt.keyCode == 82) //capture R=82
				{
					if (location.pathname != "/hkt/revamp2/English/LoginPage.html" && location.pathname != "/hkt/revamp2/Chinese/LoginPage.html")		
						cancelKey(evt);					
				}
				else if (evt.keyCode == 14 || evt.keyCode == 66 || evt.keyCode == 68 || evt.keyCode == 69 || evt.keyCode == 73)
						cancelKey(evt);  // Capture B=66, D=68, E=69, I=73
				else if ((evt.keyCode == 9) || (evt.shiftKey && evt.keyCode == 9)) //capture ctrl + tab and ctrl + shift + tab
						cancelKey(evt);
				else if (evt.keyCode == 70 || evt.keyCode == 72 || evt.keyCode == 76) //capture F = 70, H = 72, L = 76
						cancelKey(evt);
				else if (evt.keyCode == 78 || evt.keyCode == 79) //capture N = 78, O = 79
						cancelKey(evt);
			}
        }
    }
}

function checkBrowser(browserName) {
	if (browserName=="Netscape") {		
	    document.addEventListener("keypress",funDown,true);
		document.onkeydown = null;
	}	
}

function resetBrowser() {
	if (navigator.appName=="Netscape") {
	    document.removeEventListener("keypress",funDown,true);
	}
}

function cancelKey(evt) {
    if (evt.preventDefault) {
        evt.preventDefault();
        evt.returnValue = false;
    }
    else {
        evt.keyCode = 0;
        evt.returnValue = false;
    }
    return false;
}

function writeFramedChiFooter() {
	document.write("<tr>");
	document.write("<td nowrap>");
	document.write("<div class=\"footer\"><div class=\"footerText1\"><a href=\"tnc_framed.html\">兵蹿籔兵ン</a></div>"); 
	document.write("<div class=\"footerText1\"><a href=\"privacyPolicy_framed.html\">╬留現郸</a></div>");  
	document.write("<div class=\"footerText1\"><a href=\"disclaimer_framed.html\">砫羘</a></div>"); 
	document.write("<br>");
	document.write("<div class=\"epsPccwLogo\"><img src=\"/hkt/revamp2/Chinese/images/epsPCCW.gif\" alt=\"快ㄆの筿癟坝夹\"></div>");
	document.write("<div class=\"footerText2\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>");
	document.write("<div class=\"footerText2\">&copy; 2004 - 2010 快ㄆ翠ΤそのHong Kong Telecommunications (HKT) Limited┮Τ舦玂痙");
	document.write("<br>煤禣艶狝叭パ <a href=\"http://www.eps.com.hk\">快ㄆ翠Τそ</a> の <a href=\"http://www.pccw.com\">Hong Kong Telecommunications (HKT) Limited</a>  羛矗ㄑ </div>");
	document.write("</td>");
	document.write("</tr>");
}

function writeNonFramedChiFooter() {
	document.write("<TABLE width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
	document.write("<TR valign=\"top\">");
	document.write("<TD class=\"fontGray\" nowrap><img src=\"images/spacer.gif\" width=\"1\" height=\"2\" border=\"0\" alt=\"\"><br>");
	document.write("&copy; 2004 - 2010 快ㄆ翠ΤそのHong Kong Telecommunications (HKT) Limited┮Τ舦玂痙<br>");
	document.write("煤禣艶狝叭パ<a href=\"http://www.eps.com.hk\" target=\"_blank\">快ㄆ翠Τそ</a>の<a href=\"http://www.pccw.com\" target=\"_blank\">Hong Kong Telecommunications (HKT) Limited</a>  羛矗ㄑ");
	document.write("</TD>");
	document.write("<TD align=\"right\" class=\"fontGray\" nowrap=1>");
	document.write("<img src=\"/hkt/revamp2/Chinese/images/epsPCCW.gif\" alt=\"快ㄆの筿癟坝夹\">");
	document.write("</TD>");
	document.write("</TR>");
	document.write("</TABLE>");
}

function writeFramedEngFooter() {
	document.write("<tr>");
	document.write("<td nowrap>");
	document.write("<div class=\"footer\"><div class=\"footerText1\"><a href=\"tnc_framed.html\">Terms and Conditions</a></div>");
	document.write("<div class=\"footerText1\"><a href=\"privacyPolicy_framed.html\">Privacy Policy </a></div>");
	document.write("<div class=\"footerText1\"><a href=\"disclaimer_framed.html\">Disclaimer</a></div>");
	document.write("<br>");
	document.write("<div class=\"epsPccwLogo\"><img src=\"/hkt/revamp2/English/images/epsPCCW.gif\" alt=\"EPS & PCCW Logo\"></div>");
	document.write("<div class=\"footerText2\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>");
	document.write("<div class=\"footerText2\">&copy; 2004 - 2010 EPS Company (Hong Kong) Limited and Hong Kong Telecommunications (HKT) Limited.  All rights reserved.");
	document.write("<br>PPS is jointly provided by <a href=\"http://www.eps.com.hk\">EPS Company (Hong Kong) Limited</a> and <a href=\"http://www.pccw.com\">Hong Kong Telecommunications (HKT) Limited</a>.</div>");
	document.write("</td>");
	document.write("</tr>");
}

function writeNonFramedEngFooter() {
	document.write("<TABLE width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
	document.write("<TR valign=\"top\">");
	document.write("<TD class=\"fontGray\" nowrap><img src=\"images/spacer.gif\" width=\"1\" height=\"2\" border=\"0\" alt=\"\"><br>");
	document.write("&copy; 2004 - 2010 EPS Company (Hong Kong) Limited and Hong Kong Telecommunications (HKT) Limited.  All rights reserved.<br>");
	document.write("PPS is jointly provided by <a href=\"http://www.eps.com.hk\" target=\"_blank\">EPS Company (Hong Kong) Limited</a> and <a href=\"http://www.pccw.com\" target=\"_blank\">Hong Kong Telecommunications (HKT) Limited</a>.");
	document.write("</TD>");
	document.write("<TD align=\"right\" class=\"fontGray\" nowrap=1>");
	document.write("<img src=\"/hkt/revamp2/English/images/epsPCCW.gif\" alt=\"EPS & PCCW Logo\">");
	document.write("</TD>");
	document.write("</TR>");
	document.write("</TABLE>");
}

function writeFramedGBFooter() {
	document.write("<tr>");
	document.write("<td nowrap>");
	document.write("<div class=\"footer\"><div class=\"footerText1\"><a href=\"tnc_framed.html\">条款与条件</a></div>"); 
	document.write("<div class=\"footerText1\"><a href=\"privacyPolicy_framed.html\">私隐政策</a></div>");  
	document.write("<div class=\"footerText1\"><a href=\"disclaimer_framed.html\">免责声明</a></div>"); 
	document.write("<br>");
	document.write("<div class=\"epsPccwLogo\"><img src=\"/hkt/revamp2/Chinese/images/epsPCCW.gif\" alt=\"易办事及电讯盈科商标\"></div>");
	document.write("<div class=\"footerText2\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>");
	document.write("<div class=\"footerText2\">Copyright (c) 2010。保留所有权利。");
	document.write("<br>缴费灵服务由 <a href=\"http://www.eps.com.hk\">易办事（香港）有限公司</a> 及 <a href=\"http://www.pccw.com\">电讯盈科</a>联合提供。 </div>");
	document.write("</td>");
	document.write("</tr>");
}

function writeNonFramedGBFooter() {
	document.write("<TABLE width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
	document.write("<TR valign=\"top\">");
	document.write("<TD class=\"fontGray\"><img src=\"images/spacer.gif\" width=\"1\" height=\"2\" border=\"0\" alt=\"\"><br>");
	document.write("Copyright (c) 2010。保留所有权利。<br>");
	document.write("缴费灵服务由<a href=\"http://www.eps.com.hk\" target=\"_blank\">易办事（香港）有限公司</a>及<a href=\"http://www.pccw.com\" target=\"_blank\">电讯盈科</a>联合提供。");
	document.write("</TD>");
	document.write("<TD align=\"right\" class=\"fontGray\" nowrap=1>");
	document.write("<img src=\"/hkt/revamp2/Chinese/images/epsPCCW.gif\" alt=\"易办事及电讯盈科商标\">");
	document.write("</TD>");
	document.write("</TR>");
	document.write("</TABLE>");
}

function writeAckEngFooter() {
	document.write("<table width=911 border=\"0\" cellspacing=\"3\" cellpadding=\"3\" align=center>");
	document.write("<tr>");
	document.write("<td>");
	document.write("<div class=\"footerText1\"><a href=\"/hkt/revamp2/English/tnc.html\">Terms and Conditions</a></div>");   
	document.write("<div class=\"footerText1\"><a href=\"/hkt/revamp2/English/personal_stmt.html\">Privacy Policy</a></div>");
	document.write("<div class=\"footerText1\"><a href=\"/hkt/revamp2/English/legaldisclaim.html\">Disclaimer</a></div>");   
	document.write("<br>");                  
	document.write("<div class=\"epsPccwLogo\"><img src=\"/hkt/revamp2/English/images/epsPCCW.gif\" alt=\"EPS & PCCW Logo\"></div>");
	document.write("<div class=\"footerText2\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>");
	document.write("<div class=\"footerText2\">&copy; 2004 - 2010 EPS Company (Hong Kong) Limited and Hong Kong Telecommunications (HKT) Limited. All rights reserved.<br>");
	document.write("   PPS is jointly provided by <a href=\"http://www.eps.com.hk\" target=_blank>EPS Company (Hong Kong) Limited</a> and <a href=\"http://www.pccw.com\" target=_blank>Hong Kong Telecommunications (HKT) Limited</a>. </div>");
	document.write("</div>");
	document.write("</td>");
	document.write("</tr>");
	document.write("</table>");
}

function writeAckChiFooter() {
	document.write("<table width=911 border=\"0\" cellspacing=\"3\" cellpadding=\"3\" align=center>");
	document.write("<tr>");
	document.write("<td>");
	document.write("<div class=\"footerText1\"><a href=\"/hkt/revamp2/Chinese/tnc.html\">兵蹿籔兵ン</a></div>");
	document.write("<div class=\"footerText1\"><a href=\"/hkt/revamp2/Chinese/personal_stmt.html\">╬留現郸</a></div>");
	document.write("<div class=\"footerText1\"><a href=\"/hkt/revamp2/Chinese/legaldisclaim.html\">砫羘</a></div>");
	document.write("<br>");
	document.write("<div class=\"epsPccwLogo\"><img src=\"/hkt/revamp2/English/images/epsPCCW.gif\" alt=\"快ㄆの筿癟坝夹\"></div>");
	document.write("<div class=\"footerText2\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>");
	document.write("<div class=\"footerText2\">&copy; 2004 - 2010 快ㄆ翠ΤそのHong Kong Telecommunications (HKT) Limited ┮Τ舦玂痙<br>");
	document.write("   煤禣艶狝叭パ <a href=\"http://www.eps.com.hk\" target=_blank>快ㄆ翠Τそ</a> の <a href=\"http://www.pccw.com\" target=_blank>Hong Kong Telecommunications (HKT) Limited </a> 羛矗ㄑ   </div>");
	document.write("</div>");
	document.write("</td>");
	document.write("</tr>");
	document.write("</table>");
}

function printAlert(lang) {
	
	if (GetCookie("pAlert")!="N") {
		if(lang=="Chi")
			alert("叫ㄏノ绢匡兜");
		else
			alert("Please use the landscape printing option.");
			
		SetCookie("pAlert", "N");			
	}

	print();
}

function getLastPaymentDate(d)
{
	var lastPaymentDate = new Date(d.substring(0,4),d.substring(4,6)-1,d.substring(6,8));
	
	if (leadingZero(lastPaymentDate.getMonth() + 1) != d.substring(4,6) )
		lastPaymentDate.setDate(0);

	return lastPaymentDate.getFullYear() + "" + leadingZero(lastPaymentDate.getMonth() + 1) + "" + leadingZero(lastPaymentDate.getDate());
}

function getNextPaymentDate(serverTime, recPayDoM, language) {
	var d = serverTime;
	var rtDate = "";
	d = new Date(d);
	
			
	var nextPayDate = new Date(d);
	nextPayDate.setDate(recPayDoM);
	
	if (nextPayDate.getMonth() != d.getMonth())
		nextPayDate.setDate(0);
	
	if ( d >= nextPayDate ){
		nextPayDate.setFullYear(nextPayDate.getFullYear(), nextPayDate.getMonth()+1, recPayDoM);
	if ( (nextPayDate.getMonth() - d.getMonth()) == 2)
		nextPayDate.setFullYear(nextPayDate.getFullYear(), nextPayDate.getMonth(), 0);
	}
	
	if (language == 2) 
		rtDate = nextPayDate.getFullYear() + "" + leadingZero(nextPayDate.getMonth()+1) + "る" + leadingZero(nextPayDate.getDate()) + "ら";
	else
		rtDate = leadingZero(nextPayDate.getDate())+ " " + dispMonth(nextPayDate.getMonth()+1) + " " + nextPayDate.getFullYear();
	
	return rtDate;
}

function convertCardNoToBillNo(cardNo) {

	if (cardNo.length != 19) {
		return cardNo;
	}

	return cardNo.substring(0, 4) + cardNo.substring(5, 9) + cardNo.substring(10, 14) + cardNo.substring(15, 19);

}

function convertBillNoToCardNo(billNo) {
	if(billNo.length != 16) {
		return billNo;
	}
	
	return billNo.substring(0,4) + " - " + billNo.substring(4, 8) + " - " + billNo.substring(8, 12) + " - " + billNo.substring(12, 16);

}

function int2float(prefix, index) {
	result = "";
	len = prefix.length;

	for(i=0; i<len; i++){
		if ((index != 0) && (i == index)) result = "." + result;
		result = prefix.substring(len-(i+1), len-i) + result;
	}
	if (len <= index) {
		for(i=len; i<index; i++){
			result = "0" + result;
		}	
		result = "0." + result;
	}
	return result;
}

function isAlphanumericChar(str) {
	var charSet="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
	for (var i=0; i<str.length; i++) {
		temp = "" + str.substring(i, i + 1);
		if (charSet.indexOf(temp) == -1) return false
	}
	return true;
}

function divideStr(inputStr, length, part)
{
startPos = 0;
endPos = length - 1;
var outputStr;

	for(i=1; i<=part; i++)
	{						
	if (endPos >= inputStr.length) {
		outputStr = inputStr.substring(startPos, inputStr.length);
		break;
	}
				
	if (startPos <= inputStr.length && endPos <= inputStr.length)
		outputStr = inputStr.substring(startPos, endPos + 1)	
		
		startPos = endPos + 1;
		endPos = startPos + length - 1;
	}
return outputStr;	
}

function addSpace(inputStr, partLength){
	endPos = inputStr.length;

	for( j=endPos; j<partLength; j++)
		{
		inputStr = inputStr + ' ';
		}
return inputStr;
}
