function bannerObject() {
	this.id   = '';
	this.type   = '';
	this.holder = '';
	this.propNames      = new Array();	    //property names
	this.propValues     = new Array();     //property values
	
	this.hasProperty    = function (Name)                         {
		var i = 0;
		for (i=0; i<this.propNames.length; i++) {
			if (this.propNames[i] == Name) {
				return i;
			}
		}
		return -1;
	}
	
	this.syncProperty   = function (Name, Value)                  {
		var url = '?cmd=sync&objname='+escape(this.name)+'&name='+escape(Name)+'&value='+escape(Value);
		ajax_mem_load('objsync.php'+url, 'onReceiveUpdate');
	}
	
	this.addProperty    = function (Name, Value)                  {
		var hasProp = this.hasProperty(Name);
		if (hasProp == -1) {
			this.propNames.push(Name);
			this.propValues.push(Value);
		} else {
			this.propNames [hasProp] = Name;
			this.propValues[hasProp] = Value;
		}
	}
	
	this.getProperty    = function (Name, Default) 		  	 {
		var i=0;
		for (i=0; i<this.propNames.length; i++) {
			if ((this.propNames[i]) == Name) {
				return this.propValues[i];
			}
		}
		return Default;
	}
	
	this.removeProperty = function (Name)                         {
		var hasProp = this.hasProperty(Name);
		if (hasProp != -1) {
			this.propNames  = this.propNames .splice(hasProp, 1);
			this.propValues = this.propValues.splice(hasProp, 1);
		}
	}
	
	this.showProperties = function ()                             {
		var rezult = '';
		var i = 0;
		for (i=0; i<this.propNames.length; i++) {
			rezult += this.propNames[i].toString() +':'+this.propValues[i].toString()+'\n';
		}
		return rezult;
	}
	
	this.initFromString = function (id, type, holder, initString) {
		
		this.id = id;
		this.type = type;
		this.holder = holder;
		
		var noLF  = initString.replace('\r','');
		var lines = noLF.split('\n');
		//alert(lines.length);
		var i = 0;
		var ind = 0;
		
		var n = '';
		var v = '';
		
		for (i=0; i<lines.length; i++) {
			ind = lines[i].indexOf(':');
			if (ind >= 0) {
				n = lines[i].substring(0, ind);
				v = lines[i].substring(ind+1, lines[i].length - n.length + 1);
				this.addProperty(n, v);
			} else if (lines[i].length > 0) {
				alert('ERROR PARSING OBJECT PROPERTY: ":" EXPECTED.\n'+lines[i]);
			}
		}
	}
	
	this.saveToString   = function()                              {
		var rezult = '';
		rezult  = '[object]\n';
		rezult += 'id:'+this.id+'\n';
		rezult += 'type:'+this.type+'\n';
		var i=0;
		for (i=0; i<this.propNames.length; i++) {
			if (this.propValues[i] !== '') {
				rezult += 'prop:'+this.propNames[i].toString()+'='+this.propValues[i].toString()+'\n';
			}
		}
		return rezult;
	}
	
	this.toURL          = function()                              {
		return escape(this.saveToString());
	}
}

function bannerDOM () {
	this.objects        = new Array();
	
	this.count          = function ()         {
		return this.objects.length;
	}
	
	this.insert         = function (banerOBJ) {
		this.objects.push(banerOBJ);
	}
	
	this.getElementById = function (id)       {
		var i=0; var b;
		for (i=0; i<this.count(); i++) {
			b = this.objects[i];
			if (b.id == id) {
				return b;
			}
		}
		return 0;
	}
	
	this.remove         = function (id)       {
		var i = 0; var b;
		var found = -1;
		
		for (i=0; i<this.count(); i++) {
			b = this.objects[i];
			if (b.id == id) {
				found = i;
				break;
			}
		}
		
		obj = new Array();
		
		for (i = 0; i<this.count(); i++) {
			if (i != found) {
				obj.push(this.objects[i]);
			}
		}
		
		this.objects = obj;
	}
	
	this.toBuffer       = function ()         {
		var rezult = '';
		var i;
		for (i=0; i<this.count(); i++) {
			ob = this.objects[i];
			rezult += ob.saveToString();
		}
		return rezult;
	}

	this.showBorders    = function ()         {
		var i=0;
		for (i=0; i < this.count(); i++) {
			ob = this.objects[i];
			if (ob.id != 'background') {
				document.getElementById('divObject' +ob.id.toString()).style.border = '1px dotted blue';
			}
		}
	}

	this.hideBorders    = function ()         {
		var i=0; 
		for (i=0; i < this.count(); i++) {
			ob = this.objects[i];
			if (ob.id != 'background') {
				document.getElementById('divObject'+ob.id.toString()).style.border = '';
			}
		}
	}

	this.showColors    = function ()         {
		var colors = new Array();
		colors.push('#0000FF'); colors.push('#FF0000'); colors.push('#00FF00');
		var ind = colors.length - 1; var i=0;
		for (i = 0; i < this.count(); i++) {
			ob = this.objects[i];
			if (ob.id != 'background') {
				document.getElementById('divObject'+ob.id).style.backgroundColor = colors[ind];
				ind--;
				if (ind < 0) {ind = colors.length - 1;}
			}
		}
	}
	
	this.hideColors    = function ()         {
		var colors = new Array(); var i=0;
		for (i = 0; i < this.count(); i++) {
			ob = this.objects[i];
			if (ob.id != 'background') {
				document.getElementById('divObject'+ob.id).style.backgroundColor = '';
			}
		}
	}
	
	this.focus         = function (id)       {
		var i = 0; var ob;
		var found = -1;
		for (i=0; i<this.count(); i++) {
			ob = this.objects[i];
			if (ob.id != 'background') {
				if (ob.id == id) {
					found = i;
					break;
				}
			}
		}
		if (found != -1) {
			this.objects.splice(found, 1);
			this.objects.push(ob);
			for (i=0; i<this.count(); i++) {
				ob = this.objects[i];
				ob.addProperty('zindex', i.toString());
				if (ob.id != 'background') {
					document.getElementById('divObject'+ob.id).style.zIndex = i+1;
				}
			}
		}
	}

}

