--- sqwebmail/folder.orig.c	Tue Mar 19 16:28:10 2002
+++ sqwebmail/folder.c	Fri Mar  8 12:44:07 2002
@@ -323,6 +323,7 @@
 const char	*beforelab, *afterlab;
 const char	*nomsg, *selectalllab;
 const char	*qerrmsg;
+const char *mobile=getenv("SQWEBMAIL_MOBILE");
 
 	maildir_reload(dir);
 	contents=maildir_read(dir, pref_flagpagesize, &pos,
@@ -340,53 +341,73 @@
 
 	if (strcmp(cgi("error"), "quota") == 0)
 		printf("%s", qerrmsg);
-
-	printf("<TABLE WIDTH=\"100%%\" CLASS=\"folder-nextprev-background\" BORDER=0 CELLPADDING=0 CELLSPACING=0>");
-	printf("<TR><TD ALIGN=LEFT>");
-	printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS=\"folder-nextprev-buttons\"><TR><TD>");
-	if (morebefore)
-	{
-	size_t	beforepos;
-
-		if (pos < pref_flagpagesize)	beforepos=0;
-		else	beforepos=pos-pref_flagpagesize;
-
-		printf("<A HREF=\"");
-		output_scriptptrget();
-		printf("&form=folder&pos=%ld\" STYLE=\"text-decoration: none\">",
-			(long)beforepos);
-	}
-	printf("%s", beforelab);
-	if (morebefore)
-		printf("</A>");
-
-	printf("</TD></TR></TABLE>\n");
-
-	printf("</TD><TD ALIGN=RIGHT>\n");
-
-	printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS=\"folder-nextprev-buttons\"><TR><TD>");
-	if (moreafter)
-	{
-		printf("<A HREF=\"");
-		output_scriptptrget();
-		printf("&form=folder&pos=%ld\" STYLE=\"text-decoration: none\">",
-			(long)(pos+pref_flagpagesize));
+	if (!mobile || !*mobile){
+	  printf("<TABLE WIDTH=\"100%%\" CLASS=\"folder-nextprev-background\" BORDER=0 CELLPADDING=0 CELLSPACING=0>");
+	  printf("<TR><TD ALIGN=LEFT>");
+	  printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS=\"folder-nextprev-buttons\"><TR><TD>");
+	}else{
+
+	}
+	if (!mobile || !*mobile){
+	  if (morebefore)
+	    {
+	      size_t	beforepos;
+	      
+	      if (pos < pref_flagpagesize)	beforepos=0;
+	      else	beforepos=pos-pref_flagpagesize;
+	      
+	      printf("<A HREF=\"");
+	      output_scriptptrget();
+	      printf("&form=folder&pos=%ld\" STYLE=\"text-decoration: none\">",
+		     (long)beforepos);
+	    }
+	  printf("%s", beforelab);
+	  if (morebefore)
+	    printf("</A>");
+	}
+	if (!mobile || !*mobile){
+	  printf("</TD></TR></TABLE>\n");
+	  
+	  printf("</TD><TD ALIGN=RIGHT>\n");
+	  
+	  printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS=\"folder-nextprev-buttons\"><TR><TD>");
+	}else{
+
+	}
+	if (!mobile || !*mobile){
+	  if (moreafter)
+	    {
+	      printf("<A HREF=\"");
+	      output_scriptptrget();
+	      printf("&form=folder&pos=%ld\" STYLE=\"text-decoration: none\">",
+		     (long)(pos+pref_flagpagesize));
+	    }
+	  printf("%s", afterlab);
+	  if (moreafter)
+	    printf("</A>");
+	}
+	if (!mobile || !*mobile){
+	  printf("</TD></TR></TABLE>\n");
+	  
+	  printf("</TD></TR></TABLE>");
+	  printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=4><TR CLASS=\"folder-index-header\"><TH ALIGN=CENTER>%s</TH><TH>&nbsp;</TH><TH>%s</TH><TH>%s</TH><TH>%s</TH><TH>%s</TH></TR>\n",
+		 
+		 getarg("NUM"),
+		 getarg("DATE"),
+		 getarg("FROM"),
+		 getarg("SUBJECT"),
+		 getarg("SIZE"));
+	}else{
+	  /*
+	  printf("%s &nbsp; %s%s%s%s\n",
+		 
+		 getarg("NUM"),
+		 getarg("DATE"),
+		 getarg("FROM"),
+		 getarg("SUBJECT"),
+		 getarg("SIZE"));
+	  */
 	}
