<style type="text/css">
<!--
.cghjdftyu {	color: #FF0000;
	font-weight: bold;
}
.style107 {font-size: 12px; font-weight: bold; font-family: Verdana, Arial, Helvetica, sans-serif; color: #000099; }
.style1 {font-size: 24px; font-weight: bold; font-family: Verdana, Arial, Helvetica, sans-serif; color: #000099; }
.style2 {color: #009900}
.style3 {color: #FF0000}
-->
</style>
<div class="ch00">

  <p align="center" class="style1">PRODUK</p>
</div>



<div class="cc01"><img src="z.png" width="10" height="10"  align="left" />
  <?
switch($page) {
default :
$db->select("id, title", "categories", "section='product'");
while($row=$db->fetch_row()) {
	//echo "<p>$row[1]</p>";
	echo "<div id='module_produk'><h3>$row[1]</h3>";
	$sql=mysql_query("select id, nama, harga, gambar, deskripsi, hit from product where catid='$row[0]'");
	?>
  <?
	
	while($data=mysql_fetch_row($sql)) {
		if($data[2] > 0) {
			$hg = rupiah($data[2]);
		} else {
			$hg = "<span style='color:#FF0000; font-size:14px'>FREE</span>";
		}		
    	
      ?>
  <div class="productsbox"><img src="z.png" width="10" height="10"  align="left" />
<?= "<p><b>$data[1]</b></p>"; ?>
    <p><img src="z.png" width="10" height="78"  align="left" /><img src="images/news/<?= $data[3]; ?>"  align="left" /><img src="z.png" width="10" height="78"  align="left" />
      <?= $db->crops($data[4], 20); ?>
      ...</p>
    <p class="cghjdftyu">Harga :
      <?= $hg; ?>
      <br />
      <br />
      <span class="style107"><a href="?m=product&amp;page=detil&amp;pid=<?= $data[0]; ?>&amp;id=<?= $id; ?>"><img src="detail.png" width="75" height="25" border="0" /></a></span> &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<a href="?m=download&amp;page=unduh&amp;pid=<?= $data[0]; ?>"> </a><span class="style107"><a href="index3.php?m=masuk&amp;pid=<?= $data[0]; ?>&amp;id=<?= $id; ?>"><img src="beli.png" width="75" height="25" border="0" /></a></span></p>
    <p align="right"></a><a href="index3.php?m=masuk&amp;pid=<?= $data[0]; ?>&amp;id=<?= $id; ?>" class="download"></a></p>
  </div>
  <?
		
                             
	
	
	
	} //---end while	
//echo "</tr>";		
?>
  <p>&nbsp;</p>
  <?
    	//echo "<p>$data[1]</p>";
		echo "</div>";	
	//}
	echo "</fieldset>";	
	
}	
	break;
	
	case unduh :
		$db->select("id, nama, harga, gambar, deskripsi, hit", "product", "id='$pid'");
		$row=$db->fetch_row();
		
?>
  <table width="90%" border="0" align="center" cellpadding="5" cellspacing="0" class="bordertable">
    <tr class="tbl_header">
      <td> PRODUK</td>
    </tr>
    <tr>
      <td><?
	   echo "<p><b>$row[1]</b></p>"; 
	   //--cek download--
	   $db->select("username, title, password, file", "download", "username='$user_session' and title='$pid'");
	   $file = $db->result(0, "file");
	   $ada = $db->num_rows();
	   if($ada > 0) { 
	   		if( isset($_POST['submit'])) {
			
				if($passdl == $db->result(0, "password")) {
					//header("location:../produk/file/$file");
					echo "<p align=center><b>Produk yang anda pilih telah berhasil didownload.</b></p>";
					echo "<p><a href='?m=download'>Kembali ke Daftar Download</a></p>";
					echo "<meta http-equiv='refresh' content='0;URL=download2.php?pid=$pid&download=resume'>";
					//header("location:download2.php?pid=$pid&download=resume");
					$db->select("file, hit", "product", "id='$pid'");
					$newhit = $db->result(0, "hit") + 1;
					$db->update("product", "hit=$newhit", "id=$pid");
					
				} else {
					echo "<p align=center><b>Password salah!</b></p>";
				}
			} else {			
	   
	   ?>
          <form id="donlot" name="donlot" method="post" action="">
            <table width="70%" border="0" align="center" cellpadding="5" cellspacing="1">
              <tr>
                <td width="50%" align="right">Password Download :</td>
                <td width="50%"><input name="passdl" type="password" id="passdl" size="15" />
                    <input name="pid" type="hidden" id="pid" value="<?= $pid; ?>" size="15" /></td>
              </tr>
              <tr>
                <td colspan="2" align="center"><input type="submit" name="submit" id="submit" value="DOWNLOAD" /></td>
              </tr>
            </table>
          </form>
        <script language="JavaScript" type="text/javascript">
 var frmvalidator = new Validator("donlot");
 frmvalidator.addValidation("passdl","req","Masukkan password untuk download!");
    </script>
          <?
			}
		} else {
				
		?>
          <p>&nbsp;</p>
        <p><img src="images/news/<?= $row[3]; ?>"  align="left" style="padding-right:2px" />
              &nbsp;&nbsp;
              <?= $db->crops($row[4], 20); ?>
        </p>
        <p>Harga : <b>
          <?
	   if($row[2] > 0) {
				$hg = rupiah($row[2]);
			$link = "?m=ewalet&amp;page=transfer";
			$tbl = "BELI";
	   echo $hg; ?>
        </b></p>
        <p>Untuk mendownload produk ini anda harus membelinya terlebih dahulu. Gunakan account E-Walet anda untuk membelinya. Lakukan transfer e-walet kepada pengelola program ini dengan mengklik tombol <strong>DOWNLOAD</strong> di bawah ini.<br />
        </p>
        <?
		} else {
			 $hg = "<span style='color:#FF0000; font-size:14px'>FREE</span>";
			 echo $hg;
			 $link = "download2.php?pid=$pid&download=resume";
			 $tbl = "DOWNLOAD";
		}
		?>
      </td>
    </tr>
    <tr>
      <td><form id="form1" name="form1" method="post" action="<?= $link; ?>">
          <table width="100%" border="0" cellspacing="0" cellpadding="4">
            <tr>
              <td colspan="2" align="center"><p>Account e-walet anda : <b>
                  <?= rupiah($db->myewalet($user_session)); ?>
                </b></p>
                  <?
			if($db->myewalet($user_session) >= $row[2]) {
			 	$dis = "";  
			} else {
				$dis = "disabled='disabled'";
			?>
                  <p style="color:#FF0000"> Saldo e-walet anda
                    belum mencukupi untuk membeli produk ini.<br />
                    Silahkan isi atau tambah saldo e-walet anda. </p>
                <? 	
			}		
             ?>
              </td>
            </tr>
            <tr>
              <td width="50%" align="right">Harga : <span class="harga">
                <?= $hg; ?>
                <input name="tujuan" type="hidden" id="tujuan" value="admin" size="8" readonly="readonly" class="beli" />
                </span>
                  <input name="ket" type="hidden" id="ket" value="Dowload Produk <?= $row[1]; ?>" size="8" readonly="readonly" class="beli" />
                  <input name="referrer" type="hidden" id="referrer" value="download" size="8" readonly="readonly" class="beli" />
                  <input name="harga" type="hidden" id="harga" value="<?= $row[2]; ?>" size="8" readonly="readonly" class="beli" />
                  <input name="goto" type="hidden" id="goto" value="download" size="8" readonly="readonly" class="beli" />
                  <input name="pid" type="hidden" id="pid" value="<?= $row[0]; ?>" size="8" readonly="readonly" class="beli" />
              </td>
              <td width="50%" align="left"><input type="submit" name="button" id="button" value="<?= $tbl; ?>" class="tombole" <?= $dis; ?>/>
              </td>
            </tr>
          </table>
      </form>
          <?
	} //--end if udah beli
	?>
      </td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <?	
	break;
	
	case detil :
	$db->select("id, nama, deskripsi, harga, gambar, poin, berat", "product", "id=$pid");
	$data = $db->fetch_row();
	?>
  <table width="95%" border="0" align=" " cellpadding="2" cellspacing="0">
    <tr class="tbl_produk">
      <td><h4>
        <?= $data[1]; ?>
      </h4></td>
    </tr>
    <tr>
      <td><div align="justify">
        <p><img src="z.png" width="10" height="78"  align="left" /><img src="images/news/<?= $data[4]; ?>" border="0" /><img src="z.png" width="10" height="318"  align="left" />        
          </p>
        <p>
          <?= $data[2]; ?>
          <br>
          <span class="style3">          </span>
        </p>
        </div></td>
    </tr>
    <tr>
      <td align="center"><span class="cghjdftyu">&nbsp;&nbsp; Harga :
        <?= rupiah($data[3]); ?>
        <font color="#0000FF">  <a href="index3.php?m=masuk&amp;pid=<?= $data[0]; ?>&amp;id=<?= $id; ?>"><img src="beli.png" width="75" height="25" border="0" /></a></span></td>
    </tr>
    <tr>
      <td align="center">&nbsp;</td>
    </tr>
  </table>
  <p>
    <?    
	break;
	
}	
?>
</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;  </p>
</div>
