/**
* $Id: functions.js,v 1.2.2.5.2.1 2006/03/04 10:45:41 Exp $
*
* Some JavaScript functions used in the admin backend
* @since        2003-11-13
*/

function Picture(pic, title, width, height, top, left)
{
    popup = window.open(pic, title, 'width='+width+', height='+height+', top='+top+', left='+left+', toolbar=no, directories=no, status=no, scrollbars=no, resizable=yes, menubar=no');
    popup.focus();
}

function checkAll(checkBox)
{
    var v = checkBox.checked;
    var f = checkBox.form;
    for (var i = 0; i < f.elements.length; i++) {
        if (f.elements[i].type == "checkbox") {
            f.elements[i].checked = v;
            }
        }
}

function addEngine(uri, name, ext, cat)
{
    if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
        window.sidebar.addSearchEngine(uri+"/"+name+".src", uri+"/images/"+name+"."+ext, name, cat);
    } else {
        alert('Mozilla Firefox, Mozilla or Netscape 6 or later is needed to install the search plugin!');
    }
}

function focusOnUsernameField()
{
    if (document.forms[0] && document.forms[0].elements["username"]) {
        document.forms[0].elements["username"].focus();
    }
}

function showhideCategory(id)
	{
		if (document.getElementById(id).style.display == 'none')
			{
				document.getElementById(id).style.display = 'block';
			}
		else
			{
				document.getElementById(id).style.display = 'none';
			}
	}

<!--
if(document.all && !document.getElementById) { //IE4 support
  document.getElementById = function(id) { return document.all[id]; }
}
function customOption(selected) { //selected is the selected option
  if(!document.getElementById) return;

  // selected's value property is retrieved and converted to lower case to make 
  // comparing it to another string simpler
  var val = selected.value.toLowerCase();

  // gets the object reference for the element
  var el = document.getElementById('othersmartlabel');

  // if val is set to 'customoption' show the textbox
  if(val == '6'){el.style.display='block';}else{ // otherwise hide it or keep it hidden.
    el.style.display='none';
  }
}
function dss_addLoadEvent(fn) {
  if(typeof(fn)!="function")return;
  var tempFunc=window.onload;
  window.onload=function() {
    if(typeof(tempFunc)=="function")tempFunc();
    fn();
  }
}
dss_addLoadEvent(function() {
  // we find the form element and the select element and attach the event 
  // handlers to them
  var f = document.form1;
  // this next line of code is used to prevent this demo from being submitted
  // remove it or change it as needed
  f.onsubmit = function(){return false;}
  var sel = f.compsmart;
  sel.onchange=function(){customOption(this.options[this.selectedIndex])}
  // we call the function when the page loads to hide #other1label initially
  sel.onchange();
});
// -->
