function set_action(param, act)
{
  param.form.act.value = act;
  param.form.target = '_self';
  param.form.submit();
}

function select_all(param)
{
    form_length = param.form.length
    for (i=0;i<form_length;i++)
    {
		if (param.form[i].type == 'checkbox')
        {
            param.form[i].checked = param.form['p_all'].checked
        }
    }
}

function check_max_input(param, index, max_length)
{
    if (param.form(index).value.length > max_length)
    {
	    param.form(index).value = param.form(index).value.substring(0,max_length);
    }
}

function disable_form_element(frm, str_element)
{
	elements = str_element.split(',');
	for (i=0; i < elements.length; i++)
	{
		frm[elements[i]].disabled = true;
	}
}

function enable_form_element(frm, str_element)
{
	elements = str_element.split(',');
	for (i=0; i < elements.length; i++)
	{
		frm[elements[i]].disabled = false;
	}
}


function jump_url(url)
{ 
    document.location = url;
}

function over(element) {
element.style.borderStyle= "solid";
element.style.borderWidth = "1px";
element.style.borderColor = "#000000";
element.style.backgroundColor = "#F1F1F1";
element.style.cursor = "hand";
}

function out(element) {
element.style.borderColor = "#CCCCCC";
element.style.backgroundColor = "#CCCCCC"
element.style.cursor = "default";
}

function cmdExec(cmd,opt,halaman) {
if (opt==null) halaman.document.execCommand(cmd);
  else halaman.document.execCommand(cmd,"",opt);
//pageHTML.document.execCommand(cmd,"",opt);
halaman.focus();
}

function createLink(halaman) {
cmdExec("CreateLink",halaman);
}

function insert(what,halaman)
{
   //DBG(1, 'insert(' + what + ')');
   // Chose action based on what is being inserted.
   switch(what)
   {
   case "table":
      strPage = "dlg_ins_table.html";
      strAttr = "status:no;dialogWidth:340px;dialogHeight:360px;help:no";
      break;
   case "smile":
      strPage = "dlg_ins_smile.html";
      strAttr = "status:no;dialogWidth:300px;dialogHeight:350px;help:no";
      break;
   case "char":
      strPage = "dlg_ins_char.html";
      strAttr = "status:no;dialogWidth:450px;dialogHeight:290px;help:no";
      break;
   case "image":
      strPage = "dlg_ins_image.php";
      strAttr = "status:no;dialogWidth:400px;dialogHeight:200px;help:no";' '
      break;
   case "about":
      strPage = "dlg_about.html";
      strAttr = "status:no;dialogWidth:500px;dialogHeight:405px;help:no";' '
      break;
   }

   // run the dialog that implements this type of element
   html = showModalDialog(strPage, window, strAttr);

   // and insert any result into the document.
   if (html) {
      insertHtml(html,halaman);
   }
}

// insertHtml(): Insert the supplied HTML into the current position
// within the document.
function insertHtml(html,halaman)
{
   halaman.focus();
   var sel = halaman.document.selection.createRange();
   // don't try to insert HTML into a control selection (ie. image or table)
   if (halaman.document.selection.type == 'Control') {
      return;
   }
   sel.pasteHTML(html);
}
