//--------------------------------------------------------
// getCookie
//--------------------------------------------------------
function getCookie(Name) {
	var search = Name + "="
	if (document.cookie.length > 0) { // if there are any cookies
		offset = document.cookie.indexOf(search)

		if (offset != -1) { // if cookie exists
			offset += search.length
	
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset)

			// set index of end of cookie value
			if (end == -1)
				end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
			
		}
	}

}
var go = getCookie("redirect");

//--------------------------------------------------------
// fillHIDDEN
//--------------------------------------------------------
function fillHIDDEN(){
  var useForm = window.document.forms[0];
  useForm.browsertype.value =  navigator.appName;
  useForm.browserver.value = navigator.appVersion;
  useForm.redirect.value = go;
}// fillHIDDEN

//--------------------------------------------------------
// getCOST
//--------------------------------------------------------
var prices = [6,20,30,40,45,50,55,5];
function getCOST(){
  var counter = 0;
  var loop = 1;
  var value;
  var memberValues = [];
  var total = 0;
  var msg = "";
  while( loop <=100 ){
	  	value = eval( "document.forms[0].mem"+loop+".value;");

		if( value != null && value != ''){
			if( isNaN(value) )
				alert("Member id in location "+loop+" is not a number. Please fix.");
			else
				memberValues.push(value);
		}
		loop++;
  }

  
  if (memberValues.length > 0){
  /*i	switch( memberValues.length ){
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
		case 6:
			total = prices[memberValues.length];
			break;
		default:
			total = prices[6] + (memberValues.length - 6) * 5;
	}*/
	 total = 25 + (5 * memberValues.length);

    msg = memberValues.length + " members ordered at a total cost of $" + total;
   
  } else {
    msg = "No members entered, cannot calculate cost.";
  }//else
  alert(msg);
  window.document.forms[0].cost.value = total;

}//getCOST()


//--------------------------------------------------------
// fillForm
//--------------------------------------------------------
function fillForm(){
var maxFILL =99;
var loopLength = 0;
var needMORE = false;
var cost = 0;

<!-- get & parse member #s out of cookie //-->
var ALLdata = document.cookie.split(';');
var ALLsel = new Array();
ALLsel[0] = false;
var ALLnum = new Array();
ALLnum[0] = false;
var setYet = false;

var isKEPTsub = document.cookie.indexOf("KEPTmembers=");
  if(isKEPTsub != -1){setYet = true;};
  
if(setYet){
  for(loop = 0; loop < ALLdata.length; loop++){
    var fieldPair = ALLdata[loop].split('=');
    var testforKEPT = fieldPair[0].indexOf("KEPT",0);
        if (testforKEPT != -1){
			ALLsel = fieldPair[1].split(",");
		}
  }//for loop
  if(ALLsel[0] != false){
    for(loop = 0; loop < ALLsel.length; loop++){
	  var getFiles = ALLsel[loop].split("/");
	  if(getFiles[2] != null){
	    var doNUM = getFiles[2];
		var pureNUM = doNUM.split('t.');
		if(pureNUM[0]!= ''){ALLnum[loop] = pureNUM[0];}
	  }//if
	}//for loop
  }//if
}//if 

if(ALLnum[0] != false){

  if(ALLnum.length > maxFILL){needMORE = true; loopLength = maxFILL;}
  else loopLength = ALLnum.length;

  for(loop = 0; loop < loopLength; loop++){
    window.document.forms[0].elements[loop].value = ALLnum[loop]; 
  }//for

  if(needMORE){
    var concatREMAIN = '' ;
	window.document.forms[0].elements[loopLength].value = concatREMAIN;

	for (loop2 = loopLength; loop2 < ALLnum.length; loop2++){
	  concatREMAIN = concatREMAIN + ALLnum[loop2] + ' ';
	}//for
	
    window.document.forms[0].elements[loopLength].value = concatREMAIN;
  }//if(needMORE)
}}//fillForm()

