function popWin(url,title,w,h)
{
  var obj_lkupwindow = window.open(url,'','width='+w+',height='+h+',status=yes,resizable=yes,scrollbars=yes,top=200,left=200,dependent=yes,alwaysRaised=yes');
  obj_lkupwindow.opener = window;
  obj_lkupwindow.focus();
}

function settab(tab,tablist)
{
  var tstr=new String(tablist);
  var tlist=tstr.split(",");
  for(var i=0;i<tlist.length;i++)
  {
    section=document.getElementById(tlist[i]);
    section.style.visibilty='hidden';
    section.style.display='none';
    tabobj=document.getElementById('title'+tlist[i]);
    tabobj.className='tabtitle';
  }
  section=document.getElementById(tab);
  section.style.visibility='visible';
  section.style.display='inline';
  tabobj=document.getElementById('title'+tab);
  tabobj.className='tabtitlesel';
}

var eblack_list=new Array();
function validateEmail(email) 
{ 
  var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/; 
  if (!re_mail.test(email.value))
  { 
    return false; 
  }
  var x=email.value;
  x=x.toLowerCase();
  for(i=0;i<eblack_list.length;i++)
  {
     if(x.search(eblack_list[i])>0)
       return false;
  }
  return true; 
}


function setrctab(tab,tablist)
{
  var tstr=new String(tablist);
  var tlist=tstr.split(",");
  for(var i=0;i<tlist.length;i++)
  {
    section=document.getElementById(tlist[i]);
    section.style.visibilty='hidden';
    section.style.display='none';
    tabobj=document.getElementById('inner'+tlist[i]);
    tabobj.className='rctabinner';
    Nifty('div#inner'+tlist[i],'top');
  }
  section=document.getElementById(tab);
  section.style.visibility='visible';
  section.style.display='inline';
  tabobj=document.getElementById('inner'+tab);
  tabobj.className='rctabinnersel';
  Nifty('div#inner'+tab,'top');
}

function toggle(targetId) {
  target = document.getElementById(targetId);
  if (target.style.display == "none"){
     target.style.display="";
     target.style.visibility="visible";
     }
  else {
     target.style.display="none";
     target.style.visibility="hidden";
     }
}

function toggle_on(targetId) {
  target = document.getElementById(targetId);
  if(target)
  {
    target.style.display="";
    target.style.visibility="visible";
  }
}

function toggle_off(targetId) {
  targets = targetId.split(",");
  for(i=0;i<targets.length;i++)
  {
    target = document.getElementById(targets[i]);
    if(target)
    {
      target.style.display="none";
      target.style.visibility="hidden";
    }
  }
}

function toggle_with_img(targetId,imgId) {
  target = document.getElementById(targetId);
  img = document.getElementById(imgId);
  if (target.style.display == "none"){
     target.style.display="";
     target.style.visibility="visible";
     img.src=img.src.replace('up','down');
     }
  else {
     target.style.display="none";
     target.style.visibility="hidden";
     img.src=img.src.replace('down','up');
     }
}

function toggle_with_text(targetId,textId,onText,offText) {
  target = document.getElementById(targetId);
  text = document.getElementById(textId);
  if (target.style.display == "none"){
     target.style.display="";
     target.style.visibility="visible";
     text.innerHTML=onText;
     }
  else {
     target.style.display="none";
     target.style.visibility="hidden";
     text.innerHTML=offText;
     }
}

function validatePass(pass, msg, optional)
{
  if (!pass.value && optional)
    return true;
  var re_pass1 = /^.*[0-9].*/;
  var re_pass2 = /^.*[a-zA-Z].*/;
  if (pass.value.length<6||!re_pass1.test(pass.value)||!re_pass2.test(pass.value))
  {
    if(msg!='') { alert(msg); pass.focus(); pass.select(); }
    return false;    
  }             
  return true;
}


var mode=0;
function validateEmail(email, msg, optional)
{
  if (!email.value && optional)
    return true;   
  if(msg!='')     
    email.value=replaceAll(email.value," ","");
  var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
  if (!re_mail.test(email.value))                      
  {  
    if(msg!='') { alert(msg); email.focus(); email.select(); }
    return false;             
  }
  return true;                
}


