/**********************************************************************
* /js/util/color.js
* Copyright (C) 2007-2008 Kyoto University
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
* 
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-
* 1301  USA
***********************************************************************/
Color = {
	colorDataArray: new Array(
		{name:'red',tag: '#FF0000',characterColor: 'black',gradientTo: '#FFddDD'},
		{name:'blue',tag: '#0000FF',characterColor: 'white',gradientTo: '#b0e0e6'},
		{name:'green',tag: '#008000',characterColor: 'white',gradientTo: '#90ee90'},
		{name:'lime',tag: '#00ff00',characterColor: 'black',gradientTo: '#f0fff0'},
		{name:'yellow',tag: '#FFFF00',characterColor: 'black',gradientTo: '#FFFFDD'},
		{name:'gold',tag: '#FFd700',characterColor: 'black',gradientTo: '#Fafad2'},
		{name:'orange',tag: '#ffa500',characterColor: 'black',gradientTo: '#FFdead'},
		{name:'purple',tag: '#800080',characterColor: 'white',gradientTo: '#dda0dd'},
		{name:'pink',tag: '#ffc0cb',characterColor: 'black',gradientTo: '#FFFFDD'},
		{name:'hotpink',tag: '#ff69b4',characterColor: 'black',gradientTo: '#ffc0cb'},
		{name:'brown',tag: '#a52a2a',characterColor: 'white',gradientTo: '#bc8f8f'},
		{name:'black',tag: '#000000',characterColor: 'white',gradientTo: '#aaaaaa'},
		{name:'white',tag: '#FFFFFF',characterColor: 'black',gradientTo: '#444444'}
	),
	
	//* 色の名前からタグを取得する
	//* @param {String} name
	getTagByName: function(name){
		for(i=0;i<this.colorDataArray.size();i++){
			if(this.colorDataArray[i]['name'] == name){
				return this.colorDataArray[i]['tag'];
			}
		}
		//*alert('Nothing! '+name);
		return name;
	},
	
	//* 色の名前(背景色)から文字色を取得する
	//* @param {String} name
	getCharacterColorByName: function(name){
		for(i=0;i<this.colorDataArray.size();i++){
			if(this.colorDataArray[i]['name'] == name){
				return this.colorDataArray[i]['characterColor'];
			}
		}
		//*alert('Nothing! '+name);
		return name;
	},
	
	//* 色の名前(背景色)から文字色を取得する
	//* @param {String} name
	getDiluteColorByName: function(name){
		for(i=0;i<this.colorDataArray.size();i++){
			if(this.colorDataArray[i]['name'] == name){
				return this.colorDataArray[i]['gradientTo'];
			}
		}
		//*alert('Nothing! '+name);
		return name;
	},
	
	setElementColor: function(element,backgroundColor,characterColor){
		element.setStyle({
			backgroundColor: backgroundColor,
			color: characterColor
		});
	},
	
	setElementBackgroundColor: function(element,color){
		element.setStyle({
			backgroundColor: color
		});
	}
};

