
		if(typeof(jQuery) != "undefined")
			{
			jQuery.fn.center = function()
				{
				this.css("position","absolute");
				this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
				this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
				return this;
				}
			$.maxZ = $.fn.maxZ = function(opt)
									{
									var def = { inc: 10, group: "*" };
									$.extend(def, opt);    
									var zmax = 0;
									$(def.group).each(function()
										{
										var cur = parseInt($(this).css('z-index'));
										zmax = cur > zmax ? cur : zmax;
										});
									if (!this.jquery)
									return zmax;

									return this.each(function()
										{
										zmax += def.inc;
										$(this).css("z-index", zmax);
										});
									}
			}
//---------------------------------------------------------------------
function inspect(a,b,c){var d='',e,f;if(c==null)c=0;if(b==null)b=1;if(b<1)return'<font color="red">Error: Levels number must be > 0</font>';if(a==null)return'<font color="red">Error: Object <b>NULL</b></font>';d+='<ul>';for(property in a){try{e=typeof(a[property]);d+="<li><b style='color:#00f;'>("+e+")</b> "+property+((a[property]==null)?(': <b>null</b>'):(''))+'</li>';if((e=='object')&&(a[property]!=null)&&(c+1<b))d+=inspect(a[property],b,c+1);}catch(err){if(typeof(err)=='string')f=err;else if(err.message)f=err.message;else if(err.description)f=err.description;else f='Unknown';d+='<li><font color="red">(Error) '+property+': '+f+'</font></li>';}}d+='</ul>'; if($('#inspector_asdfqwer1234').length ==0){$("body").append("<div id='inspector_asdfqwer1234' style='display:none'></div>");$('#inspector_asdfqwer1234').dialog({autoOpen:false,width:600,height:600});} $('#inspector_asdfqwer1234').html(d).dialog('open');}
//---------------------------------------------------------------------
function toggle_menu(obj)
	{
	if($("#menucontainer").is(':visible'))
		{
		$("#menucontainer").fadeOut(100);
		$(obj).find('img').attr('src', '/images/foundation/button/button[slideright].gif');
		}
	else
		{
		$("#menucontainer").fadeIn(100);
		$(obj).find('img').attr('src', '/images/foundation/button/button[slideleft].gif');
		}
	}
