// JavaScript Document
function redirect($page){
window.location.href = $page;
}

//###################################################
function removeSubstring(myStr, mySubstr) {
 var newstr = "";
  mystr1 = myStr.split(mySubstr);
  for (i=0; i<mystr1.length; i++)
  {
   newstr += mystr1[i];
  }
  return newstr;
}
//###################################################

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

//###################################################
function isnumeric(field){
	var numericExpression = /^[0-9]+$/;
	if(field.value.match(numericExpression)){
		return true;
	}else{
		field.focus();
		return false;
	}
}

//###################################################

function calc(q,u){
var disform = document.frmc;

if (isnumeric(q)){
}else{
alert("Please enter only numeric value");
q.value = 1;
disform.amount.value = u;
}

var p1 = removeSubstring(disform.duration.value,",");


if (disform.duration.value == ""){
p1 = 1;
}

var tp =  parseInt(p1) * parseInt(u);
disform.amount.value = tp;
}
//###################################################