-	printf("%s", afterlab);
-	if (moreafter)
-		printf("</A>");
-
-	printf("</TD></TR></TABLE>\n");
-
-	printf("</TD></TR></TABLE>");
-	printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=4><TR CLASS=\"folder-index-header\"><TH ALIGN=CENTER>%s</TH><TH>&nbsp;</TH><TH>%s</TH><TH>%s</TH><TH>%s</TH><TH>%s</TH></TR>\n",
-
-	       getarg("NUM"),
-	       getarg("DATE"),
-	       getarg("FROM"),
-	       getarg("SUBJECT"),
-	       getarg("SIZE"));
-
 	found=0;
 	for (i=0; i<pref_flagpagesize; i++)
 	{
@@ -411,45 +432,75 @@
 		type[0]=maildirfile_type(MSGINFO_FILENAME(contents[i]));
 		type[1]='\0';
 		if (type[0] == '\0')	strcpy(type, "&nbsp;");
-
-		start_bold="<font class=\"read-message\">"; end_bold="</font>";
-
+		if (!mobile || !*mobile){
+		  start_bold="<font class=\"read-message\">"; end_bold="</font>";
+		}else{
+		  start_bold=""; end_bold="";
+		}
 		if (type[0] == MSGTYPE_NEW)
 		{
+		  if (!mobile || !*mobile){
 			start_bold="<B CLASS=\"unread-message\">";
 			end_bold="</B>";
+		  }else{
+		    start_bold=""; end_bold="";
+		  }
 		}
 
 		p=MSGINFO_FILENAME(contents[i]);
 
 		if ((q=strrchr(p, '/')) != 0)
 			p=q+1;
-
-		printf("<TR CLASS=\"folder-index-bg-%d\"><TD ALIGN=RIGHT>%s%s<font class=\"message-number\">%ld.</font>%s%s</TD><TD><INPUT TYPE=CHECKBOX NAME=\"MOVE-%ld",
-		       (i & 1)+1,
-		       folder_index_entry_start, start_bold,
-		       (long)(i+pos+1),
-		       end_bold, folder_index_entry_end,
-		       (long) (pos+i));
-		printf("\"%s><INPUT TYPE=HIDDEN NAME=\"MOVEFILE-%ld\" VALUE=\"",
-			(type[0] == MSGTYPE_DELETED ? " DISABLED":""),
-			(long)(pos+i));
-		output_attrencoded(p);
-		printf("\">&nbsp;%s%s<font class=\"message-status\">%s</font>%s%s</TD><TD>%s%s",
-		       folder_index_entry_start, start_bold,
-		       type,
-		       end_bold, folder_index_entry_end,
-
-			folder_index_entry_start, start_bold
-			);
+		if (!mobile || !*mobile){
+		  printf("<TR CLASS=\"folder-index-bg-%d\"><TD ALIGN=RIGHT>%s%s<font class=\"message-number\">%ld.</font>%s%s</TD><TD><INPUT TYPE=CHECKBOX NAME=\"MOVE-%ld",
+			 (i & 1)+1,
+			 folder_index_entry_start, start_bold,
+			 (long)(i+pos+1),
+			 end_bold, folder_index_entry_end,
+			 (long) (pos+i));
+		  printf("\"%s><INPUT TYPE=HIDDEN NAME=\"MOVEFILE-%ld\" VALUE=\"",
+			 (type[0] == MSGTYPE_DELETED ? " DISABLED":""),
+			 (long)(pos+i));
+		  output_attrencoded(p);
+		  printf("\">&nbsp;%s%s<font class=\"message-status\">%s</font>%s%s</TD><TD>%s%s",
+			 folder_index_entry_start, start_bold,
+			 type,
+			 end_bold, folder_index_entry_end,
+			 
+			 folder_index_entry_start, start_bold
+			 );
+		}else{
+		  printf("%s%ld.%s",
+			 start_bold,
+			 (long)(i+pos+1),
+			 end_bold);
+
+		  printf("&nbsp;%s %s %s %s",
+			 start_bold,
+			 type,
+			 end_bold,
+			 start_bold
+			 );
+		}
 		if (!*date)	date=" ";
-		folder_msg_link("message-date", dir, pos+i, type[0]);
+		if (!mobile || !*mobile){
+		  folder_msg_link("message-date", dir, pos+i, type[0]);
+		}
 		print_safe(date);
-		folder_msg_unlink(dir, pos+i, type[0]);
-		printf("%s%s</TD><TD>%s%s", end_bold, folder_index_entry_end,
-				folder_index_entry_start, start_bold);
+		if (!mobile || !*mobile){
+		  folder_msg_unlink(dir, pos+i, type[0]);
+		}
+		if (!mobile || !*mobile){
+		  printf("%s%s</TD><TD>%s%s", end_bold, folder_index_entry_end,
+			 folder_index_entry_start, start_bold);
+		}else{
+		  printf("%s %s", end_bold,
+			 start_bold);
+		}
 		if (!*from)	from=" ";
-		folder_msg_link("message-from", dir, pos+i, type[0]);
+		if (!mobile || !*mobile){
+		  folder_msg_link("message-from", dir, pos+i, type[0]);
+		}
 
 		froms=rfc2047_decode_simple(from);
 		if (froms == 0)	enomem();
@@ -457,11 +508,21 @@
 			strcpy(froms+27, "...");
 		print_safe(froms);
 		free(froms);
-		folder_msg_unlink(dir, pos+i, type[0]);
-		printf("%s%s<BR></TD><TD>%s%s", end_bold, folder_index_entry_end,
-				folder_index_entry_start, start_bold);
-
-		folder_msg_link("message-subject", dir, pos+i, type[0]);
+		if (!mobile || !*mobile){
+		  folder_msg_unlink(dir, pos+i, type[0]);
+		}
+		if (!mobile || !*mobile){
+		  printf("%s%s<BR></TD><TD>%s%s", end_bold, folder_index_entry_end,
+			 folder_index_entry_start, start_bold);
+		}else{
+		  printf("%s %s", end_bold,
+			 start_bold);
+		}
+		if (!mobile || !*mobile){
+		  folder_msg_link("message-subject", dir, pos+i, type[0]);
+		}else{
+		  folder_msg_link("", dir, pos+i, type[0]);
+		}
 
 		subjs=rfc2047_decode_simple(subj);
 		if (subjs == 0)	enomem();
@@ -474,23 +535,39 @@
 		free(subjs);
 
 		folder_msg_unlink(dir, pos+i, type[0]);
-		printf("%s%s</TD><TD ALIGN=RIGHT>%s%s<font class=\"message-size\">%s&nbsp;</font>%s%s<BR></TD></TR>\n", end_bold, folder_index_entry_end, folder_index_entry_start, start_bold, size, end_bold, folder_index_entry_end);
+		if (!mobile || !*mobile){
+		  printf("%s%s</TD><TD ALIGN=RIGHT>%s%s<font class=\"message-size\">%s&nbsp;</font>%s%s<BR></TD></TR>\n", end_bold, folder_index_entry_end, folder_index_entry_start, start_bold, size, end_bold, folder_index_entry_end);
+		}else{
+		  printf("%s %s %s &nbsp; %s<BR>\n", end_bold, start_bold, size, end_bold);
+		}
 	}
 	if (found)
 	{
+	  if (!mobile || !*mobile){
 		puts("<TR CLASS=\"folder-index-bg-1\"><TD COLSPAN=6><HR></TD></TR>");
 		puts("<TR CLASS=\"folder-index-bg-2\"><TD>&nbsp;</TD>");
 		printf("<TD COLSPAN=5><INPUT TYPE=CHECKBOX NAME=\"SELECTALL\">&nbsp;%s</TD></TR>",
 			selectalllab);
+	  }else{
+	    /*printf("<INPUT TYPE=CHECKBOX NAME=\"SELECTALL\">&nbsp;%s",
+	      selectalllab);*/
+	  }
 	}
 	if (!found && nomsg)
 	{
+	  if (!mobile || !*mobile){
 		puts("<TR CLASS=\"folder-index-bg-1\"><TD COLSPAN=6 ALIGN=LEFT><P>");
 		puts(nomsg);
 		puts("<BR></TD></TR>");
+	  }else{
+		puts(nomsg);
+	  }
 	}
+	if (!mobile || !*mobile){
+	  printf("</TABLE>\n");
+	}else{
 
-	printf("</TABLE>\n");
+	}
 	maildir_free(contents, pref_flagpagesize);
 }
 
@@ -571,6 +648,7 @@
 #if HAVE_SQWEBMAIL_UNICODE
 	int fd;
 #endif
+	const char *mobile=getenv("SQWEBMAIL_MOBILE");
 
 	cgi_put(MIMEGPGFILENAME, "");
 
@@ -684,8 +762,10 @@
 	info=maildir_read(dir, 1, &pos, &msg_hasprev, &msg_hasnext);
 	msg_pos=pos;
 
