function isNum(arg)
{
	var args = arg;
	var fad = true;

	if (args == "" || args == null || args.length == 0)
	{
		return false;
	}

	args = args.toString();

	for (var i = 0;  i<args.length;  i++)
	{
		if (args.substring(i,i+1) < "0" || args.substring(i, i+1) > "9")
		{
			if(args.substring(i, i+1) == ".")
			{
				if(fad == true)
					fad = false;
				else
					return false;			
			}
			else
			{
				return false;
			}
		}
	}
	return true;
}


function to(v,type)
{
	var value = v;
      if(type == "hundreds")
  	  value = value*1;
	  
	 
	else if(type == "thousands")
	  value = value*10;
	else if(type == "lakhs")
	  value = value*1000;
	else if(type == "millions")
	  value = value*10000;
	else if(type == "crores")
	 value = value*100000;
	else if(type == "billions")
	 value = value*10000000;
	else if(type == "trillions")
	 value = value*10000000000;	

	return value;
}

function convert()
{
	var val = document.cir.inp.value;
	
	if(!isNum(val))
	{
		val = val.substring(0, val.length-1);
		document.cir.inp.value = val;
	}
	else
	{
		var opt = document.cir.opt.value;
		if(opt=="hundreds")
			document.cir.va.value = val*100;
		else if(opt=="thousands")
			document.cir.va.value = val*1000;
		else if(opt=="lakhs")
			document.cir.va.value = val*100000;	
		else if(opt=="millions")
			document.cir.va.value = val*1000000;
		else if(opt=="crores")
			document.cir.va.value = val*10000000;
		else if(opt=="billions")
			document.cir.va.value = val*1000000000;
		else if(opt=="trillions")
			document.cir.va.value = val*1000000000000;
		

		document.cir.ev.value = val+" "+opt;
           
		var con = to(val,opt);
		document.cir.va1.value = con;
		document.cir.va2.value = con/10;
		document.cir.va3.value = con/1000;
		document.cir.va4.value = con/100000;
		
		
		document.cir.va5.value = con/10000;
		document.cir.va6.value = con/10000000;
		document.cir.va7.value = con/10000000000;
		
		

	}
}

function calci(a)
{
	var q = document.cir.va1.value;
	document.cir.cal.value=a.value;
	return false;
}
function aa(a){
	document.cir.res.value = eval(a.value);
	return false;
}

function color(test)
{

	for(var j=2; j<10; j++)
	{
		var myI=document.getElementsByTagName("input").item(j);
		//myI.setAttribute("style",ch);
		myI.style.backgroundColor=test;
	}
}


function color1(test)
{
var myI=document.getElementsByTagName("table").item(0);
//myI.setAttribute("style",ch);
myI.style.backgroundColor=test;
}



