<?php
    include_once("includes/config.php");
    include_once("includes/numbers-words.php");
    include_once("includes/common_functions.php");
    $common = new General_Functions();
    $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : "";
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : "";

    if($mode == 'edit' || $mode == 'edit_print'){
        include("modules/".$_REQUEST['page']."/index.php");
    }
    else if ($_REQUEST['action'] == "ajaxfunction"){
        	include("modules/".$_REQUEST['page']."/".$_REQUEST['action'].".php");
     }
    else
    {
?>
<!DOCTYPE html>
<html>
<head>
    <?php
        $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : "";
        $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : "";

        if($mode != "print")
        {
            echo '<title>'.APP_NAME.'</title>';
            include("includes/header.php");
			
			$msg_ary = false;
			if(is_array($_SESSION['msg']))
			{
				$msg_ary = true;
				$msg_link = $_SESSION['msg'][1];
				$_SESSION['msg'] = $_SESSION['msg'][0];
			}
            ?>
                <script>
                    $(document).ready(function() {
                        $("#delete_img").hide();
                        <?php if(isset($_SESSION['msg'])) { ?>
                            $(".message span").html('<?php echo $_SESSION['msg']; ?>');
                            $(".message").show();
                            $(".message").fadeOut(15000);
							<?php if($msg_ary) { ?>
								setTimeout('open_win("<?php echo $msg_link; ?>")', 5000);
							<?php } ?>
                            <?php unset($_SESSION['msg']); ?>
                        <?php } ?>
                    } );
					
					function open_win(url)
					{
						//window.open(url);
					}
                </script>
            <?php
        }
    ?>
</head>
<body>
    <div id="jquery-overlay" style="background-color: #999999; opacity: 0.8; width: 1349px; height: 920px; left: 0; position: absolute; top: 0; z-index: 90; display: none;">
        <div id="ajax_loader" style="position: absolute; width: 100%;">
            <!--<img id="loading" style="display: block; margin-left: auto; margin-right: auto;" src="images/ajax-loader.gif">-->
        </div>
    </div>
<?php
    include_once("includes/config.php");
    include_once("includes/common_functions.php");
    $common = new General_Functions();
    $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : "";
  


    if($mode != "print" && $_REQUEST['action'] != "popup" && $_REQUEST['action'] != "popup_print" && $_REQUEST['action'] != "ajaxfunction")
        include("includes/top.php");

    if(isset($_REQUEST['page']) && $_REQUEST['page'] != "login" && $_REQUEST['action'] != "popup" && $_REQUEST['action'] != "popup_print" && $_REQUEST['action'] != "ajaxfunction")
    {
        if($mode != "print")
        {
            echo '
                <div class="message">
                        <img src="includes/images/close.gif" style="float: right; padding-left: 40px; cursor: pointer;" onclick="javascript: $(\'.message\').hide();">
                        <span></span>
                </div>';
        }
        include("modules/".$_REQUEST['page']."/index.php");
    }
    elseif(isset($_REQUEST['page']) && ($_REQUEST['action'] == "popup" || $_REQUEST['action'] == "popup_print") && $_REQUEST['action'] != "ajaxfunction")
    {
        include("modules/".$_REQUEST['page']."/".$_REQUEST['action'].".php");
        echo "<script>
                $(document).ready(function() {
                        parent.set_size(this.body.offsetHeight + 5 + 'px', this.body.offsetWidth);  
                });
              </script>";
    }
    else
    {
        echo '<div class="content_bg" style="height: 400px;"></div>';
    }
    /*else
        include("dashboard.php");*/

    if($mode != "print" && $_REQUEST['action'] != "popup" && $_REQUEST['action'] != "popup_print" && $_REQUEST['action'] != "ajaxfunction")
    {
        include("includes/bottom.php");
        echo '<div id="light" class="white_content">
                <img src="includes/images/popup-close.png" style="position: absolute; margin-left: 500px; cursor: pointer;" onClick="close_frame();" />
                <iframe style="width: 100%; height: 99.9%; border: none;" id="iframe_div"></iframe>
            </div>
            <div id="fade" class="black_overlay"></div>';
    }
?>
</body>
</html>
<?php
    }
?>