-	printf("<INPUT TYPE=HIDDEN NAME=\"pos\" VALUE=\"%ld\">",
+	if (!mobile || !*mobile){
+	  printf("<INPUT TYPE=HIDDEN NAME=\"pos\" VALUE=\"%ld\">",
 		(long)msg_pos);
+	}
 
 	p=strrchr(MSGINFO_FILENAME(info[0]), '/');
 	if (p)	p++;
@@ -735,167 +815,233 @@
 
 void folder_nextprev()
 {
+const char *mobile=getenv("SQWEBMAIL_MOBILE");
+ if (!mobile || !*mobile){ 
 	printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS=\"message-menu-background\"><TR VALIGN=MIDDLE>");
 
     printf("<TD ALIGN=LEFT><TABLE BORDER=0 CELLSPACING=4 CELLPADDING=4><TR VALIGN=TOP>");
-
+ }
 	/* PREV */
-
-	printf("<TD CLASS=\"message-menu-button\">");
-
-	if (msg_hasprev)
-	{
-		printf("<A HREF=\"");
-		output_scriptptrget();
-		printf("&form=readmsg&pos=%ld\">",
-			(long)(msg_pos-1));
+        if (!mobile || !*mobile){
+	  printf("<TD CLASS=\"message-menu-button\">");
+	  
+	  if (msg_hasprev)
+	    {
+	      printf("<A HREF=\"");
+	      output_scriptptrget();
+	      printf("&form=readmsg&pos=%ld\">",
+		     (long)(msg_pos-1));
+	    }
+	  
+	  printf("%s", msg_prevlab ? msg_prevlab:"");
+	  
+	  if (msg_hasprev)
+	    {
+	      printf("</A>");
+	    }
+	  printf("</TD>");
+	}else{
+	  if (msg_hasprev)
+	    {
+	      printf("<A HREF=\"");
+	      output_scriptptrget();
+	      printf("&form=readmsg&pos=%ld\">",
+		     (long)(msg_pos-1));
+	    }
+	  
+	  printf("%s", msg_prevlab ? msg_prevlab:"");
+	  
+	  if (msg_hasprev)
+	    {
+	      printf("</A>");
+	    }
 	}
-
-	printf("%s", msg_prevlab ? msg_prevlab:"");
-
-	if (msg_hasprev)
-	{
-		printf("</A>");
-	}
-	printf("</TD>");
-
 	/* NEXT */
-
-	printf("<TD CLASS=\"message-menu-button\">");
-
-	if (msg_hasnext)
-	{
-		printf("<A HREF=\"");
-		output_scriptptrget();
+	if (!mobile || !*mobile){
+	  printf("<TD CLASS=\"message-menu-button\">");
+	  
+	  if (msg_hasnext)
+	    {
+	      printf("<A HREF=\"");
+	      output_scriptptrget();
 		printf("&form=readmsg&pos=%ld\">",
-			(long)(msg_pos+1));
-	}
-
-	printf("%s", msg_nextlab ? msg_nextlab:"");
-
-	if (msg_hasnext)
-	{
-		printf("</A>");
+		       (long)(msg_pos+1));
+	    }
+	  
+	  printf("%s", msg_nextlab ? msg_nextlab:"");
+	  
+	  if (msg_hasnext)
+	    {
+	      printf("</A>");
+	    }
+	  printf("</TD>");
+	}else{
+	  if (msg_hasnext)
+	    {
+	      printf("<A HREF=\"");
+	      output_scriptptrget();
+		printf("&form=readmsg&pos=%ld\">",
+		       (long)(msg_pos+1));
+	    }
+	  
+	  printf("%s", msg_nextlab ? msg_nextlab:"");
+	  
+	  if (msg_hasnext)
+	    {
+	      printf("</A>");
+	    }
 	}
-	printf("</TD>");
-
 	/* DEL */
+	if (!mobile || !*mobile){
+	  printf("<TD CLASS=\"message-menu-button\">");
+	  if (msg_type != MSGTYPE_DELETED)
+	    {
+	      printf("<A HREF=\"");
+	      output_scriptptrget();
+	      tokennewget();
+	      printf("&posfile=");
+	      output_urlencoded(msg_posfile);
+	      printf("&form=delmsg&pos=%ld\">",
+		     (long)msg_pos);
+	    }
+	  printf("%s", strcmp(sqwebmail_folder, TRASH) == 0
+		 ? msg_purgelab : msg_deletelab);
+	  
+	  if (msg_type != MSGTYPE_DELETED)
+	    printf("</A>");
+	  
+	  printf("</TD>\n");
+	}else{
+	  if (msg_type != MSGTYPE_DELETED)
+	    {
+	      printf("<A HREF=\"");
+	      output_scriptptrget();
+	      tokennewget();
+	      printf("&posfile=");
+	      output_urlencoded(msg_posfile);
+	      printf("&form=delmsg&pos=%ld\">",
+		     (long)msg_pos);
+	    }
+	  printf("%s", strcmp(sqwebmail_folder, TRASH) == 0
+		 ? msg_purgelab : msg_deletelab);
+	  
+	  if (msg_type != MSGTYPE_DELETED)
+	    printf("</A>");
 
-	printf("<TD CLASS=\"message-menu-button\">");
-	if (msg_type != MSGTYPE_DELETED)
-	{
-		printf("<A HREF=\"");
-		output_scriptptrget();
-		tokennewget();
-		printf("&posfile=");
-		output_urlencoded(msg_posfile);
-		printf("&form=delmsg&pos=%ld\">",
-			(long)msg_pos);
 	}
-	printf("%s", strcmp(sqwebmail_folder, TRASH) == 0
-		? msg_purgelab : msg_deletelab);
-
-	if (msg_type != MSGTYPE_DELETED)
-		printf("</A>");
-
-	printf("</TD>\n");
-
 	/* FOLDER */
-
-	printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
-	output_scriptptrget();
-	printf("&pos=%ld&form=folder\">%s</A></TD>\n",
-		(long)( (msg_pos/pref_flagpagesize)*pref_flagpagesize ),
-		msg_folderlab);
-
+	if (!mobile || !*mobile){
+	  
+	  printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
+	  output_scriptptrget();
+	  printf("&pos=%ld&form=folder\">%s</A></TD>\n",
+		 (long)( (msg_pos/pref_flagpagesize)*pref_flagpagesize ),
+		 msg_folderlab);
+	}
 	/* REPLY */
-
-	printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
-	output_scriptptrget();
-	output_mimegpgfilename();
-	printf("&pos=%ld&reply=1&form=newmsg\">%s</A></TD>\n",
-		(long)msg_pos,
+	if (!mobile || !*mobile){
+	  printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
+	  output_scriptptrget();
+	  output_mimegpgfilename();
+	  printf("&pos=%ld&reply=1&form=newmsg\">%s</A></TD>\n",
+		 (long)msg_pos,
+		 msg_replylab);
+	}else{
+	  printf("<A HREF=\"");
+	  output_scriptptrget();
+	  output_mimegpgfilename();
+	  printf("&pos=%ld&reply=1&form=newmsg\">%s</A>\n",
+		 (long)msg_pos,
 		msg_replylab);
-
+	}
 	/* REPLY ALL */
-
-	printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
-	output_scriptptrget();
-	output_mimegpgfilename();
-	printf("&pos=%ld&replyall=1&form=newmsg\">%s</A></TD>\n",
-		(long)msg_pos,
-		msg_replyalllab);
-
+	if (!mobile || !*mobile){
+	  printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
+	  output_scriptptrget();
+	  output_mimegpgfilename();
+	  printf("&pos=%ld&replyall=1&form=newmsg\">%s</A></TD>\n",
+		 (long)msg_pos,
+		 msg_replyalllab);
+	}else{
+	  printf("<A HREF=\"");
+	  output_scriptptrget();
+	  output_mimegpgfilename();
+	  printf("&pos=%ld&replyall=1&form=newmsg\">%s</A>\n",
+		 (long)msg_pos,
+		 msg_replyalllab);
+	}
 	/* REPLY LIST */
-
-	printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
-	output_scriptptrget();
-	output_mimegpgfilename();
-	printf("&pos=%ld&replylist=1&form=newmsg\">%s</A></TD>\n",
-		(long)msg_pos,
-		msg_replylistlab);
-
-	printf("<TD WIDTH=\"100%%\"></TD></TR></TABLE><TABLE BORDER=0 CELLSPACING=4 CELLPADDING=4><TR>");
-
+	if (!mobile || !*mobile){
+	  printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
+	  output_scriptptrget();
+	  output_mimegpgfilename();
+	  printf("&pos=%ld&replylist=1&form=newmsg\">%s</A></TD>\n",
+		 (long)msg_pos,
+		 msg_replylistlab);
+	  printf("<TD WIDTH=\"100%%\"></TD></TR></TABLE><TABLE BORDER=0 CELLSPACING=4 CELLPADDING=4><TR>");
+	}
 	/* FORWARD */
-
-	printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
-	output_scriptptrget();
-	output_mimegpgfilename();
-	printf("&pos=%ld&forward=1&form=newmsg\">%s</A></TD>\n",
-		(long)msg_pos,
-		msg_forwardlab);
-
+	if (!mobile || !*mobile){
+	  printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
+	  output_scriptptrget();
+	  output_mimegpgfilename();
+	  printf("&pos=%ld&forward=1&form=newmsg\">%s</A></TD>\n",
+		 (long)msg_pos,
+		 msg_forwardlab);
+	}
 	/* FORWARD AS ATTACHMENT*/
-
-	printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
-	output_scriptptrget();
-	output_mimegpgfilename();
-	printf("&pos=%ld&forwardatt=1&form=newmsg\">%s</A></TD>\n",
-		(long)msg_pos,
-		msg_forwardattlab);
-
+	if (!mobile || !*mobile){
+	  printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
+	  output_scriptptrget();
+	  output_mimegpgfilename();
+	  printf("&pos=%ld&forwardatt=1&form=newmsg\">%s</A></TD>\n",
+		 (long)msg_pos,
+		 msg_forwardattlab);
+	}
 	/* FULL HEADERS */
-
-	if (!pref_flagfullheaders && !*cgi("fullheaders"))
-	{
-		printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
-		output_scriptptrget();
-		output_mimegpgfilename();
-		printf("&pos=%ld&form=readmsg&fullheaders=1\">%s</A></TD>\n",
-			(long)msg_pos, msg_fullheaderlab);
+	if (!mobile || !*mobile){
+	  if (!pref_flagfullheaders && !*cgi("fullheaders"))
+	    {
+	      printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
+	      output_scriptptrget();
+	      output_mimegpgfilename();
+	      printf("&pos=%ld&form=readmsg&fullheaders=1\">%s</A></TD>\n",
+		     (long)msg_pos, msg_fullheaderlab);
+	    }
 	}
-
 	/* PRINT MESSAGE */
-
-	printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
-	output_scriptptrget();
-	output_mimegpgfilename();
-
-	if (pref_flagfullheaders || *cgi("fullheaders"))
-	{
-		printf("&pos=%ld&form=print&setcookie=1&fullheaders=1\" TARGET=\"_BLANK\">%s</A></TD>\n", (long)msg_pos, msg_print);
-	}
-	else
-	{
+	if (!mobile || !*mobile){
+	  printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
+	  output_scriptptrget();
+	  output_mimegpgfilename();
+	  
+	  if (pref_flagfullheaders || *cgi("fullheaders"))
+	    {
+	      printf("&pos=%ld&form=print&setcookie=1&fullheaders=1\" TARGET=\"_BLANK\">%s</A></TD>\n", (long)msg_pos, msg_print);
+	    }
+	  else
+	    {
 		printf("&pos=%ld&form=print&setcookie=1\" TARGET=\"_BLANK\">%s</A></TD>\n", (long)msg_pos, msg_print);
+	    }
 	}
-
 	/* SAVE MESSAGE */
-
-	printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
-	output_scriptptrget();
-	output_mimegpgfilename();
-
-	printf("&pos=%ld&form=fetch&download=1\">%s</A></TD>", (long)msg_pos,
-	       getarg("SAVEMESSAGE"));
-
-    printf("<TD WIDTH=100%%></TD></TR></TABLE></TD><TD ALIGN=RIGHT VALIGN=CENTER>");
-
-	printf("<TABLE BORDER=0 CELLSPACING=4><TR><TD CLASS=\"message-x-of-y\" color=\"#FFFFFF\">&nbsp;");
-	printf(msg_msglab, (int)msg_pos+1, (int)msg_count);
-	printf("&nbsp;</TD></TR></TABLE>");
-    printf("</TD></TR></TABLE>\n");
+	if (!mobile || !*mobile){
+	  printf("<TD CLASS=\"message-menu-button\"><A HREF=\"");
+	  output_scriptptrget();
+	  output_mimegpgfilename();
+	  
+	  printf("&pos=%ld&form=fetch&download=1\">%s</A></TD>", (long)msg_pos,
+		 getarg("SAVEMESSAGE"));
+	}
+
+	if (!mobile || !*mobile){  
+	  printf("<TD WIDTH=100%%></TD></TR></TABLE></TD><TD ALIGN=RIGHT VALIGN=CENTER>");
+	  
+	  printf("<TABLE BORDER=0 CELLSPACING=4><TR><TD CLASS=\"message-x-of-y\" color=\"#FFFFFF\">&nbsp;");
+	  printf(msg_msglab, (int)msg_pos+1, (int)msg_count);
+	  printf("&nbsp;</TD></TR></TABLE>");
+	  printf("</TD></TR></TABLE>\n");
+	}
 }
 
 void list_folder(const char *p)
@@ -996,20 +1142,34 @@
 
 void folder_msgmove()
 {
+const char *mobile=getenv("SQWEBMAIL_MOBILE");
 	++initnextprevcnt;
-	printf("<TABLE BORDER=0 class=\"box-small-outer\"><TR><TD>\n");
-	printf("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD CLASS=\"folder-move-background\">&nbsp;%s&nbsp;<SELECT NAME=list%d>\n", msg_movetolab, initnextprevcnt);
-
+	if (!mobile || !*mobile){ 
+	  printf("<TABLE BORDER=0 class=\"box-small-outer\"><TR><TD>\n");
+	  printf("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD CLASS=\"folder-move-background\">&nbsp;%s&nbsp;<SELECT NAME=list%d>\n", msg_movetolab, initnextprevcnt);
+	}else{
+	  printf("%s&nbsp;<SELECT NAME=list%d>\n", msg_movetolab, initnextprevcnt);
+	}
 	show_transfer_dest(sqwebmail_folder);
-
-	printf("</SELECT><INPUT TYPE=SUBMIT %s NAME=move%d VALUE=\"%s\"></TD></TR></TABLE>\n",
-		(msg_type == MSGTYPE_DELETED ? "DISABLED":""),
-		initnextprevcnt,
-		msg_golab ? msg_golab:"");
-	printf("<input type=hidden name=pos value=\"%s\">", cgi("pos"));
-	printf("<input type=hidden name=posfile value=\"");
-	output_attrencoded(msg_posfile ? msg_posfile:"");
-	printf("\"></TD></TR></TABLE>\n");
+	if (!mobile || !*mobile){ 
+	  printf("</SELECT><INPUT TYPE=SUBMIT %s NAME=move%d VALUE=\"%s\"></TD></TR></TABLE>\n",
+		 (msg_type == MSGTYPE_DELETED ? "DISABLED":""),
+		 initnextprevcnt,
+		 msg_golab ? msg_golab:"");
+	  printf("<input type=hidden name=pos value=\"%s\">", cgi("pos"));
+	  printf("<input type=hidden name=posfile value=\"");
+	  output_attrencoded(msg_posfile ? msg_posfile:"");
+	  printf("\"></TD></TR></TABLE>\n");
+	}else{
+	  printf("</SELECT><INPUT TYPE=SUBMIT %s NAME=move%d VALUE=\"%s\">\n",
+		 (msg_type == MSGTYPE_DELETED ? "DISABLED":""),
+		 initnextprevcnt,
+		 msg_golab ? msg_golab:"");
+	  printf("<input type=hidden name=pos value=\"%s\">", cgi("pos"));
+	  printf("<input type=hidden name=posfile value=\"");
+	  output_attrencoded(msg_posfile ? msg_posfile:"");
+	  printf("\">\n");
+	}
 }
 
 void folder_delmsg(size_t pos)
@@ -1397,9 +1557,16 @@
 
 void print_header_uc(char *h)
 {
+const char *mobile=getenv("SQWEBMAIL_MOBILE");
+ if (!mobile || !*mobile){ 
 	header_uc(h);
 	printf("<TR VALIGN=BASELINE><TH ALIGN=RIGHT CLASS=\"message-rfc822-header-name\">%s:<TT>&nbsp;</TT></TH>",
 	       h);
+ }else{
+	header_uc(h);
+	printf("%s:",
+	       h);
+ }
 }
 
 static void showmsgrfc822_body(FILE *fp, struct rfc2045 *rfc, struct rfc2045id *idptr, int flag)
@@ -1412,6 +1579,7 @@
 struct	rfc2045id *p, newpart;
 off_t	dummy;
 off_t	pos;
+const char *mobile=getenv("SQWEBMAIL_MOBILE");
 
 	rfc2045_mimepos(rfc, &start_pos, &end_pos, &start_body, &dummy, &dummy);
 	if (fseek(fp, start_pos, SEEK_SET) < 0)
@@ -1419,10 +1587,13 @@
 		error("Seek error.");
 		return;
 	}
-
-	printf("<P><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 CLASS=\"message-rfc822-header\">\n");
-	par="";	/* Obsolete */
-
+ 
+	if (!mobile || !*mobile){
+	  printf("<P><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 CLASS=\"message-rfc822-header\">\n");
+	  par="";	/* Obsolete */
+	}else{
+	  par="";	/* Obsolete */
+	}
 	pos=start_pos;
 	while ((header=maildir_readheader_mimepart(fp, &value, 1,
 		&pos, &start_body)) != 0)
@@ -1436,9 +1607,14 @@
 		{
 			print_header_uc(header);
 			par="";
-			printf("<TD><TT CLASS=\"message-rfc822-header-contents\">");
-			showmsgrfc2369_header(value);
-			printf("</TT></TD></TR>\n");
+			if (!mobile || !*mobile){
+			  printf("<TD><TT CLASS=\"message-rfc822-header-contents\">");
+			  showmsgrfc2369_header(value);
+			  printf("</TT></TD></TR>\n");
+			}else{
+			  showmsgrfc2369_header(value);
+			  printf("<BR>");
+			}
 			continue;
 		}
 
@@ -1447,12 +1623,20 @@
 		int	isaddress=isaddressheader(header);
 
 			print_header_uc(header);
-			printf("<TD><TT CLASS=\"message-rfc822-header-contents\">");
-			if (isaddress)
-				showmsgrfc822_addressheader(value);
-			else
-				showmsgrfc822_header(value);
-			printf("</TT></TD></TR>\n");
+			if (!mobile || !*mobile){
+			  printf("<TD><TT CLASS=\"message-rfc822-header-contents\">");
+			  if (isaddress)
+			    showmsgrfc822_addressheader(value);
+			  else
+			    showmsgrfc822_header(value);
+			  printf("</TT></TD></TR>\n");
+			}else{
+			  if (isaddress)
+			    showmsgrfc822_addressheader(value);
+			  else
+			    showmsgrfc822_header(value);
+			  printf("<BR>");
+			}
 			par="";
 			continue;
 		}
@@ -1477,9 +1661,14 @@
 		if (isaddressheader(header))
 		{
 			print_header_uc(header);
-			printf("<TD><TT CLASS=\"message-rfc822-header-contents\">");
-			showmsgrfc822_addressheader(value);
-			printf("</TT></TD></TR>\n");
+			if (!mobile || !*mobile){
+			  printf("<TD><TT CLASS=\"message-rfc822-header-contents\">");
+			  showmsgrfc822_addressheader(value);
+			  printf("</TT></TD></TR>\n");
+			}else{
+			  showmsgrfc822_addressheader(value);
+			  printf("<BR>");
+			}
 			par="";
 		}
 	}
@@ -1498,9 +1687,14 @@
 			print_header_uc(date_header);
 			strftime(date_buf, sizeof(date_buf)-1, "%d %b %Y, %I:%M:%S %p", tmp);
 			date_buf[sizeof(date_buf)-1]=0;
-			printf("<TD><TT CLASS=\"message-rfc822-header-contents\">");
-			showmsgrfc822_header(date_buf);
-			printf("</TT></TD></TR>\n");
+			if (!mobile || !*mobile){
+			  printf("<TD><TT CLASS=\"message-rfc822-header-contents\">");
+			  showmsgrfc822_header(date_buf);
+			  printf("</TT></TD></TR>\n");
+			}else{
+			  showmsgrfc822_header(date_buf);
+			  printf("<BR>");
+			}
 			par="";
 		}
 		free(save_date);
@@ -1512,20 +1706,31 @@
 
 		strcpy(subj_header, "Subject");
 		print_header_uc(subj_header);
-
-		printf("<TD><TT CLASS=\"message-rfc822-header-contents\">");
-		showmsgrfc822_header(save_subject);
-		printf("</TT></TD></TR>\n");
+		if (!mobile || !*mobile){
+		  printf("<TD><TT CLASS=\"message-rfc822-header-contents\">");
+		  showmsgrfc822_header(save_subject);
+		  printf("</TT></TD></TR>\n");
+		}else{
+		  showmsgrfc822_header(save_subject);
+		  printf("<BR>");
+		}
 		par="";
 	}
 
 	if (flag && !is_preview_mode())
 	{
-		printf("<TR VALIGN=TOP><TD>&nbsp;</TD><TD ALIGN=LEFT VALIGN=TOP>");
-		digestaction(idptr);
-		printf("</TD></TR>\n");
+	  if (!mobile || !*mobile){
+	    printf("<TR VALIGN=TOP><TD>&nbsp;</TD><TD ALIGN=LEFT VALIGN=TOP>");
+	    digestaction(idptr);
+	    printf("</TD></TR>\n");
+	  }else{
+	    digestaction(idptr);
+	    printf("<BR>");
+	  }
+	}
+	if (!mobile || !*mobile){
+	  printf("</TABLE>\n<HR WIDTH=\"100%%\">\n");
 	}
