<div>
	<h2>Tìm kiếm nâng cao</h2>
  <?php echo form_tag('', array('onsubmit'=>'AdvanceSearch(); return false;')) ?>
    <?php echo input_tag('advance_search', 'Tìm kiếm...',
        array(
        	'id'=>'advance_search',
        	'style'=>'width: 400px',
        	'onclick'=>'if (this.value=="Tìm kiếm...") this.value=""'
        )
    ) ?>
    <?php echo submit_tag('Tìm kiếm', array('id'=>'advancesearchSubmit', 'onclick'=>sfConfig::get('sf_search_function').'(getSearchCondition(), getSearchAdditional()); return false;')) ?>
    <?php if (blogStore::$blogName!='main'): ?>
      <br>
      <?php echo radiobutton_tag('asearchAll', 0, true, 'id=asone') ?>
      <?php echo label_for('asone', 'Trang này') ?>&nbsp;&nbsp;
      <?php echo radiobutton_tag('asearchAll', 1, false, 'id=asall') ?>
      <?php echo label_for('asall', 'violet.vn') ?>
    <?php else: ?>
      <?php echo input_hidden_tag('sone', 1) ?>
    <?php endif;?>

    <br/>
    <?php echo label_for('search_types', 'Tìm theo kiểu file', 'style="display: block; float: left; width: 200px"') ?>
    <select name='search_types' id='search_types'>
    	<option value="all">Tất cả</option>
    	<option value="ppt">Bài giảng Powerpoint</option>
    	<option value="xvl">Bài giảng Violet</option>
    	<option value="doc">Giáo án, đề thi word</option>
    	<option value="pdf">File PDF</option>
    	<option value="xls">File Excel</option>
    	<option value="cg3">Bài giảng bằng Cabri</option>
    	<option value="gsp">Bài giảng bằng SketchPad</option>

    	<option value="jpg">Ảnh jpg</option>
    	<option value="swf">Flash</option>
    	<option value="flv">Video</option>
    	<option value="mp3">Nhạc mp3</option>
    </select>

    <br/>
    <?php echo label_for('search_range', 'Tìm trong', 'style="display: block; float: left; width: 200px"') ?>
    <select name='search_range' id='search_range'>
    	<option value="all">Nội dung</option>
    	<option value="title">Tiêu đề</option>
    </select>

    <br/>
    <?php echo label_for('search_author', 'Tên tác giả', 'style="display: block; float: left; width: 200px"') ?>
    <input name='search_author' id='search_author' type="text" />
  </form>
</div>
<div id="search_control" style="display: none">Loading...</div>
<div id="search_result" ></div>
<script>
function getSearchAdditional() {
	var sites = [<?php echo $hosts ?>];
	var condition = "";
  if ($('asone')!=undefined && $F('asone')==0) {
    condition += sites.join(' OR ');
  } else {
    condition += 'site:bachkim.vn OR site:violet.vn';
  }

  condition += " inurl:showprint";
  return condition;
}

function getSearchCondition() {
	var condition = "";

	var types = $F('search_types');
	if (types!='all') {
		condition += ' "type: ' + types + '"';
	}

	if ($F('search_range')=='all') {
		condition += " " + $F("advance_search");
	} else {
		condition += ' "title: ' + $F('advance_search') + '"';
	}

	if ($F('search_author')!='') {
		condition += ' "sender: ' + $F('search_author') + '"';
	}
	return condition;
}
</script>
