<?
ob_start();
session_start();
if($_SESSION['uname']=='' || $_SESSION['pwd']=='')
		{
			header("location:login.php");
		}
 include("../include/db.inc.php"); 
   $db1=new db;
   $db1->open();
    mysql_query("SET NAMES 'utf8'");

	if($_POST['sub_btn']){
		$newsletter="insert into t123go_newsletter(subject,description,submit_date)values('".$_POST['TR_subject']."','".$_POST['Description']."',CURDATE())";
		$query=mysql_query($newsletter);
		
		
		?>
		<script language="javascript" >
		alert(" newsletter has been added");
		window.location="new_newsletter.php";
		</script>
		
<?	}
	
	$subject="'";
	$sub_query=mysql_query("select * from t123go_newsletter"); 
	while($myrow=mysql_fetch_array($sub_query)){
		$subject.=$myrow['subject']."','";
	}
	
	$subject=substr($subject,0,strlen($subject)-2);	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>NEWADMIN</title>
<script language="JavaScript" src="../js/common.js"></script>
<link href="../css/stylesheet.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
	function backtolist(){
		window.location="newsletter_list.php";
	}
	function validfrm()
	{
		
	
		     if(document.form1.TR_subject.value=='')
	{
		 alert("Enter News Subject");
		 document.form1.TR_subject.focus();
		return false;

	} 
		
		var check=existcheck();
		var subject=document.form1.TR_subject.value;
		if(check==false){
			alert("'"+subject+"' subject is already exist");
			document.form1.TR_subject.focus();
			return false;
		}
	}
	function existcheck(){		
		var subarr=new Array(<?=$subject?>);
		var len=subarr.length;
		var subject=document.form1.TR_subject.value;
		for(var i=0; i<len; i++){
			if(subarr[i]==subject){				
				return false;				
			}
		}		
	}
</script>
<script language="javascript" type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
	tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		plugins : "spellchecker,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable",
		theme_advanced_buttons1_add_before : "save,newdocument,separator",
		theme_advanced_buttons1_add : "fontselect,fontsizeselect",
		theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,separator,forecolor,backcolor",
		theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
		theme_advanced_buttons3_add_before : "tablecontrols,separator",
		theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,spellchecker",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_path_location : "bottom",
		content_css : "/example_data/example_full.css",
	    plugin_insertdate_dateFormat : "%Y-%m-%d",
	    plugin_insertdate_timeFormat : "%H:%M:%S",
		extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
		external_link_list_url : "example_data/example_link_list.js",
		external_image_list_url : "example_data/example_image_list.js",
		flash_external_list_url : "example_data/example_flash_list.js",
		file_browser_callback : "mcFileManager.filebrowserCallBack",
		theme_advanced_resize_horizontal : false,
		theme_advanced_resizing : true,
		apply_source_formatting : true,
		spellchecker_languages : "+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv"
	});
</script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/back.jpg" style="background-position:top; background-repeat:repeat-x" onLoad="show5()">
<div class="admin_wrapper">
<div class="logo_show"><? include("minorlogout.php");?></div>
<div style="float:left; width:200px">
<div class="topg_links_show"><? include("left.php");	?></div>
<div class="top_links_show"><? include("belowleft1.php");	?></div></div>
<div style="float:left; width:800px">
<div class="maximum">

<!-- ImageReady Slices (NEWADMIN.psd) -->
<table id="Table_01" width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
	<tr>
		<td colspan="2" align="center" valign="top"><? //include("header.php");?></td>
	</tr>
    <tr>
  
		
	    <td valign="top" align="center">
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
              <tr> 
                <td width="33" valign="top"><img src="img/03.gif" width="33" height="23"></td>
                <td background="img/bg01.gif"><strong>&nbsp;CREATE NEW NEWSLETTER</strong></td>
                <td width="35"><img src="img/04.gif" width="35" height="23"></td>
              </tr>
            </table>
            <table  width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
              <tr> 
                <td width="22" valign="top" background="img/tbl-left04.gif"><img src="img/tbl-left04.gif" width="22" height="13"></td>
                <td valign="top" align="center"> <br> 
                          <br> <FORM METHOD="post" ACTION="" name="form1" onSubmit="return validfrm();">
                    <table width="100%"  border="0" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
                      <tr bgcolor="#FFFFFF"> 
                        <td width="22%"><strong>&nbsp;&nbsp;Subject : </strong></td>
                        <td width="78%"  align="left">&nbsp;&nbsp; <input name="TR_subject" type="text" class="inputtext" size="60" value="">
                        </td>
                      </tr>
                      <tr bgcolor="#FFFFFF"> 
                        <td valign="top"><br>
                          <strong>&nbsp;&nbsp;Description :</strong></td>
                        <td  align="left" valign="top">&nbsp;&nbsp; 
						
						<textarea name="Description" cols="80" rows="15" class="inputtext"></textarea>						 
                            <!--<script language='javascript1.2'> editor_generate('Description'); </script>-->
						</td>
                      </tr>
                    </table>
                    <br>
                    <table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
                      <tr>
                        <td align="center" bgcolor="#EDEDED"> 
                          <input name="sub_btn" type="submit" class="inputtext" value="Submit Info" style="padding-bottom:20px;">
                          &nbsp;
                          <input name="back" type="button" class="inputtext" onClick="backtolist()" value="Back To List" style="padding-bottom:20px;"> </td>
                      </tr>
                    </table>
                  </FORM>
                    </td>
                <td width="19" valign="top" background="img/tbl-right04.gif"><img src="img/tbl-right04.gif" width="19" height="9"></td>
              </tr>
            </table>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
              <tr> 
                <td width="33"><img src="img/tbl-bot01.gif" width="33" height="12"></td>
                <td align="right" background="img/tbl-bg.gif"><img src="img/tbl-right05.gif" width="35" height="12"></td>
              </tr>
			  
            </table>
			<br/><br/>
        </td>
    
	
   </tr>
</table>
</div></div>
<div class="bottom_links_show"><? include("footer.php");?></div></div>

	
<!-- End ImageReady Slices -->
</body>
</html>