function textCounter(field,counter,maxlimit,remaincounter) {
var fieldWidth =  parseInt(field.offsetWidth);var charcnt = field.value.length;
if (charcnt > maxlimit) {field.value = field.value.substring(0, maxlimit);}
else {var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit);
document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
textCountersetcolor(document.getElementById(counter),percentage);
if (remaincounter.length > 0){ remaining = ((maxlimit - charcnt) < 0) ? 0 : (maxlimit - charcnt);
document.getElementById(remaincounter).innerHTML = remaining;}}}
function textCountersetcolor(obj,percentage){
if (percentage <1) {obj.style["backgroundColor"] = "rgb(100%,100%,100%)";}
else if  (percentage >97) {obj.style["backgroundColor"] = "rgb(100%,0%,0%)";
}
else{obj.style["backgroundColor"] = "rgb(0%,100%,0%)";}}
function textCounterlostfocus(obj){

document.getElementById(obj).style.width="0px";
document.getElementById(obj).style["backgroundColor"] = "rgb(100%,100%,100%)";
}
function change(id){document.getElementById(id.name.replace(/\$/gi, "_")).className='txtInput';}
var popupWin=null;
function openWin(url,wname,w,h){popupWin=window.open(url,"Win","width="+w+",height="+h);window.name=wname;}
function closewin(){if (popupWin !=null && popupWin.open) popupWin.close();}
window.onfocus=closewin;
var StayAlive = 15; 
function CloseMe(){setTimeout("self.close()",StayAlive * 1000);}
function sendEM(eEM){location.href="mai"+"lto:"+decodeEM(eEM);}
function displayStatus(eEM){window.status = "mai"+"lto:"+decodeEM(eEM);}
function clearStatus(){window.status="";}
function decodeEM(encodedEM){var EM = ""; for (i=0; i < encodedEM.length;){var letter="";letter= encodedEM.charAt(i) + encodedEM.charAt(i+1); EM += String.fromCharCode(parseInt(letter,16)); i += 2; }return EM;}
