var hdworks = {
		
  datePickers: function(imageDir) {
	$(".date-pick").datepicker({ duration: "", showOn: "button", buttonImage: imageDir + "calendar.png", buttonImageOnly: true, buttonText: "Choose a date" });
  },

  popup: function(url, width, height) {
    window.open(url, "HDworks", "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=0,height=" + (height == undefined ? "350" : height) + ",width=" + (width == undefined ? "350" : width));
    return false;
  },

  popup2: function(url, width, height) {
    window.open(url, "HDworks", "status=1,toolbar=1,location=1,menubar=1,directories=1,resizable=1,scrollbars=1,height=" + (height == undefined ? "350" : height) + ",width=" + (width == undefined ? "550" : width));
    return false;
  },
  
  popup3: function(url, width, height) {
    window.open(url, "HDworks", "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=" + (height == undefined ? "350" : height) + ",width=" + (width == undefined ? "350" : width));
    return false;
  },
  
  //thanks http://www.formhandler.net/topic/4786/resetButton_and_FCKeditor.html
  resetEditors: function()
  {
    // If the editor API does not exist, there are no editors
    if (typeof FCKeditorAPI == "undefined") return;
  
    // Loop through all FCK instances, in case there are several editors
    for (var sEditorName in FCKeditorAPI.__Instances)
    {
      // The initial value that was set when the form was created
      // is stored in a hidden <INPUT> with the same name as the
      // editor (the editor itself is in an <IFRAME> with ___Frame
      // appended to the name.  Check whether that INPUT exists
      if (document.getElementById(sEditorName))
      {
        // Get the initial value
        var sInitialValue = document.getElementById(sEditorName).value;
    
        // Overwrite the editor's current value
        FCKeditorAPI.__Instances[sEditorName].SetHTML(sInitialValue);
      }
    }
  },
  
  describe: function(obj) {
	var s = "";
	for (var a in obj) s += a + ": " + obj[a] + "\n";
	return s;
  },
  
  selectImage: function(n, v, dir) {
    $("#hidden-" + n).val(v);
    $("#current-" + n + " img").attr("src", dir + v);
  },
  
  closePopup: function(w) {
	  w.close();
  },
  
  trim: function(str) {
    var str = str.replace(/^\s\s*/, ''),
      ws = /\s/,
      i = str.length;
    while (ws.test(str.charAt(--i)));
    return str.slice(0, i + 1);
  },
  
  toString: function(obj) {
    var s = '';
    for (var a in obj) s += a + ': ' + obj[a] + '\n';
    return s;
  }
}


