if(location.href.match(new RegExp(/Articles.asp\?ID=140/))){ //|Articles.asp\?ID=140 ProductDetails.asp\?ProductCode=1001
if(window.attachEvent){window.attachEvent("onload",initBottlePicker);}else{if(window.addEventListener){window.addEventListener("load",initBottlePicker,false);}} 
try{var hasProductInstall=DetectFlashVer(6,0,65);var hasRequestedVersion=DetectFlashVer(9,0,28);if(hasProductInstall && !hasRequestedVersion){var MMPlayerType=(isIE==true)?"ActiveX":"PlugIn";var MMredirectURL=window.location;document.title=document.title.slice(0,47)+" - Flash Player Installation";var MMdoctitle=document.title;AC_FL_RunContent("src","/v/vspfiles/assets/images/playerProductInstall","FlashVars","MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"","width","100%","height","100%","align","middle","id","BottlePicker","quality","high","bgcolor","#ffffff","name","BottlePicker","allowScriptAccess","sameDomain","wmode","transparent","type","application/x-shockwave-flash","pluginspage","http://www.adobe.com/go/getflashplayer");}else if(hasRequestedVersion){AC_FL_RunContent("src","/v/vspfiles/assets/images/BottlePicker","width","100%","height","1400","align","middle","id","BottlePicker","quality","high","bgcolor","#ffffff","name","BottlePicker","flashvars","assetsPath=/v/vspfiles/assets/images/","allowScriptAccess","sameDomain","wmode","transparent","type","application/x-shockwave-flash","pluginspage","http://www.adobe.com/go/getflashplayer");}else{var alternateContent='This content requires the Adobe Flash Player. <a href="http://www.adobe.com/go/getflash/">Get Flash</a>';document.write(alternateContent);}}catch(e){}}
var bp=null;
var isDebug = false;
function initBottlePicker(){
//initDebugger();
//	getElem("div","id","content_area").style.display="none";
//	getElem("div","id","display_cart_summary").style.display="none";
	bp=new BottlePicker();
	var w=0;
	var h=0;
	if(isDebug){
		w=800;
		h=1000;
	}
	bp.iframe=bp.createIframe(bp.innerframeName,w,h); //500,1000
	if(bp.iframe){bp.frameLoadedTimeOut=setTimeout("bp.setFormTargetToParent()",700);}
}
/*var debugBox=null;
function initDebugger(){debugBox=document.createElement("div");debugBox.innerHTML="";debugBox.setAttribute("id","debuggerBox");debugBox.style.position="absolute";debugBox.style.right="0";debugBox.style.zindex="100000";debugBox.style.width="400px";debugBox.style.height="400px";debugBox.style.border="4px groove red";debugBox.style.padding="5px";debugBox.style.fontFamily='"Courier New", Courier, monospace"';debugBox.style.fontSize="12px";document.body.appendChild(debugBox);}
function trace(str){debugBox.innerHTML += "<br/>" + ((str!=null)?str.toString():"null");}*/
function PickBottle(productCode,labelType,quantity,contactName,contactEmail,productName,tagLine,distributedBy,notes,lotCoding,shrinkWrap,shrinkBand,inductionSeal,labelName,labelProof,labelReorder){
//	trace("PickBottle(productCode: "+productCode
//					+", labelType:"+labelType
//					+", quantity: "+quantity+",...)");
	bp.productCode=productCode;
	bp.setProduct();
	bp.labelProof=((labelProof=='false')?false:true);
	bp.labelReorder=((labelReorder=='false')?false:true);
	bp.labelType=labelType;
	bp.labelQuantity=quantity;
	bp.contactName=contactName;
	bp.contactEmail=contactEmail;
	bp.productName=productName;
	bp.tagLine=tagLine;
	bp.distributedBy=distributedBy;
	bp.notes=notes;
	bp.lotCoding=lotCoding;
	bp.quantity=quantity;
	bp.shrinkWrap=((shrinkWrap=='false')?false:true);
	bp.shrinkBand=((shrinkBand=='false')?false:true);
	bp.inductionSeal=((inductionSeal=='false')?false:true);
	bp.labelName=labelName;
	bp.timeOutSetProducts=setTimeout("bp.submitProductSelections()",500);
}	
function BottlePicker(){	
	this.productCode="";
	this.labelType="NONE";
	this.labelQuantity="";
	this.labelProof=false;
	this.labelReorder=false;
	this.contactName="";
	this.contactEmail="";
	this.productName="";
	this.tagLine="";
	this.distributedBy="";
	this.notes="";
	this.lotCoding="";
	this.quantity="";
	this.shrinkWrap=false;
	this.shrinkBand=false;
	this.inductionSeal=false;
	this.labelName="";
	this.frameLoadedTimeOut=null;
	this.framePageLoadedTimeOut=null;
	this.timeOutSetProducts=null;
	this.frameSrc="about:blank";
	this.innerframeName="bottlePicker";
	this.innerframeFormName="MainForm";
	this.innerframeDoc=null;
	this.createIframe=function(iframeName,width,height){
		var iframe;
		if (document.createElement && (iframe = document.createElement('iframe'))){
			iframe.setAttribute("id",iframeName);
			iframe.width=width;
			iframe.height=height;
			if(!isDebug){
				iframe.style.visibility = 'hidden';
			}
			iframe.src=this.frameSrc;
			document.body.appendChild(iframe);
		}
		return iframe;
	};
	this.setFormTargetToParent=function(){
		var iframeDoc=this.getframeElement(this.innerframeName);
		if(iframeDoc){try{iframeDoc.forms[this.innerframeFormName].setAttribute("target","_parent");}catch(e){var thisBP=this;this.frameLoadedTimeOut=setTimeout(function(){thisBP.setFormTargetToParent();},50);}}
	};
	this.getframeElement=function(frameName){
		var iframeDoc;
		var iframe=document.getElementById(frameName);
		if(iframe.contentWindow){iframeDoc=iframe.contentWindow.document;}
		else if(iframe.contentDocument){iframeDoc=iframe.contentDocument;}//Opera
		else{iframeDoc=window.frames[this.innerframeName].document;}//IE7
		this.innerframeDoc=iframeDoc;
		return iframeDoc;
	};
	this.setProduct=function(){
		this.frameSrc="ProductDetails.asp?ProductCode="+this.productCode;
		this.iframe.src=this.frameSrc;
	};
	this.submitProductSelections=function(){
	    try{this.selectLabelType(this.labelType);
		this.selectLabelQuantity(this.labelQuantity);
		this.setContactName(this.contactName);
		this.setContactEmail(this.contactEmail);
		this.setProductName(this.productName);
		this.setTagLine(this.tagLine);
		this.setDistributedBy(this.distributedBy);
		this.setContactNotes(this.notes);
		this.setLotCoding(this.lotCoding,this.quantity);
		this.setShrinkWrap(this.shrinkWrap,this.quantity);
		this.setShrinkBand(this.shrinkBand,this.quantity);
		this.setInductionSeal(this.inductionSeal,this.quantity);
		this.setLabelProof(this.labelProof);
		this.setLabelName(this.labelName);
		this.pressAddToCart();
		}catch(e){var thisBP=this; this.framePageLoadedTimeOut=setTimeout(function(){thisBP.submitProductSelections();},100);/*throw e;*/}
	};
	this.selectLabelType=function(typ){
		var val="119"; 
		switch(typ){
			case "TEMPLATE":{val="120";break;}
			case "CUSTOM":{val="121";if(this.labelReorder){val="166";};break;}
			case "CUSTOMERPROVIDED":{val="175";break;}
			default:{val="119";break;}//"NONE"
		}		
		this.getElem("input","value",val).checked=true;
	};
	this.selectLabelQuantity=function(typ){
		var val="127";
		if(this.labelType!=""){
			switch(typ){
				case "120":{val="113";break;}
				case "60":{val="114";break;}
				case "30":{val="115";break;}
				case "18":{val="116";break;}
				case "14":{val="117";break;}
				case "7":{val="118";break;}
				default:{val="127";break;}//"NONE"
			}
		}
		if(this.labelType=="CUSTOM"){
			switch(typ){
				case "120":{val="160";break;}
				case "60":{val="161";break;}
				case "30":{val="162";break;}
				case "18":{val="163";break;}
				case "14":{val="164";break;}
				case "7":{val="165";break;}
				default:{val="127";break;}//"NONE"
			}
		}
		if(this.labelType=="CUSTOMERPROVIDED"){
			switch(typ){
				case "120":{val="168";break;}
				case "60":{val="169";break;}
				case "30":{val="170";break;}
				case "18":{val="171";break;}
				case "14":{val="172";break;}
				case "7":{val="173";break;}
				default:{val="127";break;}//"NONE"
			}
		}
		this.setSelectedOption('SELECT___'+this.productCode+'___24',val);
	};
	this.setContactName=function(val){this.getElem("input","name","TEXTBOX___112___"+this.productCode+"___20").value=val;};
	this.setContactEmail=function(val){this.getElem("input","name","TEXTBOX___122___"+this.productCode+"___21").value=val;};
	this.setProductName=function(val){this.getElem("input","name","TEXTBOX___153___"+this.productCode+"___29").value=val;};
	this.setTagLine=function(val){this.getElem("input","name","TEXTBOX___154___"+this.productCode+"___30").value=val;};
	this.setDistributedBy=function(val){this.getElem("input","name","TEXTBOX___155___"+this.productCode+"___31").value=val;};
	this.setContactNotes=function(val){this.getElem("input","name","TEXTBOX___123___"+this.productCode+"___22").value=val;};
	this.setLabelName=function(val){this.getElem("input","name","TEXTBOX___156___"+this.productCode+"___32").value=val;};
	this.setLotCoding=function(val,typ){
		var lcode = val;
		this.getElem("input","name","TEXTBOX___98___"+this.productCode+"___16").value=val;
		var val="128";
		if(lcode.length>0){
			switch(typ){
				case "120":{val="129";break;}
				case "60":{val="130";break;}
				case "30":{val="131";break;}
				case "18":{val="132";break;}
				case "14":{val="133";break;}
				case "7":{val="134";break;}
				default:{val="128";break;}//"NONE"
			}
		}
		this.setSelectedOption('SELECT___'+this.productCode+'___28',val);
	};
	this.setShrinkWrap=function(isChecked,typ){
		var val="124";
//		trace("setShrinkWrap_isChecked: "+isChecked+" typ: "+typ);
		if(isChecked==true){
			switch(typ){
				case "120":{val="135";break;}
				case "60":{val="140";break;}
				case "30":{val="136";break;}
				case "18":{val="137";break;}
				case "14":{val="138";break;}
				case "7":{val="139";break;}
				default:{val="124";break;}//"NONE"
			}
		}
		this.setSelectedOption('SELECT___'+this.productCode+'___25',val);
	};
	this.setShrinkBand=function(isChecked,typ){
		var val="125";
//		trace("setShrinkBand_isChecked: "+isChecked+" typ: "+typ);
		if(isChecked==true){
			switch(typ){
				case "120":{val="141";break;}
				case "60":{val="142";break;}
				case "30":{val="152";break;}
				case "18":{val="143";break;}
				case "14":{val="144";break;}
				case "7":{val="145";break;}
				default:{val="125";break;}//"NONE"
			}
		}
		this.setSelectedOption('SELECT___'+this.productCode+'___26',val);
	};
	this.setInductionSeal=function(isChecked,typ){
		var val="126";
		if(isChecked){
			switch(typ){
				case "120":{val="146";break;}
				case "60":{val="147";break;}
				case "30":{val="148";break;}
				case "18":{val="149";break;}
				case "14":{val="150";break;}
				case "7":{val="151";break;}
				default:{val="126";break;}//"NONE"
			}
		}
		this.setSelectedOption('SELECT___'+this.productCode+'___27',val);
	};
	this.setLabelProof=function(isChecked){
		var lblProofElem = this.getElem('input','name','SELECT___'+this.productCode+'___33');
		lblProofElem.checked = isChecked;
	}
	this.pressAddToCart=function(){var e=this.getElem("input","name","btnaddtocart");if(!isDebug){this.doClick(e);}};
	this.doClick=function(obj){
		try {var evt=document.createEvent("MouseEvents");
			evt.initMouseEvent("click",true,true,window,0,0,0,0,0,false,false,false,false,0,null);
			var canceled=!obj.dispatchEvent(evt);
			if(canceled){//A handler called preventDefault
			}else{}//None of the handlers called preventDefault
		}catch(er){obj.click();}//IE
	};
	this.getElem=function(pTag,atrName,atrVal){if(this.innerframeDoc==null){this.innerframeDoc=this.getframeElement(this.innerframeName);}var e=this.innerframeDoc.getElementsByTagName(pTag);for(var i=0;i<e.length;i++){if(e[i].getAttribute(atrName)==atrVal){return e[i];}}return null;};
	this.setSelectedOption=function(elementName,val){if(this.innerframeDoc.MainForm.elements[elementName] && this.innerframeDoc.MainForm.elements[elementName].options && this.innerframeDoc.MainForm.elements[elementName].options.length>0){for(var i=0;i<this.innerframeDoc.MainForm.elements[elementName].options.length;i++){if(this.innerframeDoc.MainForm.elements[elementName].options[i].value==val){this.innerframeDoc.MainForm.elements[elementName].selectedIndex=i;return this.innerframeDoc.MainForm.elements[elementName];}}}}
}