<?php
//Load time function (in footer)
$time = microtime(true);
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;

$session_username = mysql_real_escape_string($_SESSION['username']);
$session_password = mysql_real_escape_string($_SESSION['password']);
$session_acctype = mysql_real_escape_string($_SESSION['acctype']);
$session_hash = mysql_real_escape_string($_SESSION['hash']);

$adminhash1 = "SELECT `support` FROM `Web_Premium_Login` WHERE `id` = '1'";
$adminhash2 = mysql_query($adminhash1) or die($adminhash1."<br/><br/>".mysql_error());
$adminhash3 = mysql_result($adminhash2, 0);
if($session_hash != $adminhash3) {
	echo"<script type='text/javascript'>window.location= 'f.home'</script>";
}

if(!isset($_SESSION['username']) || !isset($_SESSION['password']))  {
	echo"<script type='text/javascript'>window.location= 'f.home'</script>";
}

if($_SESSION['acctype'] != 'support')  {
	echo"<script type='text/javascript'>window.location= 'f.home'</script>";
}
$query = "SELECT * FROM Tickets_All WHERE support_username='$session_username'";
$result = mysql_query($query) or die('Error, query failed');
$tickets = 0;
if(mysql_num_rows($result)<1){
}else{
while($row = mysql_fetch_array($result))
	{
		$tickets = $tickets + 1;
	}
}

$query = "SELECT * FROM Tickets_All WHERE support_username='$session_username'";
$result = mysql_query($query) or die('Error, query failed');
$unreaded = 0;
$unanswered = 0;
if(mysql_num_rows($result)<1){
}else{
while($row = mysql_fetch_array($result))
	{
		$posts = $row['posts'];
		$readed = $row['support_readed'];
		$answered = $row['support_answered'];
		if($posts > $readed) {
			$unreaded = $unreaded +1;
		}
		if($posts > $answered) {
			$unanswered = $unanswered +1;
		}
	}
}

$query = "SELECT * FROM Accounts_Premium_Support WHERE username='$session_username'";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result)<1){
}else{
while($row = mysql_fetch_array($result))
	{
		$language = $row['language'];
		$language2 = $row['language2'];
		$language3 = $row['language3'];
		$balance = $row['balance'];
		$ppemail = $row['ppemail'];
		$pzemail = $row['pzemail'];
		$skrillemail = $row['skrillemail'];
	}
}
?>
<!DOCTYPE html>
<html lang="en"><head>
  <meta charset="utf-8">
  <title><?php echo"$title"?></title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="title" content="<?php echo $sa['title']; ?>">
  <meta name="description" content="<?php echo $sa['description']; ?>">
  <meta name="author" content="Jozef Vojtáš" >
  <link rel="icon" type="image/png" href="<?php echo $iconurl; ?>">
  
  <!-- Google Web Font -->
  <link href="http://fonts.googleapis.com/css?family=Open+Sans:300,300italic,700&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  
  <!-- Bootstrap 3 Plan styles -->
  <link id="plan-theme" href="data/templates/panelend/superhero/assets/css/bootstrap.css" rel="stylesheet">
  <link href="data/templates/panelend/superhero/assets/fonts/font-awesome.css" rel="stylesheet" type="text/css" />
  <link href="data/plugins/wysiwyg/dist/summernote.css" rel="stylesheet">

  <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Docs Custom styles -->
  <style>
    body {
      padding: 120px 0 0 0; 
    }
    footer {
      background-color: white;
      border-top: 1px solid #ddd;
      padding: 30px;
      margin-top: 50px;
    }  
    .row > [class*="col-"] {
      margin-bottom: 30px;
    }
    .navbar-container {
      position: relative;
      min-height: 100px;
    }
    .navbar-container .navbar.navbar-fixed-top,
    .navbar-container .navbar.navbar-fixed-bottom {
      position: absolute;
      top: 50px;
      z-index: 0;
    }
    .navbar-container .navbar.navbar-fixed-top .container,
    .navbar-container .navbar.navbar-fixed-bottom .container {
      max-width: 90%;
    }
    .btn-group {
      margin-bottom: 10px
    }
    .form-inline select, 
    .form-inline input[type="text"], 
    .form-inline input[type="password"] {
      width: 180px;
    }
    .input-group {
      margin-bottom: 10px;
    }
    .pagination { margin-top :0;}
    .navbar-inverse {margin: 110px 0} 
    input[type="radio"].toggle {
    display: none;
}

