void drawcalendarBG(void)
{
	int i;
	setcolor(RGB(255,0,0));
	setfont(60,30,"黑体");
	outtextxy(30,30,"Perpetual Calendar");

	setcolor(RGB(140,140,140));
	rectangle(50,150,540,500);
	for(i=0;i<6;i++){
		line(50,200+i*HEIT,540,200+i*HEIT);
		line(120+i*WEIT,150,120+i*WEIT,500);
	}
	
	setfillcolor(RGB(54,197,233));
	for(i=0;i<7;i++)
		fillrectangle(50+i*WEIT,150,120+i*WEIT,200);

	setcolor(RGB(255,255,0));
	setfont(30,15,"黑体");
	outtextxy(70,160,"日");
	outtextxy(140,160,"一");
	outtextxy(210,160,"二");
	outtextxy(280,160,"三");
	outtextxy(350,160,"四");
	outtextxy(420,160,"五");
	outtextxy(490,160,"六");

	setcolor(RGB(140,140,140));
	rectangle(INFX,INFY,690,390);

	for(i=0;i<5;i++)
		line(INFX,INFY+(i+1)*HEII,INFX+WEII,INFY+(i+1)*HEII);

	setfillcolor(RGB(54,197,233));
	fillrectangle(INFX,INFY,INFX+WEII,INFY+HEII);
	setcolor(RGB(255,255,0));
	setfont(30,15,"黑体");
	outtextxy(INFX+25,INFY+10,"Today");

	setcolor(RGB(255,10,10));
	setfillcolor(RGB(255,10,10));
	fillrectangle(INFX+10,INFY+HEII*6+10,INFX+20,INFY+HEII*6+20);

	setcolor(RGB(50,245,55));
	setfillcolor(RGB(50,245,55));
	fillrectangle(INFX+10,INFY+HEII*6+30,INFX+20,INFY+HEII*6+40);

	setcolor(RGB(45,45,250));
	setfillcolor(RGB(45,45,250));
	fillrectangle(INFX+10,INFY+HEII*6+50,INFX+20,INFY+HEII*6+60);

	setcolor(RGB(140,140,140));
	setfont(10,7,"");
	outtextxy(INFX+30,INFY+HEII*6+10,"YOU CHOOSE");
	outtextxy(INFX+30,INFY+HEII*6+30,"TODAY");
	outtextxy(INFX+30,INFY+HEII*6+50,"GENERAL");
}
void draw3Dwindow(int x1, int y1, int x2, int y2, int topcolor)
{
	if (x1 > x2) chg_num(&x1, &x2);
	if (y1 > y2) chg_num(&y1, &y2);

	if (x2 >= win.win_vertal)
		x2 = win.win_vertal - 1;
	if (y2 >= win.win_horizon)
		y2 = win.win_horizon - 1;

	fillrectangle(x1+1, y1+1, x2+1, y2+1, ' ', B_BLACK);
	fillrectangle(x1, y1, x2, y2, ' ', topcolor);
	fflush(stdout);
	drawbox(x1, y1, x2, y2);
}
void comfirm_box(int x, int y, int type, int covercolor, const char *msg)
{
	int len = strlen(msg),
		c,
		fcolor, bcolor, mode;

	getcolors(&fcolor, &bcolor);
	getcntmode(&mode);
	
	if (len < 10) len = 10;
	if (type == WARNMSG) setcolor(F_GRAY, B_RED);
	else setcolor(F_YELLOW, B_BLUE);

	setcntmode(ATTR_HIGHLIGHT);
	draw3Dwindow(x, y, x+7, y+3+len, type == WARNMSG ? B_RED : B_BLUE);
	cprintfxy(x, y+1, type == WARNMSG ? "-| WARN |-" :  "-| NOTE|-");
	cprintfxy(x+2, y+2, msg);
	resetcntmode();

	if (type == WARNMSG) setcolor(F_BLUE, B_RED);
	else setcolor(F_GREEN, B_BLUE);

	drawbox(x+4, y+(len+2)/2-5, x+6, y+(len+2)/2+4);
	setcolor(F_BLACK, B_WHITE);
	cprintfxy(x+5, y+len/2-3, "   OK   ");
	gotoxy(0, 0);
	fflush(stdout);
	while (c = getchar(), c != '\n' && c != 'q') putchar('\a');
	fillrectangle(x, y, x+7+1, y+3+len+1, ' ', covercolor);
	setcolor(fcolor, bcolor);
	setcntmode(mode);
}
void drawcalendar(void)
{
	int i;
	int num;
	int x,y;
	DAY_NUM T_day;
	T_day=CO_day;
	T_day.day=1;
	x=T_day.week=count_week(T_day.year%100,T_day.year/100,T_day.month,T_day.day);
	y=1;
	num=month[leap_year(T_day.year)][T_day.month-1];
	setfont(40,20,"");
	for(i=0;i<num;i++,T_day.day++){
		if(T_day.year==CO_day.year&&T_day.month==CO_day.month&&T_day.day==CO_day.day)
			setfillcolor(RGB(255,40,40));
		else if(T_day.year==today.year&&T_day.month==today.month&&T_day.day==today.day)
			     setfillcolor(RGB(50,245,55));
		     else
				 setfillcolor(RGB(45,45,250));
		setcolor(RGB(140,140,140));
		fillrectangle(PCOX+x*WEIT,PCOY+y*HEIT,PCOX+x*WEIT+WEIT,PCOY+y*HEIT+HEIT);
		char str[3]={0};
		sprintf(str,"%02d",i+1);
		setcolor(RGB(255,255,255));
		outtextxy(PCOX+x*WEIT+15,PCOY+y*HEIT+5,str);
		x++;
		if(x%7==0){
			y++;
			x=0;
		}
	}
}
/*
 * clrscr_color -- clear the screen and fill it with colored background
 * @background: background color
 */