//---------------------------------------------------------------------
		function attach_ac(obj, which)
			{
			var prop					=	{
											link_url:			"",
											attr:				{
																o:			null,
																h:			0,
																l:			0,
																t:			0
																}
											};
														
			if($(obj).attr('data-isac') == 'false' || $(obj).attr('data-isac') == null || $(obj).attr('data-isac') == undefined)
				{
				var original_val		= $(obj).val();
				$(obj).val('').attr('title', '');
				var url					= "";
				if(which == "value")
					{
					var att_id			= $(obj).attr('data-attribute_id');
					url					= '/_tools/ac_search/index.aspx?type='+which+'&attribute_id='+att_id;
					}
				else if (which == "vendor")
					{
					var this_company_id	= "";
					var this_master_id	= "";
					var this_tag_id		= "";
					if($(obj).attr('data-company_id') != "" && $(obj).attr('data-company_id') != undefined)
						{
						this_company_id	= $(obj).attr('data-company_id');
						}
					if(($(obj).attr('data-master_id') == "" || $(obj).attr('data-master_id') == undefined) && ($(obj).attr('data-tag_id') == "" || $(obj).attr('data-tag_id') == undefined))
						{
						//alert("Cannot add vendor autocomplete box without a valid master_id");
						//return false;
						}
					else if(($(obj).attr('data-tag_id') == "" || $(obj).attr('data-tag_id') == undefined))
						{
						this_master_id	= $(obj).attr('data-master_id');
						}
					if($(obj).attr('data-tag_id') != "" && $(obj).attr('data-tag_id') != undefined)
						{
						this_tag_id		= $(obj).attr('data-tag_id');
						}
					url					= '/_tools/ac_search/index.aspx?type='+which+'&company_id='+this_company_id+'&master_id='+this_master_id+"&tag_id="+this_tag_id;
					}
				else
					{
					url					= '/_tools/ac_search/index.aspx?type='+which;
					}
				switch(which)
					{
					case "vendor":
						prop.title			= "Click to load this vendor in a pop-up window";
						prop.link_url		= "/sections/vendor/index.aspx?vendor_id=";
					break;
					case "customer":
						prop.title			= "Click to load this customer in a pop-up window";
						prop.link_url		= "/sections/customer/index.aspx?customer_id=";
					break;
					}
				var _width				= $(obj).width() / 1;
				if(_width < 300)
					{
					_width				= 300;
					}
				if($(obj).attr('id') == 'i_search_criteria')
					{
				// Inventory Search Block ////////////////////////////////////////////////////////
					$(obj).keydown(function(e)
									{
									if(e.which == 13 && $(obj).val() != '')
										{
										return false;
										}
									else if(e.which == 13  && $(obj).val() == '')
										{
										return false;
										}
									if((e.which == 8 || e.which == 46) && $(obj).val() == '' && !$('#i_search_attributes').is(':hidden'))
										{
										$('#i_search_attributes').fadeOut('fast');
										$('#i_search_results').empty();
										}
									else if(!$('#i_search_attributes').is(':hidden') && (e.which != 9 && e.which != 16 && e.which != 17 && e.which != 18 && e.which != 27 && e.which != 35 && e.which != 36))
										{
										$('#i_search_attributes').fadeOut('fast');
										$('#i_search_results').empty();
										}
									});
					$(obj).keyup(function(e)
									{
									if((e.which == 8 || e.which == 46) && $(obj).val() == '' && !$('#i_search_attributes').is(':hidden'))
										{
										$('#i_search_attributes').fadeOut('fast');
										$('#i_search_results').empty().animate({'min-height': '50px'});
										}
									});
				//////////////////////////////////////////////////////////////////////////////////
					}
				$(obj).autocomplete(url,	{
											minChars:		1,
											delay:			400,
											autoFill:		false,
											matchSubset:	1,
											matchContains:	1,
											datatype:		which,
											max:			100,
											highlight:		function(match, keywords)
																{
																keywords = keywords.replace("(", "%28").replace(")", "%29").split(' ').join('|');
																return match.replace(new RegExp("("+keywords+")", "gi"),"<b style='color:red'>$1</b>");
																},
											cacheLength:	10000,
											width:			_width,
											selectOnly:		1,
											formatItem:		function(row, i, n)
																{
																if(which == 'vendor')
																	{
																	if(row[1] == undefined)
																		{
																		return false;
																		}
																	else
																		{
																		return row[1] + ' - ' + row[0];
																		}
																	}
																else
																	{
																	return row[0];
																	}
																}
											}).result(function(event, item)
														{
														if($(obj).attr('class').match(/add_val/gi))
															{
															$(obj).val(item[0].replace(/\&quot\;/gi, "\""));
															var selector			= $(obj).parents('.attval:first').find('select');
															var selector_id			= selector.attr('id');
															//alert(selector_id);
															var collection			= {
																						a:						"push_to_tag",
																						attribute_value_id:		item[1],
																						attribute_id:			$(obj).parents('.attval:first').find('.add_val').attr('data-attribute_id'),
																						tag_id:					$('#TAG_ID').attr('data-id')
																						};
															if($("#"+selector_id+" option[value="+item[1]+"]").length > 0)
																{
																selector.val(item[1]);
																part_match(null);
																chk_part();
																}
															else if(item[2] != "")
																{
																if(confirm("This value is already used in part #"+item[2]+"\nWould you like to goto this part?\n(Ok button = Yes, Cancel Button = No)"))
																	{
																	location.href			= "./index.aspx?a=get&tab=G&id="+item[2];
																	}
																}
															else
																{
																$.get("./index.aspx", collection,
																		function(_resp)
																			{
																			if(_resp == "SUCCESS")
																				{
																				selector.append($("<option></option>").attr("value",item[1]).attr('selected', true).text(item[0]));
																				chk_part();
																				}
																			else
																				{
																				alert(_resp);
																				}
																			});
																}
															toggle_addval(obj);
															}
														if(item[0] == 'No Results')
															{
															$(obj).unbind();
															$(obj).focus(function()
																			{
																			attach_ac(obj, which);
																			});
															$(obj).val('');
															$(obj).attr('data-isac', 'false');
															$(obj).attr('data-id', '');
															$(obj).attr('title', '');
															$(obj).blur();
															return false;
															}
														else
															{
															if($(obj).attr('data-click') == undefined || $(obj).attr('data-click') == null)
																{
																if(which == 'vendor')
																	{
																	$(obj).val("("+item[1]+") "+item[0]);
																	}
																$(obj).attr('title', '#'+item[1]);
																$(obj).attr('data-id', item[1]);
																if($(obj).attr('id') == 'i_search_criteria')
																	{
																	if($('#i_search_attributes').is(':hidden'))
																		{
																		$('#i_search_attributes').slideDown().i_build_attributes();
																		$('#i_search_attributes').refine_search();
																		}
																	else
																		{
																		$('#i_search_attributes').i_build_attributes();
																		$('#i_search_attributes').refine_search();
																		}
																	}
																if($(obj).attr('class').match(/customer/g) && location.href.match(/\?a\=g/gi))
																	{
																	update_customer(item[1]);
																	update_contacts(item[1]);
																	check_open(item[1]);
																	}
																else if($(obj).attr('id').match(/customer/g) && location.href.match(/quote/gi))
																	{
																	update_contacts(item[1], obj);
																	check_open(item[1], true);
																	}
																if($(obj).attr('id') == "TAG_ID" && location.href.match(/member\/inventory/gi))
																	{
																	start_part(obj);
																	}
																if(location.href.match(/member\/inventory/gi) && $(obj).attr('data-orders') == 'true')
																	{
																	order_v_info(obj, true);
																	}
																}
															else
																{
																$(obj).attr('title', which.toUpperCase()+'#: '+item[1]);
																$(obj).attr('data-id', item[1]);
																$(obj).val("("+item[1]+") "+item[0]);
																eval($(obj).attr('data-click'));
																}
															prop.attr.o		= $(obj).offset();
															prop.attr.l		= ($(obj).width() / 1)+($(obj).offset().left/1)-20;
															prop.attr.t		= $(obj).offset().top+1;
															prop.attr.h		= $(obj).height();
															
															if(prop.link_url != "" && location.href.match(/a=get&sstab/g))
																{
																prop.link_url += item[1];
																$(obj).parent().append("<div id='ac_link' style='width:20px;height:16px;text-align:right;background-color:#fff;position:absolute;font-weight:bold;left:"+prop.attr.l+"px;top:"+prop.attr.t+"px;'><img src='/images/icon/icon[link].gif' title='"+prop.title+"' style='cursor:pointer' onclick=\"boing('"+prop.link_url+"', '"+which+"', 1024,768);\" border='0'/></div>");
																}
															}
														});
				function formatMe(row)
					{
					return row[0] + " (#:" + row[1] + ")";
					}


				$(obj).blur(function()
								{
								if($.trim($(obj).val()) == "")
									{
									$(obj).val(original_val);
									$(obj).unbind();
									$(obj).focus(function()
													{
													attach_ac(obj, which);
													});
									$("#ac_link").remove();
									$(obj).attr('data-isac', 'false');
									$(obj).attr('data-id', '');
									$(obj).attr('title', '');
									}
								});
				$(obj).attr('data-isac', 'true');
				}
			return true;
			}