-	printf("</TABLE>\n<HR WIDTH=\"100%%\">\n");
 
 #if HAVE_SQWEBMAIL_UNICODE
 	if (!flag && has_gpg(GPGDIR) == 0 && gpgmime_has_mimegpg(rfc))
@@ -1600,7 +1805,7 @@
 static void showaddressheader_printc(char c, void *p)
 {
 	struct showaddrinfo *sai= (struct showaddrinfo *)p;
-
+	const char *mobile=getenv("SQWEBMAIL_MOBILE");
 	if (sai->isfirstchar)
 	{
 		char *name=0;
@@ -1636,12 +1841,17 @@
 				output_urlencoded(addr);
 				free(addr);
 			}
-
-			printf("\" STYLE=\"text-decoration: none\" "
-			       "ONMOUSEOVER=\"window.status='%s'; return true;\" "
-			       "ONMOUSEOUT=\"window.status=''; return true;\" >"
-			       "<FONT CLASS=\"message-rfc822-header-address\">",
-			       msg_add ? msg_add:"");
+			if (!mobile || !*mobile){
+			  printf("\" STYLE=\"text-decoration: none\" "
+				 "ONMOUSEOVER=\"window.status='%s'; return true;\" "
+				 "ONMOUSEOUT=\"window.status=''; return true;\" >"
+				 "<FONT CLASS=\"message-rfc822-header-address\">",
+				 msg_add ? msg_add:"");
+			}else{
+			  printf("\""
+				 ">"
+				 "<FONT>");
+			}
 		}
 
 		sai->isfirstchar=0;
