$(document).ready(function(){
	$("#producer").bind("change", function() {
		wp_livesearch();
	});
	$("#topic").bind("change", function() {
		wp_livesearch();
	});
	$("#cscountry").bind("change", function() {
		wp_livesearch();
	});
	$("#city").bind("change", function() {
		wp_livesearch();
	});
	$("#from").bind("change", function() {
		wp_livesearch();
	});
	$("#to").bind("change", function() {
		wp_livesearch();
	});
	$("#all_duration").bind("change", function() {
		wp_livesearch();
	});
})

function wp_livesearch (orgRequest) {
	var url = "index.php";
	var myvendor = new Array();
	var vendor_box = document.getElementById("producer").options;
	for(var i=0; i<vendor_box.length; i++){
		if (vendor_box[ i ].selected) {
			myvendor.push(vendor_box[i].value);
		}
	}
	var mytopic = new Array();
	var topic_box = document.getElementById("topic").options;
	for(var i=0; i<topic_box.length; i++){
		if (topic_box[ i ].selected) {
			mytopic.push(topic_box[i].value);
		}
	}
	if (document.getElementById('all_duration').checked == true) {
		myall_duration = 1;
	} else {
		myall_duration = 0;
	}
	$("#ajax_livesearch").load(url, {
		eID: "liveSearch",
		vendor: myvendor.join(","),
		topic: mytopic.join(","),
		country: document.getElementById('cscountry').value,
		city: document.getElementById('city').value,
		from: document.getElementById('from').value,
		to: document.getElementById('to').value,
		all_duration: myall_duration,
		cu_langid: document.getElementById('cu_langid').value,
	});
}



/*
var arSelected = new Array();
function getMultiple(ob) {
	while (ob.selectedIndex != -1) {
		if (ob.selectedIndex != 0) arSelected.push(ob.options[ob.selectedIndex].value);
		ob.options[ob.selectedIndex].selected = false;
	} // You can use the arSelected array for further processing.
}


selected = new Array();
for (var i = 0; i < ob.options.length; i++) {
	if (ob.options[ i ].selected) {
		selected.push(ob.options[ i ].value);
	}
}
*/



