	function setcolortext(name,productid) {		
		getElement('activecolor_'+productid).innerHTML = "<font class='RedText'><strong>"+name+"</strong></font>";
	}
	
	function erasecolor(productid) {
		getElement('activecolor_'+productid).innerHTML = "Roll Over Color";
	}
	
	function doublearraysort(arr1, arr2) {
		var minval, minidx, temp1, temp2, i, j, bcontinue; 
		if (arr1.length > 0 && arr2.length > 0 && arr1.length == arr2.length)
		{
			for (j=0; j<arr1.length; j++)
			{							   
				minval = arr1[j];
				minidx = j;				 
				for (i=j; i<arr1.length; i++)
				{
					if (arr1[i] < minval)
					{
						minval = arr1[i];
						minidx = i;					
					}
				}
				temp1 = arr1[minidx];
				temp2 = arr2[minidx];
				arr1[minidx] = arr1[j];
				arr2[minidx] = arr2[j];
				arr1[j] = temp1;
				arr2[j] = temp2;				   				
			}
		}	
	}
	
	function getminmax(productid,min,max) {		
		min = -1;
		max = -1;
		for (i=0; i<po_prices.length; i++) {
			if ( po_productid[i] == productid && po_availabilityflag[i] == 1 ) {
				if ( parseFloat(po_prices[i]) > parseFloat(max) || max == -1 ) {
					max = parseFloat(po_prices[i]);
				}
				if ( parseFloat(po_prices[i]) < parseFloat(min) || min == -1) {
					min = parseFloat(po_prices[i]);
				}				
			}
		}
		output="&nbsp;&nbsp;&nbsp;$"+min;
			if ( max != min ) {
				output+= " - $" + max;
			} 
		output+=" </strong>";//+eval("product"+productid+"_qtymsg");
		return output;
	}
	
	function removechar(instr,character) {
		while ( instr.indexOf(character) != -1 ) {
			instr=instr.replace(character,"");
		}
		return instr;
	}
	
	function setuparrays() {
		//: Setup ProductID Arrays
		for (j=0; j<=productids.length-1; j++) {					
			scolorids="";
			scolornames="";
			ssizeids="";
			ssizenames="";			
			for (k=0; k<=po_productid.length-1; k++) {
				if ( po_productid[k] == productids[j] && po_availabilityflag[k] == 1 ) {					
					if ( scolorids.indexOf("'"+po_colorids[k]+"'") == -1 ) {
						scolorids+="'"+po_colorids[k] + "',";
						scolornames+=po_colornames[k] + ",";
					} 										
					if ( ssizeids.indexOf("'"+po_sizeids[k]+"'") == -1 ) {
						ssizeids+="'"+po_sizeids[k] + "',";
						ssizenames+=po_sizenames[k] + ",";
					} 
				}				
			}									
			ssizeids = removechar(ssizeids,"'");
			scolorids = removechar(scolorids,"'");
			if ( ssizeids.substring(ssizeids.length-1,ssizeids.length) == "," ) {
				ssizeids=ssizeids.substring(0,ssizeids.length-1);
				ssizenames=ssizenames.substring(0,ssizenames.length-1);
			}
			if ( scolorids.substring(scolorids.length-1,scolorids.length) == "," ) {
				scolorids=scolorids.substring(0,scolorids.length-1);
				scolornames=scolornames.substring(0,scolornames.length-1);
			}				
			if ( ssizeids.length == 0 ) {
				eval("sizeids_"+productids[j]+"=new Array();");
			} else {
				eval("sizeids_"+productids[j]+"=ssizeids.split(',');");
			}
			if ( ssizenames.length == 0 ) {
				eval("sizenames_"+productids[j]+"=new Array();");
			} else {
				eval("sizenames_"+productids[j]+"=ssizenames.split(',');");
			}
			if ( scolorids.length == 0 ) {
				eval("colorids_"+productids[j]+"=new Array();");
			} else {
				eval("colorids_"+productids[j]+"=scolorids.split(',');");
			}			
			if ( scolornames.length == 0 ) {
				eval("colornames_"+productids[j]+"=new Array();");
			} else {
				eval("colornames_"+productids[j]+"=scolornames.split(',');");
			}
						
			//: Sort colornames,colorids
			doublearraysort(eval("colornames_"+productids[j]),eval("colorids_"+productids[j]));
			
			//: Set ranges				
			var srange = "<strong>#"+productskus[j]+"&nbsp;&nbsp;<font class='BlueText'><font size='1'>";
			
			if ( eval("sizeids_"+productids[j]+"[0]") != null && eval("sizeids_"+productids[j]+"["+Number(eval("sizeids_"+productids[j]+".length")-1)+"]") != null && Number( eval("sizeids_"+productids[j]+".length")-1 ) != 0 ) {
				srange+="Sizes "+eval("sizeids_"+productids[j]+"[0]")+"-"+eval("sizeids_"+productids[j]+"["+Number(eval("sizeids_"+productids[j]+".length")-1)+"]")+ "&nbsp;&nbsp;";
			}			
			var min = 0;			
			var max = 0;
								
			srange+=getminmax(productids[j],min,max);
			srange+="<BR><BR><img src='/assets/icons/right_arrow.gif' border='0' align='absmiddle'>&nbsp;<a href=\"javascript:popup('/popups/sizes.aspx','sizeinfo',600,400,'no','yes','no','yes','no');\">Size Information</a></font></font><BR><BR>";
			getElement('range'+productids[j]).innerHTML = srange;			
		}				
		return true;
	}
	
	function getprice(optionprice, productid, qty, pricegroup,indexNo) {
		if (typeof(indexNo)=="undefined") 
			indexNo=-1; 
		if ( qty == "-99" ) {
			qty = 1;
		}			
			numproducts = eval("product"+productid+"_initialcartqty");
			numproducts = numproducts + eval("pricegroup_"+pricegroup);
			
			//: Get # selected for SAME product or other products in price group
			for (m=0; m<=productids.length-1; m++) {
				if ( productids[m] == productid || eval("product_"+productids[m]+"_pricegroup") == eval("product_"+productid+"_pricegroup") ) {
					for (i=1; i<=5; i++) {
						if ( eval("document.main.qty"+productids[m]+"_"+i) != null ) {
							//: Check to see if selected
							if (  
									( eval("document.main.colors"+productids[m]+"_"+i) == null || eval("document.main.colors"+productids[m]+"_"+i+".value") != "-99" ) 
									&& ( eval("document.main.sizes"+productids[m]+"_"+i) == null || eval("document.main.sizes"+productids[m]+"_"+i+".value") != "-99" ) 
									&& ( eval("document.main.qty"+productids[m]+"_"+i+".value") != "-99" )
								) 
									{							
										numproducts=numproducts+Number(eval("document.main.qty"+productids[m]+"_"+i+".value"));																
									}													
						} else {
							//: That was last Element
							break;
						}	
					}
				}
			}
			
			
			
			//: Check Product Level Discounts
			x = eval("product"+productid+"_discounts.length");
			if ( numproducts > qty ) {
				if ( numproducts-1 > x-1 ) {
					discvalue = eval("product"+productid+"_discounts["+(x-1)+"]");
				} else {
					discvalue = eval("product"+productid+"_discounts["+(numproducts-1)+"]");
				}
			} else {
				discvalue = eval("product"+productid+"_discounts["+(qty-1)+"]");
			}
			
			//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
			//: Check Option Discounts to see if price break is greater
			if (typeof(po_discounts) != "undefined") {
				x = po_discounts[indexNo].length;
				if ( numproducts > qty ) {
					if ( numproducts-1 > x-1 ) {
						optiondiscvalue = po_discounts[indexNo][x-1];				//eval("product"+productid+"_discounts["+(x-1)+"]");
					} else {
						optiondiscvalue = po_discounts[indexNo][numproducts-1];		//eval("product"+productid+"_discounts["+(numproducts-1)+"]");
					}
				} else {
					optiondiscvalue = po_discounts[indexNo][qty-1]					//eval("product"+productid+"_discounts["+(qty-1)+"]");
				}
				
				//: Take lowest of price break vs. option price break
				//if (parseFloat(optiondiscvalue) < parseFloat(discvalue)) 
					discvalue=optiondiscvalue;
			}
			//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
					
					
			//: check to see if option is on sale and less than qty disc
			if ( parseFloat(optionprice) < parseFloat(discvalue) ) {
				return optionprice;
			} else {
				return discvalue;
			}		
	}
	
	function checkqtyselection(productid, instanceno) {
	bsizeselected = true;
	bcolorselected = true;
	bsizeavail = false;
	bcoloravail = false;
		if ( getFormElement('sizes'+productid+'_'+instanceno) != null ) {
			bsizeavail = true;
			if ( getFormElement('sizes'+productid+'_'+instanceno).value.toString() == "-99" ) {
				bsizeselected = false;
			}
		} else {
			bsizeselected = false;
		}
		if ( getFormElement('colors'+productid+'_'+instanceno) != null ) {
			bcoloravail = true;
			if ( getFormElement('colors'+productid+'_'+instanceno).value.toString() == "-99" ) {
				bcolorselected = false;
			}
		} else {
			bcolorselected = false;
		}
		if ( (!(bsizeselected) && bsizeavail) || (!(bcolorselected) && bcoloravail) ) {
			getFormElement('qty'+productid+'_'+instanceno).selectedIndex = 0;
			getFormElement('sku'+productid+'_'+instanceno).value=0;
			if ( bsizeavail && bcoloravail ) {
				alert("Please select a Size & Color first.");
			} else if ( bsizeavail ) {
				alert("Please select a Size first.");
			} else if ( bcoloravail ) {
				alert("Please select a Color first.");
			}
			return false;			
		} else {
			return true;
		}
	}

	function pcase(instring){
		var strReturn_Value = "";
		var iTemp = instring.length;
		var start = 1;
		if(iTemp==0){
			return"";
		}
		var UcaseNext = false;
		strReturn_Value += instring.charAt(0).toUpperCase();
		
		if((instring.charCodeAt(0) == 120) && (instring.charCodeAt(1) == 120)) {
			strReturn_Value += instring.charAt(1).toUpperCase();
			start=2;
		}
		for(var iCounter=start;iCounter < iTemp;iCounter++){			
			if(UcaseNext == true){
				strReturn_Value += instring.charAt(iCounter).toUpperCase();
			}
			else{
				strReturn_Value += instring.charAt(iCounter).toLowerCase();
			}
			
			var iChar = instring.charCodeAt(iCounter);
			if(iChar == 32 || iChar == 45 || iChar == 47){
				UcaseNext = true;
			}
			else{
				UcaseNext = false;
			}		
		}
		return strReturn_Value;
	}
	
	function injectddl(spanprefix, productnumber, instanceno, productid, bsetmoreproducts) {
	colorsempty = false;
	sizesempty = false;
	bonesize = false;
	bonecolor = false;
	
	if ( bsetmoreproducts == true ) { bsetmoreproducts = 1; }
		
	var sHTML = '';
		sHTML += '<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\">';
		sHTML += '<tr>';
		
		//: Size DDL
		x = eval('sizeids_'+productid);
		y = eval('sizenames_'+productid);		
		if ( x.length == 0 && y.length == 0 ) {
			sizesempty = true;
		} else {
			sHTML += '<td nowrap><select class=\"medium\" name=\"sizes'+productid+'_'+instanceno+'\" onchange=\"getavailabilityproduct('+productid+', '+instanceno+')\">\n';
			sHTML += '<option value=\"-99\">Size</option>\n';
			for (k=0; k<=x.length-1; k++) {			
				sHTML += '<option value=\"' + x[k] + '\"';
				if ( x.length-1 == 0 ) {
					//: only one element
					bonesize = true;
					sHTML += ' selected ';
				}
				if (y[k].length > 3)
					sHTML += '>' + pcase(y[k]) + '</option>\n';			
				else
					sHTML += '>' + y[k].toUpperCase() + '</option>\n';				
			}
			sHTML += '</select>';
			sHTML += '</td>';
		}
		
		//: Color DDL
		x = eval('colorids_'+productid);
		y = eval('colornames_'+productid);
		if ( x.length == 0 && y.length == 0 ) {
			colorsempty = true;
		} else {
			sHTML += '<td nowrap><select class=\"medium\" name=\"colors'+productid+'_'+instanceno+'\" onchange=\"getavailabilityproduct('+productid+', '+instanceno+');if (typeof(announcecolor)!=\'undefined\') { announcecolor('+productid+',this.value,this.options[this.selectedIndex].text); } \">\n';
			sHTML += '<option value=\"-99\">Color</option>\n';		
			for (k=0; k<=x.length-1; k++) {
				sHTML += '<option value=\"' + x[k] + '\"';
				if ( x.length-1 == 0 ) {
					//: only one element
					sHTML += ' selected ';
					bonecolor = true;
				}
				sHTML += '>' + pcase(y[k]) + '</option>\n';
			}		
			sHTML += '</select>';
			sHTML += '</td>';
		}						
		
		//: Quantity DDL
		sHTML += '<td align=\"left\" nowrap>';
		sHTML += '<select class=\"medium\" name=\"qty'+productid+'_'+instanceno+'\" onchange=\"checkqtyselection('+productid+', '+instanceno+');';
		sHTML += 'getavailabilityproduct('+productid+', '+instanceno+',1);'
		sHTML += '\">\n';		
		sHTML += '<option value=\"-99\">Qty</option>\n';
		for (k=1; k<=10; k++) {
			sHTML += '<option value=\"' + (k) + '\">' + (k) + '</option>\n';			
		}		
		sHTML += '</select>';
		//: Sku Hidden Field		
		sHTML += '</td><td width=\"100%\">';
		sHTML += '<input type=\"hidden\" name=\"sku'+productid+'_'+instanceno+'\" value=\"0\" >';
		sHTML += '<input type=\"hidden\" name=\"productdisplayid'+productid+'_'+instanceno+'\" value=\"'+eval("product_"+productid+"_productdisplayid")+'\" >';
		//: Availability
		sHTML += '<span class=\"small\" id=\"availability'+productid+'_'+instanceno+'\" class=\"medium\"></span>\n';
		sHTML += '</td></tr></table>';		
		
		getElement(spanprefix+productnumber+'_'+instanceno).innerHTML=sHTML;	
		if ( bsetmoreproducts == 1 && (!(bonecolor && bonesize)) ) { 
			setmoreproducts(); 
		}

		if ( parseFloat(instanceno) > parseFloat(1) ) {
			//: Set Size
			if ( getFormElement('sizes'+productid+'_'+instanceno) != null ) {
				getFormElement('sizes'+productid+'_'+instanceno).selectedIndex = getFormElement('sizes'+productid+'_'+Number(instanceno-1)).selectedIndex;
			}
		}	
		
	}

	function getindexof(pid,cid,sid) {
		output = -1;
		var stest = "";		
		for (z=0; z<=po_productid.length-1; z++) {			
			if (po_productid[z] == pid && (po_colorids[z] == cid || cid=='') && (po_sizeids[z] == sid || sid=='')) {
				output = z;
				break;
			}
		}				
		return output;				
	}

	function getavailability(productid, instanceno, fromqty, originstance, donotset) {
		if ( donotset == null ) {
			donotset = false;
		}

		//: If qty is selected then set qty back to 'qty' if there is not 
		//: both of the required criteria
			bsizeselected = true;
			bcolorselected = true;
			bsizeavail = false;
			bcoloravail = false;
				
			if ( getFormElement('sizes'+productid+'_'+instanceno) != null ) {
				bsizeavail = true;
				if ( getFormElement('sizes'+productid+'_'+instanceno).value == "-99" ) {
					bsizeselected = false;
				}
			} else {
				bsizeselected = false;
			}
			if ( getFormElement('colors'+productid+'_'+instanceno) != null ) {
				bcoloravail = true;
				if ( getFormElement('colors'+productid+'_'+instanceno).value == "-99" ) {
					bcolorselected = false;
				}
			} else {
				bcolorselected = false;
			}
			
			if ( ( (!(bsizeselected) && bsizeavail) || (!(bcolorselected) && bcoloravail) ) && getFormElement('qty'+productid+'_'+instanceno).selectedIndex != 0 ) {
				getFormElement('qty'+productid+'_'+instanceno).selectedIndex = 0;
				getFormElement('sku'+productid+'_'+instanceno).value=0;
			} 
					
		indexno = "";
		if ( getFormElement('qty'+productid+'_'+instanceno) != null ) {
			
			if ( getElement('availability'+productid+'_'+instanceno) != null ) {
					if ( getFormElement('colors'+productid+'_'+instanceno) != null ) {
						var colorvalue = getFormElement('colors'+productid+'_'+instanceno).value;
					} else {
						var colorvalue = "";
					}
					if ( getFormElement('sizes'+productid+'_'+instanceno) != null ) {
						var sizevalue  = getFormElement('sizes'+productid+'_'+instanceno).value;
					} else {
						var sizevalue  = "";
					}										
					indexno = getindexof(productid,colorvalue,sizevalue);				
										
				if ( output == -1 && ((getFormElement('colors'+productid+'_'+instanceno) == null || colorvalue != "-99") && (getFormElement('sizes'+productid+'_'+instanceno) == null || sizevalue != "-99")) ) {
					getElement('availability'+productid+'_'+instanceno).innerHTML="<img src='/assets/warning.gif' border='0' align='absmiddle'>&nbsp;<font class='redtext'><b>Not Available</b></font>";
					getFormElement('qty'+productid+'_'+instanceno).value="-99";
					getFormElement('sku'+productid+'_'+instanceno).value=0;	
				} else if ( indexno == -1 ) {										
					//: Not Found
					getElement('availability'+productid+'_'+instanceno).innerHTML=""
					getFormElement('sku'+productid+'_'+instanceno).value=0;					
				} else {											
					//: Found					
					//: Set qty to 1 if currently 0
					
					if ( !donotset ) {					
						if ( (fromqty != true ) && (po_availabilityflag[indexno] == 1) && (getFormElement('qty'+productid+'_'+instanceno).value == "-99") ) {						
							if ( originstance == null || originstance == instanceno ) {
								getFormElement('qty'+productid+'_'+instanceno).value = 1;
							}
						} else if ( (fromqty == true ) && getFormElement('qty'+productid+'_'+instanceno).value.toString() == "-99" ) {											
							//: If from qty ddl and set to 0, leave at 0 and wipe out availability
							getElement('availability'+productid+'_'+instanceno).innerHTML="";
							getFormElement('sku'+productid+'_'+instanceno).value=0;
						}	
					} 	
					
						if ( po_availabilityflag[indexno] != 1 ) { //&& getFormElement('qty'+productid+'_'+instanceno).value.toString() != "-99") {
							getElement('availability'+productid+'_'+instanceno).innerHTML = po_availability[indexno];
							getFormElement('sku'+productid+'_'+instanceno).value="0";
							getFormElement('qty'+productid+'_'+instanceno).value="-99";
						} else if ( getFormElement('qty'+productid+'_'+instanceno).value.toString() != "-99") {
							//: Ets Added Index No
							getElement('availability'+productid+'_'+instanceno).innerHTML = po_availability[indexno]+"<span class='small'><font color='#333333'>&nbsp;$"+getprice(po_prices[indexno],productid,getFormElement('qty'+productid+'_'+instanceno).value,po_pricegroup[indexno],indexno)+" ea.</font></span>";
							getFormElement('sku'+productid+'_'+instanceno).value=po_skus[indexno];
						}
				}				
			} 
		} 	
	}

