<?php
	include_once("core/basededatos.php");
	include_once("core/Usuario.php");
	include_once("core/Paciente.php");
	include_once("core/Semana.php");
	include_once("core/Historia.php");
	include_once("core/Fotografia.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">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1" />
<link type="text/css" rel="stylesheet" media="all" href="../style.css"/>
<link rel="shortcut icon" type="image/x-icon" href="../favicon.ico">
<!-- include jQuery library -->
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/vanadium.js"></script>
<script type="text/javascript" src="webcam.js"></script>
<title>CECOM - Centro de Cirugía Oral y Maxilofacial - La Paz B.C.S.</title>
</head>
<body>
	<?
		$paciente = $_SESSION['ObjetoPaciente'];
		$id = $_GET['id'];
		if (!$_SESSION['ObjetoUsuario']) { ?>
			 <script language="javascript">window.location="consultorio.php";</script>
		<?php
        } else {
			$usuario = $_SESSION['ObjetoUsuario'];
			$usuario->acceso($id);
		}
		
	?>
    <div align="center">
    	<div id="container">
        	<div id="cuerpo">
            <!--- Header --->
                <div id="arribapagina"></div>
                <div id="arriba">
                    <div id="fondo_izq"></div>
                    <div id="logo"><img alt="cecom" src="../img/logo_CECOM.jpg" width="400" height="150" /></div>
                    <div id="fondo_izq_sistema"><h2 align="center">Sistema Consultorio</h2>
                    	<div id="menu_sistema"><a class="item_menu" href="verDatos.php?id=<?php echo $id; ?>&Pac=<?php echo $paciente->id; ?>">- Regresar</a> <a class="item_menu_exit" href="consultorio.php">- Salir</a></div>
                    </div>
                    
                </div>
                <div id="separacion_linea"></div>
                
            <!---Cuerpo--->           
            <div id="cuerpo_sistema">
                <h3>Paciente: <?php echo $paciente->nombre." ".$paciente->apellidop." ".$paciente->apellidom; ?></h3>
                			
                        <p>Cambiar fotografia del Paciente:</p>
                         <p>
                         <script language="JavaScript">
                            webcam.set_api_url('upload.php');
                            webcam.set_quality( 90 ); // JPEG quality (1 - 100)
                            webcam.set_shutter_sound( false ); // play shutter click sound
                        </script>
                        <script language="JavaScript">
                            document.write( webcam.get_html(320, 240) );
                        </script>
                        <br/><form>
                            <input type=button value="Configurar Camara" onClick="webcam.configure()">
                            &nbsp;&nbsp;
                            <input type=button value="Tomar Fotografia" onClick="take_snapshot()">
                        </form>
                        <!-- Code to handle the server response (see upload.php) -->
                            <script language="JavaScript">
                                webcam.set_hook( 'onComplete', 'my_completion_handler' );
                                
                                function take_snapshot() {
                                    // take snapshot and upload to server
                                    document.getElementById('upload_results').innerHTML = '<h1>Uploading...</h1>';
                                    webcam.snap();
                                }
                                
                                function my_completion_handler(msg) {
                                    // extract URL out of PHP output
                                    if (msg.match(/(http\:\/\/\S+)/)) {
                                        var image_url = RegExp.$1;
                                        // show JPEG image in page
                                        document.getElementById('upload_results').innerHTML = 
                                            '<form name="fotografia" action="cambiandofoto.php" method="post">' + 
                                            '<input type="hidden" name="txt_imagen" value="' + image_url + '">'
                                            '</form>>'; 
                                        document.fotografia.submit();
                                            
                                        
                                        // reset camera for another shot
                                        webcam.reset();
                                    }
                                    else alert("PHP Error: " + msg);
                                }
                            </script>
                            </td><td width=50>&nbsp;</td><td valign=top>
                                <div id="upload_results" style="background-color:#eee;"></div>
                            </td></tr></table>
                        </p>	                	
                
   
            </div>    
            
            <!--Pie-->    
        	<div id="footer">
            <p>CECOM Centro de Cirugía Oral y Maxilofacial</p>
            </div>
       </div>
	</div>
</body>
</html>