@@ -2303,6 +2513,7 @@
 
 static void showtextplain(FILE *fp, struct rfc2045 *rfc, struct rfc2045id *id)
 {
+const char *mobile=getenv("SQWEBMAIL_MOBILE");
 	int rc;
 
 	const char *mime_charset, *dummy;
@@ -2358,12 +2569,15 @@
 			rfc2646tohtml_free(flowtohtml);
 			enomem();
 		}
-
-		printf("<TT CLASS=\"message-text-plain\">");
+		if (!mobile || !*mobile){
+		  printf("<TT CLASS=\"message-text-plain\">");
+		}
 	}
 	else
 	{
-		printf("<TT><PRE CLASS=\"message-text-plain\">");
+	        if (!mobile || !*mobile){ 
+		  printf("<TT><PRE CLASS=\"message-text-plain\">");
+		}
 		filter_start(FILTER_FOR_DISPLAY, &showtextplainfunc);
 	}
 
@@ -2392,10 +2606,19 @@
 	showtextplainfunc(0, 0);
 	buf_free(&showtextplain_buf);
 
-	if (isflowed)
-		printf("</TT><BR>\n");
-	else
-		printf("</PRE></TT><BR>\n");
+	if (isflowed){
+	  if (!mobile || !*mobile){
+	    printf("</TT><BR>\n");
+	  }else{
+	    printf("<BR>\n");
+	  }
+	}else{
+	  if (!mobile || !*mobile){
+	    printf("</PRE></TT><BR>\n");
+	  }else{
+	    printf("</PRE><BR>\n");
+	  }
+	}
 }
 
 static void showdsn(FILE *fp, struct rfc2045 *rfc, struct rfc2045id *id)
