<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	
	<title><?php echo ((PageContext::$metaTitle != '') ? PageContext::$metaTitle : META_TITLE); ?></title>
	<meta name="description" content="<?php echo ((PageContext::$metaDes != '') ? PageContext::$metaDes : META_DES); ?>" />
	<meta name="keywords" content="<?php echo ((PageContext::$metaKey != '') ? PageContext::$metaKey : META_KEYWORDS); ?>" />
		
		
		<script src="<?php  echo BASE_URL; ?>js/jquery-2.1.4.min.js" type="text/javascript"></script>
        <!--<script src="<?php echo BASE_URL; ?>public/js/library/jquery.js" type="text/javascript"></script>
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>-->
		
		<script src="<?php echo BASE_URL; ?>js/bootstrap.js" type="text/javascript"></script>
		
        <script src="<?php echo BASE_URL; ?>public/js/library/jquery.form.js" type="text/javascript"></script>
        <script src="<?php echo BASE_URL; ?>public/js/library/jquery.validate.js" type="text/javascript"></script>
        <script src="<?php echo BASE_URL; ?>public/js/library/jquery.pop.js" type="text/javascript"></script>
        <script src="<?php echo BASE_URL; ?>public/js/library/jquery.tipsy.js" type="text/javascript"></script>
        <?php if ($_SESSION['facebookKey']['enableFb'] == 'Y') { ?>
            <?php if (isset($_SESSION['facebookKey']['facebookAppId']) && !empty($_SESSION['facebookKey']['facebookAppId'])) { ?>
                <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_US/all.js#xfbml=1&appId=<?php echo $_SESSION['facebookKey']['facebookAppId']; ?>";
                    fjs.parentNode.insertBefore(js, fjs);
                }(document, 'script', 'facebook-jssdk'));*/</script> <!-- Facebook Like Button Script -->
            <?php } ?>
        <?php } ?>
        <script type="text/javascript">
        $().ready(function() {
<?php if (!isset($_SESSION['user']['userID']) && empty($_SESSION['user']['userID'])) { ?>
                   $("#frmuserLogin").validate({
                       rules: { txtUsername: { required: true },
                           txtPassword: { required: true } },
                       messages: { txtUsername: { required: "Please enter Username" },
                           txtPassword: { required: "Please enter Password" } 	}
                   });
<?php } ?>
                $("#frmSearch").validate({
                    rules: { txtsearch: { required: true } },
                    messages: { txtsearch: { required: "Please enter search text" }},
				errorPlacement: function(error, element) {
    				error.insertAfter( ".main_search_btn");
  					}
                });
			
			$('.custom-dropdown').on('click', function (event) {
				$(this).parent().toggleClass('open');
			});

			$('body').on('click', function (e) {
				if (!$('.custom-dropdown').is(e.target)
					&& $('.custom-dropdown').has(e.target).length === 0
					&& $('.open').has(e.target).length === 0
				) {
					$('.custom-dropdown-parent').removeClass('open');
				}
			});   
                

            });
            function checkLogin()
    {
        var error = false;
        if($("#txtUsername").val().trim() == '')
        {
            $('.errorBox').html('Please enter username');
            return false;
        }
        else  if($("#txtPassword").val().trim() == '')
        {
            $('.errorBox').html('Please enter password');
            return false;
        }
        else
        {
            var data 	= 'username='+$("#txtUsername").val()+'&password='+$("#txtPassword").val();
            $.ajax({
                url: "<?php echo ConfigUrl::base(); ?>login/checkLogin/",
                type: "POST",
                data: data,
                cache: false,
                async:false,
                success: function (response) {
                    if(response != '')
                       {
                        error = true;
                        $('.errorBox').html(response);
                       }
                       
                }
            });
            
        }
        if(error)
            return false;

        return true;
                
    }
        </script>
		
		
        <script src="<?php echo BASE_URL; ?>public/js/library/slidx.js" type="text/javascript"></script>
		
        <link rel="stylesheet" type="text/css"  href="<?php echo ConfigUrl::style(); ?>styles.css" media="all" />
		<link rel="stylesheet" type="text/css"  href="<?php echo ConfigUrl::style(); ?>bootstrap.css" media="all" />
		<link rel="stylesheet" type="text/css"  href="<?php echo ConfigUrl::style(); ?>style_new.css" media="all" />
		<link rel="stylesheet" type="text/css"  href="<?php echo ConfigUrl::style(); ?>responsive.css" media="all" />
		<link rel="stylesheet" type="text/css"  href="<?php echo BASE_URL; ?>css/font-awesome.min.css" media="all" />

	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
	<script src="<?php echo BASE_URL; ?>js/jquery.ui.touch-punch.min.js" type="text/javascript"></script>
	<script src="<?php echo BASE_URL; ?>js/facescroll.js" type="text/javascript"></script>


    <script type="text/javascript">
		jQuery(function(){ // on page DOM load
			if(window.innerWidth > 991)
				$('.cotegory_list_box_scroll').alternateScroll();
		})
	</script>

	</head>

    <body>
        <div id="fb-root"></div>
        <?php if ($_SESSION['facebookKey']['enableFb'] == 'Y' &&  ($_SESSION['loggedin'] != 1 || $_SESSION['fbLogout'] == 1)) { ?>
            <?php if (isset($_SESSION['facebookKey']['facebookAppId']) && !empty($_SESSION['facebookKey']['facebookAppId'])) { ?>
                <script>
                window.fbAsyncInit = function() {
                    FB.Event.subscribe('auth.login', function(response) {
                        var accesstoken =   response.authResponse.accessToken;
                        /*Function to insert data into database*/
                        loginSuccess(accesstoken);
                        /*Function to insert data into database Ends*/
                        //login();
                    });

                    FB.Event.subscribe('auth.logout', function(response) {
                        // logout();
                    });

                    FB.getLoginStatus(function(response) {
                        //alert(response.status);
                        if (response.status === 'connected') {
                            var accesstoken =   response.authResponse.accessToken;
                            <?php if ( $_SESSION['fbLogout'] == 1) {?>
                                logout();
                            <?php
                            } else {
                            ?>
                            /*Function to insert data into database*/
                            loginSuccess(accesstoken);
                            /*Function to insert data into database Ends*/
                            <?php } ?>

                        }
                    });



                };
                (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_US/all.js#xfbml=1&appId=<?php echo $_SESSION['facebookKey']['facebookAppId']; ?>";
                  fjs.parentNode.insertBefore(js, fjs);
                }(document, 'script', 'facebook-jssdk'));

                 function logout() {
                    FB.logout(function(response) {                       
                    });
                }


                function loginSuccess(accesstoken)
                {
                    /** Function to update DB ***/
                    FB.api('/me', function(response) {
                        $.ajax({
                            url: "<?php echo ConfigUrl::base(); ?>login/userloginfb",
                            type: "GET",
                            data:{user_fbid: response.id,user_fbname: response.name,user_fname: response.first_name,
                                user_middle_name: response.middle_name, user_lname: response.last_name,user_email: response.email,
                                user_uname: response.username,user_location: response.location,user_dob: response.birthday,user_gender: response.gender,access_token:accesstoken},
                            cache: false,
                            success: function (html) {
                                
                                if(html==1)
                                {
                                    window.location.href   =   "<?php echo ConfigUrl::base('business'); ?>";
                                    /*
                                    FB.logout(function(response) {

                                    });
                                     */

                                } else {
                                    alert('Sorry, Your account is no longer active!');
                                }

                            }
                        });
                    });
                    /** Function to update DB Ends ***/
                }
                </script>
            <?php } ?>
        <?php } ?>
                <?php $connection=Globalutils::db_connection(); ?>
                <?php  
        // Force logout ,if admin deactivates a user account
        if (isset($_SESSION['user']['userID'])) {
            $this->_common		= new ModelCommon;
            $userStatus = $this->_common->selectRecord("users","nUserId,vStatus",""," nUserId = '".$_SESSION['user']['userID']."'");
            $status = $userStatus->vStatus;
             
            if($status == 0)
            {
                session_destroy();
                session_unset($_SESSION['user']);
                header("location:".ConfigUrl::base());
                $this->view->disableView();
                exit();
            }
        } ?> 
        <div id="main_wrapper">
			<div class="header_outer">
				<div class="container">
				<div class="row">
					<div class="col-xs-12 col-sm-3 col-md-3">
						<div class="logo_outer">
							<a href="<?php echo ConfigUrl::base('default'); ?>"><img src="<?php echo ConfigUrl::images() . PRODUCT_LOGO; ?>" border="0" alt="Logo"></a>
						</div>
						
						<div class="category_btt_outer">
								<a id="slidx-button"><i class="fa fa-bars" aria-hidden="true"></i></a>
							<div class="slidx-menu">
								<ul class="slidx-menu-list-outer cotegory_list_box_scroll" style="height:100%; margin:0px;">
									<a href="<?php echo ConfigUrl::base(); ?>index/viewlisting/" class="all_categories_btt">All Categories</a>
								<?php
								if ($this->category_flag) {
									foreach ($this->category_title as $category_key => $category_val) {
										?>
										<li>
											<h6><a href="<?php echo ConfigUrl::base(); ?>index/listing/<?php echo $category_key . '/'; ?>"  ><?php echo $category_val ?></a></h6>
										<?php
										$subCategoriesSql = "SELECT * from ".MYSQL_TABLE_PREFIX."category WHERE nParentId= '$category_key'";
										$subCategories = mysqli_query($connection,$subCategoriesSql) or die(mysqli_error($connection));
										?>
											<?php if (mysqli_num_rows($subCategories) > 0) { ?>
												<?php
												$parentSql = "SELECT nParentId from ".MYSQL_TABLE_PREFIX."category WHERE nCategoryId = '$this->catId'";
												$parentRes = mysqli_query($connection,$parentSql) or die(mysqli_error($connection));
												$parent = mysqli_fetch_array($parentRes);
												$parentId = $parent['nParentId'];
												//echo $parentId;
												?>
												<ul class="menu-lft-sub sublevelmenu" <?php if ($this->catId != $category_key) { ?> style="display:none;"<?php } ?> id="sub_<?php echo $category_key; ?>" >
												<?php while ($arr = mysqli_fetch_array($subCategories)) { ?>
						
														<li>
													<?php $class = ($arr['nCategoryId'] == $this->subCatId) ? 'menu-lft-active' : 'tt' ?>
															<a class="<?php echo $class; ?>" href="<?php echo ConfigUrl::base(); ?>index/listing/<?php echo $category_key ?>/<?php echo $arr['nCategoryId'] . '/'; ?>"><?php echo $arr['vCategoryDesc']; ?></a>
														</li>
						<?php } ?>
												</ul>
						
						<?php } ?>
										</li>
												<?php
											}
										} else {
											?>
									<li>No Categories added</li>
									<?php
								}
								?>
									
									
								</ul>
							</div>
						</div>
					</div>
					<div class="col-xs-12 col-sm-9 col-md-9">
					<div class="row">
					<nav class="navbar navbar-default main_nav">
					<div class="container-fluid">
					<!-- Brand and toggle get grouped for better mobile display -->
						<div class="navbar-header">
							<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
								<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="bs-example-navbar-collapse-1">
						
							<div class="my_account_top">
								<div class="row">
									<ul>
									<?php if (isset($_SESSION['user']['userID']) && !empty($_SESSION['user']['userID'])) { ?>
										<li><a >Welcome <span class="user_clr"><?php echo $_SESSION['user']['userName'] ?></span></a></li>
										<li><a href="<?php echo ConfigUrl::base('business'); ?>index/dashboard">My Account </a></li>
										<li><a href="<?php echo ConfigUrl::base(); ?>login/logout">Logout</a></li>
									<?php } ?>
									</ul>
								</div>
							</div>
							
							<ul class="nav navbar-nav navbar-right">
								 <li><a  id="jq_home" href="<?php echo ConfigUrl::base(); ?>">Home</a></li>
								<?php if (PRODUCT_FORUM_MODE == "Y") { ?>
									<li><a href="<?php echo ConfigUrl::root(); ?>forum/index.php">Forum</a></li>
									<?php }
								?> 
								
								<li><a href="<?php echo ConfigUrl::root(); ?>index/cmscontents/1">Contact Us</a></li>
								
								
								  <!-- ***************** Login Area ********************** -->
									<?php if (!isset($_SESSION['user']['userID']) && empty($_SESSION['user']['userID'])) { ?>
								
								<li class="custom-dropdown-parent  <?php echo (isset($_SESSION['errorLogin']) && !empty($_SESSION['errorLogin']))?'open':'';?>">
									<button type="button" class="btn btn-default custom-dropdown" aria-haspopup="true" aria-expanded="false">
									Sign in <span class="caret"></span>
									</button>
									<ul class="dropdown-menu head_signin">
									<li>
										<?php $setLoginDisplay = (isset($_SESSION['errorLogin']) && !empty($_SESSION['errorLogin'])) ? ' style="display: block;"' : ''; ?>
									<div>
										<form method="post" id="frmuserLogin" action="<?php echo ConfigUrl::base(); ?>login">
											<div class="errorBox"><?php echo $_SESSION['errorLogin'] ?></div>
											<?php $_SESSION['errorLogin'] = '' ?>
											
											<div class="head_signin_inner">
												<input id="txtUsername" name="txtUsername" value="" title="username" placeholder="Username" tabindex="4" type="text" class="form-control"/>
											</div>
											<div class="head_signin_inner">
												<input id="txtPassword" name="txtPassword" value="" title="password" placeholder="Password" tabindex="5" type="password" class="form-control" />
											</div>											
											<div class="head_signin_inner">
												<!--<input id="remember" name="remember_me" value="1" tabindex="7" type="checkbox"/>-->
												<!--<label for="remember">Remember me</label>-->
												<input id="submitLogin" name="submitLogin" value="Sign in" tabindex="6" type="submit" class="primary_button" onClick="return checkLogin()"/>
											</div>
											
											
											
											<div class="header_sign_in_sep">
												<span>OR</span>
											</div>
											
											<?php if ($_SESSION['facebookKey']['enableFb'] == 'Y') { ?>
												<?php if (isset($_SESSION['facebookKey']['facebookAppId']) && !empty($_SESSION['facebookKey']['facebookAppId'])) { ?>
													<!--start facebook div-->
													<div class="head_signin_inner">
														<div class="fb_facebook" align="center">
															<div class="fb-login-button" scope="email,publish_actions">
																Login with Facebook
															</div>
														</div><!--end div facebook-->
													</div>
												<?php } ?>
											<?php } ?>
											<?php
											// echopre($_SESSION);
											?>
											<?php if ($_SESSION['twitterKey']['enableTwitter'] == 'Y') { ?>
													<?php if (isset($_SESSION['twitterKey']['twitterConsumerKey']) && !empty($_SESSION['twitterKey']['twitterConsumerSecret'])) { ?>
														<div class="head_signin_inner">
															<div class="logindefault"> </div>
															<div>
																<a href="<?php echo ConfigUrl::base() ?>index/twitterlogin" class="twitter-login">Login with twitter</a>
															</div>
														</div>
													<?php } ?>
												<?php } ?> 								
											<div class="head_signin_inner forgot">
												<a href="<?php echo ConfigUrl::base() ?>index/forgotpwd" id="resend_password_link">Forgot your password?</a>
											</div>
											
											 
										</form>
										<?php $_SESSION['errorLogin'] = ''; ?>
									</div>
									
									<script type="text/javascript">
									function SetCookie(cookieName,cookieValue,nDays) {
										var today = new Date();
										var expire = new Date();
										if (nDays==null || nDays==0) nDays=1;
										expire.setTime(today.getTime() + 3600000*24*nDays);
										document.cookie = cookieName+"="+escape(cookieValue)
											+ ";expires="+expire.toGMTString();
									}

									$(document).ready(function() {
										$("#jq_post_add").click(function(e) {
											//alert("hii");
											SetCookie('errorLogin','',0);
											$(".signin").removeClass("menu-open");
											$("fieldset#signin_menu").hide();
										});
										$("#jq_home").click(function(e) {
											SetCookie('errorLogin','',0);
											$(".signin").removeClass("menu-open");
											$("fieldset#signin_menu").hide();
										});
										//$('ul.sublevelmenu').css('display', 'none');
										

									});
								   
									$(function() {
										$('#forgot_username_link').tipsy({gravity: 'w'});
									});
									/*function openSubCatUL(catId){
										alert('hiiiii');return false;
											 $('ul.sublevelmenu').css('display', 'none');
											 $('#sub_'+catId).toggle();

									}*/
									</script>
									
									
									</li>
									</ul>
								</li>

								 
								<?php } ?>
								<?php if (!isset($_SESSION['user']['userID']) && empty($_SESSION['user']['userID'])) { ?>
									<!-- <div class="reg_btn">
										 <a class="register" href="<?php echo ConfigUrl::base(); ?>users/register">Create New Account</a>
									 </div> -->
								<?php } ?>
								<!-- ***************** Login Area End ****************** -->
								<!-- top Smal Nav end -->
						 
							
								
								
							</ul>
						</div>
					</div>
					</nav>
					</div>
				</div>
				</div>
				</div>
				<div class="sub_head">
				<div class="container">
					<div class="row">
						<form method="post" name="frmSearch" id="frmSearch" action="<?php echo ConfigUrl::base(); ?>search/index">
						<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
							<div class="inner_header_search">
									<input name="txtsearch" id="txtsearch" class="mainsearch_txtfld" type="text" value="<?php echo stripslashes($this->txtsearch) ?>" placeholder="What do you want to find?">
									<?php //echo $this->select('txtsearchField', $this->listingFields, $this->searchField, 'main_selectbx' ,'' , 'txtsearchField');  ?>
									<button class="main_search_btn" value="Search" type="submit"><i aria-hidden="true" class="fa fa-search"></i></button>
							</div>
						</div>
						<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
							<a href="<?php echo ConfigUrl::base(); ?>search/advanced" class="inner_advanced_aearch">Advanced Search</a>
						</div>
						</form>
						<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
							<div class="inner_post_btt_outer">
								<a id="jq_post_add" href="<?php echo ConfigUrl::base(); ?>postads"><i class="fa fa-paper-plane" aria-hidden="true"></i> POST ADS</a>
							</div>
						</div>
					</div>
				</div>
				</div>
				
			</div>
		
			<div class="clear"></div>
            
			<!-- Mid Section Start -->
            <?php echo $this->_content; ?>
            <div class="btmad_section">
                <?php if ($this->setting['enablesiteBanner'] == 'Y') { ?>
                    <?php
                   $url  = (strpos(LOGO_URL,'http://')===false)?"http://".LOGO_URL:LOGO_URL;
                     
                    
                    
                    $siteBanner = ConfigUrl::imageroot() . $this->setting['siteBanner'];
                    if (is_file($siteBanner)) {
                        ?>
                        <div class="ad_1"><a href="<?php echo $url; ?>" target="_blank"><img src="<?php echo ConfigUrl::images() . $this->setting['siteBanner']; ?>" alt="siteBanner" /></a></div>
                    <?php } ?>
                <?php } ?>
                <?php if ($this->setting['enableGoogleAdsense'] == 'Y') { ?>
                    <div class="ad_2"><?php echo $this->setting['googleAdsense']; ?></div>
                <?php } ?>
                <div class="clear"></div>
            </div>
            <!-- Mid Section End -->



            <div class="clear"></div>

        </div>

        <!-- Footer Div Start -->
		<div class="footer_wrap">
			<div class="container">
				<div class="btm_menu">
					<a href="<?php echo ConfigUrl::root(); ?>index/cmscontents/1">Contact Us</a>
					<a href="<?php echo ConfigUrl::root(); ?>index/cmscontents/2">Terms of Use</a>
					<a href="<?php echo ConfigUrl::root(); ?>index/cmscontents/3">Privacy Policy</a>
					<a target="_blank" href="<?php echo ConfigUrl::base(); ?>index/feed"><i class="fa fa-rss" aria-hidden="true"></i></a>
					<div class="clear"></div>
					<div class="cpright">
						<p>Powered by <a rel="nofollow" href="http://www.iscripts.com/directory/" target="_blank">iScripts EasyIndex</a> . A premium product from <a rel="nofollow" href="http://www.iscripts.com/" target="_blank">iScripts.com</a></p>
					</div>
				</div>
			<div class="clear"></div>
			</div>

		<div class="clear"></div>
		</div>
        <!-- Footer Div End -->

        <div class="clear"></div>
    </div>

</body>
</html>
