var SearchQuery;
var SearchReq;
var SearchTimer;


function Lists_Search(PageId,Vars){
	if(!PageId){
		alert('Invalid request.');
		return;
	}
	
	Data=new Object;
	for(i in Vars){
		Data=Vars;
	}

	if(SearchReq){
		SearchReq.abort();
	}

	SearchReq=$.ajax({
		type: "GET",
		url: "ajax/?cmd=lists&PageId="+PageId,
		data: Data,
		dataType: "json",
		cache:false,
		error: function(){
			//Failed to get the data
		},
		success: function(json){
			for(i in json){
				if(i=="refresh" && json[i]=="true"){
					location.reload(true);
					return;
				}
				
				if('List_'+PageId+'_'+i){
					$('#List_'+PageId+'_'+i).html(json[i]);
				}
			}
		}
	});
}

function Lists_GetList(PageId,ListId,Vars){
	if(!PageId){
		alert('Invalid request.');
		return;
	}
	
	Data=new Object;
	for(i in Vars){
		Data=Vars;		
	}
	Data['PageId']=PageId;
	
	if(ListId){
		Data['ListId']=ListId;
	}

	$.ajax({
		type: "GET",
		url: "ajax/?cmd=lists",
		data: Data,
		dataType: "json",
		cache:false,
		error: function(){
			//Failed to get the data
		},
		success: function(json){
			for(i in json){
				if(i=="refresh" && json[i]=="true"){
					location.reload(true);
					return;
				}
				
				if('List_'+PageId+'_'+i){
					$('#List_'+PageId+'_'+i).html(json[i]);
				}
			}
		}
	});
}