@@ -2775,6 +2998,7 @@
 const char	*folders_img;
 
 const char *folderdir;
+const char *mobile=getenv("SQWEBMAIL_MOBILE");
 
 	unread_label=getarg("UNREAD");
 	err_invalid=getarg("INVALID");
@@ -2944,15 +3168,19 @@
 
 	sqwebmail_folder=0;
 	folderdir=cgi("folderdir");
-
-       	printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLPADDING=2 CELLSPACING=0 class=\"folderlist\">\n");
+	if (!mobile || !*mobile){
+	  printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLPADDING=2 CELLSPACING=0 class=\"folderlist\">\n");
+	}
 	maildir_readfolders(&folders);
 	if (*folderdir)
 	{
 	char *parentfolder=get_parent_folder(folderdir);
 	size_t	i;
-
+	if (!mobile || !*mobile){
 		printf("<TR><TD ALIGN=LEFT COLSPAN=2 class=\"folderparentdir\">%s&lt;&lt;&lt;&nbsp;<A HREF=\"", folders_img);
+	}else{
+	  printf("%s&lt;&lt;&lt;&nbsp;<A HREF=\"", folders_img);
+	}
 		output_scriptptrget();
 		printf("&form=folders&folder=INBOX\">");
 		print_safe(name_inbox);
@@ -2982,7 +3210,11 @@
 			if ( (*p=c) != 0)	++p;
 			i=p-parentfolder;
 		}
-		printf("</TD></TR>\n");
+		if (!mobile || !*mobile){
+		  printf("</TD></TR>\n");
+		}else{
+		  printf("<BR>");
+		}
 		free(parentfolder);
 	}
 
@@ -3037,7 +3269,12 @@
 			s[p-folders[i]]=0;
 
 			img=folders_img;
-			printf("<TR class=\"foldersubdir\"><TD ALIGN=LEFT>%s%s&nbsp;<A HREF=\"", img, pfix);
+			if (!mobile || !*mobile){
+			  printf("<TR class=\"foldersubdir\"><TD ALIGN=LEFT>%s%s&nbsp;<A HREF=\"", img, pfix);
+			}else{
+			  /*printf("%s%s&nbsp;<A HREF=\"", img, pfix);*/
+			  printf("%s<A HREF=\"",pfix);
+			}
 			output_scriptptrget();
 			printf("&form=folders&folder=INBOX&folderdir=");
 			output_urlencoded(s);
@@ -3074,8 +3311,13 @@
 				printf(unread_label, tot_nnew);
 				printf("</FONT>");
 			}
-			printf("</TD><TD ALIGN=RIGHT VALIGN=TOP><font color=\"#000000\" class=\"subfoldercnt\">%d</font>&nbsp;&nbsp;</TD></TR>\n\n",
-				tot_nnew + tot_nother);
+			if (!mobile || !*mobile){
+			  printf("</TD><TD ALIGN=RIGHT VALIGN=TOP><font color=\"#000000\" class=\"subfoldercnt\">%d</font>&nbsp;&nbsp;</TD></TR>\n\n",
+				 tot_nnew + tot_nother);
+			}else{
+			  printf("<font color=\"#000000\" class=\"subfoldercnt\">%d</font>&nbsp;&nbsp;<BR>\n\n",
+				 tot_nnew + tot_nother);
+			}
 			continue;
 		}
 
@@ -3084,21 +3326,28 @@
 
 		if (!isunsubscribed)
 			maildir_count(folders[i], &nnew, &nother);
-
-		printf("<TR %s><TD ALIGN=LEFT VALIGN=TOP>",
-			isunsubscribed ? "class=\"folderunsubscribed\"":"");
-
-		printf("%s<INPUT BORDER=0 TYPE=\"radio\" NAME=\"DELETE\" VALUE=\"", img);
-		output_attrencoded(folders[i]);
-		printf("\">&nbsp;");
+		if (!mobile || !*mobile){
+		  printf("<TR %s><TD ALIGN=LEFT VALIGN=TOP>",
+			 isunsubscribed ? "class=\"folderunsubscribed\"":"");
+		  
+		  printf("%s<INPUT BORDER=0 TYPE=\"radio\" NAME=\"DELETE\" VALUE=\"", img);
+		  output_attrencoded(folders[i]);
+		  printf("\">&nbsp;");
+		}else{
+		  /*printf("%s", img);*/
+		}
 
 		if (!isunsubscribed)
 		{
+		  if (!mobile || !*mobile){
 			printf("<A CLASS=\"folderlink\" HREF=\"");
-			output_scriptptrget();
-			printf("&form=folder&folder=");
-			output_urlencoded(folders[i]);
-			printf("\">");
+		  }else{
+		    printf("<A HREF=\"");
+		  }
+		  output_scriptptrget();
+		  printf("&form=folder&folder=");
+		  output_urlencoded(folders[i]);
+		  printf("\">");
 		}
 		if (strcmp(folders[i], INBOX) == 0)
 			shortname=name_inbox;
@@ -3114,23 +3363,39 @@
 			printf("</A>");
 		if (nnew)
 		{
+		  if (!mobile || !*mobile){
 			printf(" <FONT CLASS=\"folderlistunread\" COLOR=\"#800000\" SIZE=\"-1\">");
 			printf(unread_label, nnew);
 			printf("</FONT>");
+		  }else{
+		    printf(unread_label, nnew);
+		  }
+		}
+		if (!mobile || !*mobile){
+		  printf("</TD><TD ALIGN=RIGHT VALIGN=TOP>");
 		}
-		printf("</TD><TD ALIGN=RIGHT VALIGN=TOP>");
-
 		if (!isunsubscribed)
 		{
+		  if (!mobile || !*mobile){
 			printf("<font class=\"foldercnt\" color=\"#000000\">%d</font>&nbsp;&nbsp;",
 			       nnew + nother);
+		  }else{
+		    printf("%d&nbsp;",
+			       nnew + nother);
+		  }
 		}
 		else
 		printf("&nbsp;\n");
-		printf("</TD></TR>\n\n");
+		if (!mobile || !*mobile){
+		  printf("</TD></TR>\n\n");
+		}else{
+		  printf("<BR>");
+		}
 	}
 	maildir_freefolders(&folders);
-	printf("</TABLE>\n");
+	if (!mobile || !*mobile){
+	  printf("</TABLE>\n");
+	}
 }
 
 void folder_list2()
