// check for invalid chip colors on group of text boxes
function chipColorCheck (style, chipcolor) {
	
	if (
	((style.substring (0,12) == "Dice Striped" || style.substring (0,28) == "11.5-gram Dice Striped Chips") && (chipcolor == "Orange" || chipcolor == "Gray")) 
	|| ((style.substring (0,6) == "Suited" || style.substring (0,29) == "11.5-gram Suited Design Chips") && chipcolor == "Orange")
	|| (style.substring (0,23) == "11.5-gram Texas Hold'em" && (chipcolor == "Pink" || chipcolor == "Orange" || chipcolor == "Gray"))
	|| ((style.substring (0,32) == "11.5-gram Tri-Color Suited Chips" || style.substring (0,38) == "11.5-gram Tri-Color Triple Crown Chips" || style.substring (0,28) == "13-gram Clay Composite Chips" || style.substring (0,27) == "11.5-gram High Roller Chips") && (chipcolor == "Orange" || chipcolor == "Gray" || chipcolor == "Pink" || chipcolor == "Purple" || chipcolor == "Yellow"))
	|| ((style.substring (0,28) == "12-gram Las Vegas Edge Chips" || style.substring (0,31) == "11.5-gram Ace/King Suited Chips" || style.substring (0,27) == "11.5-gram Lucky Crown Chips") && (chipcolor == "Orange" || chipcolor == "Gray" || chipcolor == "Pink"))
	|| ((style.substring (0,29) == "9.5-gram Dice Faux Clay Chips") && (chipcolor == "Pink"))
	|| ((style.substring (0,18) == "Nevada Jacks Chips") && (chipcolor == "$1000"))
//	((style.substring (0,12) == "Dice Striped" || style.substring (0,28) == "11.5-gram Dice Striped Chips") )&& (chipcolor == "Orange" || chipcolor == "Gray")) 
//	|| ((style.substring (0,6) == "Suited" || style.substring (0,29) == "11.5-gram Suited Design Chips") && chipcolor == "Orange")
//	|| ((style.substring (0,14) == "Deluxe Pyramid" || style.substring (0,38) == "11.5-gram Deluxe Pyramid Chips") && (chipcolor == "Pink" || chipcolor == "Orange"))
//	|| ((style.substring (0,32) == "11.5-gram Tri-Color Suited Chips" || style.substring (0,32) == "11.5-gram Tri-Color Triple Crown Chips" || style.substring (0,28) == "13-gram Clay Composite Chips" || style.substring (0,27) == "11.5-gram High Roller Chips") && (chipcolor == "Orange" || chipcolor == "Gray" || chipcolor == "Pink" || chipcolor == "Purple" || chipcolor == "Yellow"))
	){

		alert (style + " are not available in " + chipcolor + ".");
		return false;
	} // if style check

	return true
}  //function

//check for products that do not exist
function errorCheck (nbr, select1, select2, count, allowed) {
  if (nbr == "10-1090GRY" 
  || nbr == "10-1090ORA"
  || nbr == "10-1080ORA"
  || nbr == "10-1300PNK"
  || nbr == "10-1300ORA"
  || nbr == "10-1500ORA"
  || nbr == "10-1500PUR"
  || nbr == "10-1800ORA"
  || nbr == "10-1800PNK"
  || nbr == "10-1800GRY"
  || nbr == "10-1800YEL"
  || nbr == "10-1800PUR"
  || nbr == "10-1900ORA"
  || nbr == "10-1900PNK"
  || nbr == "10-1900GRY"
  || nbr == "10-1900YEL"
  || nbr == "10-1900PUR"
  || nbr == "10-0500ORA"
  || nbr == "10-0500PNK"
  || nbr == "10-0500GRY"
  || nbr == "10-0500YEL"
  || nbr == "10-0500PUR"
  || nbr == "10-8000GRY"
  || nbr == "10-8000PNK"
  || nbr == "10-8000ORA"
  || nbr == "10-1600PNK"
  || nbr == "10-1600ORA"
  || nbr == "10-1600GRY"
  || nbr == "10-NJ$1000"
  ) {
  	alert(select1 + " is not available in " + select2 + ".");
  	return false;
  }
  
  if (count > allowed ) {
	alert ("This set allows only " + allowed + " chips, and you have selected " + count + ".  Please adjust your chip quantities.");
	return false;
	}

return true

} //function


