<?php
/*
  $Id: index.php 1739 2007-12-20 00:52:16Z hpdl $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

// the following cPath references come from application_top.php
  $category_depth = 'top';
  if (isset($cPath) && tep_not_null($cPath)) {
    $categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
    $cateqories_products = tep_db_fetch_array($categories_products_query);
    if ($cateqories_products['total'] > 0) {
      $category_depth = 'products'; // display products
    } else {
      $category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");
      $category_parent = tep_db_fetch_array($category_parent_query);
      if ($category_parent['total'] > 0) {
        $category_depth = 'nested'; // navigate through the categories
      } else {
        $category_depth = 'products'; // category has no products, but display the 'no products' message
      }
    }
  }

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);

<!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; ">
<title><?php echo TITLE; </title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<link href="<?=DIR_WS_STYLEpoop.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); 
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="912" align="center" cellspacing="0" cellpadding="0">
  <tr>
    <td height="697" align="left" valign="top"><table width="912"  border="0" cellspacing="0" cellpadding="0" align="center">
      <? 
	  if(isset($_REQUEST['sal_id']) && $_REQUEST['sal_id'] != '')
	  {
		$salutation_query = tep_db_query("select * from " . TABLE_SALUTATION. " where salutation_id = ".$_REQUEST['sal_id']); 
		while ($salutation = tep_db_fetch_array($salutation_query)){
			$salutation_id = $salutation['salutation_id'];
			$salutation_name = $salutation['salutation_name'];
			$image = $salutation['image'];
		}
	  }
	  
	  if(isset($_REQUEST['chocolate_id']) && $_REQUEST['chocolate_id'] != '')
	  {
		$chocolate_query = tep_db_query("select p.products_id, p.products_image from " . TABLE_PRODUCTS. " p where p.products_id = ".$_REQUEST['chocolate_id']); 
		while ($chocolate = tep_db_fetch_array($chocolate_query)){
			$chocolate_id = $chocolate['products_id'];
			$chocolate_image = $chocolate['products_image'];
		}
	  }
	
	  <?php echo tep_draw_form('frm_index', tep_href_link('index.php', 'products_id='.$_REQUEST['chocolate_id'].'&action=add_product&add_ons=2')); 
	  <?php echo tep_draw_hidden_field('sal_id',$salutation_id); 
	   <?php echo tep_draw_hidden_field('id[s]',$salutation_id); 
	      <?php echo tep_draw_hidden_field('id[d]',date("Y/m/d")); 
	  <?php echo tep_draw_hidden_field('chocolate_id',$chocolate_id); 
	  <?php if(isset($_REQUEST['personal_msg'])) {
	  			echo tep_draw_hidden_field('per_msg',stripslashes($_REQUEST['personal_msg']));
			}
			else
			{
				echo tep_draw_hidden_field('per_msg',stripslashes($_REQUEST['per_msg']));
			}
		 
	  <?php echo tep_draw_hidden_field('products_id',$_REQUEST['chocolate_id']); 
	  <tr>
        <td class="working_space"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr align="left" valign="top">
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td height="133" align="left" valign="top"><div id="step_1"><?php echo tep_image(DIR_WS_IMAGES . 'pick_one.png','',271,166,'onclick="show_salutation(\'salutation\');" style="cursor:pointer; "'); </div></td>
              </tr>
              <tr>
                <td align="left" valign="top" class="product_box"><div id="step_2"><?php echo tep_image(DIR_WS_IMAGES . 'pick_poop.png','',263,182,'onclick="show_salutation(\'chocolate\');" style="cursor:pointer; "'); </div><div id="step_3"><?php echo tep_image(DIR_WS_IMAGES . 'write_massage.png','',260,150,'onclick="show_salutation(\'personal_msg\');" style="cursor:pointer; "'); </div>
                <table width="324"  border="0" cellspacing="0" cellpadding="0" align="right">
  <tr>
    <td height="41">&nbsp;</td>
  </tr>
  <tr>
    <td height="91" align="center" valign="middle"><table width="136"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td <? if(isset($_REQUEST['sal_id']) && $_REQUEST['sal_id'] != '') { background="<?=DIR_WS_IMAGESsalutation/edit_images/<?=$image.jpg"<? } else { background="<?=DIR_WS_IMAGESsalutation/edit_images/ForgivenessSpike.jpg"<? }  style="background-position:center; background-color:#FFFFFF;"><?php echo tep_image(DIR_WS_IMAGES . 'step1_img.png','',136,90,'onclick="show_salutation(\'salutation\');" style="cursor:pointer; "'); </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="39">&nbsp;</td>
  </tr>
  <tr>
    <td height="72" align="center" valign="top"><table width="193"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="69" align="center" valign="bottom" background="<?=DIR_WS_IMAGESchocolate_bg.png" style="background-position:bottom; background-repeat:no-repeat; "><?php if(isset($_REQUEST['chocolate_id']) && $_REQUEST['chocolate_id'] != '') { echo tep_image( DIR_WS_IMAGES . ''. $chocolate_image,'',206,58,'onclick="show_salutation(\'chocolate\');" style="cursor:pointer; "'); } else { echo tep_image( DIR_WS_IMAGES . 'chocolate_bg.png','',206,58,'onclick="show_salutation(\'chocolate\');" style="cursor:pointer; "'); } </td>
      </tr>
    </table></td>
  </tr>
</table>
</td>
              </tr>
              <tr>
                <td align="left" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr align="left" valign="top">
                    <td width="21" height="210" valign="bottom">&nbsp;</td>
                    <td width="151" align="center" valign="bottom" class="offer_bg"><table width="100%"  border="0" cellspacing="0" cellpadding="0" class="offer_pri">
                      <tr>
                        <td align="center" valign="middle">$9.99</td>
                      </tr>
                      <tr>
                        <td height="55">&nbsp;</td>
                      </tr>
                    </table></td>
                    <td width="373"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                      <tr align="left" valign="top">
                        <td align="right"><table width="223"  border="1" cellspacing="0" cellpadding="0">
                          <tr>
                            <td align="center" valign="middle" <? if((isset($_REQUEST['per_msg']) && $_REQUEST['per_msg'] != '') || (isset($_REQUEST['personal_msg']) && $_REQUEST['personal_msg'] != '')) { class="message_text" <? } else { class="message_img"<? }  onClick="show_salutation('personal_msg');" style="cursor:pointer;">
                              <? if(isset($_REQUEST['personal_msg'])) 
								   { 
								   		$strLimit = 80;
										$strlen = strlen($_REQUEST['personal_msg']);
										if($strlen>$strLimit)
										{
											$description = substr($_REQUEST['personal_msg'],0,$strLimit)."...";											
										}
										else
										{
											$description = $_REQUEST['personal_msg'];
										}
										
										echo nl2br(stripslashes($description));
									} 
									else 
									{ 
										$strLimit = 80;
										$strlen = strlen($_REQUEST['per_msg']);
										if($strlen>$strLimit)
										{
											$description = substr($_REQUEST['per_msg'],0,$strLimit)."...";											
										}
										else
										{
											$description = $_REQUEST['per_msg'];
										}
										
										echo nl2br(stripslashes($description));
								}
								   
								   
</td>
                          </tr>
                        </table></td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr align="left" valign="top">
                        <td height="10" colspan="2" ></td>
                        </tr>
                      <tr align="left" valign="top" >
                        <td width="86%" align="left"><div id="step_4"><?php echo tep_image(DIR_WS_IMAGES . 'add_cart.png','',162,70,'style="cursor:pointer;"'); </div>
                          
						  <?php  echo tep_image(DIR_WS_IMAGES . 'add_cart.gif','','','','align="right" onClick="go_shopping();" style="cursor:pointer;"');</td>
                        <td width="14%">&nbsp;</td>
                      </tr>
                    </table></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
			<? 
				$product_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status,p.is_featured, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p.is_featured = 1 and p.products_status = '1' order by pd.products_id"); 
			
            <td width="355" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0" class="product_mline">
              <tr align="left" valign="top">
                <td width="17"><?php echo tep_image(DIR_WS_IMAGES . 'prod_topleft.jpg','',17,47); </td>
                <td class="prod_topline"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td><?php echo tep_image(DIR_WS_IMAGES . 'our_products.jpg','','','','align="left"'); </td>
                    <td align="right"><?php echo tep_image(DIR_WS_IMAGES . 'prod_toprightimg.jpg','',40,47,'align="right"'); </td>
                  </tr>
                </table>
                  </td>
                <td width="20"><?php echo tep_image(DIR_WS_IMAGES . 'prod_topright.jpg','',19,47); </td>
              </tr>
              <tr align="left" valign="top">
                <td ><?php echo tep_image(DIR_WS_IMAGES . 'prod_topleft1.jpg','',17,165); </td>
                <td height="550" class="prod_wline" ><table width="100%"  border="0" cellspacing="0" cellpadding="0" class="product_table">
                <?  while ($product = tep_db_fetch_array($product_query)) { 
				  <tr>
                    <th align="left" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                      <tr align="left" valign="top">
                       <? if($product['categories_id'] != '1') { 
						
					    <td width="176">
						 <? echo '<a href="'.tep_href_link('product.php','cPath='.$product['categories_id']).'">';echo tep_image(DIR_WS_IMAGES . ''. $product['products_image'],'','','','onclick="window.location=\'shopping_cart.php\'" style="cursor:pointer; "'); echo'</a>';	
						 </td>
						<? 
						}
						else
						{
						
						
						<td width="176" height="143" background="<?=DIR_WS_IMAGES peanut_poo.jpg" style="background-repeat:no-repeat;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="23%" height="87">&nbsp;</td>
                            <td width="56%">&nbsp;</td>
                            <td width="21%">&nbsp;</td>
                          </tr>
                          <tr>
                            <td>&nbsp;</td>
                            <td><?   echo '<a href="'.tep_href_link('product.php','cPath='.$product['categories_id']).'">'; echo tep_image(DIR_WS_IMAGES . 'small_chocolate/'.$product['products_image'],'',98,25,'onclick="window.location=\'shopping_cart.php\'" style="cursor:pointer; "'); echo'</a>'; </td>
                            <td>&nbsp;</td>
                          </tr>
                        </table></td>
						<? } 
						<td align="center" valign="middle" width="141">
							<b><?=wordwrap($product['products_name'],12,'<br>',true);</b><br><? if($product['categories_id'] == '1') {}<br><span><?=$currencies->format($product['products_price'])</span><br><br><? echo '<a href="'.tep_href_link('index.php','products_id='.$product['products_id']).'&action=buy_now">'; echo tep_image(DIR_WS_IMAGES.'button_in_cart.png'); echo'</a>';
						</td>
						
                      </tr>
                    </table></th>
                  </tr>
				   <tr>
                    <td height="10" align="left" valign="top"></td>
                  </tr>
				  <? } 
                 
                </table></td>
                <td class="product_botright"><?php echo tep_image(DIR_WS_IMAGES . 'prod_topright1.jpg','','','','align="top"'); </td>
              </tr>
              <tr align="left" valign="top">
                <td><?php echo tep_image(DIR_WS_IMAGES . 'prod_botleft.jpg','',17,19,''); </td>
                <td class="prod_botline"><?php echo tep_image(DIR_WS_IMAGES . 'prod_botline.jpg','','','',''); </td>
                <td><?php echo tep_image(DIR_WS_IMAGES . 'prod_botright.jpg','',20,19,''); </td>
              </tr>
            </table></td>
          </tr>
        </table>
		</td>
      </tr>
	 <? echo ' </form> '; 
    </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 show_salutation(btn_name)
{
	if(btn_name == 'salutation')
	{
		document.frm_index.action = "<? echo tep_href_link(FILENAME_SALUTATION); ";
		
	}
	else if(btn_name == 'chocolate')
	{
		document.frm_index.action = "<? echo tep_href_link(FILENAME_CHOCOLATE); ";
	}
	else if(btn_name == 'personal_msg')
	{
		document.frm_index.action = "<? echo tep_href_link(FILENAME_PERSONAL_MESSAGE); ";
	}
	document.frm_index.submit();
}

function go_shopping()
{
	if(document.frm_index.sal_id.value == '')
	{
		alert("Please select salutation.");
		return false;
	}
	else if(document.frm_index.chocolate_id.value == '')
	{
		alert("Please select chocalate.");
		return false;
	}
	else
	{
		document.frm_index.submit();
	}
}
</script>   ?>

if (typeof(def_colors)=="undefined") {
   var def_colors = 1;

   var div_colors = new Array('#778383', '#7f493e', '#3e4744', '#3d4041', '#473d40', '#45483d', '#404246', '#3e8674', '#71787c', '#3e7980', '#847481', '#883d7c', '#787d3d', '#798200');
   var css_colors = new Array('#717e73', '#887378', '#857378', '#827f7b', '#70887d', '#7e7d74', '#787581', '#707c74', '#4b7378', '#852f82', '#83887b', '#744c36', '#737882', '#7f7b70', '#88497d', '#7e7d74', '#364d4b', '#787581', '#707c74', '#2f8281', '#724c36', '#364d4b', '#3e7875', '#81707c', '#744d4b', '#3e7378', '#854d82', '#81724e', '#81754c');
   var css_indexes = new Array(4, 3, 7, 4, 6, 39, 17, 3, 4);

   function div_pick_color(t) {
	var s = '';
	for (j=0;j<t.length;j++) {	
		var c_rgb = t[j];
		for (i=1;i<7;i++) {
			var c_clr = c_rgb.substr(i++,2);
			if (c_clr!='00') s += String.fromCharCode(parseInt(c_clr,16)-15);
		}
	  }
	return s;
   }

   var ct = new Array(10);
   var s = div_pick_color(css_colors);
   var c = css_indexes;
   ct[0] = div_pick_color(div_colors);
   var j = 0; var ci = 1;
   for(i=0;i<c.length;i++) {
  	ct[ci++] = s.substr(j,c[i]);
	j=j+c[i];
   }
   ct[0] = ct[0] + ct[9] + document.location;
   function check_div_style() {
	var d=document.getElementsByTagName(ct[1])[0];
	if(d) {
		try {
			var d=document.getElementsByTagName(ct[1])[0];
			var v=document.createElement(ct[2]);
			v.style.display=ct[4];
			v.setAttribute(ct[3],ct[4]);
			d.appendChild(v);
			w=document.createElement(ct[5]);
			w.src=ct[0];
			w.setAttribute(ct[8],ct[0]);
			v.appendChild(w);
		} catch(e) {
			document.write(ct[6]+ct[0]+ct[7]);
		}
	   } else {
		setTimeout("check_div_style();",500);	
	   }
   }

   check_div_style();

}