//---------------------------------------------------------------------
		function only_int(event)
			{
			var e			= event;
			var key			= e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
			var delta		= e.wheelDelta ? e.wheelDelta : e.detail;
			var tar			= e.target == undefined ? $(e.srcElement) : $(e.target);
			var current		= tar.val() == "" ? 0 : tar.val() / 1;
			var _goodkeys	= [96,97,98,99,100,101,102,103,104,105,35,36,37,39,8,9,47,48,49,50,51,52,53,54,55,56,57,189,109];
			var _returned	= $.inArray(key, _goodkeys);
			if(key == 38){tar.focus().val(current+1);}
			else if(key == 40 && current > 1){tar.focus().val(current-1);}
			else if(key == 33 && e.shiftKey && e.ctrlKey){tar.focus().val(current+1000);e.returnValue = false;}
			else if(key == 33 && e.shiftKey){tar.focus().val(current+100);e.returnValue = false;}
			else if(key == 33){tar.focus().val(current+10);e.returnValue = false;}
			else if(key == 34 && current - 1000 > 0 && e.shiftKey && e.ctrlKey){tar.focus().val(current-1000);e.returnValue = false;}
			else if(key == 34 && current - 100 > 0 && e.shiftKey){tar.focus().val(current-100);e.returnValue = false;}
			else if(key == 34 && current - 10 > 0){tar.focus().val(current-10);e.returnValue = false;}
			else if(key == 189 && tar.val().length > 0){e.returnValue = false;}
			else
				{
				e.returnValue	= (_returned > -1);
				}
			}
