<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mobivation </title>


<script type="text/javascript">var _siteRoot='index.php',_root='index.php';</script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/scripts.js"></script>
<link href="style/reset.css" rel="stylesheet" type="text/css" />
<link href="style/home.css" rel="stylesheet" type="text/css" />
<link href="style/style.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="js/dom_img_rollover.js"></script>
</head>
<?php 
	include 'wcp/function/classes.php';
	$limit=10; // Limit of result per page 

	
	if ($_GET['page']!= '') 
		{$pages=$_GET['page'];}
	else 
		{ $pages = 1;} //$_GET['page']; //Get the current page 
	$prodlist=getList("prod.product_id,prod.product_name,prod.product_brief_desc,prod.product_logo","tb_products prod","");
	 
	/********
	*
	* SORTER
	*
	*********/
	 	 
	if ($_POST['sortby']=="" && $_GET['sortby']=="")
	{
		$sortby="order_id";
	}
	elseif($_POST['sortby']!="")
	{
		$sortby=$_POST['sortby'];
	}
	elseif($_GET['sortby']!="")
	{
		$sortby=$_GET['sortby'];
	}	
	else
	{
		$sortby=$_SESSION['sortby_temp'];
	}		
	$_SESSION['sortby_temp']=$sortby;	
	
	/******** 
	*
	* SORT TYPE
	*
	********/
	
	if ($_POST['sorttype']=="" && $_GET['sorttype']=="")
	{
		$sorttype="asc";
	}
	elseif($_POST['sorttype']!="")
	{
		$sorttype=$_POST['sorttype'];
	}
	elseif($_GET['sorttype']!="")
	{
		$sorttype=$_GET['sorttype'];
	}
	else
	{
		$sorttype=$_SESSION['sorttype_temp'];
	}
	$_SESSION['sorttype_temp']=$sorttype;

	/*********
	*
	* PLATFORM
	*
	**********/

	//echo 'platid'.$_POST['platform'];
	//echo 'set kah? ' . $_SESSION['platid_temp'];
	if ($_POST['platform']=="" && $_GET['platform']=="")
	{
		$platid="";
		$sql = 'SELECT * FROM (SELECT platform_id FROM tb_platform ORDER BY platform) temp LIMIT 0,1';
		$query = mysql_query($sql);
		if ($query) 
		{
			$result = mysql_fetch_array($query);
			$platid = $result['platform_id'];
			//echo '1. platid: ' . $platid;
		}
		
	}
	elseif($_POST['platform']!="")
	{
		$platid=$_POST['platform'];
		//echo '2. platid: ' . $platid;
	}
	elseif($_GET['platform']!="")
	{
		$platid=$_GET['platform'];
		//echo '3. platid: ' . $platid;
	}
	else
	{	
		$platid="";
		$sql = 'SELECT * FROM (SELECT platform_id FROM tb_platform ORDER BY platform) temp LIMIT 0,1';
		$query = mysql_query($sql);
		if ($query) 
		{
			$result = mysql_fetch_array($query);
			$platid = $result['platform_id'];
			//echo 'platid: ' . $platid;
		}
		//echo '4. platid: ' . $platid;
		//$platid=$_SESSION['platid_temp'];
	}
	/*if ($_GET['platid']!='') {$platid=$_GET['platid'];}
	else {$platid=$_POST['platform'];}*/
	//unset ($_SESSION['platid_temp']);
	$_SESSION['platid_temp']=$platid;
	//echo $_SESSION['platid_temp'];
	
	if ((isset($_POST['button'])) || ($_GET['platid']!='') || $_SESSION['platid_temp'] != '')
	{
		//echo '1';
		if ($_SESSION['platid_temp']!="") {
			//echo '2';
			$getprodlist=getList("prod.product_id,prod.product_name,prod.product_brief_desc,prod.product_logo","tb_products prod,tb_supported_platform plat","where prod.product_id=plat.product_id AND plat.platform_id=".$platid." order by ". $sortby. " ".$sorttype ." LIMIT ".(($pages-1)*$limit).",". $limit);
		}
		else 
		{
			//echo '3';
			$getprodlist=getList("prod.product_id,prod.product_name,prod.product_brief_desc,prod.product_logo","tb_products prod"," order by ". $sortby. " ".$sorttype." LIMIT ".(($pages-1)*$limit).",". $limit);
		}
	}
	else
	{
		//echo '4';
		$getprodlist=getList("prod.product_id,prod.product_name,prod.product_brief_desc,prod.product_logo","tb_products prod"," order by ". $sortby. " ".$sorttype. " LIMIT ".(($pages-1)*$limit).",". $limit );
	}
