<!--

// ******** GLOBAL VARS
var isNav=navigator.appName.indexOf("Netscape");
// Array pointers for acUpdFields
var iDESTINATION= 0;
var iWCCPM = 1;
var iWC10CMIN = 2;
var iWC20CMIN = 3;
var iWCCFEE = 4;
var iWCCNAME = 5;
var iNCCPM = 6;
var iNC10CMIN = 7;
var iNC20CMIN = 8;
var iNCCFEE = 9;
var iNCCNAME = 10;


// FUNCTION acFldSize
// Attends to a Netscape problem with field widths
function acFldSize(fldName,fldSize){
	var vFldSize = fldSize;
	if(isNav == 0){
		vFldSize=parseInt(1 * vFldSize);
	}
	document.write('<INPUT type="text" name="'+fldName+'" onFocus="acNoChange(this)" class="inputBESTRATES" size="'+vFldSize+'" maxlength="19">')
}


// FUNCTION acUpdFields
// updates phonecard data based on user destination selection from SELECT object
function acUpdFields(objLIST){
	var theFORM = document.frmDestinations;
	var optValue =(objLIST.options[objLIST.selectedIndex].value);
	
	//split the value into an array
	var arCardData = optValue.split(",");
	
	//update respective form fields
	theFORM.tDESTINATION.value = arCardData[iDESTINATION];
//	theFORM.tNCCNAME.value = arCardData[iNCCNAME];
//	theFORM.tNCCPM.value = acNumFormat(parseFloat(arCardData[iNCCPM ]) * 10000,1);

//	theFORM.tNCCPM.value = arCardData[iNCCPM ];
//	theFORM.tNC10CMIN.value = arCardData[iNC10CMIN];
//	theFORM.tNC20CMIN.value = arCardData[iNC20CMIN];
	theFORM.tWCCNAME.value = arCardData[iWCCNAME];
	theFORM.tWCCPM.value = arCardData[iWCCPM];
	theFORM.tWCCPM.value = acNumFormat(parseFloat(arCardData[iWCCPM]) * 10000,1);
//	theFORM.tWC10CMIN.value = arCardData[iWC10CMIN];
	theFORM.tWC20CMIN.value = arCardData[iWC20CMIN];
//	theFORM.tWCCFEE.value = arCardData[iWCCFEE];
	
	//calculate default cost for 0 minutes
	acShowCost(theFORM.usrMINS)
}

function acNoChange(theOBJ) {
	theOBJ.blur();	
}

function acShowCost(theOBJ) {	
//	var iMins = parseInt(theOBJ.value);
	var theFORM = document.frmDestinations;

//	if(isNaN(iMins) || iMins == 0){
//		//usrMINS
//		theFORM.tAVGWCNAME.value="";
//		theFORM.tAVGWCMINS.value="";
//		theFORM.tAVGWCCOST.value="";
//		theFORM.tAVGNCNAME.value="";
//		theFORM.tAVGNCMINS.value="";
//		theFORM.tAVGNCCOST.value="";
//		theFORM.tBESTCARD.value="";
//		return;
//	}
	
//	theFORM.tAVGWCNAME.value = theFORM.tWCCNAME.value;
//	theFORM.tAVGWCMINS.value = iMins;	
//	theFORM.tAVGNCNAME.value = theFORM.tNCCNAME.value;
//	theFORM.tAVGNCMINS.value = iMins;
	
	// for readability and shorter expressions, assigning text values to vars now

//	var iNCCPM = parseFloat(theFORM.tNCCPM.value);
//	var iWCCPM = parseFloat(theFORM.tWCCPM.value);
//	var iWCCFEE = parseFloat(theFORM.tWCCFEE.value) * 100;
	
	// calculations occur here
//	theFORM.tAVGNCCOST.value = acNumFormat(iNCCPM * iMins,2);
//	theFORM.tAVGWCCOST.value = acNumFormat((iWCCPM * iMins) + iWCCFEE,2);

	// show best card
	
//if(parseFloat(theFORM.tAVGNCCOST.value) > parseFloat(theFORM.tAVGWCCOST.value)){
//		theFORM.tBESTCARD.value = theFORM.tAVGWCNAME.value;
//	} 
//	else {
//		theFORM.tBESTCARD.value = theFORM.tAVGNCNAME.value;
//	}

// theFORM.tNCCOST.value(parseFloat(CPM) * iMins) + parseFloat(CONNECT FEE)
}


// generic positive number decimal formatting function
function acNumFormat (expr, decplaces) {
	// raise incoming value by power of 10 times the
	// number of decimal places; round to an integer; convert to string

var str = "" + Math.round (eval(expr) * Math.pow(10,decplaces)/100);
	// pad small value strings with zeros to the left of rounded number
	while (str.length <= decplaces) {
		str = "0" + str;
	}
	// establish location of decimal point
	var decpoint = str.length - decplaces;
	// assemble final result from: (a) the string up to the position of
	// the decimal point; (b) the decimal point; and (c) the balance
	// of the string. Return finished product.

	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

function acGetIt(theObj){
	var sVal = theObj.value;
	
	if(sVal.indexOf('Star of Asia') >= 0){
       var sURL = 'https://secure.black-hole.com/phonecardsavers/phonecard-order-starofasia.html';
	}


	if(sVal.indexOf('Latino America') >= 0){
       var sURL = 'https://secure.black-hole.com/phonecardsavers/phonecard-order-latamer.html';
	}
	else{
       var sURL = 'https://secure.black-hole.com/phonecardsavers/`phonecard-order.html';
	}

	window.location.href = sURL;
}

//-->