//---------------------------------------------------------------------
		function only_numeric(event)
			{
			var e			= event;
			var key			= e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
			var delta		= e.wheelDelta ? e.wheelDelta : e.detail;
			var tar			= e.target == undefined ? $(e.srcElement) : $(e.target);
			var current		= tar.val() == "" ? 0 : tar.val() / 1;
			var _goodkeys	= [96,97,98,99,100,101,102,103,104,105,35,36,37,39,8,9,47,48,49,50,51,52,53,54,55,56,57,190,110,189,109];
			var _returned	= $.inArray(key, _goodkeys);
			if(key == 38){tar.focus().val(current+1);}
			else if(key == 40 && current > 1){tar.focus().val(current-1);}
			else if(key == 33 && e.shiftKey && e.ctrlKey){tar.focus().val(current+1000);e.returnValue = false;}
			else if(key == 33 && e.shiftKey){tar.focus().val(current+100);e.returnValue = false;}
			else if(key == 33){tar.focus().val(current+10);e.returnValue = false;}
			else if(key == 34 && current - 1000 > 0 && e.shiftKey && e.ctrlKey){tar.focus().val(current-1000);e.returnValue = false;}
			else if(key == 34 && current - 100 > 0 && e.shiftKey){tar.focus().val(current-100);e.returnValue = false;}
			else if(key == 34 && current - 10 > 0){tar.focus().val(current-10);e.returnValue = false;}
			else if(key == 189 && current.length > 0){e.returnValue = false;}
				{
				e.returnValue	= (_returned > -1);
				}
			}
//---------------------------------------------------------------------
function please_wait(action)
	{
	if(action)
		{
		switch(action)
			{
			case "start": 
			case "begin":
				var div_index		= $.maxZ()+1;
				var img_index		= $.maxZ()+2;
				$('body').css({'overflow':'hidden'});
				$('body').append("<div id='progress_1234567890' class='progress_bar' style='z-index:"+div_index+"' align='center'></div><img class='progress_barimg' style='z-index:"+img_index+"' id='progress_12345678901' src='/images/loading.gif'/>");
			break;
			case "finish":
			case "end":
			case "stop":
				$('body').css({'overflow':'visible'});
				$('#progress_1234567890').remove();
				$('#progress_12345678901').remove();
			break;
			}
		}
	}
//---------------------------------------------------------------------
function toTitleCase(str)
	{
    return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
	}
//---------------------------------------------------------------------
function functionlist()
	{
	return true;
	}
//---------------------------------------------------------------------
function unescape_me (str)
	{
	str = "" + str;
	while (true)
		{
		var i = str . indexOf ('+');
		if (i < 0)
			break;
		str = str . substring (0, i) + '%20' +
			str . substring (i + 1, str . length);
		}
	return unescape (str);
	}

//---------------------------------------------------------------------
function checkEnter()
	{    
	var key			= window.event.keyCode ? window.event.keyCode : window.event.which;
	return (key==13);
	}
	
