
/****************************************************************************************/
/* RULE OBJECT **************************************************************************/
/*``````````````````````````````````````````````````````````````````````````````````````*/

function HRule( width ) {
	this.init( width );
}

HRule.prototype.init = function( width ) {
	this.width = width;
	this.thickness = 1;
	this.color = "#000000";
	this.marginTop = 0;
	this.marginRight = 0;
	this.marginBottom = 0;
	this.marginLeft = 0;
}

// Serialize for debugging by calling: alert(myBtn);
HRule.prototype.toString = function() {
	ruleString = "Width: \t \t " + this.width + "\t\n";
	ruleString += "Thickness: \t \t " + this.thickness + "\t\n";
	ruleString += "Color: \t \t " + this.color + "\t\n";
	ruleString += "Margin: \t \t " + this.marginTop + ", " + this.marginRight + ", " + this.marginBottom + ", " + this.marginLeft + "\t\n";
	return ruleString;
}

HRule.prototype.setThickness = function( val ) {
	this.thickness = val;
}
HRule.prototype.setColor = function( val ) {
	this.color = val;
}
HRule.prototype.setMarginTop = function( val ) {
	this.marginTop = val;
}
HRule.prototype.setMarginRight = function( val ) {
	this.marginRight = val;
}
HRule.prototype.setMarginBottom = function( val ) {
	this.marginBottom = val;
}
HRule.prototype.setMarginLeft = function( val ) {
	this.marginLeft = val;
}
HRule.prototype.setMargin = function( top, right, bottom, left ) {
	this.setMarginTop( top );
	this.setMarginRight( right );
	this.setMarginBottom( bottom );
	this.setMarginLeft( left );	
}

// Serialize for display onscreen
HRule.prototype.generate = function() {

	// write HTML
	document.write('<div class="hRule" style="background:'+this.color+'; height:'+this.thickness+'px; width:'+this.width+'px; margin:'+this.marginTop+'px '+this.marginRight+'px '+this.marginBottom+'px '+this.marginLeft+'px;">' + spacer + '</div>');
}

