

//form field names:
//Keywords - text field

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

var helpDoc = MM.HELP_inspKeywords;


// ******************** 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()=="keywords");
}

function inspectSelection(){

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

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

  if (getSelectedObj().getAttribute("content"))	 
    findObject("Keywords").value= getSelectedObj().getAttribute("content");
  else
    findObject("Keywords").value="";
  showHideTranslated();
}

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


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

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