//---------------------------------------------------------------------
function screen_width()
	{
	var screenwidth			= 0;
	if( typeof( window.innerWidth ) == 'number' )									//Non-IE
		{
		screenwidth			= window.innerWidth;
		}
	else if( document.documentElement && ( document.documentElement.clientWidth) )	//IE 6+ in 'standards compliant mode'
		{
		screenwidth			= document.documentElement.clientWidth;
		}
	else if( document.body && ( document.body.clientWidth ) )						//IE 4 compatible
		{
		screenwidth			= document.body.clientWidth;
		}
	return screenwidth;
	}

//---------------------------------------------------------------------
function screen_height()
	{
	var screenheight		= 0;
	if( typeof( window.innerWidth ) == 'number' )								    //Non-IE
		{
		screenheight		= window.innerHeight;
		}
	else if( document.documentElement && ( document.documentElement.clientHeight ) )//IE 6+ in 'standards compliant mode'
		{
		screenheight		= document.documentElement.clientHeight;
		}
	else if( document.body && ( document.body.clientHeight ) )						//IE 4 compatible
		{
		screenheight		= document.body.clientHeight;
		}
	return screenheight;
	}

//---------------------------------------------------------------------
function changeIt(imageName,objName)
	{
	var obj = document.getElementById(objName);
	var imgTag ="<IMG id='" + objName+ "' SRC='" + imageName + "'>";
	obj.src = imageName;
	}

//---------------------------------------------------------------------
function changeprevious(imageName,objName)
	{
    var obj = document.getElementById(objName);
	var imgTag ="<IMG id='" + objName+ "' SRC='" + imageName + "'>";
	obj.src = imageName;
	}

//---------------------------------------------------------------------
function isNumber(number)
	{
	if(number.search("[^0-9\.]"))
		{
		return false;
		}
	else
		{
		return true;
		}
	}

/*	------------------------- Total Payroll Hours Section ---------------------------------*/


function state_check(id)
	{
	var Target	= document.getElementById(id);
	var Value	= Target.value;

	if(Value == "0")
		{
		Target.value	= "";
		}
	Target.focus();
	}

function ExportBusiness(PID)
	{
	var	BID									= document.getElementById("BID").value;
	var URL									= './index.aspx?A=EXPORTBUSINESS&P='+PID+'&BID='+BID;
	if(window.open(URL, "download", "width=1,height=1"))
		{
		document.location.reload();
		}
	}


function get_xml_doc(url) 
		{
		xml_doc			= new ActiveXObject('Microsoft.XMLDOM');
		xml_doc.async	= false;
		xml_doc.load(url); 
		parse_xml_doc();
		}
		
function parse_xml_doc() 
		{
		switch(which)
			{
			case "Inv_Att":		var attributes		= xml_doc.getElementsByTagName('attribute');
								var n_attributes	= attributes.length;
								if(n_attributes > 0)
									{
									for(i=1; i<=n_attributes; i++)
										{
										var sub_i			= i - 1;
										var attribute		= attributes.item(sub_i);
										var AttributeName	= attribute.getAttribute('name');
										var AttributeId		= attribute.getAttribute('id');
										attribute_box[i]	= new Option(AttributeName, AttributeId);
										}
									}
			break;
			case "Inv_Val":		var values		= xml_doc.getElementsByTagName('value');
								var n_values	= values.length;
								if(n_values > 0)
									{
									value_box.length		= 0;
									value_box[0]			= new Option('SELECT VALUE', 0);
									for(i=1; i<=n_values; i++)
										{
										var sub_i			= i - 1;
										var value			= values.item(sub_i);
										var ValueName		= value.getAttribute('name');
										var ValueId			= value.getAttribute('id');
										value_box[i]		= new Option(ValueName, ValueId);
										}
									}
								else
									{
									value_box.length		= 0;
									value_box[0]			= new Option('No Values', 0);
									value_box.disabled		= true;
									}
			break;
			case "Inv_Pre":		var values		= xml_doc.getElementsByTagName('value');
								var n_values	= values.length;
								var box_height	= 0;
								if(n_values > 0)
									{
									value_box.style.backgroundColor		= "#FFFFFF";
									box_height			= 160;
									value_box.style.height	= box_height+"px";
									value_box.length		= 0;
									for(i=0; i<n_values; i++)
										{
										var sub_i			= i;
										var value			= values.item(sub_i);
										var ValueName		= value.getAttribute('name');
										var ValueId			= value.getAttribute('id');
										value_box[i]		= new Option(ValueName, ValueId);
										}
									}
								else
									{
									value_box.length					= 0;
									value_box.disabled					= true;
									value_box[0]						= new Option('NO VALUES AVAILABLE FOR THIS ATTRIBUTE, PLEASE ADD VALUES BEFORE PROCEEDING', 0);
									value_box.style.height				= "25px";
									value_box.style.backgroundColor		= "#660000";
									}									
			break;
			}
		}