function openmenu(menu,curmenu)
{
  var mymenu=document.getElementById(menu);
  mymenu.style.visibility='visible';
  var mytab=document.getElementById('tab'+menu);
  mytab.className='menucellon';
  try{
    var mycur=document.getElementById('tab'+curmenu);
    mycur.className='menucell';
  }catch(e) {}
}

function closemenu(menu,curmenu)
{
  var mymenu=document.getElementById(menu);
  mymenu.style.visibility='hidden';
  var mytab=document.getElementById('tab'+menu);
  mytab.className='menucell';
  try{
    var mycur=document.getElementById('tab'+curmenu);
    mycur.className='menucellon';
  }catch(e) {}
}

function itemover(ctrlid,newstyle)
{
  var myitem=document.getElementById(ctrlid);
  myitem.className=newstyle;
}
function itemout(ctrlid,oldstyle)
{
  var myitem=document.getElementById(ctrlid);
  myitem.className=oldstyle;
}

var tinyMCEmode = false;
var tinyMCEsettings= new Array();
function toggleEditorMode(id) 
{
  if(tinyMCEmode) 
  {
    tinyMCE.execCommand('mceRemoveControl', false, id)
    tinyMCEmode = false;
    document.getElementById(id).style.height='600';
  } 
  else 
  {
    tinyMCE.settings=tinyMCEsettings[0];
    tinyMCE.execCommand('mceAddControl', false, id)
    tinyMCEmode = true;
    document.getElementById(id).className='';
  }
}

function remove_from_list(from_list,from_pool)
{
  var fl=document.getElementById(from_list);
  var fp=document.getElementById(from_pool);
  var fpl=new String(fp.value).split(",")            
  var newfpl=new Array;
  if(fl.selectedIndex!=-1&&fl.value!='')
  {
    for(i=0,j=0;i<fpl.length;i++)
    {
      if(fl.value!=fpl[i])        
        newfpl[j++]=fpl[i];
    }
    fl.remove(fl.selectedIndex);
    fp.value=newfpl.join(",");
  }
}  
        
function add_to_list(to_list,from_list,to_pool)
{  
  var tl=document.getElementById(to_list);
  var fl=document.getElementById(from_list);      
  var tp=document.getElementById(to_pool);
  var tpl=new String(tp.value).split(",")
  if(fl.type=='select-one'&&fl.selectedIndex!=-1&&fl.value!=''&&get_index(tpl,fl.value)<0)
  {
    tpl[tp.value.length==0?0:tpl.length]=fl.value;
    tp.value=tpl.join(",");    
    newopt=document.createElement('option');
    newopt.text=fl.options[fl.selectedIndex].text;
    newopt.value=fl.options[fl.selectedIndex].value;
    try{ tl.add(newopt,null); }
    catch (e) { tl.add(newopt,Number(-1)); }
  }
  if(fl.type=='text'&&fl.value!='')
  {
    tpl[tp.value.length==0?0:tpl.length]=fl.value;
    tp.value=tpl.join(",");    
    newopt=document.createElement('option');
    newopt.text=fl.value;
    newopt.value=fl.value;
    try{ tl.add(newopt,null); }
    catch (e) { tl.add(newopt,Number(-1)); }
  }
}

function get_index(arr,item)
{
  for(i=0;i<arr.length;i++)  
    if(item==arr[i])          
      return i;
  return -1;
}



//ROUNDED CORNER STUFF
var niftyOk=(document.getElementById && document.createElement && Array.prototype.push);

String.prototype.find=function(what){
  return(this.indexOf(what)>=0 ? true : false);
}

function Nifty(selector,options)
{
  if(niftyOk==false) return; 
  var i,v=selector.split(","),h=0;
  if(options==null) options="";
  if(options.find("fixed-height"))
    h=getElementsBySelector(v[0])[0].offsetHeight;
  for(i=0;i<v.length;i++)
  {
    NiftyReset(v[i]);
    Rounded(v[i],options);
  }
  if(options.find("height")) SameHeight(selector,h);
}

