<!-- PreLoad Wait - Script -->
		function preloadPopUp()
		{
			setTimeout('wait()',750);
		}
		// End -->
		<!--
		function wait() { //DOM
			if (document.getElementById){
				document.getElementById('preload').style.display='none';
				document.getElementById('body').style.visibility='visible';
				document.getElementById('body').style.dispaly='block';
			}else{
				if (document.layers){ //NS4
					document.preload.display = 'none';
					document.body.visibility='visible';
					document.body.style.dispaly='block';
				}
				else { //IE4
					document.all.preload.style.display = 'none';
					document.all.body.style.visibility='visible';
					document.all.body.style.dispaly='block';
				}
			}
		}

		function MM_preloadImages() { //v3.0
			var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
				var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
				if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
		}
		
		function MM_swapImgRestore() { //v3.0
			var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
		}
		
		function MM_findObj(n, d) { //v4.01
			var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
				d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
			if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
			for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
			if(!x && d.getElementById) x=d.getElementById(n); return x;
		}
		
		function MM_swapImage() { //v3.0
			var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
			 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
		}
		function MM_openBrWindow(theURL,winName,features) { //v2.0
			window.open(theURL,winName,features);
		}
		//-->
		function addToCart(){
			document.getElementById('divProduct').style.visibility = 'hidden';
			document.getElementById('divLoading').style.display = 'block';
			var browserName=navigator.appName; 
			
			if (browserName=="Microsoft Internet Explorer"){
				 var frm=document.getElementById('printingForm');
			     var act =frm.action;
				 jQuery.ajax({  		   
				 url: act, 				   
				 type: "POST",  
				 data: jQuery("#printingForm").serialize(),
				 success: callbackShipCart

				 });
			}else{
			submitForm('printingForm',document.getElementById('printingForm').action,callbackShipCart);
			}
		}
		function fRemove()
		{
		
         document.getElementById("divProduct").style.visibility = "hidden";
			document.getElementById("divLoading").style.display = "block";
			var browserName=navigator.appName; 
			
			if (browserName=="Microsoft Internet Explorer"){
				
				 jQuery.ajax({  		   
				 url: "../cw3/removeFromCart.cfm", 
				   
				 type: "POST",  
				 data: jQuery("#updatecart").serialize(),
				 success: callbackCart

				 });
			
			}
			else{
		//	document.getElementById("divProduct").style.visibility = "hidden";
		//	document.getElementById("divLoading").style.display = "block";
			
			submitForm('updatecart','../cw3/removeFromCart.cfm',callbackCart)
		  }
		}
		
		function fGetShipping(obj){
			obj.value=obj.value.toUpperCase();
			res = /^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Za-z]{1} *\d{1}[A-Z]{1}\d{1} *$/.test(obj.value.toUpperCase());
			
			if (res==false){
			   
				if(document.getElementById('taxPST') &&  document.getElementById('taxHST')&& document.getElementById('taxDefaultHST')){
				 document.getElementById('taxHST').innerHTML=document.getElementById('taxDefaultHST').value;}
				if(document.getElementById('taxGST')) document.getElementById('taxGST').innerHTML=document.getElementById('taxDefaultGST').value;
				if(document.getElementById('shipping')) document.getElementById('shipping').innerHTML=document.getElementById('shipUPS').value;
				if(document.getElementById('totalDefault') && document.getElementById('grandTotal')) document.getElementById('grandTotal').innerHTML=document.getElementById('totalDefault').value;
				if(document.getElementById('shippingMethod'))
				   document.getElementById('shippingMethod').style.display = 'none'
			
				document.getElementById('PostalCodeContent').className= 'postalCodeContent1';
				document.getElementById('PostalCodeContent').innerHTML='Shipping:<br/> Enter your Postal Code:';
			//	obj.style.border="none";
			/**	document.getElementById('PostalCodeNotEnter').style.border="2px solid #a10900";*/
				obj.focus();
				return false;
			}
			else{
				if(document.getElementById('ShipWeight').value > 3000){
					alert('Your purchases weigh over 3000 pounds and will be sent to you by truck rather than UPS.\n Please call before completing your order.\n\n Call 1 888 587 2383.\n');
				}
				document.getElementById('cstShpZipHidden').value=obj.value;
				
				//obj.style.border="1px solid #001128";
			//	document.getElementById('PostalCodeNotEnter').style.border="none";
			
				document.getElementById('PostalCodeContent').className='postalCodeContent2';
			
				document.getElementById('PostalCodeContent').innerHTML='Shipping:<br/> Enter your Postal Code:';
				obj.disabled="true";
				obj.value="Please Wait...";
				
				 if("\v"=="v"){
	               var frm = document.getElementById("updatecart");
				 
				 //  frm.submit();
				    jQuery.ajax({  
			      	 url: "../cfincludes/Cart.cfm", 
				    type: "POST",  
				 data: jQuery("#updatecart").serialize(),
				//Do not cache the page  
				cache: false,  
				  
				//success  
				 success: function (data) { 			 
				   callbackCart(data);
				
						
				 }         
			});  		
					}else{
				       submitForm('updatecart','../cfincludes/Cart.cfm',callbackCart);
					}
			}
		
		}
		
		function fSelect(obj, showMess){
			
			var shipMethod=document.getElementById('shipMethod');
			var postalCode=document.getElementById('cstShpZip');
			shipMethod.disabled="true";
			postalCode.disabled="true";
			shipMethod.options[shipMethod.selectedIndex].text="Please Wait...";
			var temp = new Array();
			temp = obj.split('_');
			if(showMess){
			if(temp[0]=="Pickup"){
				alert('If you want to pick up, please call before completing your order.\r\rOur suppliers are scattered all over Ontario. Before placing your order, please speak with us to verify that picking up your order is practical.\r\r Call 1 888 587 2383.\r');
			  }
			}
		 document.getElementById('Shipoption').value=temp[0];
		 document.getElementById('ShipTotal').value=temp[1];
		 document.getElementById('PickShipPref').value=temp[2];
		 document.getElementById('actionCart').value="select";
		

		 submitForm('updatecart','../cfincludes/Cart.cfm',callbackShipCart);
			
		}		
		function fCheckOut(obj){
		// if(document.getElementById('Shipoption').value=="" || document.getElementById('cstShpZip').value==""){
			// alert('Please enter your postal code and choose a shipping method');
			// document.getElementById('cstShpZip').focus();
			 //return false;
		 //}
		// else {
		 document.formCheckOut.submit();
		 //}
			
		}
		function submitForm(formName,template, callback) {
		
				
			
			ColdFusion.Ajax.submitForm(formName, template, callback,errorHandler);
			
		}
		function callbackCart(text)
		{   
		
					document.getElementById('theDiv').innerHTML=text;
				if(document.getElementById('shipMethod')){
					var objShipMethod=document.getElementById('shipMethod');
					if(objShipMethod.selectedIndex != -1) fSelect(objShipMethod.options[objShipMethod.selectedIndex].id);
				}
		
		}
		function callbackShipCart(text)
		{
		document.getElementById('theDiv').innerHTML=text;
		}
		
		function errorHandler(code, msg)
		{
		alert("Error!!! " + code + ": " + msg);
		}
		fDefaultShipping = function() {
			if(document.getElementById('shipMethod')){
				var objShipMethod=document.getElementById('shipMethod');
				if(objShipMethod.selectedIndex != -1) fSelect(objShipMethod.options[objShipMethod.selectedIndex].id);
			}
		}
		
		
		// This is to shorten getElementById()
		// ref: http://www.dustindiaz.com/top-ten-javascript/
		// author: Vlad
			function $() {
				var elements = new Array();
				for (var i = 0; i < arguments.length; i++) {
					var element = arguments[i];
					if (typeof element == 'string')
						element = document.getElementById(element);
					if (arguments.length == 1)
						return element;
					elements.push(element);
				}
				return elements;
			}
function trim(s)
{
	return rtrim(ltrim(s));
}

function ltrim(s)
{
	var l=0;
	while(l < s.length && s[l] == ' ')
	{	l++; }
	return s.substring(l, s.length);
}

function rtrim(s)
{
	var r=s.length -1;
	while(r > 0 && s[r] == ' ')
	{	r-=1;	}
	return s.substring(0, r+1);
}

function showWin(name, location,x,y,hi,wi, closebool){
	//	ColdFusion.Window.show(name);
	 var winName=name;
      ColdFusion.Window.create(winName,'',location,{x:x,y:y, height:hi, width:wi,closable:closebool,destroyonclose:true,resizable:false,draggable:true});
    
	}
	
	function closeAudio(name){
		 ColdFusion.Window.destroy(name,true);
	}

	 /**Edit the special item discount in the vte edition*/
		function goEditDiscount() {			
			
			
			submitForm('updatecart','/vte/cfincludes/Cart.cfm',callbackCart)
		}
	
	
