var http_search = createRequestObject();
var divhandler_search = new handleDivTag(null);

function sendRequest_spec_search(more,divtag) {
	//alert(more);
	try {
		if (window.timeoutID) window.clearTimeout(window.timeoutID);
		if (more.length>2) window.timeoutID = window.setTimeout("load_easy_search('"+more+"', '"+divtag+"')",50);
	}
	catch(e) {
		alert(e);	
	}
}
function sendRequest_search(more,divtag) {
	if (divtag == "ajax_dropmenu") http_search.open("get", "easy_search.php?tag="+more);
	http_search.onreadystatechange = handleResponse_search;
	divhandler_search.divtag = divtag;
	http_search.send(null);
}
function load_easy_search(var_str, divtag) {
	//type=cart, total, all
	//var postvars = "action="+cart_action+"&type="+type;
	var postvars = "tag="+var_str;
	//$("#mini_cart").html("<span style='color:white;background-color:#747474;font-weight:bold;'>Loading...</span>");
	$.ajax({
		type: "GET",
		url: "easy_search.php",
		data: postvars,
		dataType: "json",
		success: function(data) {
			try {
				if (data.easy_search) {
					document.getElementById(divtag).style.display= "block";
					$("#ajax_dropmenu").html(data.easy_search);
				}
			}
			catch(e) {
				alert(e);	
			}
		}
	});
	return false;
}
function handleResponse_search() {    
	if(http_search.readyState == 4 && http_search.status == 200){
		var response = http_search.responseText;
		if(response) {
			if (divhandler_search.divtag == "ajax_dropmenu") document.getElementById(divhandler_search.divtag).style.display= "block";
			document.getElementById(divhandler_search.divtag).innerHTML = response;
		}
	}
}
function hide_drop() {
	document.getElementById("ajax_dropmenu").style.display="none";
}
function auto_fill(val,id, tag) {
	document.getElementById("easy_name").value = val;
	document.getElementById("easy_id").value = id;
	document.getElementById("easy_tag").value = tag;
	hide_drop();
	document.search_form.submit();
}
//function click_search_easy() {
//	var str_query = "/pages/events/2.php?event_id="+document.getElementById("easy_id").value;
//	window.location = str_query;
//}

function hide_show(id) {
	if(document.getElementById(id).style.display != "none") {
		document.getElementById(id).style.display = "none";
	} else {
		document.getElementById(id).style.display = "block";
	}
}
function hide_show_loop(id) {
	count = 5;
	while(document.getElementById("tr"+count)) {
		document.getElementById("tr"+count).style.display = "";
		count++;
	}
}
function hide_show_loop_auth(id) {
	counta = 5;
	while(document.getElementById("tra"+counta)) {
		document.getElementById("tra"+counta).style.display = "";
		counta++;
	}
}