//This is the doMethods object Constructor
function objImprint(){
}

//This runs through all the methods in the object
function doMethods(){
	for (var i in oImprint){
		
		if(eval("oImprint." + i + "()")){
		}else{
			//alert(i);
			return false;
		}
	}
	
	return true;
}

function doSeparateMethods(oObj){
	for (var i in oObj){
		if(eval("oObj." + i + "()")){
		}else{
			bClicked=false;
			return false;
		}
	}
	return true;
}

function checkKitID(){
	if (productNumber > 1){
		document.form1.kitid.value=0;
	}else{
		document.form1.kitid.value="";
	}
	//alert("in check KitID productNumber=" + productNumber + "\nKitID=" + document.form1.kitid.value);
}

/*
remProdID compares a product id array with the additional productid array. It will
remove additional product ids (ie, KITTED items) from prid if they already appear in the
productid array. This function, along with function addProdID(prID, addProdVals) insures that 
KITTED productid sttrings are always built acurately. 

addProdID(prID, addProdVals) unbuilds, then rebuilds the product id string by comparing the 
arrays and only adding a value if it doesn't already appear in the original string. This prevents
duplication of product ids in the final product id string.

Both functions return the completed productid string, which will always consist of at least the 
"head" product of the KIT. The string will also contain any "additional_products" (KITTED items)
that belong to that product based on user selections.

IMPORTANT: remember that either parameter (prID and addProdVals) MAY be either an array (or more
accurately, a delimited string) OR an individual productid. This is why they must be split and 
then parsed.

JK 7/05/01
*/
function remProdID(prID, addProdVals){
	//alert("BEGIN REMPRODID \nprodid=" + prID + "\naddprodvals=" + addProdVals);
	var prodid = '';
	var noDelete;
	var s = ''; 
	var a = '';
	s =	prID;
	a = s.split(",");
	var s1 = ''; 
	var a1 = '';
	s1 = addProdVals;
	a1 = s1.split("|");
	
	//check for a match, set the "noDelete" flag if match found. 
	for (i=0; i < a.length;i++){
		noDelete = 0;
		for(j=0; j < a1.length;j++){
			if(a[i]==a1[j]){
				noDelete = noDelete + 1;
			}					
		}
		//if the "noDelete" flag is not set, don't delete the productid, ie, add it to the string we're rebuilding. 
		if (noDelete < 1){
			if (i == 0){
				prodid = a[i];
			}else{
				prodid = prodid + "," + a[i];
			}
		}
	}
	//alert("END REMPRODID \nprodid=" + prID + "\naddprodvals=" + addProdVals);
	
	return prodid;
	
}

//see the note above function remProdID(prID, addProdVals) for documentation on addProdID()

function addProdID(prID, addProdVals){
	//alert("BEGIN ADDPRODID \nprodid=" + prID + "\naddprodvals=" + addProdVals);
	var prodid = '';
	var noAdd;
	
	//set up an array of productids
	var s = ''; 
	var a = '';	
	s =	prID;
	a = s.split(",");
	
	//set up an array of additional productids
	var s1 = ''; 
	var a1 = '';
	s1 = addProdVals;
	a1 = s1.split("|");	
	
	//this loop "adds" (actually recreates) the productid string from current productids
	for (i=0; i < a.length;i++){
		if(i==0){
			prodid = a[i];
		}
		else {
			prodid = prodid + "," + a[i];					
		}
	}
	//this loop "adds" the additional_productids to the productid string		 
	for(j=0; j < a1.length;j++){
		noAdd = 0;
		for (i=0; i < a.length;i++){
			//check for a match, set the "noAdd" flag if match found. 
			if(a[i]==a1[j]){
				noAdd = noAdd + 1;							
			}					
		}
		//if the "noAdd" flag is not set, add the productid to the string we're rebuilding.
		if(noAdd < 1){
			prodid = prodid + "," + a1[j];
		}				
	}
	//alert("END ADDPRODID \nprodid=" + prodid  + "\naddprodvals=" + addProdVals);

	return prodid;
}

//document.form1.imprintproduct.value = 'true';		//setting the imprint flag
//alert(document.form1.imprintproduct.value);
var oImprint = new objImprint();	//Creating the validation object
