function phonenum()
{
	
	var a = Math.ceil(900*Math.random())+100;
	var b = Math.ceil(900*Math.random())+100;
	var c = Math.ceil(9000*Math.random())+1000;
	
	
	var num = a +"-"+b+"-"+c;
	return num;
}

function zipnum()
{
	var num = Math.ceil(90000*Math.random())+10000;
	return num;
}

function somename()
{
	fnames = Array('','John','James','Tad','Britney','Lilly');
	snames = Array('','Cox','Doe','Smith','Carter','Jackson');
	var somename = fnames[Math.ceil(5*Math.random())]+" "+snames[Math.ceil(5*Math.random())];
	return somename;
}

function populator()
{
	
	var allElementList = document.forms[0].elements;	//If you have more than one form element you must iterate it also
    var l = allElementList.length;
    for( var i = 0; i < l; i++){
        var element = allElementList[i];				//element is taken
        if( element.type == "text")
        {												//here you can handle which element be. 
			element.value = Math.ceil(100*Math.random());
        }
    }
	
	cities = Array('','Atlanta','Las Vegas','New York','San Diego','Miami');
	states = Array('','GA','NV','NY','CA','FL');
	colors = Array('','Gold','Silver','Red','Green','Blue');
	var city_id = Math.ceil(5*Math.random());
	var zipnum2 = zipnum();


	document.gform.f1.value = cities[city_id]+" "+ states[city_id]+", Dec "+Math.ceil(31*Math.random())+" 2008";
	document.gform.f2.value = "Best "+cities[city_id]+" Dance School";
	document.gform.f3.value = somename();

	document.gform.f4.value = Math.ceil(200*Math.random())+" some street";	
	document.gform.f8.value = Math.ceil(200*Math.random())+" some street";	

	document.gform.f5.value = cities[city_id];	
	document.gform.f9.value = cities[city_id];
	
	document.gform.f6.value = states[city_id];	
	document.gform.f10.value = states[city_id];
		
	document.gform.f7.value = zipnum2;	
	document.gform.f11.value = zipnum2;

	document.gform.f12.value = phonenum();
	document.gform.f13.value = phonenum();
	document.gform.f14.value = phonenum();
	document.gform.f15.value = phonenum();
	document.gform.f16.value = "info@Best"+cities[city_id]+"DanceSchool.com";
	document.gform.f17.value = colors[Math.ceil(5*Math.random())];
	
	
	
	
}

function ShowFieldsNames()
{
	var allElementList = document.forms[0].elements;	//If you have more than one form element you must iterate it also
    var l = allElementList.length;
    for( var i = 0; i < l; i++){
        var element = allElementList[i];				//element is taken
        if( element.type == "text")
        {												//here you can handle which element be. 
			element.value = element.name;
            
        }
    }
}

function allforms()
{
	eval("location='list.php'");
}

//**************************** autocalculation formula:    f2 = f1 * sum   ***************************************
function ac(f1,sum,f2)
{
	document.gform.elements['f'+f2].value = document.gform.elements['f'+f1].value * sum;
//	document.gform.elements['f'+f2].disabled = true;
//	if(f2==f1+1) document.gform.elements['f'+(f2+1)].focus();
	subtotalcalc();
}

function fed(f1,sum,f2,fedex)
{
	document.gform.elements['f'+f2].value = document.gform.elements['f'+f1].value * sum;
//	document.gform.elements['f'+f2].disabled = true;
	if(document.gform.elements['f'+f2].value+1-1 > 0)
	{ 
		document.gform.elements['f'+fedex].value = 25;
//		document.gform.elements['f'+fedex].disabled = true;
	}
	else 
	{
		document.gform.elements['f'+fedex].value = 0;
	}

//	document.gform.elements['f'+(fedex+1)].focus();
	
	
}

function fedex(f1,f2)  // f1 - checkboxs,  f2 - text field
{
	if(document.gform.elements['f'+f1].checked == true) document.gform.elements['f'+f2].value = 25;
	else document.gform.elements['f'+f2].value = 0;

	subtotalcalc();
}

function disableEnterKey(e)
{
     var key;
     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     				//firefox
     if(key == 13)
          return false;
     else
          return true;
}


function IsNumeric(sText)
{
	var ValidChars = "0123456789.";
   	var IsNumber=true;
   	var Char;

 
   	for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
    	Char = sText.charAt(i); 
      	if (ValidChars.indexOf(Char) == -1) 
        {
        	IsNumber = false;
        }
    }
   	return IsNumber;
}

function strtofloat(str) 
{ 
	if (str.indexOf(",")!= -1) 
	{ 
		str = str.replace(",","."); 
	} 
	var result = parseFloat(str); 
	if (isNaN(result)) 
	{ 
		result = 0.0; 
	} 
	return result; 
}