function NiftyReset(selector)
{
  //DELETE ALL THE OLD JUNK
  if(selector)
  {
    var a=selector.split('#');
    x=document.getElementById(a[1]);
    try{
      y=document.getElementById(a[1]+'main');
      x.removeChild(y);
    }catch(e) {}
  }
}

function Rounded(selector,options)
{
  var i,top="",bottom="",v=new Array();
  if(options!="")
  {
    options=options.replace("left","tl bl");
    options=options.replace("left-top","tl");
    options=options.replace("right","tr br");
    options=options.replace("right-top","tr");
    options=options.replace("top","tr tl");
    options=options.replace("bottom","br bl");
    options=options.replace("transparent","alias");
    if(options.find("tl"))
    {
      top="both";
      if(!options.find("tr")) top="left";
    }
    else if(options.find("tr")) top="right";
    if(options.find("bl"))
    {
      bottom="both";
      if(!options.find("br")) bottom="left";
    }
    else if(options.find("br")) bottom="right";
  }
  if(top=="" && bottom=="" && !options.find("none")){top="both";bottom="both";}
  v=getElementsBySelector(selector);
  for(i=0;i<v.length;i++)
  {
    FixIE(v[i]);
    if(top!="") AddTop(v[i],top,options);
    if(bottom!="") AddBottom(v[i],bottom,options);
  }
}

function AddTop(el,side,options)
{
  var d=CreateEl("b",el.id+'main'),lim=4,border="",p,i,btype="r",bk,color;
  d.style.marginLeft="-"+getPadding(el,"Left")+"px";
  d.style.marginRight="-"+getPadding(el,"Right")+"px";
  if(options.find("alias") || ((color=getBk(el))=="transparent" && !options.find("outline")))
  {
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
  }
  else
  {
    bk=getParentBk(el); border=Mix(color,bk);
  }
  d.style.background=bk;
  d.className="niftycorners";
  p=getPadding(el,"Top");
  if(options.find("small"))
  {
    d.style.marginBottom=(p-2)+"px";
    btype+="s"; lim=2;
  }
  else if(options.find("big"))
  {
    d.style.marginBottom=(p-10)+"px";
    btype+="b"; lim=8;
  }
  else 
    d.style.marginBottom=(p-5)+"px";
  for(i=1;i<=lim;i++)
    d.appendChild(CreateStrip(el.id,i,side,color,border,btype));
  el.style.paddingTop="0";
  el.insertBefore(d,el.firstChild);
}

function AddBottom(el,side,options)
{
  var d=CreateEl("b",el),lim=4,border="",p,i,btype="r",bk,color;
  d.style.marginLeft="-"+getPadding(el,"Left")+"px";
  d.style.marginRight="-"+getPadding(el,"Right")+"px";
  if(options.find("alias") || (color=getBk(el))=="transparent")
  {
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
  }
  else
  {
    bk=getParentBk(el); border=Mix(color,bk);
  }
  d.style.background=bk;
  d.className="niftycorners";
  p=getPadding(el,"Bottom");
  if(options.find("small"))
  {
    d.style.marginTop=(p-2)+"px";
    btype+="s"; lim=2;
  }
  else if(options.find("big"))
  {
    d.style.marginTop=(p-10)+"px";
    btype+="b"; lim=8;
  }
  else d.style.marginTop=(p-5)+"px";
  for(i=lim;i>0;i--)
    d.appendChild(CreateStrip(el.id,i,side,color,border,btype));
  el.style.paddingBottom=0;
  el.appendChild(d);
}

function CreateStrip(id,index,side,color,border,btype)
{
  var x=CreateEl("b",id+index);
  x.className=btype+index;
  x.style.backgroundColor=color;
  x.style.borderColor=border;
  if(side=="left")
  {
    x.style.borderRightWidth="0";
    x.style.marginRight="0";
  }
  else if(side=="right")
  {
    x.style.borderLeftWidth="0";
    x.style.marginLeft="0";
  }
  return(x);
}