input[type="radio"].toggle:checked + label {
    background-color: #3B4B5C;
    cursor: default;
    color: #E6E6E6;
    border-color: transparent;
    text-shadow: 0 1px 1px rgba(40, 40, 40, 0.75);
}

input[type="radio"].toggle + label {
    width: 20%;
}

input[type="radio"].toggle:checked + label.btn:hover {
    background-color: #445260;
    background-position: 0 0;
    -webkit-transition: none;
    -moz-trainsition: none;
    transition: none;
}

input[type="radio"].toggle-left + label {
    border-right: 0;
    -webkit-border-top-right-radius: 0;
    -webkit-border-bottom-right-radius: 0;
    -moz-border-top-right-radius: 0;
    -moz-border-bottom-right-radius: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

input[type="radio"].toggle-right + label {
    -webkit-border-top-left-radius: 0;
    -webkit-border-bottom-left-radius: 0;
    -moz-border-top-left-radius: 0;
    -moz-border-bottom-left-radius: 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}
  </style>
  
</head>

<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_EN/sdk.js#xfbml=1&version=v2.3&appId=903187829694150";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
  <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation" style="margin: 0"><!-- WHITE navbar-superhero -->
    <div class="container">
      <!-- Brand and toggle get grouped for better mobile display -->
     	<?php 
  		if($showicon == '1') { 
  		?>
			<a class="navbar-brand" href="support.Dashboard"><img style="margin-top: -6px; height: 35px;" src="<?php echo $iconurl; ?>"></a>
		<?php
		}
  		if($showtitle == '1') { 
  		?>
			<a class="navbar-brand" href="support.Dashboard"><?php echo"$title"?></a>
		<?php
		}
		?>
      <div class="navbar-header navbar-right">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-nav">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
      </div>

      <!-- Collect the nav links, forms, and other content for toggling -->
      <div class="collapse navbar-collapse" id="main-nav">
        <ul class="nav navbar-nav">
          <li>
            <a href="payments.Dashboard"><i class="fa fa-home"></i></a>
          </li>
          <li class="dropdown">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-ticket"></i> Tickets <span class="badge"><?php echo $tickets;?></span><b class="caret"></b></a>
				<ul class="dropdown-menu">
					<li><a href="support.Tickets"><i class="fa fa-terminal"></i> Start browsing</a></li>
				</ul>
			</li> 
        </ul>
		<ul class="nav navbar-nav navbar-right">
			<li class="dropdown">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-language"></i> <b class="caret"></b></a>
				<ul class="dropdown-menu">
					<li><a href="language.english">English</a></li>
					<li><a href="language.slovak">Slovak</a></li>
					<li><a href="language.german">German</a></li>
					<li><a href="language.chinese">Chinese</a></li>
					<li><a href="language.portuguese">Portuguese</a></li>
					<li><a href="language.russian">Russian</a></li>
					<li><a href="language.czech">Czech</a></li>
					<li><a href="language.spanish">Spanish</a></li>
					<li><a href="language.french">French</a></li>
					<li><a href="language.arabic">Arabic</a></li>
					<li><a href="language.croatian">Croatian</a></li>
					<li><a href="language.danish">Danish</a></li>
					<li><a href="language.hungarian">Hungarian</a></li>
					<li><a href="language.italian">Italian</a></li>
					<li><a href="language.japanese">Japanese</a></li>
					<li><a href="language.polish">Polish</a></li>
					<li><a href="language.slovenian">Slovenian</a></li>
					<li><a href="language.swedish">Swedish</a></li>
				</ul>
			</li> 
			<li>
				<a href="#"> <i class="fa fa-sign-in"></i> <?php echo $_SESSION['username'];?> </a>
			</li>
			<li class="dropdown">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-money"></i> Balance: <?php echo $balance; ?> <?php echo $acu['ISO']; ?> <b class="caret"></b></a>
				<ul class="dropdown-menu">
					<li><a href="support.Withdraw"><i class="fa fa-level-up"></i> Withdraw</a></li>
				</ul>
			</li>
			<li>
				<a data-toggle="modal" href="#logout"> <i class="fa fa-sign-out"></i> Logout</a>
			</li>
		</ul>
      </div><!-- /.navbar-collapse -->
    </div>
  </nav>