function addreview(id, button, action)
{
	$(button + id).style.display = 'none';
	$(action + ++id).style.display = 'block';
}

function ChangeFlag()
{
	var x = $("flag");
	var cs = $("Country");
	image = cs.options[cs.selectedIndex].value;
	if (image) 
			x.src = 'img/flags/' + image + '.GIF';
}

function Part(textarea) {
  Part.parts.push(this);
  this.textarea = textarea;
  this.textarea.style.overflow = 'hidden';

  this.element = document.createElement('div');

  var s = this.element.style;
  var getStyle = YAHOO.util.Dom.getStyle;
  s.visibility = 'hidden';
  s.position = 'absolute';
  s.zIndex = '1';
  s.fontFamily = getStyle(this.textarea, 'fontFamily');
  s.fontSize = getStyle(this.textarea, 'fontSize');
  s.fontStyle = getStyle(this.textarea, 'fontStyle');
  s.fontVariant = getStyle(this.textarea, 'fontVariant');
  this.textarea.parentNode.insertBefore(this.element, this.textarea);
  this.copyToElement();
  this.resizeTextarea();
}

Part.parts = [];

Part.prototype.copyToElement = function() {
  /* The non-breaking space insures Safari will resize box even when
     the last characters in the textarea are new line characters. */
  this.element.innerHTML = this.textarea.value.replace(/\n/g,'<br />') + '&nbsp;';
};

Part.prototype.resizeTextarea = function() {
  this.copyToElement();
  this.syncRegions();
  this.setTimeout();
};

Part.prototype.setTimeout = function() {
  var thisC = this;
  this.timeout = setTimeout(function() {thisC.resizeTextarea();}, 300);      
};

Part.prototype.syncRegions = function() {
  var a = parseInt(YAHOO.util.Dom.getStyle(this.textarea, 'fontSize').split('px',1)[0], 10);
  var rt =  YAHOO.util.Dom.getRegion(this.textarea);
  this.element.style.width = (rt.right-rt.left)+'px';
  var re =  YAHOO.util.Dom.getRegion(this.element);
  this.textarea.style.height = (re.bottom-re.top+a*1.5)+'px';
};


function find_parts() {
  var the_form = document.getElementById('my_form');
  if(the_form != null)
  {
	var es = the_form.elements;
	for (var i=0; i<es.length; i++) {
	  if (es[i].tagName.toLowerCase() !== 'textarea') {continue;}
	  new Part(es[i]);
	}
  }
}
YAHOO.util.Event.addListener(window, "load", find_parts);
