//form field names:
//metaAttribute - drop down menu - name is [0] and http is [1]
//metaValue - text field
//metaContent - text field

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

var helpDoc = MM.HELP_inspMeta;

// ******************** API ****************************
function canInspectSelection(){
  metaObj = getSelectedObj();
  return (metaObj.tagName && metaObj.tagName=="META");
}

function inspectSelection(){

  var metaObj = getSelectedObj();
  if (String(metaObj.tagName) == "undefined") return; 
  var metaValue = findObject("metaValue");
  var metaAttribute = findObject("metaAttribute");
  var metaContent = findObject("metaContent");
  var useNameAttr = metaObj.getAttribute("name") || metaObj.getAttribute("name")=="";
  var thisContent = metaObj.getAttribute("content");
  var thisAttribute;
  

 //fill in PI
  metaAttribute.selectedIndex = (useNameAttr)?0:1;
  if (useNameAttr){
    thisAttribute = metaObj.getAttribute("name");
	findObject("metaImage").src="name.gif";
  }
  else{
    thisAttribute = metaObj.getAttribute("http-equiv");	
	findObject("metaImage").src="http.gif";
  }	
	
  //fill in attribute value if present, otherwise fill text field with empty string	
  findObject("metaValue").value = thisAttribute;	
  //fill in meta content if present, otherwise fill text field with empty string
  if (metaObj.getAttribute("content") || metaObj.getAttribute("content")=="")
    metaContent.value = (thisContent)?thisContent:"";
  showHideTranslated();	
}




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

function setMetaTag(){
  var metaObj=getSelectedObj();
  var metaValue = findObject("metaValue").value;
 
  if (findObject("metaAttribute").selectedIndex==0){
    metaObj.removeAttribute("http-equiv");
    metaObj.setAttribute("name",metaValue);
  } else {
    metaObj.removeAttribute("name");
    metaObj.setAttribute("http-equiv",metaValue);
  }
   //attribute is removed and then re-applied so that content attribute
   //always appears after name and http-equiv attributes
   metaObj.removeAttribute("content"); 
   metaObj.setAttribute("content",findObject("metaContent").value);
 
   var dom = dreamweaver.getDocumentDOM("document");
   if (dom &&
		(findObject("metaAttribute").selectedIndex==1) &&	// set to http-equiv 
		 metaValue.toLowerCase() ==  "content-type") 
   {
	   dom.setCharSet(findObject("metaContent").value);  // this causes dreamweaver to recognize the changes to the encoding and update the fonts in the code view
	} 
}