?>
<body>
<div id="page">
  <div id="container">
   <?php include "menu.php"; ?>
    <div id="top_content">
      <!--
      <div id="product">
        <div id="header">
          <div class="wrap">
            <div id="slide-holder">
              	<div id="slide-runner" class="product_img">
	              <?php 
	              	if (count($prodlist) > 0){
						while($row=mysql_fetch_array($prodlist) ){
						   echo "<img width=128 id='prod" . $row['product_id'] . "' src='wcp/logo/" . $row['product_logo'] . "'  class='slide' alt='' />";
						}
					}
	              ?>
              	</div>
                <div id="slide-controls">
                  <div id="slide-client" class="bubble_text_title"><span></span></div>
                  <div id="slide-desc" class="bubble_text"></div><br><br>                
                </div>
                <div id="slide-nav" class="prod_nav"></div>
            </div>
            
          </div>
        </div>
      </div>
      -->
	<form name="frmplatid" enctype="multipart/form-data" method="post">
      <table width="850" border="0" align="center" cellpadding="1" cellspacing="4" class="upper_three_columns">	  
      <tr>
        <td ><p class="page_title">Mobile Applications <br />
        </p>
          <p>&nbsp;&nbsp;<br />
            <br />
          </p>
          <p>The following is a list of products that are developed by mobivation's developers.<br />
            <br />
          </p></td>
      </tr>
      <tr>
        <td >
        	<div class="page_header">
              <p><br />
                &nbsp;&nbsp;Filter based on platform: 
                <?php
			getInputType("selectproduct","platform","platform",$platid);
				?>                    				  
				<select  name="sortby" style="display:none"><option value="order_id" selected>Product</option></select> 
				<select  name="sorttype"  style="display:none"><option value="asc" selected>A-Z</option></select> 
                <input type="submit" name="button" id="button" value="Go" />
                <!--
                <select  name="sortby"><option value="product_name" <?php if ($_SESSION['sortby_temp']=="product_name") { echo "selected"; }?>>Product</option><option value="product_price" <?php if ($_SESSION['sortby_temp']=="product_price") { echo "selected"; }?>>Price</option></select> 
				<select  name="sorttype"><option value="asc" <?php if ($_SESSION['sorttype_temp']=="asc") { echo "selected"; }?>>A-Z</option><option value="desc" <?php if ($_SESSION['sorttype_temp']=="desc") { echo "selected"; }?>>Z-A</option></select> 
                <input type="submit" name="button" id="button" value="Go" />
                -->
                <br /><br />
              </p>
</div>
        	<br />
          <div class="">
          <table width="100%" border="0" style="border-collapse:separate; border-spacing:10px;">
		  <?php 
	      	if (count($getprodlist) > 0){
				while($prodrow=mysql_fetch_array($getprodlist) ){
						   echo "";
			?>
            <tr>
				<td width="150"><span class="location_title"><a href="single_products.php?prodid=<?php echo $prodrow['product_id'];?>"><img src="wcp/logo/<?php echo $prodrow['product_logo'];?>" alt="" width=128 align="left" class="slide" id="prod<?php echo $prodrow['product_id'];?>" /> 
				  </a></span></td>                
				<td width="680" valign="top">
                <span class="location_title"><a href="single_products.php?prodid=<?php echo $prodrow['product_id'];?>"><?php echo $prodrow['product_name']?></a></span><br /><br /><?php echo $prodrow['product_brief_desc']?>                
                </td>
            </tr>       
            <tr>
            	<td colspan="2"><img src="images/separator.png" width="820" height="8" /></td>
            </tr>    		
		 <?php
				}
			}
	      ?>
    </table>
    </div>
    </td>
	</tr>
	<?php include 'wcp/include/paging.php';?>
	</table>
	</form>
    <div id="nothing" style="clear:both">
    </div>    
    <?php include "footer.php"; ?>        
  </div>  
</div>
<script type="" text="" javascript="">
if(!window.slider) 
var slider={};
slider.data=[<?php
$prodlist2=getList("product_id,product_name,product_brief_desc,product_logo","tb_products","");
$strTemp="";				
if (count($prodlist2) > 0)
{	
	while($row=mysql_fetch_array($prodlist2) ){
		$strTemp = $strTemp . "{'id':'prod" . $row['product_id'] . "','client':'" . $row['product_name'] . "','desc':'" . $row['product_brief_desc'] . "'},";
	}
	if (substr($strTemp, -1) == ","){
		$strTemp = substr_replace($strTemp,'',-1,1);
	}
	echo $strTemp;
}?>];
</script>

</body>
</html>
