<div class="second_categoriess">
	<div class="top_selection">
		<div class="text"><div class="all_serch"><span></span><div class="allc_tohide"><?php _e("All Country", 'one'); ?></div><div class="new_value"></div></div>
			<div class="search_hide">
				<form action="<?php echo osc_base_url(true); ?>" method="get" class="second_search" <?php /* onsubmit="javascript:return doSearch();"*/ ?>>
					<input type="hidden" name="page" value="search" />
					<fieldset class="main">
						<input type="hidden" name="sRegion" id="newsRegion"/>
						<input type="hidden" id="sCategory" name="sCategory"/>  
						<div class="new_input"><div class="to_select"><?php _e('Select a region...', 'one'); ?></div><div class="replace"></div></div>
						<div class="regionnew">	
							<div class="sicon"></div>		
							<div class="alltw"><strong><?php _e('All Country', 'one'); ?></strong></div>
							<?php $aRegions = Region::newInstance()->listAll(); ?>
							<?php if(count($aRegions) > 0 ) { ?>
								<?php foreach($aRegions as $region) { ?>
									<p class="<?php echo $region['pk_i_id'] ; ?>"><strong><?php echo $region['s_name'] ; ?></strong>
									</p>
								<?php } ?>
							<?php } ?>
						</div>
						<input class="sub" type="submit" value=""></input>
					</fieldset>
				</form>
			</div>
		</div> 
		<div class="text_for">
			<div class="change_location">
				<span><?php _e('Change location', 'one'); ?></span>
			</div>
			<div class="save_location">
				<span><?php _e('Save location', 'one'); ?></span>
			</div>
		</div>
		<script type="text/javascript">
			$( document ).ready(function() {
				$('.new_input').click(function() {
					$('.regionnew').show();
					$("#sRegion").val('');	// scoate valorile selectate anterior
					$("#newsRegion").val('');
					$(".replace").html("");
					$(".new_value").html("");
				});
				
				$('html').click(function() {
					$('.regionnew').hide();
				});
				
				$('.new_input ').click(function(event){
					event.stopPropagation();
				});
				
				$('.regionnew p').click(function() {
					$('.regionnew').hide();
					var value = $(this).attr('class');
					var input = $('#newsRegion');
					input.val(input.val() + value);
					return false;
				});
				
				$('.second_category .subcategory strong').click(function() {
					var value = $(this).attr('class');
					var input = $('#sCategory');
					input.val(input.val() + value);
					$('.sub').click();
					return false;	
				});
				
				$('.second_category .parent span').click(function() { //pentru categoriile principale salveaza selectia la regiune
					var value = $(this).attr('class');
					var input = $('#sCategory');
					input.val(input.val() + value);
					$('.sub').click();
					return false;	
				});
				
			});
			$( document ).ready(function() { //functia asta sa ascunda textul si sa-l afisez cel selectat
				$('.alltw, .regionnew p').click(function() {
					$('.allc_tohide').hide();
					$('.to_select').hide();
					var chat_screen = $(this).text();
					$(".replace").append(chat_screen);
					$(".new_value").append(chat_screen);
				});
				
				
			});
			$( document ).ready(function() { //functia asta sa ascunda textul si sa-l afisez cel selectat
				$('.text_for .change_location, .all_serch').click(function() {
					$('.change_location').hide();
					$('.save_location').show();
					$('.search_hide').show();
					$('.all_serch').hide();   
				});
				$('.text_for .save_location').click(function() {
					$('.change_location').show();
					$('.save_location').hide();
					$('.search_hide').hide();
					$('.all_serch').show();  
				});
			});
		</script>
	</div>
	<div class="force_down">
	</div>
	<div class="sidebar_categ">
		<div class="title">
			<h3><?php _e('Main categories', 'one') ; ?></h3>
		</div>
		<div class="all_ads">
			<a href="<?php echo osc_search_show_all_url();?>"><?php _e("See all offers", 'one'); ?></a>
		</div>
		<div class="casst">
			<?php osc_goto_first_category(); ?>
			<?php while ( osc_has_categories() ) { ?>
				<div class="second_category">
					<div class="thisone">
						<strong id="one<?php echo osc_category_id(); ?>"class="second cat_<?php echo osc_category_id(); ?>"><?php echo osc_category_name(); ?>
							<span class="ist">
							</span>
						</strong>
					</div>
					<div id="loopone<?php echo osc_category_id(); ?>" class="parent" >
						<div class="image_st"><img src="<?php echo osc_current_web_theme_url('images/categ_image/') . osc_category_id() .'.png' ?>" width="" height="" alt="<?php echo osc_category_name(); ?>" />
						</div>
						<div class="name"><?php echo osc_category_name(); ?></div>
						<p><?php echo osc_category_total_items(); ?> <?php _e("ads", 'one'); ?></p>
						<span class="<?php echo osc_category_id(); ?>"><?php _e("See all offers", 'one'); ?> >></span>
					</div>
					<?php if ( osc_count_subcategories() > 0 ) { ?>
						<div class="subcategory">                                     
							<?php while ( osc_has_subcategories() ) { ?>									
								<strong class="<?php echo osc_category_id() ; ?>">			
									<span class="sub_subcategimg"><img src="<?php if(file_exists(osc_themes_path() . 'one/images/categ_image/' . osc_category_id() . '.png')) { echo osc_base_url() . 'oc-content/themes/one/images/categ_image/' . osc_category_id() . '.png'; } else { echo osc_base_url() . 'oc-content/themes/one/images/none.png'; } ?>" width="" height="" alt="<?php echo osc_category_name() ; ?>" /></span>
								<span class="title_sub"><?php echo osc_highlight( strip_tags( osc_category_name() ),33 ); ?></span></strong>
							<?php } ?>
						</div>
					<?php } ?>
				</div>
			<?php } ?>
		</div>
	</div>
	<script type="text/javascript">
		$(document).ready(function(){
			$(".second_category .thisone strong").click(function() { 
				$('.parent').removeClass('selected');
				$('#loop' + this.id).addClass('selected');
			})
		});
		$(document).ready(function(){
			$(".second_category strong").click(function() {
				var category = $(this).attr('class');
				$('#one' + category).addClass('red').click();    
			})
		});
		$(document).ready(function() {
			$('.casst .second').click(function() {
				$('.second').removeClass('red');
				$(this).addClass('red');
			})
		});	
		$(document).ready(function() {	      
			$('.second').live('click',function(){		  
				$(".subcategory").removeClass("active");			   
				$(this).parents('.second_category').find('.subcategory').addClass("active");			
				$(".force_down").css({'height':($(".active").height()+'px')});				
			});
		});	
	</script>
</div>