// ========================================================================================================
// "Extra" - Module de changement d'une balise
//   by Extrafine (contact@extrafine.fr)
// ========================================================================================================
/*
 * Copyright (c) 2010 Extrafine
 * Version: 1.0.1 (23/12/2010)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
// ========================================================================================================
// 

function Extra(pId,pName)
{	
	// Attribut ###############################################
	this.Id = pId;
	this.Name = pName;
	this.X = 0;
	this.Y = 0;
	this.Width = 0 ;
	this.Height = 0;
	this.Frequence = 50;
	this.InExtra = false;
	this._Break = false;
	this._Move = false;
	this._Color = false;
	this._Size = false;
	this._Opacity = false;
	this._Writer = false;
	
	// Méthode ################################################
	// 	this.Constructor
	//	this.Init
	
	this.Constructor = function()
	{		
		if(typeof(ExtraMove) == 'function' && this._Move) {
			this.addMod = ExtraMove;
			this.addMod();
			delete this.addMod;
		}
		if(typeof(ExtraColor) == 'function' && this._Color) {
			this.addMod = ExtraColor;
			this.addMod();
			delete this.addMod;
		}
		if(typeof(ExtraSize) == 'function' && this._Size) {
			this.addMod = ExtraSize;
			this.addMod();
			delete this.addMod;
		}
		if(typeof(ExtraOpacity) == 'function' && this._Opacity) {
			this.addMod = ExtraOpacity;
			this.addMod();
			delete this.addMod;
		}
		if(typeof(ExtraWriter) == 'function' && this._Writer) {
			this.addMod = ExtraWriter;
			this.addMod();
			delete this.addMod;
		}
	}
	
	this.Init = function()
	{
		this.X = document.getElementById(this.Id).style.left == '' ? 0 : parseInt(document.getElementById(this.Id).style.left.replace(/px/,''));
		this.Y = document.getElementById(this.Id).style.top == '' ? 0 : parseInt(document.getElementById(this.Id).style.top.replace(/px/,''));

		if(document.getElementById(this.Id).style.width != '' || document.getElementById(this.Id).style.height != '') {
			if(document.getElementById(this.Id).style.width != '' && document.getElementById(this.Id).style.height != ''){
				
			} else if(document.getElementById(this.Id).style.width != '') {
				this.Width = parseInt(document.getElementById(this.Id).style.width.replace(/px/,''));
				this.Height = 0;
			} else if(document.getElementById(this.Id).style.height != '') { 
				this.Height = parseInt(document.getElementById(this.Id).style.height.replace(/px/,''));
				this.Width = 0;
			}
		} else {
			if(typeof(document.getElementById(this.Id).width) != 'undefined') 
				this.Width = parseInt(document.getElementById(this.Id).width);
			else
				this.Width = document.getElementById(this.Id).offsetWidth == '' ? 0 : parseInt(document.getElementById(this.Id).offsetWidth)-2;
				
			if(typeof(document.getElementById(this.Id).height) != 'undefined') 
				this.Height = parseInt(document.getElementById(this.Id).height);	
			else
				this.Height = document.getElementById(this.Id).offsetHeight == '' ? 0 : parseInt(document.getElementById(this.Id).offsetHeight)-2;
		}		
		if(typeof(ExtraMove) == 'function' && this._Move) {
			this.MoveInit();
		}
		if(typeof(ExtraColor) == 'function' && this._Color) {
			this.ColorInit();
		}
		if(typeof(ExtraSize) == 'function' && this._Size) {
			this.SizeInit();
		}
		if(typeof(ExtraOpacity) == 'function' && this._Opacity) {
			this.OpacityInit();
		}
		if(typeof(ExtraWriter) == 'function' && this._Writer) {
			this.WriterInit();
		}
	}
}