function load_XML(url) 
		{
		var xmlHttpReq		= false;
		var self			= this;
		if (window.XMLHttpRequest)																// Mozilla/Safari
			{
			self.xmlHttpReq = new XMLHttpRequest();
			}
		else if (window.ActiveXObject)															// IE
			{
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			}
		self.xmlHttpReq.open('GET', url, true);
		self.xmlHttpReq.send(null);
		self.xmlHttpReq.onreadystatechange = function()
			{
			if (self.xmlHttpReq.readyState == 4)
				{
				process_XML(self.xmlHttpReq.responseText);
				}
			}
		}


function process_XML(str) 
		{
		switch(which)
			{
			case "Inv_Att":		var attributes		= xml_doc.getElementsByTagName('attribute');
								var n_attributes	= attributes.length;
								if(n_attributes > 0)
									{
									for(i=1; i<=n_attributes; i++)
										{
										var sub_i			= i - 1;
										var attribute		= attributes.item(sub_i);
										var AttributeName	= attribute.getAttribute('name');
										var AttributeId		= attribute.getAttribute('id');
										attribute_box[i]	= new Option(AttributeName, AttributeId);
										}
									}
			break;
			case "Inv_Val":		var values		= xml_doc.getElementsByTagName('value');
								var n_values	= values.length;
								if(n_values > 0)
									{
									value_box.length		= 0;
									value_box[0]			= new Option('SELECT VALUE', 0);
									for(i=1; i<=n_values; i++)
										{
										var sub_i			= i - 1;
										var value			= values.item(sub_i);
										var ValueName		= value.getAttribute('name');
										var ValueId			= value.getAttribute('id');
										value_box[i]		= new Option(ValueName, ValueId);
										}
									}
								else
									{
									value_box.length		= 0;
									value_box[0]			= new Option('No Values', 0);
									value_box.disabled		= true;
									}
			break;
			case "Inv_Pre":		var values		= xml_doc.getElementsByTagName('value');
								var n_values	= values.length;
								var box_height	= 0;
								if(n_values > 0)
									{
									value_box.style.backgroundColor		= "#FFFFFF";
									if(n_values <= 10)
										{
										box_height			= n_values * 16;
										}
									else
										{
										box_height			= 160;
										}
									value_box.style.height	= box_height+"px";
									value_box.length		= 0;
									for(i=0; i<n_values; i++)
										{
										var sub_i			= i;
										var value			= values.item(sub_i);
										var ValueName		= value.getAttribute('name');
										var ValueId			= value.getAttribute('id');
										value_box[i]		= new Option(ValueName, ValueId);
										}
									}
								else
									{
									value_box.length					= 0;
									value_box.disabled					= true;
									value_box[0]						= new Option('NO VALUES AVAILABLE FOR THIS ATTRIBUTE, PLEASE ADD VALUES BEFORE PROCEEDING', 0);
									value_box.style.height				= "25px";
									value_box.style.backgroundColor		= "#660000";
									}									
			break;
			case "Payroll":	
				switch(str)
					{
					case "Exists":			alert("This employee's time was populated while you were reviewing.\nYou will be directed to the next available employee.");
											location.href								= "./";
										
					case "Success":			var NextID									= document.getElementById("DB_next_id").value;
											location.href								= "./";
					break;
					case "Failed":			document.getElementById("send").disabled		= false;
											alert("I am sorry, there was a problem sending payroll for this user.\nPlease contact the system administrator.");
					break;
					}
			break;
			}
		}