--- sqwebmail/newmsg.org.c	Tue Mar 19 16:28:34 2002
+++ sqwebmail/newmsg.c	Tue Mar 19 15:59:19 2002
@@ -65,13 +65,22 @@
 
 static void newmsg_header(const char *label, const char *field, const char *val)
 {
-	printf("<TR><TH ALIGN=RIGHT><P CLASS=\"new-message-header\">"
-	       "<FONT CLASS=\"new-message-header-%s\">%s</FONT></TD>"
-	       "<TD WIDTH=6>&nbsp;</TD>",
-	       field, label);
-
-	printf("<TD><INPUT NAME=%s SIZE=50 MAXLENGTH=512 VALUE=\"",
-		field);
+const char *mobile=getenv("SQWEBMAIL_MOBILE");
+        if (!mobile || !*mobile){
+	  printf("<TR><TH ALIGN=RIGHT><P CLASS=\"new-message-header\">"
+		 "<FONT CLASS=\"new-message-header-%s\">%s</FONT></TD>"
+		 "<TD WIDTH=6>&nbsp;</TD>",
+		 field, label);
+	  
+	  printf("<TD><INPUT NAME=%s SIZE=50 MAXLENGTH=512 VALUE=\"",
+		 field);
+	}else{
+	  printf("%s",
+		 label);
+	  
+	  printf("<INPUT NAME=%s SIZE=50 MAXLENGTH=512 VALUE=\"",
+		 field);
+	}
 	if (val)
 	{
 	char	*s;
@@ -81,7 +90,11 @@
 		output_attrencoded(s);
 		free(s);
 	}
-	printf("\"></TD></TR>\n");
+	if (!mobile || !*mobile){
+	  printf("\"></TD></TR>\n");
+	}else{
+	  printf("\"><BR>\n");
+	}
 }
 
 static const char *ispreviewmsg()
@@ -352,6 +365,7 @@
 	FILE	*fp;
 	int	attachcnt=0;
 	char	*cursubj, *curto, *curcc, *curbcc, *curfrom, *curreplyto;
+	const char *mobile=getenv("SQWEBMAIL_MOBILE");
 
 	/* Picking up an existing draft? */
 
@@ -395,9 +409,13 @@
 		if (strcmp(p, "SPELLCHK") == 0)
 			printf("%s<BR><BR>\n", checkspellingdone);
 #endif
-		printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=1 CLASS=\"box-small-outer\"><TR><TD>\n");
-		printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=4 CLASS=\"preview\"><TR><TD>\n");
+		if (!mobile || !*mobile){
 
+		  printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=1 CLASS=\"box-small-outer\"><TR><TD>\n");
+		  printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=4 CLASS=\"preview\"><TR><TD>\n");
+		}else{
+
+		}
 		if (draftmessagefilename)
 		{
 			const char *p=strrchr(draftmessagefilename, '/');
@@ -409,10 +427,14 @@
 
 			newmsg_preview(p);
 		}
-		printf("</TD></TR></TABLE>\n");
-		printf("</TD></TR></TABLE>\n");
+		if (!mobile || !*mobile){
+		  printf("</TD></TR></TABLE>\n");
+		  printf("</TD></TR></TABLE>\n");
+
+		  printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=6><TR><TD><HR WIDTH=\"80%%\"></TD></TR></TABLE>\n");
+		}else{
 
-		printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=6><TR><TD><HR WIDTH=\"80%%\"></TD></TR></TABLE>\n");
+		}
 	}
 
 	printf("<INPUT TYPE=HIDDEN NAME=form VALUE=\"donewmsg\">\n");
@@ -428,9 +450,14 @@
 
 	if (*cgi("foldermsg"))
 	{
+	  if (!mobile || !*mobile){
 		printf("<P><FONT CLASS=\"error\" COLOR=\"#FF0000\">");
 		output_attrencoded_nltobr(cgi("foldermsg"));
 		printf("</FONT><BR>");
+	  }else{
+		output_attrencoded_nltobr(cgi("foldermsg"));
+		printf("<BR>");
+	  }
 	}
 
 	if (strcmp(cgi("error"), "quota") == 0)
@@ -494,37 +521,55 @@
 			}
 		}
 	}
+	if (!mobile || !*mobile){
+	  printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=1 CLASS=\"box-small-outer\"><TR><TD>\n");
+	  printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=4 CLASS=\"new-message-box\"><TR><TD>\n");
 
-	printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=1 CLASS=\"box-small-outer\"><TR><TD>\n");
-	printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=4 CLASS=\"new-message-box\"><TR><TD>\n");
+	  printf("<TABLE BORDER=0 WIDTH=\"100%%\">\n");
+	}else{
 
-	printf("<TABLE BORDER=0 WIDTH=\"100%%\">\n");
+	}
 	if (access(NOCHANGINGFROM, 0))
 		newmsg_header(fromlab, "headerfrom", curfrom ? curfrom:
 			*cgi("from") ? cgi("from"):
 			pref_from && *pref_from ? pref_from:
 			login_fromhdr());
-
-	printf("<TR VALIGN=MIDDLE><TH ALIGN=RIGHT>"
-	       "<P CLASS=\"new-message-header\">"
-	       "<FONT CLASS=\"new-message-header-addressbook\">"
-	       "%s</FONT></TD><TD WIDTH=6>&nbsp;</TH>",
-	       addressbooklab);
-
-	printf("<TD VALIGN=MIDDLE>");
-	printf("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=4>");
-	printf("<TR VALIGN=MIDDLE><TD><SELECT NAME=\"nick\" SIZE=4 MULTIPLE>\n");
-	ab_listselect();
-	printf("</select></TD><TD WIDTH=\"100%%\">");
-	printf("<input type=submit name=\"addressbook_to\" value=\"%s\">",
-			tolab);
-	printf("<input type=submit name=\"addressbook_cc\" value=\"%s\">",
-			cclab);
-	printf("<input type=submit name=\"addressbook_bcc\" value=\"%s\">",
-			bcclab);
-	printf("</TD></TR></TABLE>");
-
-	printf("</TD></TR>\n");
+	if (!mobile || !*mobile){
+	  printf("<TR VALIGN=MIDDLE><TH ALIGN=RIGHT>"
+		 "<P CLASS=\"new-message-header\">"
+		 "<FONT CLASS=\"new-message-header-addressbook\">"
+		 "%s</FONT></TD><TD WIDTH=6>&nbsp;</TH>",
+		 addressbooklab);
+	  
+	  printf("<TD VALIGN=MIDDLE>");
+	  printf("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=4>");
+	  printf("<TR VALIGN=MIDDLE><TD><SELECT NAME=\"nick\" SIZE=4 MULTIPLE>\n");
+	  ab_listselect();
+	  printf("</select></TD><TD WIDTH=\"100%%\">");
+
+	  printf("<input type=submit name=\"addressbook_to\" value=\"%s\">",
+		 tolab);
+	  printf("<input type=submit name=\"addressbook_cc\" value=\"%s\">",
+		 cclab);
+	  printf("<input type=submit name=\"addressbook_bcc\" value=\"%s\">",
+		 bcclab);
+	  printf("</TD></TR></TABLE>");
+	  
+	  printf("</TD></TR>\n");
+	}else{
+	  printf("%s",
+		 addressbooklab);
+	  printf("<SELECT NAME=\"nick\" SIZE=4 MULTIPLE>\n");
+	  ab_listselect();
+	  printf("</select>");
+	  printf("<input type=\"submit\" name=\"addressbook_to\" value=\"%s\">",
+		 tolab);
+	  printf("<input type=\"submit\" name=\"addressbook_cc\" value=\"%s\">",
+		 cclab);
+	  printf("<input type=\"submit\" name=\"addressbook_bcc\" value=\"%s\">",
+		 bcclab);
+	  printf("<BR>\n");
+	}
 	newmsg_header(tolab, "headerto", curto ? curto:cgi("to"));
 	newmsg_header(cclab, "headercc", curcc ? curcc:cgi("cc"));
 	newmsg_header(bcclab, "headerbcc", curbcc ? curbcc:cgi("bcc"));
