<?php
  include "include.php";
  session_start();
?>

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


<?php  include_jquery(); ?>
   <link href="style.css" rel="stylesheet" type="text/css" />
  <!--link rel="stylesheet" href="/resources/demos/style.css" /-->
  <!--link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" /-->
  
  <!--<script>
function loadXMLDoc(str)
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("dynamicPhone").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","phone-panel.php>q="+str);
xmlhttp.send();
}
</script>
  <!--Tooltip Hover for Phones-->
  <!--link href="css/blitzer/jquery-ui-1.10.2.custom.css" rel="stylesheet"-->


  <!--Buttons-->

  <script>
/*  $(function() {
    $( "input[type=submit], a, button" )
      .button()
      .click(function( event ) {
       // event.preventDefault();
      });
  });

  $(function() {
    //scrollpane parts
    var scrollPane = $( ".scroll-pane" ),
      scrollContent = $( ".scroll-content" );
 
    //build slider
    var scrollbar = $( ".scroll-bar" ).slider({
      slide: function( event, ui ) {
        if ( scrollContent.width() > scrollPane.width() ) {
          scrollContent.css( "margin-left", Math.round(
            ui.value / 100 * ( scrollPane.width() - scrollContent.width() )
          ) + "px" );
        } else {
          scrollContent.css( "margin-left", 0 );
        }
      }
    });
 
    //append icon to handle
    var handleHelper = scrollbar.find( ".ui-slider-handle" )
    .mousedown(function() {
      scrollbar.width( handleHelper.width() );
    })
    .mouseup(function() {
      scrollbar.width( "100%" );
    })
    .append( "<span class='ui-icon ui-icon-grip-dotted-vertical'></span>" )
    .wrap( "<div class='ui-handle-helper-parent'></div>" ).parent();
 
    //change overflow to hidden now that slider handles the scrolling
    scrollPane.css( "overflow", "hidden" );
 
    //size scrollbar and handle proportionally to scroll distance
    function sizeScrollbar() {
      var remainder = scrollContent.width() - scrollPane.width();
      var proportion = remainder / scrollContent.width();
      var handleSize = scrollPane.width() - ( proportion * scrollPane.width() );
      scrollbar.find( ".ui-slider-handle" ).css({
        width: handleSize,
        "margin-left": -handleSize / 2
      });
      handleHelper.width( "" ).width( scrollbar.width() - handleSize );
    }
 
    //reset slider value based on scroll content position
    function resetValue() {
      var remainder = scrollPane.width() - scrollContent.width();
      var leftVal = scrollContent.css( "margin-left" ) === "auto" ? 0 :
        parseInt( scrollContent.css( "margin-left" ) );
      var percentage = Math.round( leftVal / remainder * 100 );
      scrollbar.slider( "value", percentage );
    }
 
    //if the slider is 100% and window gets larger, reveal content
    function reflowContent() {
        var showing = scrollContent.width() + parseInt( scrollContent.css( "margin-left" ), 10 );
        var gap = scrollPane.width() - showing;
        if ( gap > 0 ) {
          scrollContent.css( "margin-left", parseInt( scrollContent.css( "margin-left" ), 10 ) + gap );
        }
    }
 
    //change handle position on window resize
    $( window ).resize(function() {
      resetValue();
      sizeScrollbar();
      reflowContent();
    });
    //init scrollbar size
    setTimeout( sizeScrollbar, 10 );//safari wants a timeout
  });
*/  
$(document).ready(function() {
//	var num = $(".phone-item").toArray().length;
//	var w = Math.ceil(num / 3) * 63 + 20;
//	$(".scroll-content").css("width", w);
//	console.log(num, w);
});

  </script>

  </head>


<body>
<?php

echo "<div id='phone-grid' class='scroll-pane ui-widget ui-widget-header ui-corner-all'>";
echo "<h1>Phone Details</h1><div id='phones-images' class='scroll-content'>\n";

//include "Step1-c.php";
$gbrand = $_GET["Brand"];
$priority = $_GET["Priority"];
$arrays = stripslashes($_GET["arrays"]);

	
	//Depending on the number passed 
	
	if ($priority == '1')
		$PhoneArray = $_SESSION['FinalMost'];
		
	if ($priority == '2')
		$PhoneArray = $_SESSION['FinalWell'];
		
	if ($priority == '3')
		$PhoneArray = $_SESSION['FinalSuit'];
		

$con = get_database_connection();
$count = 0;
foreach($PhoneArray as $array_value){ 
	$result = mysqli_query($con,"SELECT Model, ImagePath, PhoneID, Brand FROM `Phone`  WHERE PhoneID =".$array_value);
	
	while($row = mysqli_fetch_array($result)){
		$phoneid = $row['PhoneID'];
		$model = $row['Model'];
		$path = $row['ImagePath'];
		$brand = $row['Brand'];
	
	//print the item if it's the same brand
		if ($gbrand != $brand){
			//echo "[{$count}]";
				
			if ($count % 3 == 0){
				if ($count > 0) 
					echo "</div>\n";
				echo "<div class='phone-column'>\n";
			}
			 echo "<div class='phone-item'><a href='phonescroller.php?PhoneID=".$phoneid."&arrays=".$arrays."' target='_blank'><img src='".$path."' alt='".$model."' width='50' height='60' class='phone-pic' /><div class='phone-name'>".$model."</div></a></div>\n";
		
		$count++;
		}
	}	
}
echo "</div>\n";
	
echo "<div class='scroll-bar-wrap ui-widget-content ui-corner-bottom'>
        <div class='scroll-bar'></div>";
?>
</body>
</html>