function CreateEl(x,id)
{
  var y=document.createElement(x);
  y.id=id;
  return(y);
}

function FixIE(el)
{
  if(el.currentStyle!=null && el.currentStyle.hasLayout!=null && el.currentStyle.hasLayout==false)
    el.style.display="inline-block";
}

function SameHeight(selector,maxh)
{
  var i,v=selector.split(","),t,j,els=[],gap;
  for(i=0;i<v.length;i++)
  {
    t=getElementsBySelector(v[i]);
    els=els.concat(t);
  }
  for(i=0;i<els.length;i++)
  {
    if(els[i].offsetHeight>maxh) maxh=els[i].offsetHeight;
    els[i].style.height="auto";
  }
  for(i=0;i<els.length;i++)
  {
    gap=maxh-els[i].offsetHeight;
    if(gap>0)
    {
      t=CreateEl("b",els[i].id+'fix'+i);t.className="niftyfill";t.style.height=gap+"px";
      nc=els[i].lastChild;
      if(nc.className=="niftycorners")
          els[i].insertBefore(t,nc);
      else 
          els[i].appendChild(t);
    }
  }
}

function getElementsBySelector(selector)
{
  var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c;
  if(selector.find("#"))
  { //id selector like "tag#id"
    if(selector.find(" "))
    {  //descendant selector like "tag#id tag"
      s=selector.split(" ");
      var fs=s[0].split("#");
      if(fs.length==1) return(objlist);
      f=document.getElementById(fs[1]);
      if(f)
      {
        v=f.getElementsByTagName(s[1]);
        for(i=0;i<v.length;i++) objlist.push(v[i]);
      }
      return(objlist);
    }
    else
    {
      s=selector.split("#");
      tag=s[0];
      selid=s[1];
      if(selid!="")
      {
        f=document.getElementById(selid);
        if(f) objlist.push(f);
        return(objlist);
      }
    }
  }
  if(selector.find("."))
  {      //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    if(selclass.find(" "))
    {   //descendant selector like tag1.classname tag2
      s=selclass.split(" ");
      selclass=s[0];
      tag2=s[1];
    }
  }
  var v=document.getElementsByTagName(tag);  // tag selector like "tag"
  if(selclass=="")
  {
    for(i=0;i<v.length;i++) objlist.push(v[i]);
    return(objlist);
  }
  for(i=0;i<v.length;i++)
  {
    c=v[i].className.split(" ");
    for(j=0;j<c.length;j++)
    {
      if(c[j]==selclass)
      {
        if(tag2=="") objlist.push(v[i]);
        else
        {
          v2=v[i].getElementsByTagName(tag2);
          for(k=0;k<v2.length;k++) objlist.push(v2[k]);
        }
      }
    }
  }
  return(objlist);
}

function getParentBk(x)
{
  var el=x.parentNode,c;
  while(el.tagName.toUpperCase()!="HTML" && (c=getBk(el))=="transparent")
    el=el.parentNode;
  if(c=="transparent") c="#FFFFFF";
  return(c);
}

function getBk(x)
{
  var c=getStyleProp(x,"backgroundColor");
  if(c==null || c=="transparent" || c.find("rgba(0, 0, 0, 0)"))
    return("transparent");
  if(c.find("rgb")) c=rgb2hex(c);
  return(c);
}

function getPadding(x,side)
{
  var p=getStyleProp(x,"padding"+side);
  if(p==null || !p.find("px")) return(0);
  return(parseInt(p));
}

function getStyleProp(x,prop)
{
  if(x.currentStyle)
    return(x.currentStyle[prop]);
  if(document.defaultView.getComputedStyle)
    return(document.defaultView.getComputedStyle(x,'')[prop]);
  return(null);
}

function rgb2hex(value)
{
  var hex="",v,h,i;
  var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
  var h=regexp.exec(value);
  for(i=1;i<4;i++)
  {
    v=parseInt(h[i]).toString(16);
    if(v.length==1) hex+="0"+v;
    else hex+=v;
  }
  return("#"+hex);
}