function ReadForm (obj1, comma, nbrallowed) { // process un-named selects
var i,amt,des,obj,pos,val,desval,comma,nbr,nbrval,posCost,colors,chipcount,chipstyle;
  amt = obj1.baseamt.value*1.0;       // base amount
  des = obj1.basedes.value;           // base description
  nbr = obj1.basenbr.value; 			  // base item number
  select1 = "";
  select2 = "";
  colors = "";
  chipcount = 0;
  chipstyle = "";
  for (i=0; i<obj1.length; i++) {     // run entire form
    obj = obj1.elements[i];           // a form element
    if (obj.type == "select-one" && obj.name == "") {    // just get selects
      	nbrval = ""
      	desval = ""						// clear temp vars
      	pos = obj.selectedIndex;        // which option selected
      	val = obj.options[pos].value;   // selected value
      	pos  = val.indexOf ("#");       // get part number
      	posCost  = val.indexOf ("@");       // price set?
      	if (pos > 0) {
      		nbrval = val.substring (pos + 1);
      		desval = val.substring (0,pos);
     		}  // if pos>0 
      	else desval = val
		if (posCost > 0) {
			if (chipstyle == "") chipstyle = desval.substring (0,posCost);
      		} // if posCost>0
      	else if (chipstyle == "") chipstyle = desval;
      	if (posCost > 0) {
      		amt = amt + val.substring (posCost + 1,pos)*1.0;
      		desval = val.substring (0,posCost);
      		}  // if posCost>0
      	if (nbr.length == 0) nbr = nbrval;
      	else nbr = nbr + nbrval;            // accumulate value
      	if (des.length == 0) des = desval;
      	else {
         if (comma == 0)  {				// don't print comma before first select
      		des = des + " " + desval;
      		comma = 1;
      		select1 = desval;  }
	     else {
	     	if (select1 == "") select1 = desval;
	     	else select2 = desval;
	     	des = des + ", " + desval; 
	     	} //else
	     }  // accumulate value
    }  // if select

//new code for colors
	else {
		if (obj.type == "text" && obj.value > 0 && obj.name != "quantity") {
			if (chipColorCheck(chipstyle,obj.name) == false) return false;
			if (colors != "") colors = colors + ", ";
			colors = colors + obj.value + " " + obj.name;
			chipcount = chipcount + (obj.value*1.0);
		}  // if <> ""

	} //else

//end new code

  }		// for loop

  	obj1.item_name.value = des;
  	obj1.amount.value = Dollar (amt);
  	obj1.item_number.value = nbr;
	if (colors != "") obj1.os0.value = colors;
  	if (obj1.tot) obj1.tot.value = "$" + Dollar (amt);
  	
	return (errorCheck (nbr, select1, select2, chipcount, nbrallowed));
	
} //function


function Dollar (val) {  // force to valid dollar amount
var str,pos,rnd=0;
  if (val < .995) rnd = 1;  // for old Netscape browsers
  str = escape (val*1.0 + 0.005001 + rnd);  // float, round, escape
  pos = str.indexOf (".");
  if (pos > 0) str = str.substring (rnd, pos + 3);
  return str;
} //dollar


//Display a pop-up window

function PopUpWindow(url)  {


	var newWindow = window.open(url,"","height=500,width=350,scrollbars=1")

}  //popup

//Display a large pop-up window

function PopUpBigWindow(url)  {


	var newWindow = window.open(url,"","height=325,width=500,scrollbars=1")

}  //popup

function PopUpTallWindow(url)  {


	var newWindow = window.open(url,"","height=600,width=350,scrollbars=1")

}  //popup

function PopUpBigTallWindow(url)  {


	var newWindow = window.open(url,"","height=600,width=600,scrollbars=1")

}  //popup




function Close() {
var temp=window.close() }
