
divShow = function(which)
{
	formdiv = which.setStyles({	display: 'block', opacity: 0});
	var fadein = new Fx(formdiv, 'opacity',{duration:500}).start(1);
}

divHide = function(which)
{
	var fadein = new Fx(which, 'opacity',{duration:500}).start(0);
	which.setStyles({display: 'none'});
}



// Adam's old show/hide div script
var state = 'none';
function showhide(layer_ref) {
	if (state == 'block') {
		state = 'none';
	} else {
		state = 'block';
	}
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		eval( "document.all." + layer_ref + ".style.display = state");
	}
	if (document.getElementById &&!document.all) {
		hza = document.getElementById(layer_ref);
		hza.style.display = state;
	}
}


// Load Flash Video
var params = {};
params.menu = "false";
params.quality = "best"
params.bgcolor = "#0f8ae8"
params.allowfullscreen = "true";

var attributes = {};





function memberInputObj(args)
{

	var my = this;
	my.handler = "/messages_view.php";
	my.action = "membersearch";
	my.selectedelm = "dd-selected";
	my.inputelm = "dd-input";
	my.triggerlock = false;
	
	my.init = function(args)
	{
	
		// initialize arguments, overwriting defaults
		if (typeof args == 'object' && args != null)
			for (var v in args)
				this[v] = args[v];	

		if (this.inputelm)
		{
			my.inputelm = $( this.inputelm );

			my.valuefield = String(my.inputelm.id);
		
			my.form = my.inputelm.form;
		
			my.inputelm.set('id', my.inputelm.id+'_search');
			my.inputelm.set('name', my.inputelm.id+'_search');
		}
		
	}
	
	
	
	this.trigger = function(which)
	{	

		if (!my.triggerlock)
		{
			my.triggerlock = true;
			searchstr = my.inputelm.value;
			inputelm = my.inputelm;
			inputelm.coords = inputelm.getCoordinates();

			
			if (searchstr.length > 0)
			{
				var jaxx = new Request( 
				{
				    url: this.handler,
				    method: "post",
				    data: "a="+this.action+"&q="+searchstr,
				    onComplete: function(response)
				    {

				        if (response != 'none')
				        {
				        
				        	if ($('ddmatches'))
				        		$('ddmatches').destroy();
				        
				        
				        	mdiv = new Element('div', {
				        								"id": "ddmatches",
				        								"styles": { 
				        										'position': 'absolute',
				        										'z-index': 1,
				        										'top': inputelm.coords.top + inputelm.coords.height,
				        										'left': inputelm.coords.left,
				        										'width': inputelm.coords.width
				        								}
				        						});   	


				            var matches = JSON.decode(response);
				            if (matches.length > 0)
				            {
				                for (var x = 0; x < matches.length; x++)
				               	{				                
				                	matches[x].elm = new Element('div', { 
				                									'class': 'dd-results',
				                									'html': matches[x].name,
				                									'events' : {
				                										'click': function() { 
				                											who = this.retrieve('match');
				                											my.select(who); 
				                										}
				                									}
				                								});	

									new Element('img', {
													'src': '/profile_view.php?action=thumbnail&memberid='+matches[x].memberid,
														'styles': { 
															'width':'50px',
															'height':'50px'
														}													
													}).inject(matches[x].elm);

									matches[x].elm.store('match',matches[x]);
									matches[x].elm.inject(mdiv);
				                }

				                mdiv.inject($(document.body));				               
				            } 
				        }
		                my.triggerlock = false;				        
				    }
				}).send();    
			}
		} 
	}
	
	this.select = function(who)
	{

		tagdiv = new Element('span', {
										'id': my.valuefield+'div'+who.memberid,
										'class': 'dd-name',
										'html': who.name
									  });
									      	
    	cbut = new Element('a', {
					  		"styles": { 
					  			"width": "auto", 
					  			"border":"solid 1px #000"
					  		},
					  		"events": {
					  			"click": function()
					  			{
					  				who = this.retrieve('who');
					  				my.remove(who);
					  			}
					  		}
					  	}).set("html","x");
					  	
		cbut.store('who', who);
		cbut.inject(tagdiv);


		new Element('input', {
						'type': 'hidden',
						'name': my.valuefield+"[]",
						'value': who.memberid
					 }).inject(tagdiv);

		tagdiv.injectAfter($(my.inputelm));

		my.inputelm.value = '';

		$('ddmatches').destroy();

	}

	this.remove = function(who)
	{
		$(my.valuefield+'div'+who.memberid).destroy();
		
		if ($('ddmatches'))
			$('ddmatches').destroy();

	}

	this.show = function()
	{

	}
	
	this.hide = function()
	{

	}
	
	my.init(args);
} 