void clrscr_color(int background)
{
		/*Set the colors*/
	bak_color = background;
	fillrectangle(1, 1, win.win_vertal, win.win_horizon,
			' ', bak_color);
	setcolor(fnt_color, bak_color);
}
void cleancalendar(void)
{
	int i;
	setcolor(RGB(140,140,140));
	setfillcolor(RGB(0,0,0));
	fillrectangle(50,200,540,500);
	for(i=0;i<6;i++){
		line(50,200+i*HEIT,540,200+i*HEIT);
		line(120+i*WEIT,150,120+i*WEIT,500);
	}
}
int askbox(int x, int y, int type, int covercolor, const char *ask)
{
	int 	len = strlen(ask),
			choice, oldchoice,
			fcolor, bcolor, mode,
			doneflg = 0;
	char 	c;

	getcolors(&fcolor, &bcolor);
	getcntmode(&mode);

	if (len < 10) len = 10;
	if (type == WARNASK) setcolor(F_GRAY, B_RED);
	else setcolor(F_YELLOW, B_BLUE);

	setcntmode(ATTR_HIGHLIGHT);
	draw3Dwindow(x, y, x+5, y+3+len, type == WARNASK ? B_RED : B_BLUE);
	cprintfxy(x, y+1, type == WARNASK ? "-| WARNASK |-" :  "-| NOTEASK |-");
	cprintfxy(x+2, y+2, ask);
	resetcntmode();
	setcolor(F_GRAY, B_BLACK);
	cprintfxy(x+4, y+1+len/4-2, " YES ");
	setcolor(F_BLACK, type == WARNASK ? B_RED : B_BLUE);
	cprintfxy(x+4, y+1+3*len/4-2, " NO ");
	gotoxy(0, 0);
	setcolor(fcolor, bcolor);
	choice = 0;
	for ( ; ; ) {
		oldchoice = choice;
		while (c = getchar(),
			   c != 'j' && c != 'l' && c != 'q' && c != '\n')
			putchar('\a');
		switch (c) {
			case 'j': choice = choice == 0 ? 1 : choice - 1;	break;
			case 'l': choice = choice == 1 ? 0 : choice + 1;	break;
			case 'q': choice = 1;
			case '\n': doneflg = 1;	break;
		}
		setcolor(F_BLACK, type == WARNASK ? B_RED : B_BLUE);
		cprintfxy(x+4, oldchoice == 0 ? y+1+len/4-2 : y+1+3*len/4-2,
				  oldchoice == 0 ? " YES " : " NO ");
		setcolor(F_GRAY, B_BLACK);
		cprintfxy(x+4, choice == 0 ? y+1+len/4-2 : y+1+3*len/4-2,
				  choice == 0 ? " YES " : " NO ");
		if (doneflg) break;
		gotoxy(0, 0);
		fflush(stdout);
	}
	fillrectangle(x, y, x+5+1, y+3+len+1, ' ', covercolor);
	setcolor(fcolor, bcolor);
	setcntmode(mode);
	return choice;
}