var c="%47%59%41%54%52%49%44%4E%46%48%55%58%4B%4C%4D%45%4F%50%51%42%53%43%56%57%4A%5A%30%31%32%33%34%35%36%37%38%39";
var u="%30%31%32%33%34%35%36%37%38%39%41%42%43%44%45%46%47%48%49%4A%4B%4C%4D%4E%4F%50%51%52%53%54%55%56%57%58%59%5A";
var Sec;
var ET=30;

function SetChk(){
var y,M,D,h,m,s;
var d=new Date();
y="0"+d.getYear();
M="0"+d.getMonth();
D="0"+d.getDate();
h="0"+d.getHours();
m="0"+d.getMinutes();
s="0"+d.getSeconds();
if (y.length>4) y=y.substring(1,5);
if (M.length>2) M=M.substring(1,3);
if (D.length>2) D=D.substring(1,3);
if (h.length>2) h=h.substring(1,3);
if (m.length>2) m=m.substring(1,3);
if (s.length>2) s=s.substring(1,3);
return(h+m+s+y+M+D);
}

function GetChk(){
var p=window.location.search;
var r,s,S,i;
r="";
p=unescape(p);
s=p.split("?");
for (i=0;i<s.length;i++){
    S=s[i].toUpperCase();
    if (S.substring(0,5)=="_LOG="){
	    r=S.substring(5,S.length);
	 }
}
return(r);
}

function URLlogin(p,v){
var r="";
var w="";
var ps;
var rw;
w = p.toUpperCase();
if (Sec.length>0){
   r="?_Log="+Sec;
}
if (typeof Path2 != "undefined"){
	if ((Path2 != "") && (v.indexOf("path=") == -1) && (w.indexOf("WELCOME2.HTM") == -1)) {
		r=r+"&path="+Path2;
	}
}
if (v.length>0){
   r=r+"&"+v;
}
document.location=p+r;
// Added for temporary display of the Pharmacare window
ps = 'width=600,height=550,menubar=no,locationbar=no,toolbar=no,scrollbars=yes,resizable=1';
rw = window.open("fpharmacare.htm", 'FPWindow', ps);
rw.focus();
}

function URL(p,v){
var r="";
var w="";
var ps;
var rw;
w = p.toUpperCase();
if (Sec.length>0){
   r="?_Log="+Sec;
}
if (typeof Path2 != "undefined"){
	if ((Path2 != "") && (v.indexOf("path=") == -1) && (w.indexOf("WELCOME2.HTM") == -1)) {
		r=r+"&path="+Path2;
	}
}
if (v.length>0){
   r=r+"&"+v;
}
document.location=p+r;
}

function URLOpen(p,v){
var r;
var ps;
var rw;
r="";
if (Sec.length>0){
   r="?_Log="+Sec;
}
if (v.length>0){
   r=r+"&"+v;
}
ps = 'width=600,height=440,menubar=no,locationbar=no,toolbar=no,scrollbars=yes';
rw = window.open(p+r, 'hWindow', ps);
rw.focus();
}

function PageJump(p){
var r,i,s;
r="";
s=window.location.href;
i=s.indexOf("?");
if (i != -1) {
	s=s.substring(0,i);
}
if (Sec.length>0){
   r="?_Log="+Sec;
}
if (typeof Path2 != "undefined"){
	if (Path2 != "") {
		r=r+"&path="+Path2;
	}
}
document.location=s+r+p;
}

function CmpChk(p1,p2){
var y1,M1,d1,h1,m1,s1;
var y2,M2,d2,h2,m2,s2;
if ((p1.length==0)||(p2.length==0)) return(60000);
h1=parseInt(p1.substring(0,2));
m1=parseInt(p1.substring(2,4));
s1=parseInt(p1.substring(4,6));
h2=parseInt(p2.substring(0,2));
m2=parseInt(p2.substring(2,4));
s2=parseInt(p2.substring(4,6));
y1=parseInt(p1.substring(6,10));
M1=parseInt(p1.substring(10,12));
d1=parseInt(p1.substring(12,14));
y2=parseInt(p2.substring(6,10));
M2=parseInt(p2.substring(10,12));
d2=parseInt(p2.substring(12,14));
s1=(h1*3600)+(m1*60)+s1;
s2=(h2*3600)+(m2*60)+s2;
if ((y1==y2)&&(M1==M2)&&(d1==d2)){
   if (s1>s2){
      s1=s1-s2;
   }else{
      s1=s2-s1;
   }
}else{
   s1=60000;
}
return(s1/60);
}

function TF(p){
var r,i,j;
r="";
for (i=0;i<p.length;i++){
    j=p.charAt(i);
    j=c.indexOf(j);
    r=r+u.substring(j,j+1);
}
return(r);
}

function tf(p){
var r,i,j;
r="";
for (i=0;i<p.length;i++){
    j=p.charAt(i);
    j=u.indexOf(j);
    r=r+c.substring(j,j+1);
}
return(r);
}

function ChkPwd(p){
// p=p.toUpperCase();
// p=tf(p);
// if (p=="ZMJZCM"){
//   return("T");
// }else{
//   return("F");
// }
return("T");
}

function ChkLogin(p){
var _T;
Sec=GetChk();
Sec=TF(Sec);
_T=SetChk();
//if (CmpChk(_T,Sec)>ET){
//   document.location=p;
//}else{
   Sec=SetChk();
   Sec=tf(Sec);
//}
}

function CheckPWD(u,p,l){
if (ChkPwd(p)=="T"){
	Sec=SetChk();
	Sec=tf(Sec);
	URLlogin(l,"");
}else{
   alert("Wrong password!");
}
}

u = unescape(u);
c = unescape(c);

