$('#id_b, #id_e').onlyPressNum();
$('#id_b, #id_e').keypress(function(evt){
	if(evt.keyCode==13){
		keyword_search();
	}
});
$('#start,#end').keypress(function(evt){
	if(evt.keyCode==13){
		pinche_search();
	}
});

function keyword_search()
{
	var url = $('#id_rooturl').val();
	var fix = '/';
	var buf = [];
	$(':input',$('#changeCounty_new')).each(function(){
		if (this.name) {
			var val = $(this).val();
			if (val.length>0) {
				buf.push(this.name + val);
			}
		}
	});
	$(':input',$('#agent_dealtype')).each(function(){
		if (this.name) {
			var val = $(this).val();
			if (val.length>0) {
				buf.push(this.name + val);
			}
		}
	});
	url += buf.join('');
	url = url.replace(/a1s1/, '');
	var text = $.trim( $('#id_keyword').fixInputPromptText().val() );
	//text = text.replace('/', '');
	text = text.replace(/\//g,'');
	if (text.length>0) {		
		url += '_' + encodeURIComponent(text);		
	}
	url += fix;
	url = url.replace(/\/\/$/, '/');
	if ($('#id_type').val() == 1 && text) {
		$.post('/ajax/ershouche_search.php', {
			keyword: text
		});
	}
	window.location = url;
	return false;
}
function pinche_search()
{
	var url = $('#id_rooturl').val();
	var fix = '/';
	var buf = [];
	$(':input',$('#changeCounty_new')).each(function(){
		if (this.name && this.name != '_' && this.name != '-' && this.name != 'bun') {
			var val = $(this).val();
			if (val.length>0) {
				buf.push(this.name + val);
			}
		}
	});
	var start = $('#start').val();
	var end = $('#end').val();
	start = start.replace(/\//g,'');
	end = end.replace(/\//g,'');
	if (start.length>0 || end.length>0) {
		buf.push('_' + encodeURIComponent(start));
		if ( end.length>0 )
			buf.push('-' + encodeURIComponent(end));
	} 
	url += buf.join('');

	if( start.length >0 || end.length>0 ){
		url += fix;
	}
	window.location = url;
	return false;
}
function adClick()
{
	$.getJSON('http://logserver.ganji.com/count/count.php?source_code=ucar&source_id=liebiao&type=2');
}
