
function isIE()
{ 	
	if (window.ActiveXObject) return true;
	return false;
}

function isChrome()
{ 	
	if (Microsoft.ActiveXObject) return true;
	return false;
}

function Erreur(txt) {
    var err = new Error();
    err.message = txt;
    return err;
}

Event =  function(source) {
    try { 
        this.source = source; 
    } catch(e) { 
        this.source = null; 
    } 
};

Listener = function(parent) {
    try {
        this.parent = parent; 
    } catch(e) { 
        this.parent = null; 
    } 
    this.enventFired = function() {}; 
}

MouseOverListener = function(parent) { 
    this.parent = parent; 
    this.enventFired = function(mouseOverEvent) { 
        if ( this.parent.mouseOvered ) this.parent.mouseOvered(mouseOverEvent); 
    };
};
MouseOverListener.prototype = new Listener();
MouseOverEvent = function(source) { this.source = source; };
MouseOverEvent.prototype = new Event();

MouseOutListener =  function(parent) { 
    this.parent = parent; 
    this.enventFired = function(mouseOutEvent) { 
        if ( this.parent.mouseOuted ) this.parent.mouseOuted(mouseOutEvent); 
    };
};
MouseOutListener.prototype = new Listener();
MouseOutEvent = function(source) { this.source = source; };
MouseOutEvent.prototype = new Event();

MouseDownListener =  function(parent) { this.parent = parent; };
MouseDownListener.prototype = new Listener();
MouseDownListener.enventFired = function(mouseDownEvent) { if ( this.parent.mouseDowned ) this.parent.mouseDowned(mouseDownEvent); };
MouseDownEvent = function(source) { this.source = source; };
MouseDownEvent.prototype = new Event();

MouseUpListener =  function(parent) { 
    this.parent = parent; 
    this.enventFired = function(mouseUpEvent) { 
        if ( this.parent.mouseUped ) this.parent.mouseUped(mouseUpEvent); 
    };
};
MouseUpListener.prototype = new Listener();
MouseUpEvent = function(source) { this.source = source; };
MouseUpEvent.prototype = new Event();

MouseClickListener =  function(parent) { 
    this.parent = parent; 
    this.enventFired = function(mouseClickEvent) { 
        if ( this.parent.mouseClicked ) this.parent.mouseClicked(mouseClickEvent); 
    };
};
MouseClickListener.prototype = new Listener();
MouseClickEvent = function(source) { this.source = source; };
MouseClickEvent.prototype = new Event();

function getObject(objectId) { return document.getElementById(objectId); }

function CommonHtmlObj(object) { 

    object.listenerList = new Array();

    object.fireMouseOverEvent = function(mouseOverEvent) {
        for( var i=0; i<this.listenerList.length; i++)
        { if (MouseOverListener.prototype.isPrototypeOf(this.listenerList[i])) this.listenerList[i].enventFired(mouseOverEvent); }
    }
    object.fireMouseOutEvent = function(mouseOutEvent) {
        for( var i=0; i<this.listenerList.length; i++)
        { if (MouseOutListener.prototype.isPrototypeOf(this.listenerList[i])) this.listenerList[i].enventFired(mouseOutEvent); }
    }
    object.fireMouseDownEvent = function(mouseDownEvent) {
        for( var i=0; i<this.listenerList.length; i++)
        { if (MouseDownListener.prototype.isPrototypeOf(this.listenerList[i])) this.listenerList[i].enventFired(mouseDownEvent); }
    }
    object.fireMouseUpEvent = function(mouseUpEvent) {
        for( var i=0; i<this.listenerList.length; i++)
        { if (MouseUpListener.prototype.isPrototypeOf(this.listenerList[i])) this.listenerList[i].enventFired(mouseUpEvent); }
    }
    object.fireMouseClickEvent = function(mouseClickEvent) { 
        for( var i=0; i<this.listenerList.length; i++)
        { if (MouseClickListener.prototype.isPrototypeOf(this.listenerList[i])) this.listenerList[i].enventFired(mouseClickEvent); }
    }

    object.onmouseover = function() { this.fireMouseOverEvent(new MouseOverEvent(this)); };
    object.onmouseout = function() { this.fireMouseOutEvent(new MouseOutEvent(this)); };
    object.onmousedown = function() { this.fireMouseDownEvent(new MouseDownEvent(this)); };
    object.onmouseup = function() { this.fireMouseUpEvent(new MouseUpEvent(this)); };
    object.onclick = function() { this.fireMouseClickEvent(new MouseClickEvent(this)); };

    object.setPosition = function(type, x, y) {
        this.style.position = type;
        this.style.left = x + "px";
        this.style.top = y + "px";
    };

    object.setGrandeur = function(largeur, hauteur) {
        this.style.width = largeur + "px";
        this.style.height = hauteur + "px";
    };
    
    object.addListener = function(listener) 
    { this.listenerList[this.listenerList.length] = listener; };

    object.setListenerList = function(l) { this.listenerList = l; };
    object.getListenerList = function() { return this.listenerList; };
    
    return object;
}

function HtmlObj(objectId, parent) {

  var obj = getObject(objectId);
  //obj.parent = parent;
  alert();
  return CommonHtmlObj(obj); 
	
}

function NewHtmlObj(tagName, objectId, parent) { 

    var obj = document.createElement(tagName);
    obj.id = objectId;
	obj.parent = parent;

    return CommonHtmlObj(obj);
}

function PageUrl()
{
    var Add_Barre = document.location.href;

    if (Add_Barre.indexOf('?') > -1) 
       {
        var Real_Add = Add_Barre.substring(0, Add_Barre.indexOf('?'));
        var Params = Add_Barre.substring(Add_Barre.indexOf('?')+1, Add_Barre.length);
       } else
       { var Real_Add = Add_Barre;   var Params = ''; }
         
    var Domaine_String = Real_Add.substring(Real_Add.indexOf(':')+3,Real_Add.length);

    var TabParam = Params.split('&');
    var TabParams = new Array();
    for (var i=0; i<TabParam.length; i++)
          { TabParams[i] = TabParam[i].split('='); }


    this.GetNumberOfParam = function() 
    { if (Add_Barre.indexOf('?') > -1) return (TabParam.length); else return (0); }


    this.GetAllParam = function() 
    { if (TabParams.length > 0) return (TabParams); else return (null);}


    this.GetAllParamName = function()
    {
     var TabName =  new Array();
     for (i=0; i<TabParams.length; i++)
     { TabName[i] = TabParams[i][0]; }  
     return(TabName);  
    }


    this.GetAllParamValue = function()
    {
     var TabValue =  new Array();
     for (i=0; i<TabParams.length; i++)
     { TabValue[i] = TabParams[i][1]; }  
     return(TabValue);  
    }
     

    this.GetParam = function(paramName)
    { for (i=0; i<TabParams.length; i++)
      { if ( TabParams[i][0] == paramName) return(TabParams[i][1]); }
      return null;
    }


    this.GetParamNum = function(paramNun) 
    { return(TabParams[paramNun-1]); }  

}
