//------------------------------------------------------------------------------------------------
// PROPERTIES
//------------------------------------------------------------------------------------------------
function onPropertyFieldEnter(id)
{
  if(id == "txtKey")
    changeProperty("NODEKEY",document.getElementById("txtKey").value );
  if(id == "txtExternal")
    changeProperty("TAG",document.getElementById("txtExternal").value );
  if(id == "txtFormat")
    changeProperty("TAG2",document.getElementById("txtFormat").value );
  //if(id == "txtImage")
  //  changeProperty("IMAGE",document.getElementById("txtImage").value );
}

function onVisibleChange(combo)
{
  changeProperty("VISIBLE",combo.value);
}

function changeProperty(name, value, value2)
{
  try {
    if(selectedNode == null) {
      return;
    }
    var ajax = new Ajax();
    ajax.callback = __ajax_callback;
    ajax.tag = selectedNode;
    ajax.tag2 = name;
    ajax.tag3 = value;
    if(value2)
      ajax.tag4 = value2;
    var aParams = new Array();
    aParams[0] = ajax.createParam("key","CHANGEPROPERTY");
    aParams[1] = ajax.createParam("param1",selectedNode.key);
    aParams[2] = ajax.createParam("param2",name);
    aParams[3] = ajax.createParam("param3",value);
    aParams[4] = ajax.createParam("param4",selectedNode.key);
    ajax.request(webRoot + "application/server.aspx?r=" + Math.random(),aParams);
  } catch(e) {
    log("changeProperty",e,"");
  }

}

function propertyInit()
{
  try {
    // draw node icon and text
    document.getElementById("imgNodeIcon").src = imagePath + "empty.gif";
    document.getElementById("lblNodeText").innerHTML = "";
    
    //document.getElementById("txtExternal").disabled = true;

    // set properties
    document.getElementById("txtID").innerHTML = ""; 
    comboSet(document.getElementById("cmbVisible"),"1");
    document.getElementById("txtKey").value = ""; 
    document.getElementById("txtExternal").value = ""; 
    document.getElementById("txtFormat").innerHTML = ""; 
    document.getElementById("txtImage").innerHTML = ""; 
    document.getElementById("txtChangeDate").innerHTML = ""; 
    document.getElementById("txtCreationDate").innerHTML = ""; 
  } catch(e) {
    log("propertyInit",e,"");
  }
}

function propertySelectImage()
{
  if(selectedNode){
    if(browser.ie)
      //openDialogWindow("400","330","open_dialog.aspx?mode=image&name=" + document.getElementById("txtImage").innerHTML);
      window.showModalDialog("open_dialog.aspx?mode=image&name=" + document.getElementById("txtImage").innerHTML,window,"dialogHeight:330px;dialogWidth:400px;resizable:1;status:0;scroll:0");
    else
      openDialogWindow("400","335","open_dialog.aspx?mode=image&name=" + document.getElementById("txtImage").innerHTML);
  } else {
    alert(getString(10008));
  }
}

function openDialogSave(name, url)
{
  try {
    changeProperty("IMAGE",name,url);
  } catch(e) {
    log("openDialogSave",e,"");
  }
}

function propertySelectFormat()
{
  if(selectedNode) {
    if(browser.ie)  
      openDialogWindow("310","320","property_format.aspx?id=" + selectedNode.key + "&r=" + Math.random());
    else
      openDialogWindow("310","335","property_format.aspx?id=" + selectedNode.key + "&r=" + Math.random());
  } else {
    alert(getString(10008));
  }
}

function dialogFormatSave(style)
{
  try {
    changeProperty("TAG2",style);
  } catch(e) {
    log("dialogFormatSave",e,"");
  }
}

