<?php
    /*
		*
		*                        Copyright (C) 2015 Puiu Calin
		*
		*       This program is a commercial software. Copying or distribution without a license is forbidden.
		*     
	*/
	
?>

<script type="text/javascript">
	$( document ).ready(function() {
		$('.regionselect span').click(function() {
			$('.regionselect').hide();
			var value = $(this).attr('class');
			var input = $('#sRegion');
			input.val(input.val() + value);
			return false;
		});
		$('.regionselect span').click(function() {
			$('.regionselect').hide();
			var value = $(this).attr('class');
			var input = $('#newsRegion');
			input.val(input.val() + value);
			return false;
		});
		$('.input_visibile').click(function() {
			$('.regionselect').show();
			$("#sRegion").val('');
			$(".intr").html("");
			$("#newsRegion").val('');
			$(".replace").html("");
			$(".new_value").html("");
		});
		$('.clic').click(function() {
			$('.clicc').click();	
		});
		$('html').click(function() {
			$('.regionselect').hide();
		});
		
		$('.input_visibile ').click(function(event){
			event.stopPropagation();
		});
	});
	$( document ).ready(function() {
		$('.regionselect span, .all').click(function() {
			$('.slectt').hide();
			$('.to_select').hide();
			$('.allc_tohide').hide();
			var chat_screen = $(this).text();
			$(".intr").append(chat_screen);
			$(".replace").append(chat_screen);
			$(".new_value").append(chat_screen);
		});
	});
</script>
<form action="<?php echo osc_base_url(true); ?>" method="get" class="search nocsrf" <?php /* onsubmit="javascript:return doSearch();"*/ ?>>
    <input type="hidden" name="page" value="search" />
    <fieldset class="main">
		<div class="backf">
			<input type="text" name="sPattern" placeholder="<?php echo osc_esc_html(__(osc_get_preference('keyword_placeholder', 'one'), 'one')); ?>" id="query" value="" />
			<input type="hidden" name="sRegion" id="sRegion"/>
			<div class="input_visibile"><span class="slectt"><?php _e('Select a region...', 'one'); ?></span><span class="intr"></span></div>
			<div class="regionselect">
				<div class="icon"></div>
				<div class="all"><strong><?php _e('All Country', 'one'); ?></strong></div>
				<?php $aRegions = Region::newInstance()->listAll(); ?>
				<?php if(count($aRegions) > 0 ) { ?>
					<?php foreach($aRegions as $region) { ?>
						<span class="<?php echo $region['pk_i_id'] ; ?>"><strong><?php echo $region['s_name'] ; ?></strong></span>
					<?php } ?>
				<?php } ?>
			</div>
		</div>
    	<div class="home_b"><input class="clicc" type="submit" value=""/><span class="icon"></span><span class="clic"><?php _e('Search', 'one'); ?></span></div>
	</fieldset>
    <div id="search-example"></div>
</form>