/* 
* SimpleImage v.0.9 - To Handling Photo.
* Copyright (c) 2009 Uwe Franke <uwe.franke@w3xp.de>
*/
/* [SimpleImage-Klasse] */
var SimpleImage = {
img: null,
src: null,
name: null,
title: null,
width: null,
height: null,
alt: null,
id: null,
load: function(attr) {
try {
if (attr == undefined) {
throw new Error("SimpleImage.load() needed one 'src'-parameter, sample SimpleImage.load({src: [path to graphic]}");
}
this.alt = attr.alt || '';
this.name = attr.name || '';
this.title = attr.title || '';
this.width = attr.width || null;
this.height = attr.height || null;
this.id = attr.id || 'simpleImageID';
this.src = attr.src;
this.img = new Image();
} catch (e) {
if (e instanceof Error) {
alert(e.name + ": " + e.message);
}
} finally {
return this;
}
},
pack: function() {
if (this.width) {
this.img.width = this.width;
}
if (this.height) {
this.img.height = this.height;
}
this.img.src = this.src;
},
getHtml: function() {
return "<img id='" + this.id + "' src='" + this.img.src + "' width='" + this.img.width + "' height='" + this.img.height + "' alt='" + this.alt + "'/>";
},
getImage: function() {
return this.img;
},
setID: function(id) {
this.id = id;
},
getID: function(id) {
return this.id;
},
setWidth: function(w) {
this.img.width = w;
},
getWidth: function() {
return this.img.width;
},
setHeight: function(h) {
this.img.height = h;
},
getHeight: function() {
return this.img.height;
}
}

