function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function toCount(entrance,exit,text,characters) {
  var entranceObj=getObject(entrance);
  var exitObj=getObject(exit);
  var length=characters - entranceObj.value.length;
  if(length <= 0) {
    length=0;
    text='<span class="disable"> '+text+' </span>';
    entranceObj.value=entranceObj.value.substr(0,characters);
  }
  exitObj.innerHTML = text.replace("{CHAR}",length);
}

/* ----- Popup Function ------ */
// How to USE
// javascript:popup('map.htm','550','540');
			
function popup(url,w,h) {
	var x = (screen.availWidth / 2) - (document.body.clientWidth / 2);
	var y = ((screen.availHeight - 60) / 2) - (document.body.clientHeight / 2);
	x = (x > 0) ? x : 0;
	y = (y > 0) ? y : 0;
	window.open( url, "myWindow","status = 1,  width =" +  w + ", height =" + h + " ,resizable = 0")
	//window.moveTo(x, y);
}
