__exception_version=1;

///<Documentation>
///<Class name="Exception">
///<Constructor>
///<summary>Error constructor</summary>
///<param name="obj" type="string" required="false">
///     The name of the object throwing the error.
///</param>
///<param name="func" type="string" required="false">
///     The name of the function within the object that is throwing the error.
///</param>
///<param name="desc" type="string" required="false">
///     A brief description of the error.
///</param>
function Exception(obj,func,desc)
{
    this.Object=obj;
    this.Function=func;
    this.Description=desc;
}
///</Constructor>

///<Methods>
///<Method name="Throw">
///<summary>Throws a custom WebControl error</summary>
///<returns>HTML object</returns>
Exception.prototype.Throw=function()
{
    throw new Error("WebControl Error\nObject: "+this.Object+"\nFunction: "+this.Function+"\nDescription: "+this.Description);
} 
///</Method>

///<Method name="Attach">
///<summary>Attaches an error description to a user control</summary>
///<returns>HTML object</returns>
Exception.prototype.Attach=function(control)
{
	if(control==null)
 		return;
 		
 	if(typeof control != 'object')
 	    control = $getControl(control);
 
   if (!control.parentNode)
      return;

	if(control.className.indexOf('exception_control')<0)
   	control.className+=' exception_control';

	if ($getControl(control.id + '_exc'))
		return;
		
	var err=document.createElement('IMG');
	err.alt=this.Description;
	err.src='images/error.png';
   err.id=control.id+'_exc';
   control.parentNode.insertBefore(err, control);
   
	var space = document.createElement("SPAN");
	space.id=control.id+'_excspace';
	space.innerHTML='&nbsp';
	control.parentNode.insertBefore(space, control);
} 
///</Method>

///<Method name="Attach">
///<summary>Attaches an error description to a user control</summary>
///<returns>HTML object</returns>
Exception.prototype.Detach=function(control)
{
	if(control==null)
 		return;
 		
 	if(typeof control != 'object')
 	    control = $getControl(control);
 
   if (!control.parentNode)
      return;

   var err = $getControl(control.id + '_exc');
	if(err)
	{
		control.parentNode.removeChild(err);
		control.parentNode.removeChild($getControl(control.id + '_excspace'));
	}
	
	if(control.className.indexOf('exception_control')>=0)
   	control.className=control.className.replace(' exception_control','');
} 
///</Method>

///<Method name="IsAttached">
///<summary>Checks to see if there is an exception attached to the control</summary>
///<returns>HTML object</returns>
Exception.prototype.IsAttached=function(controlID)
{
	if(controlID==null)
 		return;
 		
 	if(typeof control == 'object')
 	    controlID = $getControl(controlID).id;

 	var err = $getControl(controlID + '_exc');
	alert(controlID+'_exc'+'/'+err);
	if(err)
		return true;
	return false;
} 
///</Method>
///</Methods>
///</Class>
///</Documentation>


