function a() {};
function MTVNI_COMMON_MODULE_INIT(params) {
  var obj = params.object;
  MTVNI_COMMON_MODULE_BINDING(obj);	// Bind functions to current module
  
  // Setting default parameters
  obj.setId("MTNVI" + parseInt(Math.random() * 1000000));	// Unique object id  
  obj.setType(params.type);    
  obj.setParams( (params.parameters) ? params.parameters : {} );
  
  // Setting HTML Reference
  if (params.type == "parent") {	
	obj.setParent(null);	
	obj.setScriptFolder(params.scriptfolder);
	obj.setLanguageCode(params.languagecode);  
	obj.setBaseObject(obj);
	obj.setHTMLReference(params.href);
  } else {	 
	obj.setParent(params.parent);
	obj.getParent().setComponent(obj.getId(), obj);  
	obj.setBaseObject(params.parent.getBaseObject());	
    obj.setHTMLReference(obj.getParent().getHTMLReference() + ".getComponent('"+obj.getId()+"')");
    obj.init();
  }; 
};

function MTVNI_COMMON_MODULE_BINDING(obj) {
  // Initialize module container
  obj._module = {};
  obj._module.globalids = [];
	
  // Set default function to associate object
  // Module functions
  obj.setId = MTVNI_COMMON_MODULE_SetId;
  obj.getId = MTVNI_COMMON_MODULE_GetId;
  obj.setType = MTVNI_COMMON_MODULE_SetType;
  obj.getType = MTVNI_COMMON_MODULE_GetType;  
  obj.setParent = MTVNI_COMMON_MODULE_SetParent;
  obj.getParent = MTVNI_COMMON_MODULE_GetParent;
  obj.setBaseObject = MTVNI_COMMON_MODULE_SetBaseObject;
  obj.getBaseObject = MTVNI_COMMON_MODULE_GetBaseObject;  
  obj.setHTMLReference = MTVNI_COMMON_MODULE_SetHTMLReference;
  obj.getHTMLReference = MTVNI_COMMON_MODULE_GetHTMLReference;
  obj.add = MTVNI_COMMON_MODULE_Add;
  obj.remove = MTVNI_COMMON_MODULE_Remove;
  obj.setComponent = MTVNI_COMMON_MODULE_SetComponent;
  obj.getComponent = MTVNI_COMMON_MODULE_GetComponent;
  obj.setParams = MTVNI_COMMON_MODULE_SetParams;
  obj.getParams = MTVNI_COMMON_MODULE_GetParams;
  obj.preloadImage = MTVNI_COMMON_MODULE_PreloadImage;
  obj.popup = MTVNI_COMMON_MODULE_PopUp;
  obj.removeFlashLeakInIE = MTVNI_COMMON_MODULE_RemoveFlashLeakInIE;
  obj.setGlobalVariable = MTVNI_COMMON_MODULE_SetGlobalVariable;
  obj.getGlobalVariable = MTVNI_COMMON_MODULE_GetGlobalVariable;
  
  // Parent functions
  obj.setScriptFolder = MTVNI_COMMON_MODULE_SetScriptFolder;
  obj.getScriptFolder = MTVNI_COMMON_MODULE_GetScriptFolder;
  obj.setLanguageCode = MTVNI_COMMON_MODULE_SetLanguageCode;
  obj.getLanguageCode = MTVNI_COMMON_MODULE_GetLanguageCode;
  
};

// Common functions
function MTVNI_COMMON_MODULE_SetId(value) { this._module.id = value; };
function MTVNI_COMMON_MODULE_GetId() { return this._module.id; };
function MTVNI_COMMON_MODULE_SetType(value) { this._module.type = value; };
function MTVNI_COMMON_MODULE_GetType() { return this._module.type; };
function MTVNI_COMMON_MODULE_SetParent(obj) { this._module._parentObj = obj; };
function MTVNI_COMMON_MODULE_GetParent() { return this._module._parentObj; };
function MTVNI_COMMON_MODULE_SetBaseObject(obj) { this._module._baseObj = obj; };
function MTVNI_COMMON_MODULE_GetBaseObject() { return this._module._baseObj; };
function MTVNI_COMMON_MODULE_SetHTMLReference(value) { this._module.htmlReference = value; };
function MTVNI_COMMON_MODULE_GetHTMLReference() { return this._module.htmlReference; };
function MTVNI_COMMON_MODULE_Add(obj, parent, params) {  MTVNI_COMMON_MODULE_INIT({type: "component", object: obj, parent: parent, parameters: params});  return obj;};
function MTVNI_COMMON_MODULE_Remove(obj) {  delete obj; };
function MTVNI_COMMON_MODULE_SetComponent(id, obj) { eval("this._module."+id+"=obj;"); };
function MTVNI_COMMON_MODULE_GetComponent(id) { eval("var obj = this._module."+id+";"); return obj; };
function MTVNI_COMMON_MODULE_SetParams(params) { this._module._params = params; };
function MTVNI_COMMON_MODULE_GetParams() { return this._module._params; };
function MTVNI_COMMON_MODULE_PreloadImage(img) { return jQuery(new Image()).load().attr('src',img); };
function MTVNI_COMMON_MODULE_PopUp (params) {
  var popWindow=window.open(params.url,params.title,params.args);
  if (window.focus) {
    popWindow.focus();
  };
};
function MTVNI_COMMON_MODULE_RemoveFlashLeakInIE(id){
  var obj = document.getElementById(id);
  if (obj) {
    for (var i in obj) {
      if (typeof obj[i] == "function") {
        obj[i] = null;
      };
    };
    obj.parentNode.removeChild(obj);
  };
};
function MTVNI_COMMON_MODULE_SetGlobalVariable(id, value) {  
  if (this.getParent())	this.getParent()._module.globalids[id] = value;
  else this._module.globalids[id] = value;
};
function MTVNI_COMMON_MODULE_GetGlobalVariable(id) {
  var obj = this.getParent() ? this.getParent() : this;
  var value = obj._module.globalids[id];
  return value;
};

//Parent functions
function MTVNI_COMMON_MODULE_SetScriptFolder(value) { this._module._scriptFolder = value; };
function MTVNI_COMMON_MODULE_GetScriptFolder() { return this._module._scriptFolder; };
function MTVNI_COMMON_MODULE_SetLanguageCode(value) { this._module._languageCode = value; };
function MTVNI_COMMON_MODULE_GetLanguageCode() { return this._module._languageCode; };

//Common functions
jQuery(document).ready(function(){
	jQuery(".clickable").hover(function(){
			jQuery(this).addClass("hover");
		},
		function(){
			jQuery(this).removeClass("hover");
		}
	);
	// all clickable modules start with an image with a link - so the first link should be good...
	jQuery(".clickable").bind("click", function(e){

		if((jQuery(this).find("a:eq(0)").attr("target")) && (jQuery(this).find("a:eq(0)").attr("target") == "_blank")){
			window.open(jQuery(this).find("a:eq(0)").attr("href"));
			e.preventDefault();
		}
		else {
			location.href = jQuery(this).find("a:eq(0)").attr("href");
		}
	});
});

// Loading com object
if (!mtvni) var mtvni = {};