function Mix(c1,c2)
{
  var i,step1,step2,x,y,r=new Array(3);
  if(c1.length==4)step1=1;
  else step1=2;
  if(c2.length==4) step2=1;
  else step2=2;
  for(i=0;i<3;i++)
  {
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    r[i]=r[i].toString(16);
    if(r[i].length==1) r[i]="0"+r[i];
  }
  return("#"+r[0]+r[1]+r[2]);
}


function disable_screen(screen,w,h)
{
  var x,y,t,l,b;
  if (self.innerHeight) // all except Explorer
  {
        x = self.innerWidth;
        y = self.innerHeight;
        t = window.pageYOffset;
        if(document.body.scrollHeight)
          b=document.body.scrollHeight
        if(document.documentElement&&document.documentElement.scrollHeight)
          b = document.documentElement.scrollHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight)
        // Explorer 6 Strict Mode
  {
        x = document.documentElement.clientWidth;
        y = document.documentElement.clientHeight;
        t = document.documentElement.scrollTop;
        b = document.documentElement.scrollHeight;
  }
  else if (document.body) // other Explorers
  {
        x = document.body.clientWidth;
        y = document.body.clientHeight;
        t = document.body.scrollTop;
        b = document.body.scrollHeight;
  }

  var a=document.getElementById('disable_screen');

  a.style.visibility='visible';
  a.style.display='block';
  a.style.height=b+'px';
  a.style.width=x+'px';
  var b=document.getElementById(screen);
  b.style.visibility='visible';
  b.style.display='block';
  b.style.top=t+Math.round(y/2-h/2)+'px';
  b.style.left=Math.round(x/2-w/2)+'px';
}

function enable_screen(screen)
{
  var x=document.getElementById('disable_screen');
  x.style.visbility='hidden';
  x.style.display='none';
  var y=document.getElementById(screen);
  y.style.visbility='hidden';
  y.style.display='none';
}

function move_item_up(id,cpid)
{
  var sel=document.getElementById(id);
  var cpl=document.getElementById(cpid);
  var retval=true;

  //DETECT IF ITEM IS SELECTED
  if(sel.selectedIndex==-1)
  { retval=false; code=1; }

  //DETECT IF WE ARE AT THE TOP OF THE LIST
  if(sel.selectedIndex==0)
  { retval=false; code=2; }
 
  if(retval)
  {
    swap_options(cpl,sel,sel.selectedIndex,sel.selectedIndex-1); 
    sel.selectedIndex-=1; 
  }
  
  if(!retval)
  {
    if(code==1)
      alert("You must select an Item to move");
    if(code==2)
      alert("You cannot move this item up anymore");
  }
  return retval;
}

function move_item_down(id,cpid)
{
  var sel=document.getElementById(id);
  var cpl=document.getElementById(cpid);
  var retval=true;
 
  //DETECT IF ITEM IS SELECTED
  if(sel.selectedIndex==-1)
  { retval=false; code=1; }

  //DETECT IF WE ARE AT THE END
  if(sel.selectedIndex==sel.options.length-1)
  { retval=false; code=2; }

  if(retval)
  { 
    swap_options(cpl,sel,sel.selectedIndex,sel.selectedIndex+1);
    sel.selectedIndex+=1; 
  }

  if(!retval)
  {
    if(code==1)
      alert("You must select an Item to move");
    if(code==2)
      alert("You cannot move this item down anymore");
  }
  return retval;
}

function swap_options(olist,list,a,b)
{
  var tmp_text;
  var tmp_value;
  tmp_text=list.options[a].text;
  tmp_value=list.options[a].value;
  list.options[a].text=list.options[b].text;
  list.options[a].value=list.options[b].value;
  list.options[b].text=tmp_text;
  list.options[b].value=tmp_value;
    
  var s=new String(olist.value);
  var tmp;
  s=s.split(",");
  tmp=s[a];    
  s[a]=s[b];
  s[b]=tmp;
  olist.value=s.join(",");
} 

