function downSlider()
{
    $("#downSlider").slideDown(600);
	setTimeout(function() {
		$("#downSlider").slideUp(600);
	}, 10000);	    
}

function popupSelectValue(field, val)
{
	top.$("#"+field).val(val);
	top.$("#"+field).blur();
	top.tb_remove();
}

function customerLookupResults(fieldId, customerId)
{
	$.get("/customers/ajaxGetCustomer",{'customerId': customerId}, function(data){
		$("#"+fieldId).html(data);
	});
}

function selectValue(field, val, fieldId, control)
{
	var c = top.$("#"+field);
	var p = top.$("#"+control);
	var obj = new Object;
	obj.value = $.trim(val);
	obj.name = $.trim(fieldId);
	
	var k = $.toJSON( obj );
	
	var a = $.trim($(c).val()).split('|');
	var i = parseInt($.inArray(k, a));
	
	if(i != -1)
	{
		var d = '<div id="dialog" title="Warning!!"><p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>The selected item is currently in your list.</p></div>';
		$(d).dialog({bgiframe: true,height: 140,modal: true});		
		stop;
	}
	else
	{
		$(c).val($.trim($.trim($(c).val())) + '|' + k).blur();
		$(p).append("<li id=\"" + control + obj.value + "\" class=\"ui-widget-content\">" + obj.name + " <a href=\"javascript:removeValue('" + field + "','" + control + obj.value + "','" + obj.name + "','" + obj.value + "');\">Remove</a></li>");
		top.tb_remove();
	}
	
	stop;
}

function removeValue(field,control,name,value)
{
	var c = $("#"+field);
	var a = $.trim($(c).val()).split('|');
	var k = '{"value": "' + $.trim(value)  + '", "name": "' + $.trim(name) + '"}';
	var i = parseInt($.inArray(k, a));

	if(i > -1)
	{
		if(a.length >= 2)
		{
			a.splice(i,1);
			$(c).val(a.join("|"));
		}
		else
		{
			$(c).val("");
		}
		$("#"+control).remove();
	}
}


function lookup(section, fieldId, val)
{
	$.get("/lookup/" + section,{'val': val}, function(data){
		$("#"+fieldId).html(data);
	});
}
