var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById &&!document.all
var crossobj;

function initializeCrossObject(index)
{
if (ns4)
crossobj=document.layers.reviewnote
else if (ie4||ns6)
crossobj=document.getElementById("reviewnote"+ index)
}

function close_review_note(){
if (ie4||ns6) {
crossobj.style.visibility="hidden";
noteObject.notearea.style.visibility="hidden";
}
else if (ns4) {
crossobj.visibility="hide";
noteObject.notearea.style.visibility="hide";
}
}

function show_review_note(){  

if (arguments.length == 1 && !isNaN(arguments[0]))
{
  initializeCrossObject(arguments[0]);
  noteObject = document.getElementById('note' + arguments[0]);
  reviewTable = document.getElementById('userreviewtable' + arguments[0]);
}
else
  noteObject = document.getElementById('note');

if (ie4||ns6) {
crossobj.style.visibility="visible";
noteObject.notearea.style.visibility="visible";
}
else if (ns4) {
crossobj.visibility="show";
noteObject.notearea.style.visibility="show";
}

noteObject.notearea.focus();
}

var has_changed = false;

function save_note(listing_url) {

  if (arguments.length == 2 && !isNaN(arguments[1]) && arguments[1] > 0)
  {
    var frm = document.getElementById('note' + arguments[1]);
  }
  else
  {
    var frm = document.getElementById('note');
  }
  var original_length = frm.elements['notearea'].value.length;

  new_length = frm.elements['notearea'].value.length;
  if(new_length == original_length && !has_changed) {
    close_review_note();
  }

  url=listing_url+"?action=savenote&user_name="+ frm.elements['user_name'].value +"&item_id=" + frm.elements['item_id'].value+ "&notearea="+escape(frm.elements['notearea'].value);
  if(xmlhttp) {
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null)
    close_review_note();
    return false;
  }
  else {
    document.note.submit();
  }
}
function close_note() {
    close_review_note();
}
