<?php

	

	//$getPage = $_GET['p'];
	
	$getPage = $_GET['p'];
	
	if($getPage == "out"){
		$getSP = $_GET['sp'];
		$getLINK = file_get_contents("admin/nav/nav". $getSP ."_out.txt", true);
		echo $getLINK;
		header("Location: $getLINK");
	} else {
	}
	
	$getPageTitle = file_get_contents("admin/pages/$getPage/title.txt", true);
	
	$getName = file_get_contents("admin/rr/productname.txt", true);
	$getHTML = file_get_contents("admin/pages/$getPage/html.txt", true);

	
	$filename= "admin/pages/$getPage/views.txt" ;
	$fd = fopen ($filename , "r") or die ("Can't open $filename") ;
	$fstring = fread ($fd , filesize ($filename)) ;
	fclose($fd) ;
	
	$fd = fopen ($filename , "w") or die ("Can't open $filename") ;
	$fcounted = $fstring + 1 ;
	$fout= fwrite ($fd , $fcounted ) ;
	fclose($fd) ;

?>
<!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="text/html; charset=utf-8" />
<title><?php echo $getPageTitle; ?></title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<style type="text/css">
<!--
#mainWrapper {
	width: 520px;
	margin-top: 0px;
	background-color: #<?php echo file_get_contents("admin/design/bg.txt", true); ?>;
	background-image: url(imgs/bg<?php echo file_get_contents("admin/design/bgtexture.txt", true); ?>.png);
	background-repeat: repeat;
}

#mainWrapper2 {
	width: 520px;
	margin-top: 0px;
}

#NAV {
	background-color: #<?php echo file_get_contents("admin/design/nav.txt", true); ?>;
	height: 50px;
	width: 506px;
	background-image: url(imgs/bg<?php echo file_get_contents("admin/design/navtexture.txt", true); ?>.png);
	background-repeat: repeat;
	margin-left: 4px;
	box-shadow: 0px 0px 5px #212121;
}
-->
</style>
</head>

<body>



<?php
	
		$getTmp = file_get_contents("admin/pages/$getPage/tmp.txt", true);
	
		if($getTmp == "1"){
?>

	<div id="mainWrapper2">
    	<?php echo "$getHTML"; ?>
    </div>

<?php
		} else {
?>

<div id="mainWrapper">

	    <?php
	
		$getHeader = file_get_contents("admin/pages/$getPage/header.txt", true);
	
		if($getHeader == "0"){
		?>
        
        	<div id="headerArea2" style="height:70px;"></div>
        	
		<?php
		} else {
		?>

			<div id="headerArea" style="height:187px;"></div>
		
        <?php
		}
		?>
    
    
    <div id="contentArea" style=" margin-top:-60px;">
    
    
    <?php
	
		$getNav = file_get_contents("admin/pages/$getPage/nav.txt", true);
	
		if($getNav == "0"){
		?>
		
			    <div id="contentTop">
					<img src="imgs/content-top.png" />
				</div>
		
		<?php
		} else {
		?>
		
              <div id="NAV">
             
                <div id="navOverlay" >
               
               		<?php $getNav1 = file_get_contents("admin/nav/nav1.txt", true); if($getNav1 == ""){ } else { ?>
                    <div id="navItem"> <a href="view.php?p=<?php echo file_get_contents("admin/nav/nav1_link.txt", true); ?>&sp=1"><?php echo $getNav1; ?></a></div>
					<?php } ?>
                    
                    <?php $getNav2 = file_get_contents("admin/nav/nav2.txt", true); if($getNav2 == ""){ } else { ?>
                    <div id="navItem"> <a href="view.php?p=<?php echo file_get_contents("admin/nav/nav2_link.txt", true); ?>&sp=2"><?php echo $getNav2; ?></a></div>
					<?php } ?>
                    
                    <?php $getNav3 = file_get_contents("admin/nav/nav3.txt", true); if($getNav3 == ""){ } else { ?>
                    <div id="navItem"> <a href="view.php?p=<?php echo file_get_contents("admin/nav/nav3_link.txt", true); ?>&sp=2"><?php echo $getNav3; ?></a></div>
					<?php } ?>
                    
                    <?php $getNav4 = file_get_contents("admin/nav/nav4.txt", true); if($getNav4 == ""){ } else { ?>
                    <div id="navItem"> <a href="view.php?p=<?php echo file_get_contents("admin/nav/nav4_link.txt", true); ?>&sp=4"><?php echo $getNav4; ?></a></div>
					<?php } ?>
                   
                   
                   
                
                    <br clear="left" />
                    
                 </div>   
              </div>
		
		<?php
		}
		?>
        

     
        
        <div id="contentHere">
        
        		<?php echo "$getHTML"; ?>
        
        </div>
        
        <div id="contentFooter">
        	<img src="imgs/content-footer.png" />
        </div>
        
        <div style="height:5px;"></div>
    
    </div>


</div>

<?php
		}
?>

</body>
</html>
