
function initSendNumber(){
	/*
	if($_('localZone')!=null&&$_('localZone').style.display!='none'){
		$_('radioLocal').onclick();
	}
	*/


	var npa=getVarSearch('npa');
	if(npa=='888'||npa=='877'||npa=='866'||npa=='800'||npa=='8**'||npa=='855'){
		$_('npa').value=npa;
		$_('nxx').value=getVarSearch('nxx');
		$_('line').value=getVarSearch('line');
		$_('searchVanityButton').onclick();
	}
	var numdef = getVarSearch('numdef');
	if( !(!!numdef) )
	{
		$_('radioLocal').onclick();
	}
	if(numdef && numdef == '866'){
		var arr = Array('866','877','888','855');
		numdef = arr[array_rand(arr)];
	}

	//$_('radio_vanity').onclick();
	/*
	if(window.location.pathname=='/ordernow/choose-your-toll-free-number.html'){
	        //$_('radioTollFree').onclick();
			if(numdef && numdef == '800'){
				clearBut();clearArrow();
				$_('arrow_radioTollFree').style.display='';
				$_('op2').style.color='#AD4625';
				$_('radio800').onclick();
				$_('radioTollFree').src=$_('radioTollFree').src.replace(/\.gif$/,'_a.gif');
			}
			else{
				$_('radioTollFree').onclick();
				numdef = '888';
			}
	}
	else{$_('radio_vanity').onclick();}
    */
	//alert(numdef);


	switch (numdef){

		case '888':
			//clearBut();clearArrow();
			//$_('arrow_radioTollFree').style.display='';
			//$_('op2').style.color='#AD4625';
			$_('radio888').onclick();
			//$_('radioTollFree').src=$_('radioTollFree').src.replace(/\.gif$/,'_a.gif');

		break;
		case '877':
			//clearBut();clearArrow();
			//$_('arrow_radioTollFree').style.display='';
			//$_('op2').style.color='#AD4625';
			$_('radio877').onclick();
			//$_('radioTollFree').src=$_('radioTollFree').src.replace(/\.gif$/,'_a.gif');
		break;
		case '855':
			//clearBut();clearArrow();
			//$_('arrow_radioTollFree').style.display='';
			//$_('op2').style.color='#AD4625';
			$_('radio855').onclick();
			//$_('radioTollFree').src=$_('radioTollFree').src.replace(/\.gif$/,'_a.gif');
		break;
		case '866':
			//clearBut();clearArrow();
			//$_('arrow_radioTollFree').style.display='';
			//$_('op2').style.color='#AD4625';
			$_('radio866').onclick();
			//$_('radioTollFree').src=$_('radioTollFree').src.replace(/\.gif$/,'_a.gif');
		break;
		case '800':
			//clearBut();clearArrow();
			//$_('arrow_radioTollFree').style.display='';
			//$_('op2').style.color='#AD4625';
			$_('radio800').onclick();
			//$_('radioTollFree').src=$_('radioTollFree').src.replace(/\.gif$/,'_a.gif');
		break;
		case 'vanity':
			$_('radio_vanity').onclick();
		break;
		case 'local':
			$_('radioLocal').onclick();
		break;
		default:
			$_('radioLocal').onclick();
	}
	switch (getVarSearch('zone')){
	// local
	case '2':
		state=getVarSearch('state');
		city=getVarSearch('city');
		sort=getVarSearch('sort');
		area=getVarSearch('area');
		if(sort!=null&&$_('boxArea')!=null&&$_('boxCity')!=null){
			if(sort=='area'){
				$_('boxArea').checked=true;
				$_('boxCity').checked=false;
			}
			if(sort=='city'){
				$_('boxCity').checked=true;
				$_('boxArea').checked=false;
			}
		}

		if(state!=null&&city!=null && area!= null){
			$_('radioLocal').onclick();
			timerState = setInterval(
				function(){
					objState=$_('state');
					if(objState.options.length>1){
						objState.value=state;
						objState.onchange();
							timerCity = setInterval(
								function(){
									objCity=$_('city');
									if(objCity.options.length>1){
										for(var i =0; i < objCity.options.length; i++){
											var op = objCity.options[i];
											if(op.value == city && op.getAttribute('area') == area){
												//alert(op.value + ' ' + op.getAttribute('area'));
												op.selected = true;
												//objCity.onchange();
												//clearInterval(timerCity);
												continue;
											}
										}
										//objCity.value=city;
										objCity.onchange();
										clearInterval(timerCity);
									}
								}
							,100)
						clearInterval(timerState);
					}
				},100)
			//$_('city').value=city;
		}
	default:break;
	}
}

function getVarSearch( varName ){
	var regexS = "[?&]"+varName+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var tmpURL = window.location.href;
	var results = regex.exec( tmpURL );
	if( results == null )
		return null;
	else
		return results[1].replace(/%20/g,' ');
}

function array_rand ( input, num_req ) {
	var Indexes = [];
	var Ticks = num_req || 1;
	var Check = {
		Duplicate    : function ( input, value ) {
			var Exist = false, Index = 0;
			while ( Index < input.length ) {
				if ( input [ Index ] === value ) {
					Exist = true;
					break;
				}
				Index++;
			}
			return Exist;
		}
	};

	if ( input instanceof Array && Ticks <= input.length ) {
		while ( true ) {
			var Rand = Math.floor ( ( Math.random ( ) * input.length ) );
			if ( Indexes.length === Ticks ) { break; }
			if ( !Check.Duplicate ( Indexes, Rand ) ) { Indexes.push ( Rand ); }
		}
	} else {
		Indexes = null;
	}

	return ( ( Ticks == 1 ) ? Indexes.join ( ) : Indexes );
}