@@ -537,16 +582,20 @@
 	if (curcc)	free(curcc);
 	if (curbcc)	free(curbcc);
 	if (cursubj)	free(cursubj);
-
-	printf("<TR><TD COLSPAN=3><HR WIDTH=\"100%%\"></TD></TR>");
-	printf("<TR><TH VALIGN=TOP ALIGN=RIGHT>"
-	       "<P CLASS=\"new-message-header\">"
-	       "<FONT CLASS=\"new-message-header-message\">"
-	       "%s</FONT></P></TD><TD WIDTH=6>&nbsp;</TD>", messagelab);
-
-	printf("<TD><TEXTAREA NAME=message COLS=%d ROWS=15 WRAP=soft>",
-		MYLINESIZE);
-
+	if (!mobile || !*mobile){
+	  printf("<TR><TD COLSPAN=3><HR WIDTH=\"100%%\"></TD></TR>");
+	  printf("<TR><TH VALIGN=TOP ALIGN=RIGHT>"
+		 "<P CLASS=\"new-message-header\">"
+		 "<FONT CLASS=\"new-message-header-message\">"
+		 "%s</FONT></P></TD><TD WIDTH=6>&nbsp;</TD>", messagelab);
+	  
+	  printf("<TD><TEXTAREA NAME=message COLS=%d ROWS=15 WRAP=soft>",
+		 MYLINESIZE);
+	}else{
+	  printf("%s", messagelab);
+	  printf("<TEXTAREA NAME=message COLS=%d ROWS=15 WRAP=soft>",
+		 MYLINESIZE);
+	}
 	if (fp)
 	{
 		newmsg_showfp(fp, &attachcnt);
@@ -578,17 +627,24 @@
 		printf("\">");
 	}
 	if (draftmessage)	free(draftmessage);
-	printf("</TD></TR>\n");
-
-	printf("<TR><TD><P>&nbsp</TD><TD>&nbsp;</TD><TD><INPUT TYPE=SUBMIT NAME=doattachments VALUE=\"");
+	if (!mobile || !*mobile){
+	  printf("</TD></TR>\n");
 
-	printf(uploadlab, attachcnt);
-	printf("\"></TD></TR>");
+	  printf("<TR><TD><P>&nbsp</TD><TD>&nbsp;</TD><TD><INPUT TYPE=SUBMIT NAME=doattachments VALUE=\"");
 
-	printf("<TR><TD COLSPAN=2 ALIGN=RIGHT><INPUT TYPE=CHECKBOX "
-	       "NAME=fcc%s></TD><TD>%s</TD></TR>\n",
-	       pref_noarchive ? "":" CHECKED",
-	       getarg("PRESERVELAB"));
+	  printf(uploadlab, attachcnt);
+	  printf("\"></TD></TR>");
+	  
+	  printf("<TR><TD COLSPAN=2 ALIGN=RIGHT><INPUT TYPE=CHECKBOX "
+		 "NAME=fcc%s></TD><TD>%s</TD></TR>\n",
+		 pref_noarchive ? "":" CHECKED",
+		 getarg("PRESERVELAB"));
+	}else{
+	  printf("<INPUT TYPE=\"CHECKBOX\" "
+		 "NAME=fcc%s>%s<BR>\n",
+		 pref_noarchive ? "":" CHECKED",
+		 getarg("PRESERVELAB"));
+	}
 #if HAVE_SQWEBMAIL_UNICODE
 	if (has_gpg(GPGDIR) == 0)
 	{
@@ -623,23 +679,35 @@
 		fclose(fp);
 	if (draftmessagefilename)
 		free(draftmessagefilename);
-
-	printf("<TR><TD COLSPAN=2>&nbsp;</TD><TD>");
-	printf("<INPUT TYPE=SUBMIT NAME=previewmsg VALUE=\"%s\">",
-		previewlab);
-	printf("<INPUT TYPE=SUBMIT NAME=sendmsg VALUE=\"%s\">",
-		sendlab);
-	printf("<INPUT TYPE=SUBMIT NAME=savedraft VALUE=\"%s\">",
-		savedraft);
+	if (!mobile || !*mobile){
+	  printf("<TR><TD COLSPAN=2>&nbsp;</TD><TD>");
+	  printf("<INPUT TYPE=SUBMIT NAME=previewmsg VALUE=\"%s\">",
+		 previewlab);
+	}
+	if (!mobile || !*mobile){
+	  printf("<INPUT TYPE=SUBMIT NAME=sendmsg VALUE=\"%s\">",
+		 sendlab);
+	  printf("<INPUT TYPE=SUBMIT NAME=savedraft VALUE=\"%s\">",
+		 savedraft);
+	}else{
+	  printf("<INPUT TYPE=\"SUBMIT\" NAME=sendmsg VALUE=\"%s\"><BR>\n",
+		 sendlab);
+	  /*printf("<INPUT TYPE=SUBMIT NAME=savedraft VALUE=\"%s\"><BR>\n",
+	    savedraft);*/
+	}
 #ifdef	ISPELL
-	printf("<INPUT TYPE=SUBMIT NAME=startspellchk VALUE=\"%s\">",
-		checkspelling);
+	if (!mobile || !*mobile){
+	  printf("<INPUT TYPE=SUBMIT NAME=startspellchk VALUE=\"%s\">",
+		 checkspelling);
+	}
 #endif
-	printf("</TD></TR>\n");
-	printf("</TD></TABLE>\n");
-
-	printf("</TD></TR></TABLE>\n");
-	printf("</TD></TR></TABLE>\n");
+	if (!mobile || !*mobile){
+	  printf("</TD></TR>\n");
+	  printf("</TD></TABLE>\n");
+	  
+	  printf("</TD></TR></TABLE>\n");
+	  printf("</TD></TR></TABLE>\n");
+	}
 }
 
 static const char *geterrbuf(int fd)
--- sqwebmail/newmsg_create.org.c	Tue Mar 19 16:28:52 2002
+++ sqwebmail/newmsg_create.c	Tue Mar 19 13:27:11 2002
@@ -589,6 +589,7 @@
 char	*header, *value;
 struct	rfc2045 *rfcp;
 int	x;
+const char *mobile=getenv("SQWEBMAIL_MOBILE");
 
 #if 0
 off_t	transferencodingpos;
@@ -654,11 +655,17 @@
 		if (strcasecmp(header, "Content-Type") == 0 &&
 		    !rfcp->firstpart)	/* Need to punt this header */
 		{
+		  if (!mobile || !*mobile){
 			maildir_writemsgstr(newdraftfd,
 					    "Content-Type: text/plain;"
 					    " format=flowed; charset=\"");
 			maildir_writemsgstr(newdraftfd,
 					    sqwebmail_content_charset);
+		  }else{
+			maildir_writemsgstr(newdraftfd,
+					    "Content-Type: text/plain;"
+					    " format=flowed; charset=\"iso-2022-jp");
+		  }
 			maildir_writemsgstr(newdraftfd, "\"\n");
 			continue;
 		}
@@ -702,11 +709,18 @@
 			if (strcmp(content_type, "text/plain") == 0 &&
 				!p->isdummy && !found_textplain)
 			{
+			  if (!mobile || !*mobile){
 				maildir_writemsgstr(newdraftfd,
 						    "Content-Type: text/plain;"
 						    " format=flowed;"
 						    " charset=");
 				maildir_writemsgstr(newdraftfd, charset);
+			  }else{
+				maildir_writemsgstr(newdraftfd,
+						    "Content-Type: text/plain;"
+						    " format=flowed;"
+						    " charset=iso-2022-jp");
+			  }
 				maildir_writemsgstr(newdraftfd,
 					"\nContent-Transfer-Encoding: ");
 				maildir_writemsgstr(newdraftfd,
