// ****
function openPopUp(_Url, _Name, _Conf)
{
	var oPopup = window.open(_Url, _Name, _Conf);
}

function InitTag_setPopupArgs()
{
	// ****
	var rValue;
	
	// ****
	var property;
	var properties;
	
	// ****
	properties = Array();
	
	// ****
	for(property in this.args)
	{
		properties.push(property + "=" + this.args[property]);
	}
	
	// ****
	rValue = properties.join(",");
	
    // ****
	return rValue;
}

// ***
function InitTag_isInPrefixedCollection(sID, sPrefix)
{
	// ****
	var rValue;
	
	// ****
	var aID;
	
	// ****
	aID = sID.split("_");
	
	// ****
	rValue  = aID[0].toUpperCase() == this.idPrefix;
	
	// ****
	return rValue;
}

// ****
function InitTag_getTagCollection()
{
	// ****
	var rValue;
	
	// ***
	var tagCollection;
	
	// ****
	tagCollection = window.document.getElementsByTagName(this.tagName);
	rValue        = ( tagCollection.length > 0 ) ? tagCollection : null;
	
	// ****
	if( this.onDebugMod && (tagCollection.length == 0) )
	{
		alert("La collection recherch�e n'existe pas");
	}
	
	// ****
	return rValue;
}

// ****
function InitTag_getTagPrefixedCollection()
{
	// ****
	var rValue;
	
	// ****
	var i;
	var iMax;
	var idPrefix;
	var tagPrefixedCollection;
	var hasID;
	
	// ****
	rValue                = null;
	tagPrefixedCollection = Array();
	
	// ****
	if( this.tagCollection != null )
	{
		// ****
		iMax = this.tagCollection.length;		
		
		// ****
		for(i = 0; i < iMax; i++)
		{
			// ****
			hasID = this.tagCollection[i].id;
			
			// ****
			if( hasID && this.isInPrefixedCollection(this.tagCollection[i].getAttribute("id"), this.idPrefix) )
			{
				tagPrefixedCollection.push(this.tagCollection[i]);
			}
		}
		
		// ****
		rValue = tagPrefixedCollection;
	}
	
	// ****
	return rValue;
}
	
function InitTag_setNewProperties()
{	
	// ****
	var o;
	var i;
	var iMax;
	
	// ****
	var sHREF;
	var sURL;
	var sNAME;
	var sARGS;
	
	// ****
	if( this.tagPrefixedCollection != null )
	{
		// ****
		iMax = this.tagPrefixedCollection.length;
		
		// ****
        this.popupArgs = this.setPopupArgs();
	    
        // ****
		for(i = 0; i < iMax; i++)
		{
			// ****
			o = this.tagPrefixedCollection[i];
			
			// ****
			sURL  = o.getAttribute("href");
			sNAME = "nom";
			sARGS = this.popupArgs;
			
			// ****
			if( this.onDebugMod )
			{
				alert(i + "\nsURL : " +  sURL + "\nsNAME : " +  sNAME + "\nsARGS : " +  sARGS)
			}
			
			
			// ****
			sHREF = "javascript:openPopUp('" + sURL + "', '" + sNAME + "', '" + sARGS + "');";
			
			// ****
			o.setAttribute("title", this.newTitle.replace("{0}", o.getAttribute("title")));
			o.setAttribute("href", sHREF);
			//o.setAttribute("target", "_self");
			o.removeAttribute("target");
		}
	}
}

// ****
function InitTag_setNewProperty(_prop_name, _prop_value)
{
    // ****
    var prop_name;
    var prop_value;
    
    // ****
    if( _prop_value != "" )
    {
        // ****
        prop_name  = _prop_name.toString();
        prop_value = _prop_value.toString();
        
        // ****
        this.args[prop_name] = prop_value;
    }
}

// ****
function InitTag(_prefix)
{
	// ****
	this.tagName  = "a";
	this.idPrefix = _prefix.toUpperCase();
	this.re       = /[{]0[}]/gi;
	this.popup    = "";
	this.newTitle = "{0} (nouvelle fen\xEAtre)"; 
	this.args     = new Array();
	
	// ****
	this.args["directories"] = "0";
	this.args["location"]    = "0";
	this.args["menubar"]     = "0";
	this.args["resizable"]   = "1";
	this.args["scrollbars"]  = "1";
	this.args["status"]      = "1";
	this.args["toolbar"]     = "0";
	this.args["width"]       = "250";
	this.args["height"]      = "250";
	
	// ****
	this.onDebugMod = false;
	
	// ****
	this.setPopupArgs             = InitTag_setPopupArgs;
	this.isInPrefixedCollection   = InitTag_isInPrefixedCollection;
	this.getTagCollection         = InitTag_getTagCollection;
	this.getTagPrefixedCollection = InitTag_getTagPrefixedCollection;
	this.setNewProperties         = InitTag_setNewProperties;
	this.setNewProperty           = InitTag_setNewProperty;
	
    // ****
	this.tagCollection         = this.getTagCollection();
	this.tagPrefixedCollection = this.getTagPrefixedCollection();
}
