function jscss(a,o,c1,c2)
{
  switch (a){
    case 'swap':
      o.className=!jscss('check',o,c1)?o.className.replace(c2,c1): o.className.replace(c1,c2);
    break;
    case 'add':
      if(!jscss('check',o,c1)){o.className+=o.className?' '+c1:c1;}
    break;
    case 'remove':
      var rep=o.className.match(' '+c1)?' '+c1:c1;
      o.className=o.className.replace(rep,'');
    break;
    case 'check':
      return new RegExp('\\b'+c1+'\\b').test(o.className)
    break;
  }
}
// Numeric only control handler
//USAGE: $("#yourTextBoxName").ForceNumericOnly();
jQuery.fn.ForceNumericOnly =
function()
{
    return this.each(function()
    {
        $(this).keydown(function(e)
        {
            var key = e.charCode || e.keyCode || 0;
            // allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
            return (
                key == 8 || 
                key == 9 ||
                key == 46 ||
                (key >= 37 && key <= 40) ||
                (key >= 48 && key <= 57) ||
                (key >= 96 && key <= 105));
        })
    })
};
//Limit input in textarea
jQuery.fn.LimitText =
function(limit)
{
	return this.each(function()
	{
		$(this).keydown(function(e)
        {
            var key = e.charCode || e.keyCode || 0;
			if(key == 8 || key == 46 || key == 38 || key == 39 
			|| key == 40 || key == 37) //backspace, delete, up, right, down, left
			{
				return true;
			}
			else
			{
				return !($(this).val().length > limit-1);
			}
		})
	})
};

function showLoadDetail(ordernumber)
{	
	var noCache = new Date();
	$.ajax({
		type: 'get',
		url: 'LoadDetail.aspx',
		data: 'id='+ordernumber+'&noCache='+noCache.toString(),
		success: function(msg) {
			$('#loadDetail').dialog('destroy'); //dialog plugin's bug. need to be destroyed first
			$('#loadDetail').html(msg);
			$('#loadDetail').dialog({modal: true, width: 600, resizable: false, title: 'Load Detail'});
		}
	});
}

