var page={
	init:function(){
		main.defaulter.make(".default");
		main.order.init();
		$("#tracker").change(main.order.check).blur(main.order.check).keyup(main.order.keywatcher);
		$("form.check").submit(main.defaulter.formChecker);
		$(".suggest").each(page.suggest).result(page.onItemSelect);
		$(".nosubmit").keydown(main.nosubmit);
		real.init();
		},
	cityFormat:function(row, i, num) {
		return row[0];
		},
	placesFormat:function(row, i, num) {
		return row[3]+((typeof row[5]!= 'undefined')?'<br/><i>'+row[5]+'</i>':'');
		},
	onItemSelect:function(event, d, formatted){
		var prefixForObjects="#"+$(this).data("name");
		$(prefixForObjects+"Point").val(d[1]);
		},
	suggest:function(){
		var $obj=$(this);
		if($obj.data("mode")=='getPlaces'){
			$obj.autocomplete("/javascripts/index.html", {
				delay:50,
				minChars:1,
				matchSubset:1,
				autoFill:false,
				matchContains:1,
				cacheLength:15,
				selectFirst:true,
				formatItem:page.placesFormat,
				max:35,
				mustMatch:true,
				extraParams:{
					mode: 'getPlaces',
					answerType:'plain'
					}
				});
			}else{
			$obj.autocomplete("/javascripts/index.html", {
				delay:50,
				minChars:1,
				matchSubset:1,
				autoFill:false,
				matchContains:1,
				cacheLength:15,
				selectFirst:true,
				formatItem:page.cityFormat,
				max:35,
				mustMatch:true,
				extraParams:{
					direction:'forward',
					mode: $obj.data("mode"),
					answerType:'plain'
					}
				}).result(page.onItemSelectCity);
			}
		},
	onItemSelectCity:function(event, d, formatted){
		var prefixForObjects="#"+$(this).data("name");
		$(prefixForObjects+"Point").val(d[1]);
		},
	version:'2012-02-02'
	}

$(page.init);