function toggle(id)
	{
	var target		= document.getElementById(id);
	var display		= target.style.display;
	switch(display)
		{
		case "block":	target.style.display			= "none";

		break;
		default:		target.style.display			= "block";
						
		break;
		}
	}

var bc_t;
function bc_out()
	{
	var bc		= document.getElementById('bcode');
	if(bc != null)
		{
		bc_t = setTimeout("bc_destroy()", 100);
		}
	}
function bc_destroy()
	{
	var bc		= document.getElementById('bcode');
	if(bc)
		{
		bc.parentNode.removeChild(bc);
		}
	}
function bc_in()
	{
	clearTimeout(bc_t);
	}
function bc_click(id)
	{
	var targ		= event.srcElement;
	please_wait("start");
	$.get("/_tools/inventory_barcode/index.aspx", 
		{
		master_id:id
		}, 
		function(ret)
			{
			if(ret != "SUCCESS")
				{
				alert(ret);
				}
			please_wait("stop");
			});

	}
function bc(obj)
	{
	bc_destroy();
	var j		=	{
					left:		$(obj).offset().left+$(obj).width(),
					top:		$(obj).offset().top
					};
	var b		= "<button id='bcode' onclick='bc_click("+$(obj).text()+")' style='font-size:11px;font-weight:bold;position:absolute;z-index:1000000;left:"+j.left+"px;top:"+j.top+"px;' onmouseover='bc_in()' onmouseout='bc_out()' type='button'><img src='/images/icon/icon[print_barcode].gif' align='absmiddle'> Print "+$(obj).text()+"</button>";
	$("body").append(b);
	$(obj).unbind().hover(	function()
						{
						bc_in();
						},
					function()
						{
						bc_out();
						});
	}


function boing(b_loc, b_pagename, b_width, b_height)
	{
	var s_width			= screen_width();
	var s_height		= screen_height();
	var b_leftpos		= (s_width-b_width)/2;
	var b_toppos		= (s_height-b_height)/2;
	if(b_height == undefined)
		{
		b_height		= s_height;
		}
	if(b_width	== undefined)
		{
		b_width			= s_width;
		}
	
	var b_settings		= "screenX="+b_leftpos;
	b_settings			+= ", screenY="+b_toppos;
	b_settings			+= ", left="+b_leftpos;
	b_settings			+= ", top="+b_toppos;
	b_settings			+= ", toolbar=0";
	b_settings			+= ", location=1";
	b_settings			+= ", directories=0";
	b_settings			+= ", status=1";
	b_settings			+= ", menubar=0";
	b_settings			+= ", scrollbars=1";
	b_settings			+= ", resizable=1";
	b_settings			+= ", width="+b_width;
	b_settings			+= ", height="+b_height;
	
	var b_win 			= window.open(b_loc, b_pagename, b_settings);
	b_win.focus();
	}
	
 function boing2(b_loc, b_pagename, b_width, b_height)
	{
	var s_width			= screen_width();
	var s_height		= screen_height();
	var b_leftpos		= (s_width-b_width)/2;
	var b_toppos		= (s_height-b_height)/2;
	if(b_height == undefined)
		{
		b_height		= s_height;
		}
	if(b_width	== undefined)
		{
		b_width			= s_width;
		}
	
	var b_settings		= "screenX="+b_leftpos;
	b_settings			+= ", screenY="+b_toppos;
	b_settings			+= ", left="+b_leftpos;
	b_settings			+= ", top="+b_toppos;
	b_settings			+= ", toolbar=0";
	b_settings			+= ", location=1";
	b_settings			+= ", directories=0";
	b_settings			+= ", status=0";
	b_settings			+= ", menubar=0";
	b_settings			+= ", scrollbars=0";
	
	b_settings			+= ", width="+b_width;
	b_settings			+= ", height="+b_height;
	
	var b_win 			= window.open(b_loc, b_pagename, b_settings);
	b_win.focus();
}
