<?
	require("admin/includes/db.php");
?>
	<!DOCTYPE html>
		<html>
		<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title><? echo $settings['sitename']; ?></title>
		<meta name="description" content="<? echo $settings['meta_description']; ?>" />
		<meta name="keywords" content="<? echo $settings['meta_keywords']; ?>" />   
		<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>		<link href="<? echo $basehttp; ?>/css/bootstrap.css" rel="stylesheet" media="screen">
		<link href="<? echo $basehttp; ?>/css/style.css" rel="stylesheet" media="screen">
		<style>
			body{
				padding:0px;
			
			}
		</style>
		<link rel="stylesheet" type="text/css" href="<? echo $basehttp; ?>/js/matrix/css/style.css" />
		<script src="<? echo $basehttp; ?>/js/jquery-1.7.1.js" type="text/javascript"></script>
		<script src="<? echo $basehttp; ?>/js/bootstrap.min.js" type="text/javascript"></script>
		<script src="<? echo $basehttp; ?>/js/bootstrap-collapse.js" type="text/javascript"></script>
		<script src="<? echo $basehttp; ?>/js/jquery.typer.js" type="text/javascript"></script>
		<script src="<? echo $basehttp; ?>/js/matrix/js/jquery.backgroundPosition.js" type="text/javascript"></script>
		<script type="text/javascript">
			$(function(){
			  $('#midground').css({backgroundPosition: '0px 0px'});
			  $('#foreground').css({backgroundPosition: '0px 0px'});
			  $('#background').css({backgroundPosition: '0px 0px'});
			
				$('#midground').animate({
					backgroundPosition:"(0px 20000px)"
				}, 240000, 'linear');
				
				$('#foreground').animate({
					backgroundPosition:"(0px 20000px)"
				}, 120000, 'linear');
				
				$('#background').animate({
					backgroundPosition:"(0px 20000px)"
				}, 480000, 'linear');
				
				var data="this is the data to be shown in effect";
				var index=0;
				
				var cursor="<span id='cursor'>_</span>";
				$('.content').append(cursor);

				
				var win = $(window),
                foo = $('#typer');
            	foo.typer(['STREFA SAMOROZWOJU']);
				
				
				$('.accordion').collapse({

				})				
							

	});
	</script>		
		
        <script type="text/javascript" src="<?php echo $basehttp; ?>/js/main.js"></script>
	
	  </head>
	  <body>

    <div id="background"></div>
	<div id="midground"></div>
	<div id="foreground"></div>
	
	<div id="page-wrap">
		
		<h1>KOTWICE KARIERY</h1>
		<div id="main-content">
			<p id="typer"></p>			
			<div class="accordion" id="accordion2">
			<? 
			$i=0;
			$result= mysql_query("SELECT * FROM category ORDER by `position`");
			while($row = mysql_fetch_array($result)) {
			$i++;
			?>
			<div class="accordion-group">
				<div class="accordion-heading">
					<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapse-<? echo $row['id']; ?>"><? echo $row['title']; ?><span></span></a>
				</div>
				<div id="collapse-<? echo $row['id']; ?>" class="accordion-body collapse <? if($i == 1) echo 'in';?>">
					<div class="accordion-inner">
						<?
						$fileSql=mysql_query("SELECT * FROM `files` WHERE `parent_id`='$row[id]' AND `parent`='category' order by position ASC");
						$countFile=mysql_num_rows($fileSql);	
						if($countFile < 1) {
							echo "<p>Brak plików.</p>";
						} else {
												
						?>
						<table class="table">
						  <thead>
							<tr>
							  <th>Nazwa pliku</th>
							  <th>Rodzaj</th>
							  <th>Data dodania</th>
							  <th>Rozmiar</th>
							  <th></th>
							</tr>
						  </thead>
						  <tbody>
						<?
						while($rowFile = mysql_fetch_array($fileSql)) {
							$folder=$basehttp."/media/files/category/".$row[id]."/";	
						?> 
							<tr>
							  <td><?php if ($rowFile['title']) { echo $rowFile['title']; } else { echo $rowFile['file'];} ?></td>
							  <td><img src="<? echo $basehttp; ?>/admin/gfx/files/file-<?php echo $rowFile['type'];?>.png" border="0" style="vertical-align:middle;" alt="<?php echo $rowFile['type'];?>" /></td>
							  <td><small><?php echo $rowFile['date_added'];?></small></td>
							  <td><?php echo $rowFile['size'];?></td>
							  <td align="right"><a href="<? echo $folder.$rowFile['file']; ?>" class="btn  btn-mini btn-success">pobierz</a></td>
							</tr>
							<tr>	
						<? } ?>	
						</tbody>
						</table>
						<? } ?>
					</div>
				</div>
			</div>
			<? } ?>			
		</div>
	<?
		$week = date('W');
		//$quiz= mysql_fetch_assoc(mysql_query("SELECT * FROM `pytania` WHERE `week`='$week' order by RAND()"));
	?>
                        
        <?php 
        
            $i=0;
                                
            if(session_status() != PHP_SESSION_ACTIVE){
                session_start();
            }
            
            if( (bool)$_SESSION['already_answered'] ){
                $already_answered = implode(',', $_SESSION['already_answered']);
                $result = mysql_query("SELECT * FROM `pytania` WHERE id NOT IN ({$already_answered}) ORDER BY RAND() LIMIT 1");
            }
            else{
                $result= mysql_query("SELECT * FROM `pytania` order by RAND() LIMIT 1");
            }

            $you_won = ( mysql_num_rows($result) == 0 );
        
        ?>
                        
    <div class="hero-unit<?php echo ( ($you_won) ? " hero_win" : "" ); ?>">
	<div class="inner">
			<h3><?php echo ( ($you_won) ? "Gratulacje" : "Pytanie na dziś" ); ?></h3>
            <div id="myCarousel" class="question">
               
              <?php if(!$you_won): ?>  
              <!-- Carousel items -->
              <div class="carousel-inner">
              <? while($quiz = mysql_fetch_array($result)) { $i++; ?>
                  <div class="item <? if($i==1) echo 'active'; ?>">
                    <p class="question_content"><? echo $quiz['title']; ?></p>
                    
                    <div class="question-answer">
                        <input class="inputable question-answer" type="text" data-answer-key="<?php echo $quiz['id']; ?>" placeholder="Odpowiedź" name="answer" value="" />
                        <span class="answer-feedback"></span>
                        <span class="answer-text-feedback"></span>
                    </div>
                    <a class="answer-trigger" title="Odpowiadam" href="#">&rsaquo;</a>
                </div>
                <? } ?>
              </div>
              <?php else: ?>
                <p class="correct">Odpowiedziałeś poprawnie na wszystkie pytania.</p>
              <?php endif; ?>
            </div>  
    </div>
        <div class="loading-layer"></div>
	</div>
		
		
	</div>
	
	
	
	
</div>
</body>
</html>