var distarray = new Array();

function stripNonNumeric( str )
	{
	  str += '';
	  var rgx = /^\d|\.|-$/;
	  var out = '';
	  for( var i = 0; i < str.length; i++ )
	  {
	    if( rgx.test( str.charAt(i) ) ){
	      if( !( ( str.charAt(i) == '.' && out.indexOf( '.' ) != -1 ) ||
	             ( str.charAt(i) == '-' && out.length != 0 ) ) ){
	        out += str.charAt(i);
	      }
	    }
	  }
	  return out;
	}

function changeearlybirdread()
{
	if(document.getElementById("po").checked==true)
	{
		  document.getElementById("earlyquant").value='0';
		  document.getElementById("earlyquant").readOnly=true;
	}
	else if(document.getElementById("cheque").checked==true)
	{
		 document.getElementById("earlyquant").readOnly=false;
	}
}

function changetotal(form)
{

	changeearlybirdread();

	var regquantity = parseInt(form.regquantity.value);
	var earlyquantity = parseInt(form.earlyquantity.value);
	var total = 0;
	
	form.earlyquantity.value =  stripNonNumeric(earlyquantity);

    

	form.regquantity.value = stripNonNumeric(regquantity);
	
	regquantity = parseInt(form.regquantity.value);
    
    	earlyquantity = parseInt(form.earlyquantity.value);
    
    if(document.getElementById('earlyquant').value=='')
    	{
    		document.getElementById('earlyquant').value='0';
    	}

    if(document.getElementById('regquant').value=='')
    	{
    		document.getElementById('regquant').value='0';
    	}

	regquantity = parseInt(form.regquantity.value);
	earlyquantity = parseInt(form.earlyquantity.value);

		total += regquantity * 400;

		total += earlyquantity * 350;
		
		var quantity = regquantity + earlyquantity;
	
	
	if(quantity > 4)
		{
		total = total*0.9;
		}
	
	form.total.value = total;
}
/*

function getDistricts(country, target)
{
	for(i=0;i<distarray[country].length;i++)
	{
		var	o = document.createElement("option"), a=""+ i/2;
		if( a.indexOf(".") == -1 )
		{
			o.value = distarray[list][i];
			o.text = distarray[list][i+1];
			target.options.add(o);
		}
	}
}

*/


