<?php
session_set_cookie_params(0);
session_start();
require_once('conexion.php');
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Vicpos</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="description" content="Expand, contract, animate forms with jQuery wihtout leaving the page" />
        <meta name="keywords" content="expand, form, css3, jquery, animate, width, height, adapt, unobtrusive javascript"/>
		  <link rel="shortcut icon" href="img\vic_logo.ico" type="image/x-icon">
        <link rel="stylesheet" type="text/css" href="css/style.css" />
		<script src="js/cufon-yui.js" type="text/javascript"></script>
		<script src="js/ChunkFive_400.font.js" type="text/javascript"></script>
		<script type="text/javascript">
			Cufon.replace('h1',{ textShadow: '1px 1px #fff'});
			Cufon.replace('h2',{ textShadow: '1px 1px #fff'});
			Cufon.replace('h3',{ textShadow: '1px 1px #000'});
			Cufon.replace('.back');
		</script>
    </head>
    <body>
		<div class="wrapper">
			</br></br></br>
			<div class="content">
				<div id="form_wrapper" class="form_wrapper">

<?php 
$cero=0;
if(!empty($cero)=='0')
{

    if (!empty($_POST['registar'])=='registar')
        { 
                        $cc=$_POST['cc'];
                        $nombre=$_POST['nombre'];
						$correo=$_POST['correo'];
						$clave=$_POST['clave'];

        				$query=mysqli_query($con,"SELECT COUNT(dis_correo) AS cantidad from distribuidor where dis_correo='$correo' or dis_cc='$cc' ") or die(mysqli_error($con));
        				$results=mysqli_fetch_array($query);
        				 $numrows= $results["cantidad"]; 
    
    					if($numrows > 0) 
   						{
          				

                			echo '<h3>Registro</h3></br>';
                                      	echo '<div class="error"><strong><center>Documento o Correo no disponible.</center></strong></div> ';
                                      	echo '<center><a href="index.php" class="btn"><strong>Espera la Aprobacion o Intente con uno Diferente</strong></a></center>';
                                       	echo '<div class="bottom">
													</br></br>
												</div>';
   						}	
    					else
    					{
                     
                         $registros=mysqli_query($con,"INSERT into distribuidor (dis_cc,dis_nombre,dis_correo,dis_clave,dis_estado)
                     	 VALUES  ('$cc','$nombre','$correo','$clave','0')") or  die(mysqli_error($con));
           
                                    	echo '<h3>Registro</h3></br>';
                                      	echo '<div class="info"><strong><center>El Registro se realizo.</center></strong></div> ';
                                      	echo '<center><a href="index.php" class="btn"><strong>Espera la Aprobacion </strong></a></center>';
                                       	echo '<div class="bottom">
													</br></br>
												</div>';
                          }          
  		}

  	else if (!empty($_POST['usu_clave'])=='usu_clave')
        { 
                        $usu_nombre = mysqli_real_escape_string($con, $_POST['usu_nombre']);
                        $usu_clave =  mysqli_real_escape_string($con,$_POST['usu_clave']);
                     
                     
                                    $sql=mysqli_query($con,"SELECT clie_id, clie_nombre, clie_clave 
                                      FROM cliente WHERE clie_correo='$usu_nombre' AND clie_clave='$usu_clave'") or die(mysqli_error($con));
                                    if($row = mysqli_fetch_array($sql)) 
                                    {
                                            $_SESSION['clie_nombre'] = $row["clie_nombre"]; 
                                            $_SESSION['clie_id'] = $row["clie_id"]; 
                                          
                                           echo '<h3>Login</h3></br>';
                                           echo '<center><strong><h4>BIENVENIDO</h4><br>'.$row['clie_nombre'].'</strong></center><br>';
                                           echo '<center><img src="images/loader.gif"></center><br>';
                                           echo '<meta http-equiv="refresh" content="2;url=I_articulos.php">';
                                           echo '<div class="bottom">
													</br></br>
												</div>';
                                    }
                                    else 
                                    {
                                    	echo '<h3>Login</h3></br>';
                                     	echo '<div class="alert alert-danger"><center><strong>Usuario y Contraseña Incorrecto</strong></center></div>';
                                      	echo '<center><a href="index.php" class="btn"><strong>Intentar de Nuevo</strong></a></center>';
                                        echo '<div class="bottom">
													</br></br>
												</div>';
                                    
                                    }
        } 
	else
		{ 
?>
				<form class="login active" action=""  method="post">
						<h3>Login</h3>
						<div>
							<label>Email:</label>
							<input type="text"  id="usu_nombre" name="usu_nombre" required="" />
						</div>
						<div>
							<label>Contraseña:	<!--  <a href="forgot_password.php" rel="forgot_password" class="forgot linkform">¿Olvidaste tu contraseña?</a> --></label>
							<input type="password" id="usu_clave" name="usu_clave" required="" />
						</div>
						<div class="bottom">
							<button type="submit"   value="Login">Login</button>
						<a href="register.php" rel="register" class="linkform">¿Aún no tienes una cuenta? Registrar aquí</a> 
							<div class="clear"></div>
						</div>
					</form>
					<form class="forgot_password">
						<h3>Forgot Password</h3>
						<div>
							<label>Email:</label>
							<input type="text" />
						</div>
						<div class="bottom">
							<input type="submit" value="Enviar"></input>
							<a href="index.php" rel="login" class="linkform">La recordaste? Entre aquí</a>
							<a href="register.php" rel="register" class="linkform">¿No tienes una cuenta? Registrar aquí</a>
							<div class="clear"></div>
						</div>
					</form>
					<form class="register" action=""  method="post">
						<h3>Registro</h3>
							<div>
								<label>Identificación:</label>
								<input type="number"  id="cc" name="cc" required="" />
							</div>
							<div>
								<label>Nombre:</label>
								<input type="text"  id="nombre" name="nombre" required=""/>
							</div>
							<div>
								<label>Email:</label>
								<input type="email"  id="correo" name="correo" required=""/>
							</div>
							<div>
								<label>Contraseña:</label>
								<input type="password"  id="clave" name="clave" required=""/>
							</div>
							
						<div class="bottom">
							<button type="submit" name="registar"  value="registar">Registrate</button>
							<a href="index.php" rel="login" class="linkform">¿Ya tienes una cuenta? Entre aquí</a>
							<div class="clear"></div>
						</div>
					</form>
<?php  } 
} 
?>
				</div>
				<div class="clear"></div>
			</div>
		</div>
		

		<!-- The JavaScript -->
		<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
		<script type="text/javascript">
			$(function() {
					//the form wrapper (includes all forms)
				var $form_wrapper	= $('#form_wrapper'),
					//the current form is the one with class active
					$currentForm	= $form_wrapper.children('form.active'),
					//the change form links
					$linkform		= $form_wrapper.find('.linkform');
						
				//get width and height of each form and store them for later						
				$form_wrapper.children('form').each(function(i){
					var $theForm	= $(this);
					//solve the inline display none problem when using fadeIn fadeOut
					if(!$theForm.hasClass('active'))
						$theForm.hide();
					$theForm.data({
						width	: $theForm.width(),
						height	: $theForm.height()
					});
				});
				
				//set width and height of wrapper (same of current form)
				setWrapperWidth();
				
				/*
				clicking a link (change form event) in the form
				makes the current form hide.
				The wrapper animates its width and height to the 
				width and height of the new current form.
				After the animation, the new form is shown
				*/
				$linkform.bind('click',function(e){
					var $link	= $(this);
					var target	= $link.attr('rel');
					$currentForm.fadeOut(400,function(){
						//remove class active from current form
						$currentForm.removeClass('active');
						//new current form
						$currentForm= $form_wrapper.children('form.'+target);
						//animate the wrapper
						$form_wrapper.stop()
									 .animate({
										width	: $currentForm.data('width') + 'px',
										height	: $currentForm.data('height') + 'px'
									 },500,function(){
										//new form gets class active
										$currentForm.addClass('active');
										//show the new form
										$currentForm.fadeIn(400);
									 });
					});
					e.preventDefault();
				});
				
				function setWrapperWidth(){
					$form_wrapper.css({
						width	: $currentForm.data('width') + 'px',
						height	: $currentForm.data('height') + 'px'
					});
				}
				
				/*
				for the demo we disabled the submit buttons
				if you submit the form, you need to check the 
				which form was submited, and give the class active 
				to the form you want to show
				*/
				$form_wrapper.find('input[type="submit"]')
							 .click(function(e){
								e.preventDefault();
							 });	
			});
        </script>

        <style>
        	.info, .correcto, .ojo, .error, .validation {
    border: 1px solid;
    margin: 10px 10px;
    padding:15px 10px 15px 50px;
    background-repeat: no-repeat;
    background-position: 10px center;
    font-family:Arial, Helvetica, sans-serif;
    font-size:13px;
    text-align:center;
    width:auto;
}
.info {
    color: #00529B;
    background-color: #BDE5F8;
}
.correcto {
    color: #4F8A10;
    background-color: #DFF2BF;
}
.ojo {
    color: #9F6000;
    background-color: #FEEFB3;
}
.error {
    color: #D8000C;
    background-color: #FFBABA;
}
        </style>
    </body>
</html>