﻿// JavaScript Document

function StyleControl(){
	if(arguments.length<1){
		alert("StyleControl Object needs one DOM object as argument.");
		return;
	}
	
	this.object=arguments[0];
	
	if((typeof(arguments[0])=="string")&&arguments[0].constructor==String){
		this.object=document.getElementById(arguments[0]);
	}
}

StyleControl.prototype={
	object:null,
	setClassName:function(){
		if(this.object && arguments.length==1){
			this.object.className=arguments[0];
		}else{
			alert("The method 'setClassName' of object occurs an exception.");
		}
	},
	
	setCommonStyle:function(){
		if(this.object && arguments.length==2){
			this.object.style[arguments[0]]=arguments[1];
		}else{
			alert("The method 'setStyle' of object occurs an exception.");
		}
	},
	
	hide:function(){
		if(this.object){
			this.object.style["display"]="none";
		}
	},
	
	show:function(){
		if(this.object){
			this.object.style["display"]="";
		}
	},
	
	insertObject:function(){
		if(this.object && arguments.length==1){
			if(!this.object.hasChildNodes()){
				this.object.appendChild(arguments[0]);
			}else{
				this.object.insertBefore(arguments[0],this.object.childNodes[0]);
			}
		}else{
			alert("The method 'insertObject' of object occurs an exception.");
		}
	},
	
	appendObject:function(){
		if(this.object && arguments.length==1){
			this.object.appendChild(arguments[0]);
		}else{
			alert("The method 'appendObject' of object occurs an exception.");
		}
	},
	
	removeObject:function(){
		if(this.object && arguments.length==1){
			this.object.removeChild(arguments[0]);
		}else{
			alert("The method 'removeObject' of object occurs an exception.");
		}
	},
	
	clearObject:function(){
		if(this.object){
			this.object.innerHTML="";
		}
	}
}