function getavailabilityproduct(productid, instanceno, fromqty) {
		getavailability(productid, instanceno, fromqty, instanceno);		
		for (n=1; n<=5; n++) {		
			if ( getFormElement('qty'+productid+'_'+n) != null ) {				
				if ( n != instanceno ) {
					getavailability(productid, n, false,instanceno);					
				}								
			} else {
				break;
			}
		}
				
		//: Check other products in the same pricegroup
		for (pcnt=0; pcnt<=productids.length-1; pcnt++) {
			if ( productids[pcnt] != productid && eval("product_"+productids[pcnt]+"_pricegroup") == eval("product_"+productid+"_pricegroup") ) {
				for (n=1; n<=5; n++) {		
					if ( getFormElement('qty'+productids[pcnt]+'_'+n) != null ) {				
							getavailability(productids[pcnt], n, false,instanceno,true);		
							//alert('getavailability('+productids[pcnt]+','+n+',false,'+instanceno+');');			
					} else {
						break;
					}
				}	
			}		
		}
		
		return true;
	}
	
	function injectinitial() {		
		setuparrays();
		for (j=0; j<=productids.length-1; j++) {					
			injectddl('ddl',Number(j+1),1,productids[j],0);
		}
		setmoreproducts();
	}
	
function setmoreproducts() {	
		for (m=0; m<=productids.length-1; m++) {	
		bonecolor = false;
		bonesize = false;
		bcoloravail = true;
		bsizeavail = true;
		lastinstance = 6;				
			for (l=1; l<=5; l++) {
				if ( getFormElement('qty'+productids[m]+'_'+l) != null ) {
					//: Element Exists
					lastinstance = l;
				} else {
					//: That was last Element
					break;
				 }
			}
			
			if ( ( getFormElement('sizes'+productids[m]+'_'+lastinstance) != null || getFormElement('colors'+productids[m]+'_'+lastinstance) != null) && Number(lastinstance+1) < 6 ) {
				//: make sure there is more than one item on sizes or colors
				if ( getFormElement('sizes'+productids[m]+'_'+lastinstance) != null ) {
					if ( getFormElement('sizes'+productids[m]+'_'+lastinstance).options.length < 3 ) {
						bonesize=true;
					}	
				} else {
					bsizeavail = false;
				}
				
				if ( getFormElement('colors'+productids[m]+'_'+lastinstance) != null ) {
					if ( getFormElement('colors'+productids[m]+'_'+lastinstance).options.length < 3 ) {
						bonecolor=true;
					}	
				} else {
					bcoloravail = false;
				}
				
				bsetmore = false;
				selectmoremessage="Select Multiple Sizes/Colors";
				if ( bsizeavail && bcoloravail ) {
					if ( !bonesize && !bonecolor ) {
						bsetmore=true;						
						selectmoremessage="Select Multiple Sizes/Colors";
					} else if (!bonesize && bonecolor) {
						bsetmore=true;						
						selectmoremessage="Select Multiple Sizes";
					} else if (bonesize && !bonecolor) {
						bsetmore=true;						
						selectmoremessage="Select Multiple Colors";
					}
				} else if ( bsizeavail && !bcoloravail ) {
					if ( !(bonesize) ) {
						bsetmore=true;
						selectmoremessage="Select Multiple Sizes";
					}
				} else if ( !bsizeavail && bcoloravail ) {
					if ( !(bonecolor) ) {
						bsetmore=true;
						selectmoremessage="Select Multiple Colors";
					}				
				}
									
				if ( bsetmore ) {
					getElement('ddl'+Number(m+1)+'_'+Number(lastinstance+1)).innerHTML="&nbsp;<font class='bluetext'><font class='small' style='font-weight:normal'><a href='javascript:injectddl(\"ddl\","+Number(m+1)+","+Number(lastinstance+1)+","+productids[m]+",1);'>"+selectmoremessage+" ></a></font></font>";
				}
			}			
		}
	}
	
	function getAddToCartPostMode() {
		if (typeof(addtocart_postmode) == "undefined") {
			return("regular");
		} else {
			return(addtocart_postmode.toString());
		}
	}
	
	function addtocart(dest) {						
		if ( typeof(dest)=="undefined") dest = defaultdestination;
		var addtocart_mode=getAddToCartPostMode();
		numproducts = 0;
		spost = "";
		for (m=0; m<=productids.length-1; m++) {					
				for (l=1; l<=5; l++) {
					if ( getFormElement('qty'+productids[m]+'_'+l) != null ) {
						//: Element Exists
						lastinstance = l;
						//: Check to see if selected
						if ( (getFormElement('colors'+productids[m]+'_'+l) == null || getFormElement('colors'+productids[m]+'_'+l).value != "-99") && ( getFormElement('sizes'+productids[m]+'_'+l) == null || getFormElement('sizes'+productids[m]+'_'+l).value != "-99") && getFormElement('qty'+productids[m]+'_'+l).value != "-99" && getFormElement('sku'+productids[m]+'_'+l).value != "0" ) {
							numproducts=numproducts+1;							
							spost+="&productsku"+numproducts+"="+escape( getFormElement('sku'+productids[m]+'_'+l).value )+"&productqty"+numproducts+"="+escape( getFormElement('qty'+productids[m]+'_'+l).value)+"&productdisplayid"+numproducts+"="+escape(getFormElement('productdisplayid'+productids[m]+'_'+l).value);
							
							if ( addtocart_mode=="dynamic" ) {
								spost += "&branch"+numproducts+"="+escape(eval("product_"+productids[m]+"_branch"));
							}
						}													
					} else {
						//: That was last Element
						break;
					}
				}				
		}
		if ( numproducts == 0 ) {
			alert("Please select an item/qty first.");					
		} else {
			if ( productdisplayid != 0 ) {
				spost = dest + "?source="+escape(source)+"&productdisplayid="+productdisplayid+"&BRANCH="+branch+"&numformitems="+numproducts+spost;
				
			} else if ( addtocart_mode == "dynamic" ) {
				spost = dest + "?source="+escape(source)+"&addtocart_mode="+escape(addtocart_mode)+"&numformitems="+numproducts+spost;
				
			} else if ( productdisplaygroupid != null ) {
				spost = dest + "?source="+escape(source)+"&productdisplaygroupid="+productdisplaygroupid+"&BRANCH="+branch+"&numformitems="+numproducts+spost;
			} 
			location.href=spost;
		}
	}
	
	function setcolor(obj,val) {
		obj.value=val;
	}