<?php
  require('includes/application_top.php');
set_time_limit(0);
$httpserverpath="http://www.upowerbiz.com/";


function tep_get_products_special_price($product_id) {
    $product_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and status");
    $product = tep_db_fetch_array($product_query);

    return $product['specials_new_products_price'];
}


function CheckEmailAddr($C_mailaddr) 
{ 
if (!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*$", 
$C_mailaddr)) 
//(!ereg("^[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*@[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*$", 
//$c_mailaddr)) 
{ 
return false; 
} 
return true; 
}

if ((isset($action)) && ($action=='import'))
{
		$count_email=0;
		$import_email=0;
		$error_fomat_list="";
		$error_num=0;
		$exist_list="";
		$exist_num=0;
		$email_list = $HTTP_POST_VARS['emaillist'];

		$oldmaillist=$email_list;
/*
		for($i=0;$i<count($email_list_array);$i++){
			$oldmaillist.=$email_list_array[$i];
		}
*/
		$email_list=str_replace(array("\r","\n"), array(';',';'),$email_list);
		$email_list_array = explode(';;',$email_list);
		$count_email=count($email_list_array);
		for($i=0;$i<count($email_list_array);$i++){
			if($email_list_array[$i]){
						$email = trim($email_list_array[$i]);
						if (CheckEmailAddr($email)==true)
						{
							$check_query = tep_db_query("select * from get_email where email= '" . $email . "'");
							if (tep_db_num_rows($check_query)<=0)
								{
									$sql_data_array = array('email' => $email,
															'flag' => 0);
									if (tep_db_perform('get_email', $sql_data_array)==true) $import_email++;
								}
							else
								{
									$exist_list.=$email_list_array[$i].';';
									$exist_num++;
								}
						}
						else
						{
							$error_fomat_list.=$email_list_array[$i].';';
							$error_num++;
						}
			}
		}
}
else
if ((isset($action)) && ($action=='reset'))
{
	tep_db_query("update get_email set flag=0 where flag=1");
}
else
if ((isset($action)) && ($action=='upmail'))
{
// include currencies class and create an instance
  require(DIR_WS_CLASSES . 'currencies.php');
  $currencies = new currencies();

//rewrite the mail file
$i=0;
    $pp_query = tep_db_query("select p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products_description pd, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id left join specials s on p.products_id = s.products_id, products_to_categories p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '5' and p.products_ordered >= 25 order by rand() limit 12");
	while ($pp = tep_db_fetch_array($pp_query)) {

			$isspecial=0;
			if ($new_price = tep_get_products_special_price($pp['products_id'])) {
			$isspecial=1;
			  $products_price = '<s>' . $currencies->display_price($pp['products_price'], tep_get_tax_rate($pp['products_tax_class_id'])) . '</s> <span class="productSpecialPrice_r">' . $currencies->display_price($new_price, tep_get_tax_rate($pp['products_tax_class_id'])) . '</span>';
			  $products_price2 = '<s>' . $currencies->display_price($pp['products_price'], tep_get_tax_rate($pp['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($pp['products_tax_class_id'])) . '</span>';
			} else {
			  $products_price = $currencies->display_price($pp['products_price'], tep_get_tax_rate($pp['products_tax_class_id']));
			  $products_price2=$products_price;
			}


		$i++;
		switch ($i):
			case 1:
					$ITEM_1_1_URL = $httpserverpath."product_info.php?products_id=".$pp['products_id'];
					$ITEM_1_1_IMAGE = $httpserverpath."images/products_images/".$pp['products_image'];
					$ITEM_1_1_NAME = $pp['products_name'];
					$ITEM_1_1_PRICE = $products_price2;
				break;
			case 2:
					$ITEM_1_2_URL = $httpserverpath."product_info.php?products_id=".$pp['products_id'];
					$ITEM_1_2_IMAGE = $httpserverpath."images/products_images/".$pp['products_image'];
					$ITEM_1_2_NAME = $pp['products_name'];
					$ITEM_1_2_PRICE = $products_price2;
				break;
			case 3:
					$ITEM_1_3_URL = $httpserverpath."product_info.php?products_id=".$pp['products_id'];
					$ITEM_1_3_IMAGE = $httpserverpath."images/products_images/".$pp['products_image'];
					$ITEM_1_3_NAME = $pp['products_name'];
					$ITEM_1_3_PRICE = $products_price2;
				break;
			case 4:
					$ITEM_1_4_URL = $httpserverpath."product_info.php?products_id=".$pp['products_id'];
					$ITEM_1_4_IMAGE = $httpserverpath."images/products_images/".$pp['products_image'];
					$ITEM_1_4_NAME = $pp['products_name'];
					$ITEM_1_4_PRICE = $products_price2;
				break;
			case 5:
					$ITEM_2_1_URL = $httpserverpath."product_info.php?products_id=".$pp['products_id'];
					$ITEM_2_1_IMAGE = $httpserverpath."images/products_images/".$pp['products_image'];
					$ITEM_2_1_NAME = $pp['products_name'];
					$ITEM_2_1_PRICE = $products_price2;
				break;
			case 6:
					$ITEM_2_2_URL = $httpserverpath."product_info.php?products_id=".$pp['products_id'];
					$ITEM_2_2_IMAGE = $httpserverpath."images/products_images/".$pp['products_image'];
					$ITEM_2_2_NAME = $pp['products_name'];
					$ITEM_2_2_PRICE = $products_price2;
				break;
			case 7:
					$ITEM_2_3_URL = $httpserverpath."product_info.php?products_id=".$pp['products_id'];
					$ITEM_2_3_IMAGE = $httpserverpath."images/products_images/".$pp['products_image'];
					$ITEM_2_3_NAME = $pp['products_name'];
					$ITEM_2_3_PRICE = $products_price2;
				break;
			case 8:
					$ITEM_2_4_URL = $httpserverpath."product_info.php?products_id=".$pp['products_id'];
					$ITEM_2_4_IMAGE = $httpserverpath."images/products_images/".$pp['products_image'];
					$ITEM_2_4_NAME = $pp['products_name'];
					$ITEM_2_4_PRICE = $products_price2;
				break;
			case 9:
					$ITEM_3_1_URL = $httpserverpath."product_info.php?products_id=".$pp['products_id'];
					$ITEM_3_1_IMAGE = $httpserverpath."images/products_images/".$pp['products_image'];
					$ITEM_3_1_NAME = $pp['products_name'];
					$ITEM_3_1_PRICE = $products_price2;
				break;
			case 10:
					$ITEM_3_2_URL = $httpserverpath."product_info.php?products_id=".$pp['products_id'];
					$ITEM_3_2_IMAGE = $httpserverpath."images/products_images/".$pp['products_image'];
					$ITEM_3_2_NAME = $pp['products_name'];
					$ITEM_3_2_PRICE = $products_price2;
				break;
			case 11:
					$ITEM_3_3_URL = $httpserverpath."product_info.php?products_id=".$pp['products_id'];
					$ITEM_3_3_IMAGE = $httpserverpath."images/products_images/".$pp['products_image'];
					$ITEM_3_3_NAME = $pp['products_name'];
					$ITEM_3_3_PRICE = $products_price2;
				break;
			case 12:
					$ITEM_3_4_URL = $httpserverpath."product_info.php?products_id=".$pp['products_id'];
					$ITEM_3_4_IMAGE = $httpserverpath."images/products_images/".$pp['products_image'];
					$ITEM_3_4_NAME = $pp['products_name'];
					$ITEM_3_4_PRICE = $products_price2;
				break;
		endswitch;
	}
	$message="";
	$message=file_get_contents("./mailtp/mail_t.htm");

				$message=str_replace('ITEM_1_1_URL',$ITEM_1_1_URL,$message);
				$message=str_replace('ITEM_1_1_IMAGE',$ITEM_1_1_IMAGE,$message);
				$message=str_replace('ITEM_1_1_NAME',$ITEM_1_1_NAME,$message);
				$message=str_replace('ITEM_1_1_PRICE',$ITEM_1_1_PRICE,$message);
				$message=str_replace('ITEM_1_2_URL',$ITEM_1_2_URL,$message);
				$message=str_replace('ITEM_1_2_IMAGE',$ITEM_1_2_IMAGE,$message);
				$message=str_replace('ITEM_1_2_NAME',$ITEM_1_2_NAME,$message);
				$message=str_replace('ITEM_1_2_PRICE',$ITEM_1_2_PRICE,$message);
				$message=str_replace('ITEM_1_3_URL',$ITEM_1_3_URL,$message);
				$message=str_replace('ITEM_1_3_IMAGE',$ITEM_1_3_IMAGE,$message);
				$message=str_replace('ITEM_1_3_NAME',$ITEM_1_3_NAME,$message);
				$message=str_replace('ITEM_1_3_PRICE',$ITEM_1_3_PRICE,$message);
				$message=str_replace('ITEM_1_4_URL',$ITEM_1_4_URL,$message);
				$message=str_replace('ITEM_1_4_IMAGE',$ITEM_1_4_IMAGE,$message);
				$message=str_replace('ITEM_1_4_NAME',$ITEM_1_4_NAME,$message);
				$message=str_replace('ITEM_1_4_PRICE',$ITEM_1_4_PRICE,$message);

				$message=str_replace('ITEM_2_1_URL',$ITEM_2_1_URL,$message);
				$message=str_replace('ITEM_2_1_IMAGE',$ITEM_2_1_IMAGE,$message);
				$message=str_replace('ITEM_2_1_NAME',$ITEM_2_1_NAME,$message);
				$message=str_replace('ITEM_2_1_PRICE',$ITEM_2_1_PRICE,$message);
				$message=str_replace('ITEM_2_2_URL',$ITEM_2_2_URL,$message);
				$message=str_replace('ITEM_2_2_IMAGE',$ITEM_2_2_IMAGE,$message);
				$message=str_replace('ITEM_2_2_NAME',$ITEM_2_2_NAME,$message);
				$message=str_replace('ITEM_2_2_PRICE',$ITEM_2_2_PRICE,$message);
				$message=str_replace('ITEM_2_3_URL',$ITEM_2_3_URL,$message);
				$message=str_replace('ITEM_2_3_IMAGE',$ITEM_2_3_IMAGE,$message);
				$message=str_replace('ITEM_2_3_NAME',$ITEM_2_3_NAME,$message);
				$message=str_replace('ITEM_2_3_PRICE',$ITEM_2_3_PRICE,$message);
				$message=str_replace('ITEM_2_4_URL',$ITEM_2_4_URL,$message);
				$message=str_replace('ITEM_2_4_IMAGE',$ITEM_2_4_IMAGE,$message);
				$message=str_replace('ITEM_2_4_NAME',$ITEM_2_4_NAME,$message);
				$message=str_replace('ITEM_2_4_PRICE',$ITEM_2_4_PRICE,$message);

				$message=str_replace('ITEM_3_1_URL',$ITEM_3_1_URL,$message);
				$message=str_replace('ITEM_3_1_IMAGE',$ITEM_3_1_IMAGE,$message);
				$message=str_replace('ITEM_3_1_NAME',$ITEM_3_1_NAME,$message);
				$message=str_replace('ITEM_3_1_PRICE',$ITEM_3_1_PRICE,$message);
				$message=str_replace('ITEM_3_2_URL',$ITEM_3_2_URL,$message);
				$message=str_replace('ITEM_3_2_IMAGE',$ITEM_3_2_IMAGE,$message);
				$message=str_replace('ITEM_3_2_NAME',$ITEM_3_2_NAME,$message);
				$message=str_replace('ITEM_3_2_PRICE',$ITEM_3_2_PRICE,$message);
				$message=str_replace('ITEM_3_3_URL',$ITEM_3_3_URL,$message);
				$message=str_replace('ITEM_3_3_IMAGE',$ITEM_3_3_IMAGE,$message);
				$message=str_replace('ITEM_3_3_NAME',$ITEM_3_3_NAME,$message);
				$message=str_replace('ITEM_3_3_PRICE',$ITEM_3_3_PRICE,$message);
				$message=str_replace('ITEM_3_4_URL',$ITEM_3_4_URL,$message);
				$message=str_replace('ITEM_3_4_IMAGE',$ITEM_3_4_IMAGE,$message);
				$message=str_replace('ITEM_3_4_NAME',$ITEM_3_4_NAME,$message);
				$message=str_replace('ITEM_3_4_PRICE',$ITEM_3_4_PRICE,$message);



	$fp = fopen('./mailtp/mail.htm', "w");
	fwrite($fp, $message);
	fclose($fp);
}
else
if ((isset($action)) && ($action=='send'))
{
	$total_num=0;
	$hassent_num=0;
	$message="";
	$message=file_get_contents("./mailtp/mail.htm");
    $from = STORE_OWNER_EMAIL_ADDRESS;
	$sent_number=$HTTP_POST_VARS['sentnumber'];
	$include_cancel=$HTTP_POST_VARS['includecancel'];
	$isreg=$HTTP_POST_VARS['isreg'];
	$subject=$HTTP_POST_VARS['subject'];

	if ($include_cancel==1)
		$str_cancel=' or flag=2 ';
	else
		$str_cancel=' ';

	if ($isreg==1)
		$str_isreg=' and reg=1 ';
	else
		$str_isreg=' and reg=0 ';

//echo "sql=="."select * from get_email where (flag=0 ".$str_cancel.") ".$str_isreg." limit ".(int)$sent_number;
//return;

  $email_query = tep_db_query("select * from get_email where (flag=0 ".$str_cancel.") ".$str_isreg." limit ".(int)$sent_number);
  //echo "sql=="."select * from get_email where flag=0 ".$str_cancel." limit ".(int)$sent_number;
  $total_num=tep_db_num_rows($email_query);
  while ($mailnames = tep_db_fetch_array($email_query)) {
		//send mail for every customer start
/*
			switch ($mailnames['email']) {
			  case '***':
				$mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS);
				$mail_sent_to = TEXT_ALL_CUSTOMERS;
				break;
			  case '**D':
				$mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
				$mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS;
				break;
			  default:
				$customers_email_address = tep_db_prepare_input($mailnames['email']);
				$mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($customers_email_address) . "'");
				$mail_sent_to = $mailnames['email'];
				break;
			}
*/
		
			//Let's build a message object using the email class
			$mimemessage = new email(array('X-Mailer: osCommerce'));
			// add the message to the object
			$message=str_replace(array("\r","\n"), array('',''),  $message);
			$text = strip_tags($message);
		    $mimemessage->add_html($message,$text);
//			if (EMAIL_USE_HTML == 'true') {
//			  $mimemessage->add_html($message);
//			} else {
//			  $mimemessage->add_text($text);
//			}
//			  $mimemessage->add_text($message);
		
			$mimemessage->build_message();
/*
			while ($mail = tep_db_fetch_array($mail_query)) {
			  $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', $from, $subject);
			  //update the send status for this email
			  tep_db_query("update get_email set flag=1 where flag=0 and email='..'");
			  $hassent_num++;
			}
*/
			  $mimemessage->send('', $mailnames['email'], '', $from, $subject);
			  //update the send status for this email
			  tep_db_query("update get_email set flag=1 where flag=0 and email='".$mailnames['email']."' limit 1");
			  $hassent_num++;

		//send mail for every customer end
			}
}

//get all email  infomations
$allemail=0;
$sendemail=0;
$cancelemail=0;
$notsendemail=0;
$sql='select count(id) as cnum,flag from get_email group by flag';
$status_query = tep_db_query($sql);

while ($status = tep_db_fetch_array($status_query))
{
	if ($status['flag']==0)
	{
		$notsendemail=$status['cnum'];
	}
	else
	if ($status['flag']==1)
	{
		$sendemail=$status['cnum'];
	}
	else
	if ($status['flag']==2)
	{
		$cancelemail=$status['cnum'];
	}
}
$allemail=$notsendemail+$sendemail+$cancelemail;

?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<style type="text/css">
<!--
	h1{
		color:#ff0000;
	}
    .font1{
	    font-family: Arial, Helvetica, sans-serif;
	    font-size: 12px;		
	}
-->
</style>
<title>Send mail</title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
<style type="text/css">
<!--
.style1 {
	color: #0000FF;
	font-weight: bold;
}
.style2 {
	color: #FF0000;
	font-weight: bold;
}
.style3 {
	color: #FF00FF;
	font-weight: bold;
}
-->
</style>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //--> 
  
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <td width="2%" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
   <td valign="top" width="25%" align="left">
		<table width="100%"  border="0" height="100%">
		<?php echo tep_draw_form('myimportmail','sendemail.php', tep_get_all_get_params(array('action')) . 'action=import'); ?>
			  <tr>
				<td class="main"><b>Import emails </b></td>
			  </tr>
			  <tr>
				<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
			  </tr>
			  <tr>
				<td class="main"><textarea name="emaillist" cols="40" rows="25" id="emaillist"><?=$oldmaillist?></textarea></td>
			  </tr>
			  <tr>
				<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
			  </tr>
			  <tr>
				  <td valign="top"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?></td>
			  </tr>
	</form>
		</table>   
   </td>
   <td width="6">&nbsp;</td>
   <td valign="top" align="left">
		<table width="100%"  border="0" height="100%">
		<?php echo tep_draw_form('mysendmail','sendemail.php', tep_get_all_get_params(array('action')) . 'action=send'); ?>
			  <tr>
				<td class="main"><b>Send emails </b></td>
			  </tr>
			  <tr>
				<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
			  </tr>
			  <tr>
				<td class="main">
				  	<legend class="font1">Status</legend>
					<table width="100%" border="1" align="left" bordercolor="#CC99FF">
						<tr>
							<td width="31%" class="font1">email template</td>
							<td width="69%" class="font1">mail.htm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="sendemail.php?action=upmail" title="update then email template" target="_self" class="font1"><strong>Update</strong></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailtp/mail.htm" title="View this mail template" target="_blank" class="font1"><strong>View</strong></a></td>
						</tr>
						<tr>
							<td class="font1">email total</td>
							<td class="font1"><?=$allemail?></td>
						</tr>
						<tr>
							<td class="font1">send</td>
							<td class="font1"><?=$sendemail?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="sendemail.php?action=reset" title="Clear all records that had been sent" target="_self" class="font1"><strong>Reset</strong></a></td>
						</tr>
						<tr>
							<td class="font1">not send</td>
							<td class="font1"><?=$notsendemail?></td>
						</tr>
						<tr>
							<td class="font1">canceled</td>
							<td class="font1"><?=$cancelemail?></td>
						</tr>
				  </table>
					</fieldset>
				</td>
			  </tr>
			  <tr>
				<td class="main">
				  	<legend class="font1">Option</legend>
					<table width="100%" border="1" align="left" bordercolor="#CC99FF">
						<tr>
							<td width="31%" class="font1">subject</td>
							<td><input type="text" name="subject"  size="60" value="<?php if ($subject!=''){echo $subject;}else{echo 'Top Dix Produits';}?>"></td>
						</tr>
						<tr>
							<td width="31%" class="font1">sent number</td>
							<td><input name="sentnumber" type="text"  onKeyPress="javascript:checkdig();" value="<?php if ($sent_number!=''){echo $sent_number;}else{echo '200';}?>" maxlength="60"></td>
						</tr>
						<tr>
							<td class="font1" colspan="2"><input name="includecancel" type="checkbox" value="1" <?php if ($include_cancel==1){echo 'checked';}else{echo '';}?>>include canceled&nbsp;&nbsp;&nbsp;&nbsp;<input name="isreg" type="checkbox" value="1" <?php if ($isreg==1){echo 'checked';}else{echo '';}?>>Registered</td>
						</tr>
				  </table>
					</fieldset>

				</td>
			  </tr>
			  <tr>
				<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
			  </tr>
			  <tr>
				  <td valign="top"><?php echo tep_image_submit('button_send_mail.gif', 'send mail'); ?></td>
			  </tr>
			<?php if ($action=='send') {?>
			<tr>
				<td>
				<table>
								<tr>
								  <td valign="top" class="font1"><span class="style1">Total: </span><?=$total_num?></td>
								  <td valign="top" class="font1"><span class="style1">Send:</span><?=$hassent_num?></td>
								</tr>
				</table>
				</td>
			</tr>
			<? }?>

	</form>
		</table>   
   </td>

<!-- body_text //-->
  </tr>
<tr>
<td>&nbsp;

</td>
<td colspan="3"  style="WORD-BREAK: break-all; BORDER-COLLAPSE: collapse">
<?php if ($action=='import') {?>
	<table>
					<tr>
					  <td valign="top" class="font1"><span class="style1">Total: </span>					    <?=$count_email?>&nbsp;&nbsp;&nbsp;&nbsp;<span class="style1">Import:</span>					    <?=$import_email?>&nbsp;&nbsp;&nbsp;&nbsp;<span class="style1">Failed:</span><? echo $count_email-$import_email;?></td>
					</tr>
	
					<?php if ($error_fomat_list!='') {?>
						<tr>
						  <td valign="top" class="font1"><span class="style2">Error format emails</span>(<?=$error_num?>):<?=$error_fomat_list?></td>
						</tr>
					<? }?>
	
					<?php if ($exist_list!='') {?>
						<tr>
						  <td valign="top" class="font1"><span class="style3">Exist emails</span>(<?=$exist_num?>):<?=$exist_list?></td>
						</tr>
					<? }?>
	
	</table>
<? }?>
</td>
</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
<script language="javascript"> 

	function checkdigone() {
		 if(event.keyCode<48 || event.keyCode>57) event.returnValue=false;  
	}  
	function checkdig() {
		 if (event.keyCode==13) event.returnValue=true;
		 else  
		 if(event.keyCode<48 || event.keyCode>57) event.returnValue=false;  
	}  
	function checkdigdate() {
		 if(event.keyCode==45) event.returnValue=true;
		 else  
		 if(event.keyCode<48 || event.keyCode>57) event.returnValue=false;  
	}
	
	
function check_form(form_name) {
  error = false;
  form = form_name;
  error_message = "";

									  if (form.elements["sentnumber"] && (form.elements["sentnumber"].type != "hidden")) 
									  {
											var field_value = form.elements["sentnumber"].value;										
											if (field_value == '') 
											{
											  error_message = error_message  + "please input one number" + "\n";
											  error = true;
											  form.elements["sentnumber"].focus();
											}
									  }
  if (error == true) {
    alert(error_message);
    return false;
  } else {
    submitted = true;
    return true;
  }
}	
</script>