function search_init()
{
	r = $('results');
	new Form.Element.Observer(
  		'search_string',
  		2,  // 200 milliseconds
  		function(el, value)
  		{
        	r.innerHTML = "Searching.... please wait...";
        	new Ajax.Request("ajax/search.php?s="+value,
          	{
	            method:"get",
    		    onSuccess: function(transport)
    		    {
            		r.show();
	            	r.innerHTML = transport.responseText || "error transfering data";
            	},
            	onFailure: function()
            	{
            		r.innerHTML = "search error";
            	}
          	});
  		})
}

function top_slot_click()
{
	var elt = Event.findElement(event, 'img');
	id = elt.identify();
	new Ajax.Request("ajax/banner_click.php?id="+id+"&pos=top",
    {
		method:"get",
    	onSuccess: function(transport)
    	{
        },
        onFailure: function()
        {
        }
	});
}
function bottom_slot_click()
{
	var elt = Event.findElement(event, 'img');
	id = elt.identify();
	new Ajax.Request("ajax/banner_click.php?id="+id+"&pos=bottom",
    {
		method:"get",
    	onSuccess: function(transport)
    	{
        },
        onFailure: function()
        {
        }
	});
}

function side_slot_click()
{
	var elt = Event.findElement(event, 'img');
	id = elt.identify();
	new Ajax.Request("ajax/banner_click.php?id="+id+"&pos=side",
    {
		method:"get",
    	onSuccess: function(transport)
    	{
        },
        onFailure: function()
        {
        }
	});
}

function showTopSlot()
{
	var elems = document.getElementsByTagName("img")

	for(var i=0; i<elems.length; i++)
	{
		name = elems[i].getAttribute("name");
		if (name != "")
		{
			id = elems[i].id;
			if (name == "top_slot")
			{
				new Ajax.Request("ajax/banner_impression.php?id="+id+"&pos=top",
			    {
					method:"get",
			    	onSuccess: function(transport)
			    	{
        			},
        			onFailure: function()
        			{
        			}
				});
			}
			if (name == "bottom_slot")
			{
				new Ajax.Request("ajax/banner_impression.php?id="+id+"&pos=bottom",
			    {
					method:"get",
			    	onSuccess: function(transport)
			    	{
        			},
        			onFailure: function()
        			{
        			}
				});

			}
			if (name == "side_slot")
			{
				new Ajax.Request("ajax/banner_impression.php?id="+id+"&pos=side",
			    {
					method:"get",
			    	onSuccess: function(transport)
			    	{
        			},
        			onFailure: function()
        			{
        			}
				});
			}
		}
	}
}
