<?
if( !isset($obj_class_data) )
{
	require_once('includes/common.php');

	require_once('includes/data.php');
	$obj_class_data = new class_data();
}

if( !isset($arr_news_cates) )
	$arr_news_cates = $obj_class_data->get_news_cates();
?>
	<script type="text/javascript">
<!--
var global_bool_processing = false;

function do_search_news(element_form)
{
	if( global_bool_processing )
		return false;

	if( element_form.keyword.value == '' )
	{
		alert('請輸入您要搜尋之商品關鍵字');
		return false;
	}
	else if( element_form.keyword.value.length <= 1 )
	{
		alert('關鍵字太短，請多輸入一些關鍵字以便精確搜尋');
		return false;
	}

	var obj_form_data = new FormData(element_form);

	global_bool_processing = true;

	$.ajax(
	{
		url: 'ajax_do_search_news.php',
		type: 'POST',
		data: obj_form_data,
		cache: false,
		processData: false,
		contentType: false,
		dataType: 'json',
		success: function(jdata)
		{
			if( jdata['ErrMessage'] != '' )
				alert(jdata['ErrMessage']);
			else if( jdata['ErrCode'] != '1' )
				alert('Error:' + jdata['ErrCode']);

			if( jdata['RedirectURL'] )
				window.location.href = jdata['RedirectURL'];

			global_bool_processing = false;
		}
	});

	return false;
}
//-->
	</script>
	<div id="top">
    <div id="top_box"><a href="index.php"><img src="images/top/logo.png" alt="" id="logo"/></a></div>
    </div>
    <nav class="navbar navbar-default">
      <div class="container-fluid top_navbar">
        <!-- 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="#defaultNavbar1"><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="defaultNavbar1">
          <ul class="nav navbar-nav">
            <li<?=( !isset($static_uint_cate_id) || !$static_uint_cate_id ? ' class="active"' : '' )?>><a href="latest_news_list.php">最新<span class="sr-only">(current)</span></a></li>
<?
if( $arr_news_cates )
{
	foreach( $arr_news_cates as $arr_row )
		echo('            <li' . ( isset($static_uint_cate_id) && $arr_row['NewsCateId'] == $static_uint_cate_id ? ' class="active"' : ''  ) . '><a href="news_list.php?cate_id=' . $arr_row['NewsCateId'] . '">' . $arr_row['NewsCateName'] . '</a></li>' . "\n");
}
?>
          </ul>
          <form class="navbar-form navbar-right" role="search" method="post" action="search_news.php" onsubmit="return do_search_news(this);">
            <div class="form-group">
              <input type="text" name="keyword" class="form-control" placeholder="Search" maxlength="25" />
            </div>
            <button type="submit" class="btn btn-default">搜尋新聞</button>
          </form>
          
        </div>
        <!-- /.navbar-collapse -->
      </div>
      <!-- /.container-fluid -->
    </nav>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '237860413299796',
      xfbml      : true,
      version    : 'v2.8'
    });
  };

  (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/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));
</script>