
Element.extend({show:function(){this.setStyle("display","");},
                hide:function(){this.setStyle("display","none");}});


/** 
Register a namespace in the window scope.
Every class using namespaces <b>must</b> call this function prior the class definition
@function ? 
@param {string} ns - Name of the namespace to register.
*/
function Namespace(ns)
{
 var nsParts = ns.split(".");
 var root = window;

 for(var i=0; i<nsParts.length; i++)
 {
  if(typeof root[nsParts[i]] == "undefined"){root[nsParts[i]] = {};}
  root = root[nsParts[i]];
 }
}

/**
Extends the built-in Function object with a method that alleviates the creation of methods.
If the method already exists, it's override by the new implementation.
@function addMethod
@param {string} name -  Name of the method to add.
@param {Function} fn -  Function that provides the implementation of the method.
*/
Function.prototype.addMethod = function(name, fn) {
  this.prototype[name] = fn;
  return this;
};

/**
Extends the built-in Function object with a method that alleviates the removal of methods .
@function removeMethod
@param {string} name -  Name of the method to remove.
@returns A reference to itself in order to facilitate <b>chaining</b>.
*/
Function.prototype.removeMethod = function(name) {
  this.prototype[name] = null;
  return this;
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////// DT.UTILS ///////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/**
Namespace containing common functions and class definitions
@namespace dt.utils
*/
Namespace("dt.utils");

/**
@scope dt.utils
*/

/** 
Provides an efficient way of concatening strings.
@class dt.utils.StringBuilder 
*/

/**
@constructor StringBuilder 
@returns A new instance of StringBuilder
*/
dt.utils.StringBuilder=function(){
    /**
     * Array holding the strings.
     * @var {private string} _strings
     */
    this._strings=[];
};
/**
Adds a string to concatenat
@function {void} append 
@param {string} str - string to concatenate.
*/
dt.utils.StringBuilder.addMethod("append",function(str){this._strings.push(str);});

/**
Removes the last string added to the builder
@function {void} removeLast 
*/
dt.utils.StringBuilder.addMethod("removeLast",function(str){this._strings.pop();});

/**
@function {string} toString Concatenate the strings appended via the append method
@returns A concatenated string
*/
dt.utils.StringBuilder.addMethod("toString",function(){return this._strings.join("");});    



 /*/
/ /  Author: Jeremy Falcon
/ /    Date: November 08, 2001
/ / Version: 1.4
/*/

/*/ THIS FILE CONTAINS FUNCTIONS THAT WILL WRAP THE POP-UP PROCESS /*/

// this variable will hold the window obect
// we only allow one pop-up at a time
var popup = null;

/*/
/ / PURPOSE:
/ /		To create and center a pop-up window.
/ /
/ / COMMENTS:
/ /		It will replace to old pop-up if called
/ / 	without calling DestroyWnd() first..
/*/

dt.utils.CreateWnd=function(file, title,width, height, resize)
{
	var doCenter = false;

	if((popup == null) || popup.closed)
	{
		attribs = "";

		/*/ there's no popup displayed /*/

		// assemble some params
		if(resize) size = "yes"; else size = "no";

		/*/
		/ / We want to center the pop-up; however, to do this we need to know the
		/ / screen size.  The screen object is only available in JavaScript 1.2 and
		/ / later (w/o Java and/or CGI helping), so we must check for the existance
		/ / of it in the window object to determine if we can get the screen size.
		/ /
		/ / It is safe to assume the window object exists because it was implemented
		/ / in the very first version of JavaScript (that's 1.0).
		/*/
		for(var item in window)
			{ if(item == "screen") { doCenter = true; break; } }

		if(doCenter)
		{	/*/ center the window /*/

			// if the screen is smaller than the window, override the resize setting
			if(screen.width <= width || screen.height <= height) size = "yes";

			WndTop  = (screen.height - height) / 2;
			WndLeft = (screen.width  - width)  / 2;

			// collect the attributes
			attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars= yes ," + 
			"status=no,toolbar=no,directories=no,menubar=no,location=no,top=" + WndTop + ",left=" + WndLeft;
		}
		else
		{
			/*/
			/ / There is still one last thing we can do for JavaScrpt 1.1
			/ / users in Netscape.  Using the AWT in Java we can pull the
			/ / information we need, provided it is enabled.
			/*/
			if(navigator.appName=="Netscape" && navigator.javaEnabled())
			{	/*/ center the window /*/

				var toolkit = java.awt.Toolkit.getDefaultToolkit();
				var screen_size = toolkit.getScreenSize();

				// if the screen is smaller than the window, override the resize setting
				if(screen_size.width <= width || screen_size.height <= height) size = "yes";

				WndTop  = (screen_size.height - height) / 2;
				WndLeft = (screen_size.width  - width)  / 2;

				// collect the attributes
				attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," + 
				"status=no,toolbar=no,directories=no,menubar=no,location=no,top=" + WndTop + ",left=" + WndLeft;
			}
			else
			{	/*/ use the default window position /*/

				// override the resize setting
				size = "yes";

				// collect the attributes
				attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," + 
				"status=no,toolbar=no,directories=no,menubar=no,location=no";
			}
		}

		// create the window
		popup = open(file, title, attribs);
	}
	else
	{
		// destory the current window
		dt.utils.DestroyWnd();
		// recurse, just once, to display the new window
		dt.utils.CreateWnd(file,title, width, height, resize);
	}
}

/*/
/ / PURPOSE:
/ /		To destroy the pop-up window.
/ /
/ / COMMENTS:
/ /		This is available if wish to destroy
/ / 	the pop-up window manually.
/*/

dt.utils.DestroyWnd=function()
{
	// close the current window
	if(popup != null)
	{
		popup.close();
		popup = null;
	}
}   


/**
 * @end
 */

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////// DT.UTILS.CONTROLS  ////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
Namespace containing common functions and classes for validation
@namespace dt.utils.controls
*/
Namespace("dt.utils.controls");

/**
@scope dt.utils.controls
*/

/*Shows a confirm message*/
dt.utils.controls.ConfirmBox=function(msg)
{
	if (confirm(msg) == true){
		return true;
		}
	else{
		return false;
		}
}
dt.utils.controls.AddOptionItem=function(list,item,selectItem){
        try {
		    list.add(item, null); // standards compliant; doesn't work in IE
	    }
	    catch(ex) {
		    list.add(item); // IE only
	    }
	    if(!selectItem)
    	    list.selectedIndex=-1;
};

dt.utils.controls.SelectionList={};
dt.utils.controls.SelectionList.Move=function(sourceList,destList,hiddenField){
        var source=$(sourceList);
        var destination=$(destList);
        
        for (i =0;i<= (source.length-1); i++) {
	
		    if(source.options[i]!=null)
		    {
			    if (source.options[i].selected) 
			    {
				    var item = document.createElement('option');
	                item.text = source.options[i].text;
	                item.value =source.options[i].value;			
	                
	                dt.utils.controls.AddOptionItem(destination,item,false);
			    }
		    }
	    }
	    
	    for (i = source.length - 1; i>=0; i--){
		    if(source.options[i]!=null){
			    if (source.options[i].selected){
			        source.options[i]=null;
			    }
		    }
	    }
   	    source.selectedIndex=-1;  
	    
	    dt.utils.controls.SelectionList.UpdateHiddenField(destination,hiddenField);
};

dt.utils.controls.SelectionList.UpdateHiddenField=function(sourceList,hiddenField){

   var list=$(sourceList);
   var hidden=$(hiddenField);
   var totalItems = list.options.length;
    
   hidden.value = "";
   for (i = 0; i < totalItems; i++)
        if (hidden.value.length == 0)
            hidden.value += list.options[i].value +"/"+list.options[i].text;
        else
            hidden.value += "#" + list.options[i].value +"/"+list.options[i].text;

};

/**
 * @end
 */
 
 
