

//form field names:
//Description - text field

// *********** GLOBAL VARS *****************************

var helpDoc = MM.HELP_inspDescription;

// ******************** API ****************************
function canInspectSelection(){

  var metaObj = getSelectedObj();
  if (!metaObj || !metaObj.getAttribute) return false;

  return (metaObj.tagName && metaObj.tagName == "META" &&
          metaObj.getTranslatedAttribute("name") && 
          metaObj.getTranslatedAttribute("name").toLowerCase()=="description");
}

function inspectSelection(){
  var metaObj = getSelectedObj();
  if (!metaObj || !metaObj.getAttribute) return;
  
  var inspectorState = arguments[0],currKeyVal;
  var contentLayer = findObject("contentField");
  var contentCell = contentLayer.getElementsByTagName("TD").item(0);
  var minText= '<textarea name="Description" onBlur="setMetaTag()" '
  + 'style="width:350;height:32" rows="2" wrap="virtual"></textarea>'
  var maxText='<textarea name="Description" onBlur="setMetaTag()" '+
  'style="width:350;height:76" rows="4" wrap="virtual"></textarea>';
  //change inspector state if needed
  //the rows=X check determines whether current state is min or max
  if (inspectorState=="min"&& (findString('rows="4"',contentCell.innerHTML)||contentCell.innerHTML=="")){
    currKeyVal = findObject("Description").value;
    contentCell.innerHTML=minText;
	findObject("Description").value = currKeyVal;
  }	
  else if (inspectorState=="max" && (findString('rows="2"',contentCell.innerHTML)||contentCell.innerHTML=="")){
    currKeyVal = findObject("Description").value; 
    contentCell.innerHTML=maxText; 
	findObject("Description").value = currKeyVal;
  }
  if (getSelectedObj().getAttribute("content"))	 
    findObject("Description").value= getSelectedObj().getAttribute("content");
  else
    findObject("Description").value="";	

  showHideTranslated();
  //showHideTranslated( getSelectedObj(), 'tButtonSpan' );
}

function findString(stringToFind,stringToLookIn){
  if (stringToLookIn.indexOf(stringToFind)==-1)
    return false;
  return true;	
}


// ******************** LOCAL FUNCTIONS ****************************

function setMetaTag(){
  getSelectedObj().setAttribute("content",findObject("Description").value);
}



