function smReport(id) {
	for (var i=0; i<5; i++) {
		if (i == id) {
			EL('div_SalesPerson' + i).className = 'showGrp';
		}
		else {
			EL('div_SalesPerson' + i).className = 'hideGrp';
		}
	}
}

function EL(id) {
  return document.getElementById(id);
}

function checkall(field) {
  var isChecked = true;
  for (i = 0; i < field.length; i++) {
    if (!field[i].checked) {
      isChecked = false;
    }
  }
  if (isChecked) {
    for (i = 0; i < field.length; i++) {
      field[i].checked = false;
    }
   return "check all";
  }
  else {
    for (i = 0; i < field.length; i++) {
      field[i].checked = true;
    }
    return "uncheck all";
  }
}

function warnAction(q, p, n) { //df
	if (confirm(q)) {
		if (n == 'new')
			window.open(p,'win2','scrollbars=yes,width=800,height=640');
		else
			location.href = p;
	}
}
function goTo(pagename) {
	if (pagename.options[pagename.selectedIndex].value != 'null') {
		parent.top.document.location.href=pagename.options[pagename.selectedIndex].value;
	}
	return true;
}


function printreport(str) {
	window.open(str,'freight','menubar=yes,scrollbars=yes,resizable=yes,toolbar=yes,width=620,height=420');
}

function passwordReminder() {
	window.open('sendpassword.cfm','password','width=400,height=150');
}
function passwordFwd(cEmail) {
	window.open('sendpassword.cfm?cEmail=' + cEmail,'password','width=400,height=150');
}
function openLgWindow (loc) {
	window.open(loc,'presentation','width=480,height=400');
}
function openSmWindow (loc) {
	window.open(loc,'win1','scrollbars=yes,width=520,height=240');
}
function openLgWindow2 (loc,winName) {
	window.open(loc,winName,'scrollbars=yes,width=640,height=480');
}

function openInvoice (loc){
	window.open(loc,'Invoice','menubar=yes,scrollbars=yes,resizable=yes,toolbar=yes,width=620,height=420');
}

function modified(obj) {
  var fm = document.getElementById('h_FieldsModified');
  var str = fm.value;  
  var skip = false;
  if (str == '') {
    fm.value = obj.name;
  }
  else {
    var arr_str = str.split(",");
    for (var i = 0;i < arr_str.length;i++) {
      if (trim(arr_str[i]) == obj.name)
        skip = true;
    }
    if (!skip)
      fm.value = fm.value + ', ' + obj.name;
     
  }
  //alert (fm.value);
}

// Removes leading whitespaces
function LTrim( value ) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim( value ) {
	return LTrim(RTrim(value));
}

function EL(id) {
  return document.getElementById(id);
}

function updateTotal (t) {
	var subtotal = document.getElementById('subtotal').value;
	var newtotal;
	newtotal = 1*t + 1*subtotal;
	newtotal = newtotal.toFixed(2);
	
	var s_newtotal = "";
	j = newtotal.length;
	for	(var i=0; i < j; i++) {
		if ((j-i == 6 && i != 0) || (j-i == 9 && i != 0))
			s_newtotal += ',';
		s_newtotal += newtotal.charAt(i);
	}
	document.getElementById('div_total').innerHTML = '$' + s_newtotal;
	//obj.txtTotal.value = '$' + s_newtotal;
}