var MD5 = function (string) {
 
	function RotateLeft(lValue, iShiftBits) {
		return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
	}
 
	function AddUnsigned(lX,lY) {
		var lX4,lY4,lX8,lY8,lResult;
		lX8 = (lX & 0x80000000);
		lY8 = (lY & 0x80000000);
		lX4 = (lX & 0x40000000);
		lY4 = (lY & 0x40000000);
		lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
		if (lX4 & lY4) {
			return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
		}
		if (lX4 | lY4) {
			if (lResult & 0x40000000) {
				return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
			} else {
				return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
			}
		} else {
			return (lResult ^ lX8 ^ lY8);
		}
 	}
 
 	function F(x,y,z) { return (x & y) | ((~x) & z); }
 	function G(x,y,z) { return (x & z) | (y & (~z)); }
 	function H(x,y,z) { return (x ^ y ^ z); }
	function I(x,y,z) { return (y ^ (x | (~z))); }
 
	function FF(a,b,c,d,x,s,ac) {
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
		return AddUnsigned(RotateLeft(a, s), b);
	};
 
	function GG(a,b,c,d,x,s,ac) {
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
		return AddUnsigned(RotateLeft(a, s), b);
	};
 
	function HH(a,b,c,d,x,s,ac) {
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
		return AddUnsigned(RotateLeft(a, s), b);
	};
 
	function II(a,b,c,d,x,s,ac) {
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
		return AddUnsigned(RotateLeft(a, s), b);
	};
 
	function ConvertToWordArray(string) {
		var lWordCount;
		var lMessageLength = string.length;
		var lNumberOfWords_temp1=lMessageLength + 8;
		var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
		var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
		var lWordArray=Array(lNumberOfWords-1);
		var lBytePosition = 0;
		var lByteCount = 0;
		while ( lByteCount < lMessageLength ) {
			lWordCount = (lByteCount-(lByteCount % 4))/4;
			lBytePosition = (lByteCount % 4)*8;
			lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
			lByteCount++;
		}
		lWordCount = (lByteCount-(lByteCount % 4))/4;
		lBytePosition = (lByteCount % 4)*8;
		lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
		lWordArray[lNumberOfWords-2] = lMessageLength<<3;
		lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
		return lWordArray;
	};
 
	function WordToHex(lValue) {
		var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
		for (lCount = 0;lCount<=3;lCount++) {
			lByte = (lValue>>>(lCount*8)) & 255;
			WordToHexValue_temp = "0" + lByte.toString(16);
			WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
		}
		return WordToHexValue;
	};
 
	function Utf8Encode(string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	};
 
	var x=Array();
	var k,AA,BB,CC,DD,a,b,c,d;
	var S11=7, S12=12, S13=17, S14=22;
	var S21=5, S22=9 , S23=14, S24=20;
	var S31=4, S32=11, S33=16, S34=23;
	var S41=6, S42=10, S43=15, S44=21;
 
	string = Utf8Encode(string);
 
	x = ConvertToWordArray(string);
 
	a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
 
	for (k=0;k<x.length;k+=16) {
		AA=a; BB=b; CC=c; DD=d;
		a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
		d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
		c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
		b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
		a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
		d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
		c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
		b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
		a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
		d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
		c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
		b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
		a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
		d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
		c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
		b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
		a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
		d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
		c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
		b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
		a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
		d=GG(d,a,b,c,x[k+10],S22,0x2441453);
		c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
		b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
		a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
		d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
		c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
		b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
		a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
		d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
		c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
		b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
		a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
		d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
		c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
		b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
		a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
		d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
		c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
		b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
		a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
		d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
		c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
		b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
		a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
		d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
		c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
		b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
		a=II(a,b,c,d,x[k+0], S41,0xF4292244);
		d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
		c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
		b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
		a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
		d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
		c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
		b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
		a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
		d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
		c=II(c,d,a,b,x[k+6], S43,0xA3014314);
		b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
		a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
		d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
		c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
		b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
		a=AddUnsigned(a,AA);
		b=AddUnsigned(b,BB);
		c=AddUnsigned(c,CC);
		d=AddUnsigned(d,DD);
	}
 
	var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);
 
	return temp.toLowerCase();
}

