
var fontSize = 12;
var fontColorIndex = 0;
var bgColorIndex = 0;


fontColor = new Array();
fontColor[0] = "";
fontColor[1] = "";
fontColor[2] = "#ffff00";
fontColor[3] = "#ffffff";
fontColor[4] = "#6666ff";
fontColor[5] = "#ff6666";
fontColor[6] = "#ff66ff";
fontColor[7] = "#66ff66";

bgColor = new Array();
bgColor[0] = "";
bgColor[1] = "";
bgColor[2] = "#000000";
bgColor[3] = "#6666ff";
bgColor[4] = "#ff6666";
bgColor[5] = "#ff66ff";
bgColor[6] = "#66ff66";

function f_setInit() {
	if (readCookie("fontSize").length == 0)
		setFontCookie("fontSize", 12, 1);
	else
		fontSize = readCookie("fontSize");

	if (readCookie("fontColorIndex").length == 0)
		setFontCookie("fontColorIndex", 0, 1);
	else
		fontColorIndex = readCookie("fontColorIndex");
	
	if (readCookie("bgColorIndex").length == 0)
		setFontCookie("bgColorIndex", 0, 1);
	else
		bgColorIndex = readCookie("bgColorIndex");

	if (readCookie("fontSize")== 12 && readCookie("fontColorIndex")==0 && readCookie("bgColorIndex") == 0) {
	
	} else {
		f_setFace();
	}
}

function f_fontPlus() 
{
	if (fontSize < 20) 
	{
		fontSize = parseInt(fontSize) + 2;		
		f_setFace();
	}
}

function f_fontMinus() {
	if (fontSize > 11) {
		fontSize = parseInt(fontSize) - 2;		
		f_setFace();
	}
}

function f_setFontColor1(param){
	var keyCode = window.event.keyCode;
	if( keyCode == 13 )
	{
		if ( param >= 0 && param <= 7 )
		{
			fontColorIndex = param;
			f_setFace();
		}		
	}
}

function f_setFontColor2(param){
	if ( param >= 0 && param <= 7 ) 
	{
		fontColorIndex = param;
		f_setFace();
	}
}

function f_setBgColor1(param) {
	var keyCode = window.event.keyCode;
	if( keyCode == 13 )
	{
		if ( param >= 0 && param <= 6 ) 
		{
			bgColorIndex = param;
			f_setFace();		
		}
	}
}	


function f_setBgColor2(param) {
	if ( param >= 0 && param <= 6 ) {
		bgColorIndex = param;
		f_setFace();		
	}
}

function f_setFace(){
	var objs_td		= new Array();
	var	objs_a		= new Array();
	var	objs_span	= new Array();
	var objs_p		= new Array();
/*
	var iCntFrames = parent.frames.length;


	if (iCntFrames == 0 )
	{
		iCntFrames = 1;
	}

	for(a=0; a<iCntFrames; a++)
	{
		if(iCntFrames >= 3)
		{
			objs_td = parent.frames[a].document.getElementsByTagName("td");
			objs_a = parent.frames[a].document.getElementsByTagName("a");
			objs_span = parent.frames[a].document.getElementsByTagName("span");
			objs_p = parent.frames[a].document.getElementsByTagName("p");
		}
		else
		{*/
			objs_td = document.getElementsByTagName("td");
			objs_a = document.getElementsByTagName("a");
			objs_span = document.getElementsByTagName("span");
			objs_p = document.getElementsByTagName("P");
		//}

		for (i=0;i<objs_td.length;i++) 
		{
			objs_td[i].style.fontSize=fontSize+'px';
			objs_td[i].style.color=fontColor[fontColorIndex];
			objs_td[i].style.backgroundColor=bgColor[bgColorIndex];
		}
		for (i=0;i<objs_a.length;i++) 
		{
			objs_a[i].style.fontSize=fontSize+'px';
			objs_a[i].style.color=fontColor[fontColorIndex];
		} 
		for (i=0;i<objs_span.length;i++) 
		{
			objs_span[i].style.fontSize=fontSize+'px';
			objs_span[i].style.color=fontColor[fontColorIndex];
		} 
		for (i=0;i<objs_p.length;i++) 
		{
			objs_p[i].style.fontSize=fontSize+'px';
			objs_p[i].style.color=fontColor[fontColorIndex];
		}
	//}

	/*if( iCntFrames >= 3)
	{
		if ( parent.frames[0].document.all['select2'] == "[object]" )
		{
			parent.frames[0].document.frmMain.select2.selectedIndex = parseInt(fontColorIndex);
			parent.frames[0].document.frmMain.select.selectedIndex = parseInt(bgColorIndex);
		}
	}
	else
	{*/
		if ( document.all['select2'] == "[object]" )
		{
			document.all['select2'].selectedIndex = parseInt(fontColorIndex);
			document.all['select'].selectedIndex = parseInt(bgColorIndex);
		}
	//}

	setFontCookie("fontSize", fontSize, 1);
	setFontCookie("fontColorIndex", fontColorIndex, 1);
	setFontCookie("bgColorIndex", bgColorIndex, 1);	
}


function readCookie( str ) {
	var key = str + "=" ;
	var key_len = key.length ;
	var cookie_len = document.cookie.length;
	var i = 0;

	while (i < cookie_len )
	{
		var j = i + key_len;
		if ( document.cookie.substring( i, j ) == key )
		{
			var cookie_end = document.cookie.indexOf(";",j);

			if (cookie_end == -1)
			{
				cookie_end = document.cookie.length;
			}
			return document.cookie.substring(j,cookie_end );
		}
		i++
	}
	return ""
}

function setFontCookie( key, value, term ){
	var expire = new Date();  
	expire.setDate( expire.getDate() + term );
//	document.cookie = key + "=" + escape( value ) + "; path=/; expires="+expire.toGMTString().substring(0,17)+"15:00:00"+expire.toGMTString().substring(25)+";";
	document.cookie = key + "=" + escape( value ) + "; path=/; expires=" + expire.toGMTString() + ";";

}

function f_setBasic() {
	setFontCookie("fontSize", 12, 1);
	fontSize = readCookie("fontSize");
		
	setFontCookie("fontColorIndex", 0, 1);
	fontColorIndex = readCookie("fontColorIndex");
	
	setFontCookie("bgColorIndex", 0, 1);
	bgColorIndex = readCookie("bgColorIndex");

	f_setFace();
}