<?php 
    include('php/config.php');
    include('php/functions.php');

    if (preg_match('|^/([^/]+)/|', $_SERVER['PATH_INFO'], $matches)) {
        if ($MySQL->select_one("SELECT COUNT(*) FROM subcategory WHERE id='".$matches[1]."'") == 1) {
        	$id = $matches[1];
        } 
    	else {
    		print $matches[1]."<br>\n";
    		// die ("case not found in database: ".$_SERVER['SCRIPT_NAME'].$_SERVER['PATH_INFO']);
    		header('Location: /errors/notfound.php');
    	}
    } 
    else {
    	//die ("case not found (no match): ".$_SERVER['SCRIPT_NAME'].$_SERVER['PATH_INFO']);
    	header('Location: /errors/notfound.php');
    }
    $vars = $MySQL->select_row("SELECT * FROM subcategory WHERE id='$id'");
    	if (strlen($vars['sub_cat'])>0) {
    	define('PAGE_TITLE', $vars['sub_cat']);
        }
        else {
        define('PAGE_TITLE', DEFAULT_PAGE_TITLE);
        }
    	if (strlen($vars['meta_description'])>0) {
    		define('PAGE_DESCRIPTION', $vars['meta_description']);
    	} 
        else {
    		define('PAGE_DESCRIPTION', DEFAULT_PAGE_DESCRIPTION);
    	}
    	if (strlen($vars['meta_keywords'])>0) {
    		define('PAGE_KEYWORDS', $vars['meta_keywords']);
    	} 
        else {
    		define('PAGE_KEYWORDS', DEFAULT_PAGE_KEYWORDS);
    	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html class="wf-kulturistaweb1kulturistaweb2-n6-active wf-kulturistaweb1kulturistaweb2-n7-active wf-active" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	
    <head>
        <?php include("modules/page_head.php"); ?>
        <script type="text/javascript" src="/js/floating_nav.js"></script>
    </head>

    <body>
		<?php include("modules/header.php"); ?>
   
        <div id = "body_container" class="content_column">
        	
            <div id="content_wrapper">
        		<div id="content_left">
                    <h2 style="padding-left:10px;">Forging Materials</h2>
                    <?php include("modules/quote_request_dropdown.php"); ?>
                    <div id="floating_nav">
                        <?php print_subcategory_nav(); ?>
                    </div>
                </div>
                <div id="content_center">

					<?php print_subcategory_page($id) ?>
                    
                    <div class="clearfix"></div>
                	<div id="materials_quote">
                    	<h2><a href="/request_quote.php">Request a Quote Today</a></h2><br/>
                        <h3>Or call <strong>(845)471-5010</strong></h3>
                    </div>
                </div><!-- content_center -->    
        	</div><!-- content_wrapper -->    
		
        </div><!-- body_container -->    	
        
        <div id="clearfix"></div>
        <?php include("modules/footer.php"); ?>
    </body>
</html>