
function getbyid(id) {
	if (document.getElementById) {
		return document.getElementById(id);
	} else if (document.all) {
		return document.all[id];
	} else if (document.layers) {
		return document.layers[id];
	} else {
		return null;
	}
}

function settitlestyle() {
	var objsubject=document.getElementById('title');
	var objfontcolor=document.getElementById('fontcolor');
	var objfontsize=document.getElementById('fontsize');
	var objem=document.getElementById('em');
	var objstrong=document.getElementById('strong');
	var objunderline=document.getElementById('underline');
	objsubject.style.color = objfontcolor.value;
	objfontcolor.style.backgroundColor = objfontcolor.value;
	objsubject.style.fontSize = objfontsize.value;
	objsubject.style.width = 500;
	if(objem.checked == true) {
		objsubject.style.fontStyle = "italic";
	} else {
		objsubject.style.fontStyle = "";
	}
	if(objstrong.checked == true) {
		objsubject.style.fontWeight = "bold";
	} else {
		objsubject.style.fontWeight = "";
	}
	if(objunderline.checked == true) {
		objsubject.style.textDecoration = "underline";
	} else {
		objsubject.style.textDecoration = "none";
	}
}
function loadtitlestyle() {
	var objsubject=document.getElementById('title');
	var objfontcolor=document.getElementById('fontcolor');
	var objfontsize=document.getElementById('fontsize');
	var objem=document.getElementById('em');
	var objstrong=document.getElementById('strong');
	var objunderline=document.getElementById('underline');
	objfontcolor.style.backgroundColor = objsubject.style.color;
	objfontcolor.value = objsubject.style.color;
	var colorstr = objsubject.style.color;
	if(isFirefox=navigator.userAgent.indexOf("Firefox")>0 && colorstr != ""){
		colorstr = rgbToHex(colorstr);
	}
	if(colorstr != "") {
		objfontcolor.options.selectedIndex = getbyid(colorstr).index;
		objfontcolor.options.selected = true;
	}
	objfontsize.value = objsubject.style.fontSize;
	if(objsubject.style.fontWeight == "bold") {
		objstrong.checked = true;
	} else {
		objstrong.checked = false;
	}
	if(objsubject.style.fontStyle == "italic") {
		objem.checked = true;
	} else {
		objem.checked = false;
	}
	if(objsubject.style.textDecoration == "underline") {
		objunderline.checked = true;
	} else {
		objunderline.checked = false;
	}		
}
function makeselectcolor(selectname){
	subcat = new Array('00','33','66','99','CC','FF');
	var length = subcat.length;
	var RED = subcat;
	var GREEN = subcat;
	var BLUE = subcat;
	var b,r,g;
	var objsubject=document.getElementById(selectname);
	for(r=0;r < length;r++){
		for(g=0;g < length;g++){
			for(b=0;b < length;b++){
				var oOption = document.createElement("option");
				oOption.style.backgroundColor="#"+RED[r]+GREEN[g]+BLUE[b];
				oOption.style.color="#"+RED[r]+GREEN[g]+BLUE[b];
				oOption.value="#"+RED[r]+GREEN[g]+BLUE[b];
				oOption.text="#"+RED[r]+GREEN[g]+BLUE[b];
				oOption.id="#"+RED[r]+GREEN[g]+BLUE[b];
				objsubject.appendChild(oOption);
				}
			}
		}
}
function rgbToHex(color) {
	color=color.replace("rgb(","")
	color=color.replace(")","")
	color=color.split(",")
	
	r=parseInt(color[0]);
	g=parseInt(color[1]);
	b=parseInt(color[2]);
	
	r = r.toString(16);
	if (r.length == 1) {
		r = '0' + r;
	}
	g = g.toString(16);
	if (g.length == 1) {
		g = '0' + g;
	}
	b = b.toString(16);
	if (b.length == 1) {
		b = '0' + b;
	}
	return ("#" + r + g + b).toUpperCase();
}

