# Surgeweb "dark" newlook coloring module gets the based one colour static ui coloring

(function(){
	var obj = { 
		restore: dark_restore, persist: dark_persist, record_col: dark_record_col,
		style_css: dark_style_css, dom_styling: dark_dom_styling,
		config: plain_config
	};
	
	obj.wide_only = true;
	obj.cur_col_hsl = rgb2hsl(txt2col('#ff0000'));

	function dark_record_col(col) 
	{
		obj.cur_col_hsl=col;
	}

	function dark_persist()
	{
	}
	
	function dark_restore()
	{
	}
	
	function dark_style_css(cs, opt)
	{
		dbg('called ark_style_css');
		cs.one_color = obj.cur_col_hsl;		
		var fn = newlook_modules[pref.newlook_layout].central_css; 
		if (!fn) return '';		
		return fn('dark', cs);
	
	
		var txt = '';
		col = rgb2hsl(txt2col('#272822')); //obj.cur_col_hsl;

		cs.bg_center = col; //rgb2hsl(txt2col('#272822')); //hsl_init(0,0,1);
		cs.bg_outer = col;
			cs.msghdr_reading = hsl_init(col[hsl_h],col[hsl_s]+0.25,0.92);
			cs.msghdr_compose = hsl_init(col[hsl_h],col[hsl_s]+0.25,0.91);
			cs.appmenu_dark = hsl_modulate(col,0,-0.2,-0.1);
			cs.ac_sel = hsl_modulate(col,0,+0.1,+0.7);
			cs.ac_bg = hsl_modulate(col,0,+0.1,+0.9);
			cs.ac_panel = hsl_modulate(col,0,+0.1,+0.7);
		cs.border = col;
		
			cs.page_background_css = 'background: '+hsl_out(cs.bg_center)+';';
			cs.border_color_css = hsl_out(cs.border);


			txt += '#app_menu div { background: '+hsl_out(cs.appmenu_dark)+';}';
			txt += '#msg_headers, .msg_headers { background: '+hsl_out(cs.msghdr_reading)+';}';
			txt += '.compose { background: '+hsl_out(cs.msghdr_compose)+';}';	
			txt += '#ac { background: '+hsl_out(cs.ac_bg)+';}' 
			txt += '#ac span.sel{  background:'+hsl_out(cs.ac_sel)+';}';
			txt += '.contacts_picker, .contacts_picker_edge{  background:'+hsl_out(cs.ac_panel)+';}';

		cs.col = col;
		cs.col1 = hsl_modulate(col,0,0,0.1);
		cs.col2 = hsl_modulate(col,0,0,0.2);
		cs.col3 = hsl_modulate(col,0,0,0.3);
		cs.col4 = hsl_modulate(col,0,0,0.4);
		cs.col5 = hsl_modulate(col,0,0,0.5);
		cs.col6 = hsl_modulate(col,0,0,0.6);
		cs.col7 = hsl_modulate(col,0,0,0.7);
		cs.col8 = hsl_modulate(col,0,0,0.8);
		cs.col9 = hsl_modulate(col,0,0,0.9);
		cs.col9a = hsl_modulate(col,0,0,0.95);
		
		
#		Top right text		
		txt += '#link_bar, #link_bar a{ color: white; }';
		txt += '.left_panel_header {background:white}';
		txt += '.toolbar { background:'+hsl_out(cs.col2)+';}';
		txt += '.mw_menu, .mnu_foldername,.menu_extra, .xwide { color: white; }';
		txt += '.top_line .rnd1 {background:'+hsl_out(cs.col4)+' !important}';
		
#		Left panel css
		txt += '#lpanel_body{ background:'+hsl_out(cs.col2)+' }';
		txt += '#folders .part_cursor a{color:white;}';
		txt += '#folders .part_cursor:hover, #folders .part_cursor a:hover {color:white; background:'+hsl_out(cs.col3)+'}';	
		txt += '.ftree .selected{color:white; background:'+hsl_out(cs.col3)+';}';		
		txt += '#folders li{border-bottom: 1px solid '+hsl_out(cs.col1)+' !important;}';
		txt += '.ftree{color:white;}';
		txt += '.folder_green_text{color:white;}';
		txt += '.flist_link, .ftree a, .ftree a:visited{color:'+hsl_out(cs.col8)+'; !important}';
		txt += '.fld_link {border-bottom:1px solid '+hsl_out(cs.col1)+';}';
		txt += '.folders_loading, .messages_loading {color:white !important;}';

# 		Message list css
		txt += '#msglist_box{ background:'+hsl_out(cs.col3)+' }';
		txt += '#msglist_box a {color:white !important}';
		txt += '.snippet {color: '+hsl_out(cs.col7)+' !important}';
		txt += '.wxc {color:white !important;}';
		txt += '.msgs_line td {border-bottom: 1px solid '+hsl_out(cs.col2)+' !important;}';
		txt += '.nomessages {color:white !important;}';
		txt += '.msglist_nav, #msg_navigator {color:white !important;}';
		txt += '.msgs_line td {color:white !important;}';
		
		txt += '.msgs_line:hover td{ background:'+hsl_out(cs.col4)+' !important}';
		txt += '#messages_list .selected{background:'+hsl_out(cs.col4)+' !important}';
  		txt += '.msgs_line.selected:hover td { background:'+hsl_out(cs.col5)+'  !important;}';
		txt += '.message_attachments {color:white !important;}';

		return txt;
	}
	
	function dark_dom_styling(cs, opt)
	{
		return;
		var col = obj.cur_col_hsl;
				
		safe_html_assign('custom_hsl_h', dp(col[hsl_h],3));
		safe_html_assign('custom_hsl_s', dp(col[hsl_s],3));
		safe_html_assign('custom_hsl_b', dp(col[hsl_b],3));
		safe_html_assign('custom_rgb', hsl_out(col));	
		safe_html_assign('modern_colours', modern_colours_populate(cs));

		var palette = sw.palette;
		if(palette){
			palette.set_color(col, opt.bypass)
			palette.render();
		}
	}

	function plain_config()
	{
		return 'What parameters??';
	}
		
	newlook_register('dark', 'dark', obj, {alt:false});
})();
