

function ieskoti_klienta(object){

	//alert(object.value);
	postas = 'f='+ object.value;
	ajax_get(postas, 'ieskoti_kliento');

}


function ajax_get(postas, url){


	$.ajax
	({
		type: "POST",
		url: adresas + "/ajax/"+ url,
		data: postas,
		cache: false,
		success: function(html)
		{
			//alert(html);
			$("#ieskoti_klienta_list").html(html);
		}
	});
}


function ajax_get_modeliai(str){

 //alert(str);
	$.ajax
	({
		type: "POST",
		url: adresas + "/ajax/get_modeliai/"+ str,
		data: "",
		cache: false,
		success: function(html)
		{
			//alert(html);

			//if(html == "") $("#auto_modeliai").hide();
			//else
			$("#auto_modeliai").html(html);//.show();
		}
	});
}



function ajax_get_paieska_data(chid, val, schid, type){// 2, this.value, 1, p

	postas = 'chid='+ chid + '&val='+ val + '&schid='+ schid + '&type='+ type;


	$.ajax
	({
		type: "POST",
		dataType: "json",
		url: adresas + "/ajax/get_paieska_data/",
		data: postas,
		cache: false,
		success: function(html)
		{
			var selection = '<option value="">-pasirinkite-</option>';



			if(html != ""){
				$.each(html, function(i,item){

					//alert();
					
					if(item.prid != null) val = 'pi'+item.prid;
					else val = item.name;

					selection = selection + '<option value="'+val+'">'+item.name+'</option>';

				});

				//$("#paieska_"+chid+type).html(selection).show();
				$("#paieska_"+chid+type).html(selection).removeAttr('disabled');
;


			}

			//alert(selection);
		}
	});
}




function set_paieska_button(type){

	var fname = "post_form_"+type;

	var matches = "";
		$(".paieska_"+type).each(function() {
			//alert(this.value);
		    if(this.value != "") matches = matches + this.value + "_";
		})
		
		
	$("#post_val_"+ type).val(matches);
	$("#post_form_"+ type).submit();
		
	
	//document.[fname].submit();
		//matches = escape(matches);
		
		//alert(matches);
	//var but ='<input type="button" class="auto_button" onclick="javascript:document.location.href=\'' +  adresas+ "/items/auto/"+type+ "/" + matches + '\'" value="Search"/>'



	//document.location.href='http://balsana.e-komercija.lt/index.php/lt/items/find/'+ type+'/'+ matches;
	
}


function set_auto_button(id){



	var but ='<input src="/data/images/search_lt.gif" type="image" class="auto_button" onclick="javascript:document.location.href=\'' +  adresas+ "/items/auto/"+ id + '\'" value="Search" align="absmiddle"/>'

	if(id == 0) but = "";

	$("#auto_button_field").html(but);

}



