﻿function LoginClick()
{
	if (event.keyCode == 13)
	{
		if (ValidateNewLogin() == true)
		{
			this.submit();
		}
	}
}
function UpdShippingRate() {
    if (document.getElementById('divShippingPreference')) document.getElementById('divShippingPreference').style.display = 'none';
    if (document.getElementById('divShippingCarrierEast')) document.getElementById('divShippingCarrierEast').style.display = 'none';
    if (document.getElementById('divShippingCarrierWest')) document.getElementById('divShippingCarrierWest').style.display = 'none';
    document.getElementById('divShippingLoading').style.display = 'block';
    document.getElementById('imageloader').style.display = 'block';
    setTimeout('document.images["imageloader"].src = "images/loader.gif"', 200);
    document.getElementById('updateshippingrate').value = '1';
    document.getElementById('shoppingcart').submit();
    //document.shoppingcart.submit();
}
function ValidateNewLogin()
{
	if (document.getElementById('customerTypeNew'))
	{
		if (document.getElementById('customerTypeNew').checked == true)
		{
			if (document.getElementById('userName').value == "")
			{
				alert('Please enter your email.');
				document.getElementById('userName').focus();
				return false;
			}
			if (document.getElementById('userName'))
			{
				var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
				var check=/@[\w\-]+\./;
				var checkend=/\.[a-zA-Z]{2,4}$/;
				
				emailad = document.getElementById('userName').value;
				
				if(((emailad.search(exclude) != -1)||(emailad.search(check))
				== -1)||(emailad.search(checkend) == -1)){
	  				alert("Incorrect email address! Please ammend.");
					document.getElementById('userName').focus();
					return false;
				}
			}
			if (document.getElementById('password').value == "")
			{
				alert('Please enter your password.');
				document.getElementById('password').focus();
				return false;
			}
			if (document.getElementById('passwordconfirm').value != document.getElementById('password').value)
			{
				alert('Passwords do not match.');
				document.getElementById('password').focus();
				return false;
			}
		}
	}
}
function ShowHideLogin()
{
	if (document.getElementById('customerTypeReturn'))
	{
		if (document.getElementById('customerTypeReturn').checked == true)
		{
			document.getElementById('divCustomerNew').style.display = 'none';
			return;
		}
		else
		{
			document.getElementById('divCustomerNew').style.display = 'block';
			return;
		}
	}
}
function CopyBillingInfo()
{
	if (document.getElementById('BillingShipping'))
	{
		if (document.getElementById('BillingShipping').checked == true)
		{
		    if (document.getElementById('Zip').value != document.getElementById('UpdShippingZip').value) {
		        document.getElementById('BillingShipping').checked = false;
		        document.getElementById('divShippingDetail').style.display = 'none';
		        document.getElementById('divShippingInfoMisMatch').style.display = 'block';
		        document.getElementById('divShippingInfoMisMatchFrom').value = 'popup';
		    }
		    else {
		        if (document.getElementById('FirstName')) document.getElementById('UpdShippingFirstName').value = document.getElementById('FirstName').value;
		        if (document.getElementById('LastName')) document.getElementById('UpdShippingLastName').value = document.getElementById('LastName').value;
		        if (document.getElementById('Address')) document.getElementById('UpdShippingAddress').value = document.getElementById('Address').value;
		        if (document.getElementById('Address2')) document.getElementById('UpdShippingAddress2').value = document.getElementById('Address2').value;
		        if (document.getElementById('City')) document.getElementById('UpdShippingCity').value = document.getElementById('City').value;
		        if (document.getElementById('State')) document.getElementById('UpdShippingState').value = document.getElementById('State').value;
		        if (document.getElementById('Zip')) document.getElementById('UpdShippingZip').value = document.getElementById('Zip').value;
		        if (document.getElementById('Phone')) document.getElementById('UpdShippingPhone').value = document.getElementById('Phone').value;
		    }
			//UpdShipping();
		}
		else
		{
			if (document.getElementById('FirstName')) document.getElementById('UpdShippingFirstName').value = "";
			if (document.getElementById('LastName')) document.getElementById('UpdShippingLastName').value = "";
			if (document.getElementById('Address')) document.getElementById('UpdShippingAddress').value = "";
			if (document.getElementById('Address2')) document.getElementById('UpdShippingAddress2').value = "";
			if (document.getElementById('City')) document.getElementById('UpdShippingCity').value = "";
			if (document.getElementById('State')) document.getElementById('UpdShippingState').value = "";
			if (document.getElementById('State')) document.getElementById('UpdShippingState').selectedIndex = -1;
			if (document.getElementById('Zip')) document.getElementById('UpdShippingZip').value = "";
			if (document.getElementById('Phone')) document.getElementById('UpdShippingPhone').value = "";
		}
	}
}
function CopyBillingInfoAdmin()
{
    if (document.getElementById('BillingShipping'))
	{
		if (document.getElementById('BillingShipping').checked == true)
		{
			if (document.getElementById('BillingFirstName')) document.getElementById('ShippingFirstName').value = document.getElementById('BillingFirstName').value;
			if (document.getElementById('BillingLastName')) document.getElementById('ShippingLastName').value = document.getElementById('BillingLastName').value;
			if (document.getElementById('BillingAddress1')) document.getElementById('ShippingAddress1').value = document.getElementById('BillingAddress1').value;
			if (document.getElementById('BillingAddress2')) document.getElementById('ShippingAddress2').value = document.getElementById('BillingAddress2').value;
			if (document.getElementById('BillingCity')) document.getElementById('ShippingCity').value = document.getElementById('BillingCity').value;
			if (document.getElementById('BillingState')) document.getElementById('ShippingState').value = document.getElementById('BillingState').value;
			if (document.getElementById('BillingZip')) document.getElementById('ShippingZip').value = document.getElementById('BillingZip').value;
			if (document.getElementById('BillingPhone1')) document.getElementById('ShippingPhone1').value = document.getElementById('BillingPhone1').value;
			//UpdShipping();
		}
		else
		{
			if (document.getElementById('BillingFirstName')) document.getElementById('ShippingFirstName').value = "";
			if (document.getElementById('BillingLastName')) document.getElementById('ShippingLastName').value = "";
			if (document.getElementById('BillingAddress1')) document.getElementById('ShippingAddress1').value = "";
			if (document.getElementById('BillingAddress2')) document.getElementById('ShippingAddress2').value = "";
			if (document.getElementById('BillingCity')) document.getElementById('ShippingCity').value = "";
			if (document.getElementById('BillingState')) document.getElementById('ShippingState').value = "";
			if (document.getElementById('BillingState')) document.getElementById('ShippingState').selectedIndex = -1;
			if (document.getElementById('BillingZip')) document.getElementById('ShippingZip').value = "";
			if (document.getElementById('BillingPhone1')) document.getElementById('ShippingPhone1').value = "";
		}
	}
}
function CopyBilling()
{
    if (document.getElementById('BillingShippingSame'))
	{
		if (document.getElementById('BillingShippingSame').checked == true)
		{
		    if (document.getElementById('Zip').value != document.getElementById('ShippingZipDisplay').value) {
		        document.getElementById('BillingShippingSame').checked = false;
		        grayOut(true);
		        document.getElementById('divShippingInfoMisMatch').style.display = 'block';
		        document.getElementById('divShippingInfoMisMatchFrom').value = 'main';
		    }
		    else {
		        if (document.getElementById('FirstName')) document.getElementById('ShippingFirstNameDisplay').value = document.getElementById('FirstName').value;
		        if (document.getElementById('LastName')) document.getElementById('ShippingLastNameDisplay').value = document.getElementById('LastName').value;
		        if (document.getElementById('Address')) document.getElementById('ShippingAddressDisplay').value = document.getElementById('Address').value;
		        if (document.getElementById('Address2')) document.getElementById('ShippingAddress2Display').value = document.getElementById('Address2').value;
		        //if (document.getElementById('City')) document.getElementById('ShippingCityDisplay').value = document.getElementById('City').value;
		        //if (document.getElementById('State')) document.getElementById('ShippingStateDisplay').value = document.getElementById('State').value;
		        //if (document.getElementById('Zip')) document.getElementById('ShippingZipDisplay').value = document.getElementById('Zip').value;
		        if (document.getElementById('Phone')) document.getElementById('ShippingPhoneDisplay').value = document.getElementById('Phone').value;
		    }
		}
		else
		{
			if (document.getElementById('FirstName')) document.getElementById('ShippingFirstNameDisplay').value = "";
			if (document.getElementById('LastName')) document.getElementById('ShippingLastNameDisplay').value = "";
			if (document.getElementById('Address')) document.getElementById('ShippingAddressDisplay').value = "";
			if (document.getElementById('Address2')) document.getElementById('ShippingAddress2Display').value = "";
			//if (document.getElementById('City')) document.getElementById('ShippingCityDisplay').value = "";
			//if (document.getElementById('State')) document.getElementById('ShippingStateDisplay').value = "";
			//if (document.getElementById('State')) document.getElementById('ShippingStateDisplay').selectedIndex = -1;
			//if (document.getElementById('Zip')) document.getElementById('ShippingZipDisplay').value = "";
			if (document.getElementById('Phone')) document.getElementById('ShippingPhoneDisplay').value = "";
		}
	}
}
function keepShippingAddress() {
    document.getElementById('divShippingInfoMisMatch').style.display = 'none';
    if (document.getElementById('divShippingInfoMisMatchFrom').value == 'main') {
        grayOut(false);
    }
    else {
        document.getElementById('divShippingDetail').style.display = 'block';
    }
}
function validateCheckout(frmEle)
{
	if(frmEle.FirstName.value == ""){
		alert("Please enter the Billing First Name.");
		frmEle.FirstName.focus();
		return false;
	}
	if(frmEle.LastName.value == ""){
		alert("Please enter the Billing Last Name.");
		frmEle.LastName.focus();
		return false;
	}
	if(frmEle.Address.value == ""){
		alert("Please enter the Billing Address.");
		frmEle.Address.focus();
		return false;
	}
	if(frmEle.City.value == ""){
		alert("Please enter the Billing City.");
		frmEle.City.focus();
		return false;
	}
	if(frmEle.State.value == "0"){
		alert("Please enter the Billing State.");
		frmEle.State.focus();
		return false;
	}
	if(frmEle.Zip.value == ""){
		alert("Please enter the Billing Zip.");
		frmEle.Zip.focus();
		return false;
	}
	if(frmEle.Phone.value == ""){
		alert("Please enter the Billing Phone.");
		frmEle.Phone.focus();
		return false;
	}
	if(frmEle.BillingShippingSame.checked == false)
	{
	    if(frmEle.ShippingFirstName.value == ""){
		    alert("Please enter the Shipping First Name.");
		    return false;
	    }
	    if(frmEle.ShippingLastName.value == ""){
		    alert("Please enter the Shipping Last Name.");
		    return false;
	    }
	    if(frmEle.ShippingAddress.value == ""){
		    alert("Please enter the Shipping Address.");
		    return false;
	    }
	    if(frmEle.ShippingCity.value == ""){
		    alert("Please enter the Shipping City.");
		    return false;
	    }
	    if(frmEle.ShippingState.value == "0"){
		    alert("Please enter the Shipping State.");
		    return false;
	    }
	    if(frmEle.ShippingZip.value == ""){
		    alert("Please enter the Shipping Zip.");
		    return false;
	    }
	    if(frmEle.ShippingPhone.value == ""){
	        alert("Please enter the Shipping Phone.");
		    return false;
	    }
	}
	if (document.getElementById('IsResidentialAddressYes') && document.getElementById('IsResidentialAddressNo')) {
	    if (document.getElementById('IsResidentialAddressYes').checked == false && document.getElementById('IsResidentialAddressNo').checked == false) {
	        alert("Is your shipping address a residential address? Please update your information.");
	        return false;
	    }
	}
	
	//if(frmEle.PaymentType[0].checked){//CreditCard
		if(frmEle.PaymentID.value == "0"){
			alert("Please select a credit card type.");
			frmEle.PaymentID.focus();
			return false;
		}
		if(frmEle.CardNumber.value == ""){
			alert("Please enter a credit card number.");
			frmEle.CardNumber.focus();
			return false;
		}
		// Credit Card Number Validation: AMEX, VISA, MasterCard 
		var type = "MasterCard"; 
		if(frmEle.PaymentID.value == "1") type="Visa";
		if(frmEle.PaymentID.value == "2") type="MasterCard";
		if(frmEle.PaymentID.value == "3") type="Discover";
		if(frmEle.PaymentID.value == "4") type="American Express";
		var num = frmEle.CardNumber.value;
		var dig1 = num.charAt(0);

		if(type == "American Express"){  
			if ((dig1 != "3") || (num.length != 15)) {
				alert('Invalid credit card number! Please ensure you are using an American Express card or change the Type of Card.');
				frmEle.PaymentID.focus();
				return false; 
			}  
		}
		if(type == "Visa") {  
			if ((dig1 != "4") || (num.length != 16))  {
				alert('Invalid credit card number! Please ensure you are using a Visa or change the Type of Card.');  
				frmEle.PaymentID.focus();
				return false; 
			}
		}
		if(type == "MasterCard") {  
			if ((dig1 != 5) || (num.length != 16)) {
				alert('Invalid credit card number! Please ensure you are using a Mastercard or change the Type of Card.'); 
				frmEle.PaymentID.focus();
				return false; 
			}  
		}
		if(frmEle.cvv2.value.length < 3){
			
			alert("Please enter the CVV2 number on the credit card.");
			frmEle.cvv2.focus();
			return false;
		}
	//}
	//if(frmEle.PaymentType[1].checked){//Alternative methods
	//}
	
	if(frmEle.disclaimer.checked == false){
		alert("You must read the RubberFlooring Disclaimer and agree to the terms!");
		frmEle.disclaimer.focus();
		return false;
	}

	MM_showHideLayers('PaymentDiv','','show');
}
function validatePaymentType(clicked){
	frmEle = document.shopcart;
	
	//ENABLE-DISABLE OPTIONS
	if(frmEle.PaymentType[0].checked)
	{//credit card
		frmEle.PaymentID.disabled = false;
		frmEle.CardNumber.disabled = false;
		frmEle.expMonth.disabled = false;
		frmEle.expYear.disabled = false;
		
		if (document.getElementById('divCreditCard')) document.getElementById('divCreditCard').style.display = 'block';
		if (document.getElementById('divCheck')) document.getElementById('divCheck').style.display = 'none';
	}
	else
	{//Alternative
		frmEle.PaymentID.disabled = true;
		frmEle.CardNumber.disabled = true;
		frmEle.expMonth.disabled = true;
		frmEle.expYear.disabled = true;
		
		if (document.getElementById('divCreditCard')) document.getElementById('divCreditCard').style.display = 'none';
		if (document.getElementById('divCheck')) document.getElementById('divCheck').style.display = 'block';
	}
}
function ViewDetail()
{
	if (document.getElementById('divOrderDetails').style.display == 'none')
	{
		grayOut(true);
		document.getElementById('divMainBody').disabled = true;
		document.getElementById('CompleteOrder').disabled = true;
		document.getElementById('divOrderDetails').style.display = 'block';
	}
	else
	{
		grayOut(false);
		document.getElementById('divMainBody').disabled = false;
		document.getElementById('CompleteOrder').disabled = false;
		document.getElementById('divOrderDetails').style.display = 'none';
	}
}
function ChangeShipping()
{
	if (document.getElementById('divShippingDetail').style.display == 'none')
	{
		grayOut(true);
		
		if (document.getElementById('FirstName') && document.getElementById('UpdFirstName')) document.getElementById('UpdFirstName').value = document.getElementById('FirstName').value;
		if (document.getElementById('LastName') && document.getElementById('UpdLastName')) document.getElementById('UpdLastName').value = document.getElementById('LastName').value;
		if (document.getElementById('Address') && document.getElementById('UpdAddress')) document.getElementById('UpdAddress').value = document.getElementById('Address').value;
		if (document.getElementById('Address2') && document.getElementById('UpdAddress2')) document.getElementById('UpdAddress2').value = document.getElementById('Address2').value;
		if (document.getElementById('City') && document.getElementById('UpdCity')) document.getElementById('UpdCity').value = document.getElementById('City').value;
		if (document.getElementById('State') && document.getElementById('UpdState')) document.getElementById('UpdState').value = document.getElementById('State').value;
		if (document.getElementById('Zip') && document.getElementById('UpdZip')) document.getElementById('UpdZip').value = document.getElementById('Zip').value;
		if (document.getElementById('Phone') && document.getElementById('UpdPhone')) document.getElementById('UpdPhone').value = document.getElementById('Phone').value;
		if (document.getElementById('Phone2') && document.getElementById('UpdPhone2')) document.getElementById('UpdPhone2').value = document.getElementById('Phone2').value;
            
		document.getElementById('divMainBody').disabled = true;
		if (document.getElementById('CompleteOrder')) document.getElementById('CompleteOrder').disabled = true;
		if (document.getElementById('divShippingDetail')) document.getElementById('divShippingDetail').style.display = 'block';
	}
	else
	{
		grayOut(false);
		document.getElementById('divMainBody').disabled = false;
		if (document.getElementById('CompleteOrder')) document.getElementById('CompleteOrder').disabled = false;
		if (document.getElementById('divShippingDetail')) document.getElementById('divShippingDetail').style.display = 'none';
	}
}
function grayOut(vis, options) {  
	// Pass true to gray out screen, false to ungray  
	// options are optional.  This is a JSON object with the following (optional) properties  
	// opacity:0-100         
	// Lower number = less grayout higher = more of a blackout   
	// zindex: #             
	// HTML elements with a higher zindex appear on top of the gray out  
	// bgcolor: (#xxxxxx)    
	// Standard RGB Hex color code  
	// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});  
	// Because options is JSON opacity/zindex/bgcolor are all optional and can appear  
	// in any order.  Pass only the properties you need to set.  
	var options = options || {};   
	var zindex = options.zindex || 50;  
	var opacity = options.opacity || 30;  
	var opaque = (opacity / 100);  
	var bgcolor = options.bgcolor || '#000000';  
	var dark=document.getElementById('darkenScreenObject');  
	if (!dark) {    
		// The dark layer doesn't exist, it's never been created.  So we'll    
		// create it here and apply some basic styles.    
		// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917    
		var tbody = document.getElementsByTagName("body")[0];    
		var tnode = document.createElement('div');           // Create the layer.        
		tnode.style.position='absolute';                 // Position absolutely        
		tnode.style.top='0px';                           // In the top        
		tnode.style.left='0px';                          // Left corner of the page        
		tnode.style.overflow='hidden';                   // Try to avoid making scroll bars                    
		tnode.style.display='none';                      // Start out Hidden        
		tnode.id='darkenScreenObject';                   // Name it so we can find it later    
		tbody.appendChild(tnode);                            // Add it to the web page    
		dark=document.getElementById('darkenScreenObject');  // Get the object.  
	}  
	if (vis) {    
		// Calculate the page width and height     
		if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {        
			var pageWidth = document.body.scrollWidth+'px';        
			var pageHeight = document.body.scrollHeight+'px';    
		} else if( document.body.offsetWidth ) {      
			var pageWidth = document.body.offsetWidth+'px';      
			var pageHeight = document.body.offsetHeight+'px';    
		} else {       
			var pageWidth='100%';       
			var pageHeight='100%';    
		}       
		//set the shader to cover the entire page and make it visible.    
		dark.style.opacity=opaque;                          
		dark.style.MozOpacity=opaque;                       
		dark.style.filter='alpha(opacity='+opacity+')';     
		dark.style.zIndex=zindex;            
		dark.style.backgroundColor=bgcolor;      
		dark.style.width= pageWidth;    
		dark.style.height= pageHeight;    
		dark.style.display='block';                            
	} 
	else {     
		dark.style.display='none';  
	}
}
function getPrice()
{
    if (document.getElementById('colorid'))
    {
        var colorList = document.getElementById('colorid');
        var val = colorList.options[colorList.selectedIndex].value;
        var valArray = val.split('|');
        document.getElementById('divPrice').innerHTML = valArray[1];
        
        //rubber rolls
        if (document.getElementById('qty'))
        {
            var qty = document.getElementById('qty');
            var total = valArray[1] * qty.value; //qty.options[qty.selectedIndex].value;
            document.getElementById('divTotal').innerHTML = total.toFixed(2);
            document.getElementById('divTotal2').innerHTML = (total * .75).toFixed(2);
        }
        //universal rubber tiles
        if (document.getElementById('cornerqty'))
        {
            var qtyCorner = document.getElementById('cornerqty');
            var qtyBorder = document.getElementById('borderqty');
            var qtyCenter = document.getElementById('centerqty');
            var totalCorner = valArray[1] * qtyCorner.value; //qtyCorner.options[qtyCorner.selectedIndex].value;
            var totalBorder = valArray[1] * qtyBorder.value; //qtyBorder.options[qtyBorder.selectedIndex].value;
            var totalCenter = valArray[1] * qtyCenter.value; //qtyCenter.options[qtyCenter.selectedIndex].value;
            document.getElementById('divTotal').innerHTML = (totalCorner + totalBorder + totalCenter).toFixed(2);
            document.getElementById('divTotal2').innerHTML = ((totalCorner + totalBorder + totalCenter) * .75).toFixed(2);
        }
        
        if (document.getElementById('producttypeid'))
        {
            if (document.getElementById('topPrice')) document.getElementById('topPrice').innerHTML = "On Sale for $" + (valArray[1] * .75).toFixed(2) + "  per tile";
            
			var productTypeID = document.getElementById('producttypeid').value;
			if (productTypeID == '1')
			{
				document.getElementById('divPricePer').innerHTML = (valArray[1] * .75 / 4).toFixed(2);
			}
			else
			{
			    var pid = document.getElementById('pid').value;
			    if (pid == 1013)
			    {
			        document.getElementById('divPricePer').innerHTML = (valArray[1] * .75 / 5.64).toFixed(2);
			    }
			    else
			    {
			        if (pid == 1015 || pid == 1018)
			        {
			            document.getElementById('divPricePer').innerHTML = (valArray[1] * .75 / 6.25).toFixed(2);
			        }
			        else if (pid == 2900 || pid == 2901 || pid == 2902 || pid == 2903)
			        {
			            document.getElementById('divPricePer').innerHTML = (valArray[1] * .75 / 4).toFixed(2);
			        }
			        else if (pid == 2904)
			        {
			            document.getElementById('divPricePer').innerHTML = (valArray[1] * .75 / 11.11).toFixed(2);
			        }
			        else if (pid == 2905)
			        {
			            document.getElementById('divPricePer').innerHTML = (valArray[1] * .75 / 16).toFixed(2);
			        }
			        else
			        {
			            document.getElementById('divPricePer').innerHTML = (valArray[1] * .75 / 9).toFixed(2);
			        }
			    }
				document.getElementById('divPricePer2').innerHTML = "$" + (valArray[1] * .75).toFixed(2) + " per tile, ";
				document.getElementById('topPrice').innerHTML = "On Sale for $" + (valArray[1] * .75).toFixed(2) + "  per tile";
			}
        }
    }
    return true;
    //var val = document.getElementById('colorid').value;
}
function getPrecutPrice()
{
    if (document.getElementById('colorid'))
    {
        var colorID = document.getElementById('colorid').options[document.getElementById('colorid').selectedIndex].value;
        var skuName = document.getElementById('PreCutSize').options[document.getElementById('PreCutSize').selectedIndex].value;
        var qty = document.getElementById('qty').value;
        
        if (document.getElementById('skulookup_' + skuName + '_' + colorID))
        {
            var skuID = document.getElementById('skulookup_' + skuName + '_' + colorID).value;
            var skuPrice = document.getElementById('skuprice_' + skuID).value;
            document.getElementById('divPriceEach').innerHTML = (skuPrice * 1).toFixed(2);
            document.getElementById('divPrice').innerHTML = (skuPrice * 1 * qty).toFixed(2);
            document.getElementById('divDiscountPrice').innerHTML = (skuPrice * .75 * qty).toFixed(2);
            document.getElementById('skuid').value = skuID;
        }
    }
    return true;
}
function UpdShipping()
{
	if (document.getElementById('p'))
	{
		document.getElementById('p').value = 'stateupd';
		document.getElementById('shopcart').submit();
	}
}
function validateAddToCart(frmEle)
{
    if (document.getElementById('pid'))
    {
        if (document.getElementById('pid').value == '1010' || document.getElementById('pid').value == '1015' || document.getElementById('pid').value == '1018')
        {
            var total = 0;
            if (document.getElementById('cornerqty'))
                total = Math.abs(document.getElementById('cornerqty').value);
            if (document.getElementById('borderqty'))
                total = total + Math.abs(document.getElementById('borderqty').value);
            if (document.getElementById('centerqty'))
                total = total + Math.abs(document.getElementById('centerqty').value);
            if (total < 8) 
            {
                alert('You must order a minimum of 8 tiles.');
                return false;
            }
            else
            {
                var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
                //check for numeric characters
                isValid = objRegExp.test(total);
                if (isValid == false)
                {
                    alert('Please enter a valid number.');
                    return false;
                }
                else return true;
            }
        }
        else if (document.getElementById('pid').value == '2900' || document.getElementById('pid').value == '2901')
        {
            var total = 0;
            if (document.getElementById('cornerqty'))
                total = Math.abs(document.getElementById('cornerqty').value);
            if (document.getElementById('borderqty'))
                total = total + Math.abs(document.getElementById('borderqty').value);
            if (document.getElementById('centerqty'))
                total = total + Math.abs(document.getElementById('centerqty').value);
            if (total < 1)
            {
                alert('You must order a minimum of 1 tile.');
                return false;
            }
            else
            {
                var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
                //check for numeric characters
                isValid = objRegExp.test(total);
                if (isValid == false)
                {
                    alert('Please enter a valid number.');
                    return false;
                }
                else return true;
            }
        }
        else if (document.getElementById('pid').value == '1008' || document.getElementById('pid').value == '1013')
        {
            var total = 0;
            if (document.getElementById('qty'))
                total = Math.abs(document.getElementById('qty').value);
            if (total < 8)
            {
                alert('You must order a minimum of 8 rubber tiles.');
                return false;
            }
            else
            {
                var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
                //check for numeric characters
                isValid = objRegExp.test(total);
                if (isValid == false)
                {
                    alert('Please enter a valid number.');
                    return false;
                }
                else return true;
            }
        }
        else if (document.getElementById('pid').value == '2902' || document.getElementById('pid').value == '2903')
        {
            var total = 0;
            if (document.getElementById('qty'))
                total = Math.abs(document.getElementById('qty').value);
            if (total < 1)
            {
                alert('You must order a minimum of 1 rubber tile.');
                return false;
            }
            else
            {
                var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
                //check for numeric characters
                isValid = objRegExp.test(total);
                if (isValid == false)
                {
                    alert('Please enter a valid number.');
                    return false;
                }
                else return true;
            }
        }
        else if (document.getElementById('pid').value == '2904' || document.getElementById('pid').value == '2905')
        {
            var total = 0;
            if (document.getElementById('qty'))
                total = Math.abs(document.getElementById('qty').value);
            if (total < 10)
            {
                alert('You must order a minimum of 10 tiles.');
                return false;
            }
            else
            {
                var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
                //check for numeric characters
                isValid = objRegExp.test(total);
                if (isValid == false)
                {
                    alert('Please enter a valid number.');
                    return false;
                }
                else return true;
            }
        }
        else if (document.getElementById('pid').value == '1000' || document.getElementById('pid').value == '1006' || document.getElementById('pid').value == '1007')
        {
            var total = 0;
            total = Math.abs(document.getElementById('qty').value);
            if (total < 10)
            {
                alert('You must order a minimum of 10 linear feet.');
                return false;
            }
            
            var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
            //check for numeric characters
            isValid = objRegExp.test(total);
            if (isValid == false)
            {
                alert('Please enter a valid number.');
                return false;
            }
            else return true;
        }
        else if (document.getElementById('pid').value == '1020' || document.getElementById('pid').value == '1021')
        {
            var total = 0;
            total = Math.abs(document.getElementById('qty').value);
            
            if (total == "")
            {
                alert('Please enter a valid number.');
                return false;
            }
            var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
            //check for numeric characters
            isValid = objRegExp.test(total);
            if (isValid == false)
            {
                alert('Please enter a valid number.');
                return false;
            }
            else return true;
        }
        else return true;
    }
    else return true;
}
function validateAddSkuToCart(frmEle)
{
    var total = 0;
    var width = 0;
    var length = 0;
    length = Math.abs(frmEle.length.value);
    width = Math.abs(frmEle.width.value);
    total = width * length;
    
    var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
    //check for numeric characters
    isValid = objRegExp.test(total);
    if (isValid == false || total < 1)
    {
        alert('Please enter a valid number.');
        return false;
    }
    else
    {
        var width = document.getElementById('width').value;
        var colorDropDown = document.getElementById('colorlist');
        var colorID = colorDropDown.options[colorDropDown.selectedIndex].value;
        var priceName = width + "_" + colorID;
    
        if (document.getElementById(priceName))
        {
            var skuID = document.getElementById('sku_' + priceName).value;
            frmEle.skuid.value = skuID;
            frmEle.colorid.value = colorID;
            frmEle.qty.value = total; 
            return true;
        }
        else
        {
            alert('Pricing is not available. Please choose a different width or color.');
            return false;
        }
    }
}
function validateShippingInfo(frmEle){
	if(frmEle.FirstName.value == ""){
		alert("Please enter your Firstname!");
		frmEle.FirstName.focus();
		return false;
	}
	if(frmEle.LastName.value == ""){
		alert("Please enter your Lastname!");
		frmEle.LastName.focus();
		return false;
	}
	if(frmEle.Address.value == ""){
		alert("Please enter your Address!");
		frmEle.Address.focus();
		return false;
	}
	if(frmEle.City.value == ""){
		alert("Please enter your City!");
		frmEle.City.focus();
		return false;
	}
	if(frmEle.State.value == "" || frmEle.State.value == "0"){
		alert("Please enter your State!");
		frmEle.State.focus();
		return false;
	}
	if(frmEle.Zip.value == ""){
		alert("Please enter your Zip!");
		frmEle.Zip.focus();
		return false;
	}
	if(frmEle.Phone.value == ""){
		alert("Please enter your Phone Number!");
		frmEle.Phone.focus();
		return false;
	}
	if (document.getElementById('Email'))
	{
	    if (frmEle.Email.value == "")
	    {
	        alert("Please enter your email!");
	        frmEle.Email.focus();
	        return false;
	    }
	    var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,4}$/;
		
		emailad = document.getElementById('Email').value;
		
		if(((emailad.search(exclude) != -1)||(emailad.search(check))
		== -1)||(emailad.search(checkend) == -1)){
			alert("Incorrect email address! Please ammend.");
			document.getElementById('Email').focus();
			return false;
		}
	}
}
function calcMatPrice()
{
    var width = document.getElementById('width').value;
    var length = Math.round(document.getElementById('length').value);
    
    var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
    //check for numeric characters
    isValid = objRegExp.test(length);
    if (isValid == false || length < 1)
    {
        alert('Please enter a valid number.');
        return false;
    }
    
    var colorDropDown = document.getElementById('colorlist');
    var colorID = colorDropDown.options[colorDropDown.selectedIndex].value;
    var priceName = width + "_" + colorID;
    
    if (document.getElementById(priceName))
    {
        var price = document.getElementById(priceName).value;
        document.getElementById('regPrice').innerHTML = '$' + (width * length * price).toFixed(2);
        document.getElementById('salePrice').innerHTML = '$' + (width * length * price * .75).toFixed(2);
        document.getElementById('sqftPrice').innerHTML = '( $' + Math.abs(price * .75).toFixed(2) + ' per square foot )';
    }
    else
    {
        alert('Pricing is not available. Please choose a different width or color.');
    }
}
function validateSampleRequest(frmEle)
{
    frmEle.samplecolor1.value = frmEle.ProductColorList1.options[frmEle.ProductColorList1.selectedIndex].text;
    frmEle.samplecolor2.value = frmEle.ProductColorList2.options[frmEle.ProductColorList2.selectedIndex].text;
    frmEle.samplecolor3.value = frmEle.ProductColorList3.options[frmEle.ProductColorList3.selectedIndex].text;
    
    if (frmEle.ProductColorList1.selectedIndex == 0)
    {
        alert("Please choose a sample color.");
        frmEle.ProductColorList1.focus();
        return false;
    }
    if(frmEle.FirstName.value == ""){
		alert("Please enter your first name!");
		frmEle.FirstName.focus();
		return false;
	}
	if(frmEle.LastName.value == ""){
		alert("Please enter your last name!");
		frmEle.LastName.focus();
		return false;
	}
	if(frmEle.Address.value == ""){
		alert("Please enter your address!");
		frmEle.Address.focus();
		return false;
	}
	if(frmEle.City.value == ""){
		alert("Please enter your city!");
		frmEle.City.focus();
		return false;
	}
	if(frmEle.State.value == "" || frmEle.State.value == "0"){
		alert("Please enter your state!");
		frmEle.State.focus();
		return false;
	}
	if(frmEle.Zip.value == ""){
		alert("Please enter your zip!");
		frmEle.Zip.focus();
		return false;
	}
	if(frmEle.Phone.value == ""){
		alert("Please enter your phone number!");
		frmEle.Phone.focus();
		return false;
	}
	if (document.getElementById('Email'))
	{
	    if (frmEle.Email.value == "")
	    {
	        alert("Please enter your email!");
	        frmEle.Email.focus();
	        return false;
	    }
	    var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,4}$/;
		
		emailad = document.getElementById('Email').value;
		
		if(((emailad.search(exclude) != -1)||(emailad.search(check))
		== -1)||(emailad.search(checkend) == -1)){
			alert("Incorrect email address! Please ammend.");
			document.getElementById('Email').focus();
			return false;
		}
	}
	if(frmEle.BillingFirstName.value == ""){
		alert("Please enter your billing first name!");
		frmEle.BillingFirstName.focus();
		return false;
	}
	if(frmEle.BillingLastName.value == ""){
		alert("Please enter your billing last name!");
		frmEle.BillingLastName.focus();
		return false;
	}
	if(frmEle.BillingAddress.value == ""){
		alert("Please enter your billing address!");
		frmEle.BillingAddress.focus();
		return false;
	}
	if(frmEle.BillingCity.value == ""){
		alert("Please enter your billing city!");
		frmEle.BillingCity.focus();
		return false;
	}
	if(frmEle.BillingState.value == "" || frmEle.BillingState.value == "0"){
		alert("Please enter your billing state!");
		frmEle.BillingState.focus();
		return false;
	}
	if(frmEle.BillingZip.value == ""){
		alert("Please enter your billing zip!");
		frmEle.BillingZip.focus();
		return false;
	}
	if(frmEle.PaymentID.value == "0"){
		alert("Please select a credit card type.");
		frmEle.PaymentID.focus();
		return false;
	}
	var type = "MasterCard"; 
	if(frmEle.PaymentID.value == "1") type="Visa";
	if(frmEle.PaymentID.value == "2") type="MasterCard";
	if(frmEle.PaymentID.value == "3") type="Discover";
	if(frmEle.PaymentID.value == "4") type="American Express";
	var num = frmEle.CardNumber.value;
	var dig1 = num.charAt(0);

	if(type == "American Express"){  
		if ((dig1 != "3") || (num.length != 15)) {
			alert('Invalid credit card number! Please ensure you are using an American Express card or change the Type of Card.');
			frmEle.PaymentID.focus();
			return false; 
		}  
	}
	if(type == "Visa") {  
		if ((dig1 != "4") || (num.length != 16))  {
			alert('Invalid credit card number! Please ensure you are using a Visa or change the Type of Card.');  
			frmEle.PaymentID.focus();
			return false; 
		}
	}
	if(type == "MasterCard") {  
		if ((dig1 != 5) || (num.length != 16)) {
			alert('Invalid credit card number! Please ensure you are using a Mastercard or change the Type of Card.'); 
			frmEle.PaymentID.focus();
			return false; 
		}  
	}
	if(frmEle.cvv2.value.length < 3){
		
		alert("Please enter the CVV2 number on the credit card.");
		frmEle.cvv2.focus();
		return false;
	}
}
function showSampleColor(objEle, colorSwatch)
{
    var colorID = objEle.options[objEle.selectedIndex].value;
    document.getElementById(colorSwatch).src = 'images/colors/large/' + colorID + '.jpg';
}
function validatePaypalCheckout(frmEle)
{
    if(frmEle.ShippingPhone.value == ""){
        alert("Please enter the Shipping Phone.");
	    return false;
    }
}
function rubberRollGetTotal()
{
    var priceper = document.getElementById('ctl00_ContentPlaceHolder1_DiscountedPrice').value;
    var regularpriceper = document.getElementById('ctl00_ContentPlaceHolder1_RegularPrice').value;
    if (document.getElementById('ctl00_ContentPlaceHolder1_TotalDiscountedPrice')) 
    {
        var qty = document.getElementById('ctl00_ContentPlaceHolder1_Qty').value;
        document.getElementById('ctl00_ContentPlaceHolder1_TotalDiscountedPrice').innerHTML = (priceper * qty).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_TotalPrice').innerHTML = (regularpriceper * qty).toFixed(2);
    }
}
function noCutTileGetTotal()
{
    var priceper = document.getElementById('ctl00_ContentPlaceHolder1_DiscountedPrice').value;
    var regularpriceper = document.getElementById('ctl00_ContentPlaceHolder1_RegularPrice').value;
    var tileWeight = document.getElementById('ctl00_ContentPlaceHolder1_TileWeight').value;
    if (document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTotalPrice')) 
    {
        var cornerTiles = Math.abs(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomCornerQty').value);
        var borderTiles = Math.abs(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomBorderQty').value);
        var centerTiles = Math.abs(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomCenterQty').value);
        
        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(cornerTiles) == false) cornerTiles = 0;
        if (objRegExp.test(borderTiles) == false) borderTiles = 0;
        if (objRegExp.test(centerTiles) == false) centerTiles = 0;
        
        var qty = cornerTiles + borderTiles + centerTiles;
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTotalPrice').innerHTML = "$" + (regularpriceper * qty).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomDiscountedTotalPrice').innerHTML = "$" + (priceper * qty).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomWeight').innerHTML = (qty * tileWeight).toFixed(0) + 'lbs';
    }
}
function wallToWallTileGetTotal()
{
    var priceper = document.getElementById('ctl00_ContentPlaceHolder1_Discount').value;
    var regularpriceper = document.getElementById('ctl00_ContentPlaceHolder1_RegularPrice').value;
    if (document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTotalPrice')) 
    {
        var customTiles = Math.abs(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTileQty').value);
        
        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(customTiles) == false) customTiles = 0;
        
        var qty = customTiles;
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTotalPrice').innerHTML = "$" + (regularpriceper * qty).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomDiscountedTotalPrice').innerHTML = "$" + (priceper * regularpriceper * qty).toFixed(2);
    }
}
function smartTileGetTotal()
{
    var priceper = document.getElementById('ctl00_ContentPlaceHolder1_Discount').value;
    var regularpriceper = document.getElementById('ctl00_ContentPlaceHolder1_RegularPrice').value;
    if (document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTileQty')) 
    {
        var customTiles = Math.abs(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTileQty').value);
        
        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(customTiles) == false) customTiles = 0;
        
        var qty = customTiles;
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTotalPrice').innerHTML = "$" + (regularpriceper * qty).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomDiscountedTotalPrice').innerHTML = "$" + (priceper * regularpriceper * qty).toFixed(2);
    }
}
function wallToWallRollGetTotal()
{
    var priceper = document.getElementById('ctl00_ContentPlaceHolder1_Discount').value;
    var regularpriceper = document.getElementById('ctl00_ContentPlaceHolder1_RegularPrice').value;
    var rollWeight = document.getElementById('ctl00_ContentPlaceHolder1_RollWeight').value;
    if (document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTotalPrice')) 
    {
        var customTiles = Math.abs(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomRollQty').value);
        
        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(customTiles) == false) customTiles = 0;
        
        var qty = customTiles;
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTotalPrice').innerHTML = "$" + (regularpriceper * qty).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomDiscountedTotalPrice').innerHTML = "$" + (priceper * (regularpriceper * qty).toFixed(2)).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomWeight').innerHTML = (qty * rollWeight).toFixed(0) + 'lbs';
    }
}
function RubberMulchWCGetTotal() {
    var discount = document.getElementById('ctl00_ContentPlaceHolder1_Discount').value;
    var regularPrice30 = document.getElementById('ctl00_ContentPlaceHolder1_RegularPrice').value;
    var regularPrice1500 = document.getElementById('ctl00_ContentPlaceHolder1_RegularPrice1500').value;
    var tileWeight30 = document.getElementById('ctl00_ContentPlaceHolder1_TileWeight').value;
    var tileWeight1500 = document.getElementById('ctl00_ContentPlaceHolder1_TileWeight1500').value;
    if (document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTotalPrice')) {
        var mulchQty30 = document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomMulch30').value;
        var mulchQty1500 = document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomMulch1500').value;

        var objRegExp = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(mulchQty30) == false) mulchQty30 = 0;
        if (objRegExp.test(mulchQty1500) == false) mulchQty1500 = 0;

        var qty = mulchQty30 + mulchQty1500;
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTotalPrice').innerHTML = "$" + ((regularPrice30 * mulchQty30) + (regularPrice1500 * mulchQty1500)).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomDiscountedTotalPrice').innerHTML = "$" + (((regularPrice30 * mulchQty30) * discount) + ((regularPrice1500 * mulchQty1500) * discount)).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomWeight').innerHTML = ((mulchQty30 * tileWeight30) + (mulchQty1500 * tileWeight1500)).toFixed(0) + 'lbs';
    }
}
function MitchellTileGetTotal() {
    var priceper = document.getElementById('ctl00_ContentPlaceHolder1_DiscountedPrice').value;
    var regularpriceper = document.getElementById('ctl00_ContentPlaceHolder1_RegularPrice').value;
    var priceperCorner = document.getElementById('ctl00_ContentPlaceHolder1_DiscountedPriceCorner').value;
    var regularpriceperCorner = document.getElementById('ctl00_ContentPlaceHolder1_RegularPriceCorner').value;
    var priceperBorder = document.getElementById('ctl00_ContentPlaceHolder1_DiscountedPriceBorder').value;
    var regularpriceperBorder = document.getElementById('ctl00_ContentPlaceHolder1_RegularPriceBorder').value;
    var tileWeight = document.getElementById('ctl00_ContentPlaceHolder1_TileWeight').value;
    var tileWeightCorner = document.getElementById('ctl00_ContentPlaceHolder1_TileWeightCorner').value;
    var tileWeightBorder = document.getElementById('ctl00_ContentPlaceHolder1_TileWeightBorder').value;
    if (document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTotalPrice')) {
        var cornerTiles = Math.abs(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomCornerQty').value);
        var borderTiles = Math.abs(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomBorderQty').value);
        var centerTiles = Math.abs(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomCenterQty').value);

        var objRegExp = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(cornerTiles) == false) cornerTiles = 0;
        if (objRegExp.test(borderTiles) == false) borderTiles = 0;
        if (objRegExp.test(centerTiles) == false) centerTiles = 0;

        var qty = cornerTiles + borderTiles + centerTiles;
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTotalPrice').innerHTML = "$" + ((regularpriceper * centerTiles) + (regularpriceperCorner * cornerTiles) + (regularpriceperBorder * borderTiles)).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomDiscountedTotalPrice').innerHTML = "$" + ((priceper * centerTiles) + (priceperCorner * cornerTiles) + (priceperBorder * borderTiles)).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomWeight').innerHTML = ((centerTiles * tileWeight) + (cornerTiles * tileWeightCorner) + (borderTiles * tileWeightBorder)).toFixed(0) + 'lbs';
    }
}
function wallToWallGarageRollGetTotal()
{
    var priceper = document.getElementById('ctl00_ContentPlaceHolder1_Discount').value;
    var regularpriceper = document.getElementById('ctl00_ContentPlaceHolder1_RegularPrice').value;
    var rollWeight = document.getElementById('ctl00_ContentPlaceHolder1_RollWeight').value;
    var rollWidth = document.getElementById('ctl00_ContentPlaceHolder1_RollWidth').value;
    if (document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTotalPrice')) 
    {
        var customTiles = Math.abs(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomRollQty').value);
        
        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(customTiles) == false) customTiles = 0;
        
        var qty = customTiles;
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTotalPrice').innerHTML = "$" + (regularpriceper * qty).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomDiscountedTotalPrice').innerHTML = "$" + (priceper * (regularpriceper * qty).toFixed(2)).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomWeight').innerHTML = (rollWidth * qty * rollWeight).toFixed(0) + 'lbs';
    }
}
function setProductActiveTab(tabControl, tabIndex)
{
    var control = $find(tabControl);
    control.set_activeTab(control.get_tabs()[tabIndex]);
}
function showColorPreview(myControl, showhide)
{
    if (document.getElementById(myControl))
    {
        var colorID = document.getElementById(myControl).options[document.getElementById(myControl).selectedIndex].value;
        MM_showHideLayers('ColorImage' + colorID,'',showhide);
    }
}
function validateNoCutKitTiles()
{
    if (document.getElementById('ctl00_ContentPlaceHolder1_NoCutKit_NoCutCornerQty') && document.getElementById('ctl00_ContentPlaceHolder1_NoCutKit_NoCutBorderQty') && document.getElementById('ctl00_ContentPlaceHolder1_NoCutKit_NoCutCenterQty'))
    {
        if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked')) {
            if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked').value == "0") {
                alert('Please select a color.');
                return false;
            }
        }
        var corner = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_NoCutKit_NoCutCornerQty').value);
        var border = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_NoCutKit_NoCutBorderQty').value);
        var center = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_NoCutKit_NoCutCenterQty').value);
        var extra = 0;
        if (document.getElementById('ctl00_ContentPlaceHolder1_NoCutKit_NoCutExtraQty')) extra = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_NoCutKit_NoCutExtraQty').value);
        var qty = corner + border + center + extra;
        var pid = document.getElementById('ctl00_ContentPlaceHolder1_ProductID').value;
        if (pid == '1040') {
            if (qty < 8) {
                alert('You must order a minimum of 8 tiles');
                return false;
            }
        }
        if (pid == '2906') {
            if (qty < 8) {
                alert('You must order a minimum of 8 tiles');
                return false;
            }
            if (qty % 4 > 0) {
                alert('You must order increments of 4 tiles (4 tiles per pack)');
                return false;
            }
        }
        if (pid == '1037') {
            if (qty < 25) {
                alert('You must order a minimum of 25 tiles');
                return false;
            }
        }
        if (pid == '1025') {
            if (qty < 15) {
                alert('You must order a minimum of 15 tiles');
                return false;
            }
        }
        if (pid == '1030') {
            if (qty < 10) {
                alert('You must order a minimum of 10 tiles');
                return false;
            }
        }
        if (pid == '2910') {
            if (qty < 8) {
                alert('You must order a minimum of 8 tiles');
                return false;
            }
        }
        if (pid == '1010' || pid == '1022')
        {
            if (qty < 8)
            {
                alert('You must order a minimum of 8 tiles.');
                return false;
            }
        }
        else
        {
            if (qty < 1)
            {
                alert('You must order a minimum of 1 tiles.');
                return false;
            }
        }
        return true;
    }
}
function validateWallToWallTiles()
{
    if (document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactCornerQty') && document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactBorderQty') && document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactCenterQty'))
    {
        if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked')) {
            if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked').value == "0") {
                alert('Please select a color.');
                return false;
            }
        }
        var corner = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactCornerQty').value);
        var border = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactBorderQty').value);
        var center = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactCenterQty').value);
        var extra = 0;
        if (document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactExtraQty')) extra = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactExtraQty').value);
        var qty = corner + border + center + extra;
        var pid = document.getElementById('ctl00_ContentPlaceHolder1_ProductID').value;
        if (pid == '1040') {
            if (qty < 8) {
                alert('You must order a minimum of 8 tiles');
                return false;
            }
        }
        if (pid == '2906') {
            if (qty < 8) {
                alert('You must order a minimum of 8 tiles');
                return false;
            }
            if (qty % 4 > 0) {
                alert('You must order increments of 4 tiles (4 tiles per pack)');
                return false;
            }
        }
        if (pid == '1037') {
            if (qty < 25) {
                alert('You must order a minimum of 25 tiles');
                return false;
            }
        }
        if (pid == '1025') {
            if (qty < 15) {
                alert('You must order a minimum of 15 tiles');
                return false;
            }
        }
        if (pid == '1030') {
            if (qty < 10) {
                alert('You must order a minimum of 10 tiles');
                return false;
            }
        }
        if (pid == '2910') {
            if (qty < 8) {
                alert('You must order a minimum of 8 tiles');
                return false;
            }
        }
        if (pid == '1010' || pid == '1022')
        {
            if (qty < 8)
            {
                alert('You must order a minimum of 8 tiles.');
                return false;
            }
        }
        else
        {
            if (qty < 1)
            {
                alert('You must order a minimum of 1 tiles.');
                return false;
            }
        }
        return true;
    }
}
function validateWallToWallRolls()
{
    if (document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactQty'))
    {
        if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked')) {
            if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked').value == "0") {
                alert('Please select a color.');
                return false;
            }
        }
        var pid = document.getElementById('ctl00_ContentPlaceHolder1_ProductID').value;
        var qty = document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactQty').value;
        if (pid == "1043") {
            if (qty < 15) {
                alert('You must order a minimum of 15 linear feet.');
                return false;
            }
        }
        if (pid == "1005") {
            if (qty < 15) {
                alert('You must order a minimum of 15 linear feet.');
                return false;
            }
        }
        else {
            if (qty < 10) {
                alert('You must order a minimum of 10 linear feet.');
                return false;
            }
        }
        return true;
    }
}
function validateCustomTiles()
{
    if (document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomCornerQty') && document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomBorderQty') && document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomCenterQty'))
    {
        if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked')) {
            if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked').value == "0") {
                alert('Please select a color.');
                return false;
            }
        }
        var corner = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomCornerQty').value);
        var border = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomBorderQty').value);
        var center = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomCenterQty').value);
        var qty = corner + border + center;
        
        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(qty) == false)
        {
            alert('Please enter a valid number.');
            return false;
        }

        var pid = document.getElementById('ctl00_ContentPlaceHolder1_ProductID').value;
        if (pid == '1040') {
            if (qty < 8) {
                alert('You must order a minimum of 8 tiles');
                return false;
            }
        }
        if (pid == '1037') {
            if (qty < 25) {
                alert('You must order a minimum of 25 tiles');
                return false;
            }
        }
        if (pid == '1025') {
            if (qty < 15) {
                alert('You must order a minimum of 15 tiles');
                return false;
            }
        }
        if (pid == '1030') {
            if (qty < 10) {
                alert('You must order a minimum of 10 tiles');
                return false;
            }
        }
        if (pid == '2910') {
            if (qty < 8) {
                alert('You must order a minimum of 8 tiles');
                return false;
            }
        }
        if (pid == '1010' || pid == '1022')
        {
            if (qty < 8)
            {
                alert('You must order a minimum of 8 tiles.');
                return false;
            }
        }
        else
        {
            if (qty < 1)
            {
                alert('You must order a minimum of 1 tiles.');
                return false;
            }
        }
        return true;
    }
}
function validateMulchQty() {
    if (document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomMulch30') || document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomMulch1500')) {
        if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked')) {
            if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked').value == "0") {
                alert('Please select a color.');
                return false;
            }
        }
        var mulchQty30 = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomMulch30').value);
        var mulchQty1500 = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomMulch1500').value);

        var objRegExp = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        if (objRegExp.test(mulchQty30) == false) mulchQty30 = 0;
        if (objRegExp.test(mulchQty1500) == false) mulchQty1500 = 0;

        if ((mulchQty30 + mulchQty1500) < 1) {
            alert('You must order a minimum of 1 bag');
            return false;
        }
    }
    return true;
}
function validateWallToWallCustomTiles()
{
    if (document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTileQty'))
    {
        if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked')) {
            if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked').value == "0") {
                alert('Please select a color.');
                return false;
            }
        }
        var qty = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomTileQty').value);
        
        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(qty) == false)
        {
            alert('Please enter a valid number.');
            return false;
        }

        var pid = document.getElementById('ctl00_ContentPlaceHolder1_ProductID').value;
        if (pid == '1040') {
            if (qty < 8) {
                alert('You must order a minimum of 8 tiles');
                return false;
            }
        }
        if (pid == '2906') {
            if (qty < 8) {
                alert('You must order a minimum of 8 tiles');
                return false;
            }
            if (qty % 4 > 0) {
                alert('You must order increments of 4 tiles (4 tiles per pack)');
                return false;
            }
        }
        if (pid == '1022')
        {
            if (qty % 8 > 0)
            {
                alert('You must order increments of 8 tiles (8 tiles per box)');
                return false;
            }
        }
        if (pid == '2600' || pid == '2601') {
            var extraqty = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactExtraTileQty').value);
            if ((extraqty + qty) % 8 > 0) {
                alert('You must order increments of 8 tiles (8 tiles per box).');
                return false;
            }
        }
        if (pid == '2602') {
            var extraqty = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactExtraTileQty').value);
            if ((extraqty + qty) % 6 > 0) {
                alert('You must order increments of 6 tiles (6 tiles per box).');
                return false;
            }
        }
        if (pid == '2911') {
            if (qty % 25 > 0) {
                alert('You must order increments of 25 tiles (25 tiles per box)');
                return false;
            }
        }
	if (pid == '2912') {
            if (qty % 32 > 0) {
                alert('You must order increments of 32 tiles (32 tiles per box)');
                return false;
            }
        }
        if (pid == '1042') {
            if (qty < 50) {
                alert('You must order a minimum of 50 tiles on all Designer Series Strong Rubber Tiles.');
                return false;
            }
        }
        if (pid == '3000' || pid == '3025' || pid == '3017' || pid == '3021')
        {
            if (qty < 15)
            {
                alert('You must order a minimum of 15 tiles');
                return false;
            }
        }
        if (pid == '2910') {
            if (qty < 8) {
                alert('You must order a minimum of 8 tiles');
                return false;
            }
        }
        if (pid == '1025' || pid == '1030') {
            if (qty < 10) {
                alert('You must order a minimum of 10 tiles');
                return false;
            }
        }
        if (pid == '2620' || pid == '2621') {
            if (qty < 10) {
                alert('You must order a minimum of 10 tiles');
                return false;
            }
        }
        if (pid == '1008' || pid == '1013' || pid == '1022' || pid == '2906' || pid == '2907' || pid == '2908')
        {
            if (qty < 8)
            {
                alert('You must order a minimum of 8 tiles.');
                return false;
            }
        }
        else
        {
            if (qty < 1)
            {
                alert('You must order a minimum of 1 tiles.');
                return false;
            }
        }
        return true;
    }
}
function validateWallToWallCustomRolls()
{
    if (document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomRollQty'))
    {
        if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked')) {
            if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked').value == "0") {
                alert('Please select a color.');
                return false;
            }
        }
        var qty = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_Custom_CustomRollQty').value);
        
        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(qty) == false)
        {
            alert('Please enter a valid number.');
            return false;
        }
        var pid = document.getElementById('ctl00_ContentPlaceHolder1_ProductID').value;
        if (pid == '1043') {
            if (qty < 15) {
                alert('You must order a minimum of 15 linear feet.');
                return false;
            }
        }
        if (pid == '1005') {
            if (qty < 15) {
                alert('You must order a minimum of 15 linear feet.');
                return false;
            }
        }
        else {
            if (qty < 10) {
                alert('You must order a minimum of 10 linear feet.');
                return false;
            }
        }
        return true;
    }
}
function validateWallToWallSingleTiles()
{
    if (document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactTileQty'))
    {
        if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked')) {
            if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked').value == "0") {
                alert('Please select a color.');
                return false;
            }
        }
        var qty = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactTileQty').value);
        var pid = document.getElementById('ctl00_ContentPlaceHolder1_ProductID').value;
        if (pid == '1040') {
            if (qty < 8) {
                alert('You must order a minimum of 8 tiles');
                return false;
            }
        }
        if (pid == '1042') {
            if (qty < 50) {
                alert('You must order a minimum of 50 tiles on all Designer Series Strong Rubber Tiles.');
                return false;
            }
        }
        if (pid == '3000' || pid == '3025' || pid == '3017' || pid == '3021')
        {
            if (qty < 15)
            {
                alert('You must order a minimum of 15 tiles.');
                return false;
            }
        }
        if (pid == '2600' || pid == '2601') {
            var extraqty = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactExtraTileQty').value);
            if ((extraqty + qty) % 8 > 0) {
                alert('You must order increments of 8 tiles (8 tiles per box).');
                return false;
            }
        }
        if (pid == '2602') {
            var extraqty = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_WallToWall_ExactExtraTileQty').value);
            if ((extraqty + qty) % 6 > 0) {
                alert('You must order increments of 6 tiles (6 tiles per box).');
                return false;
            }
        }
        if (pid == '2910') {
            if (qty < 8) {
                alert('You must order a minimum of 8 tiles.');
                return false;
            }
        }
        if (pid == '2620' || pid == '2621') {
            if (qty < 10) {
                alert('You must order a minimum of 10 tiles.');
                return false;
            }
        }
        if (pid == '1008' || pid == '1013' || pid == '2906' || pid == '2907' || pid == '2908')
        {
            if (qty < 8)
            {
                alert('You must order a minimum of 8 tiles.');
                return false;
            }
        }
        else
        {
            if (qty < 1)
            {
                alert('You must order a minimum of 1 tiles.');
                return false;
            }
        }
        return true;
    }
}
function ValidateRoomSize()
{
    if (document.getElementById('ctl00_ContentPlaceHolder1_RoomWidth') && document.getElementById('ctl00_ContentPlaceHolder1_RoomHeight'))
    {
        var roomWidth = document.getElementById('ctl00_ContentPlaceHolder1_RoomWidth').value;
        var roomHeight = document.getElementById('ctl00_ContentPlaceHolder1_RoomHeight').value;
        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(roomWidth) == false) 
        {
            alert('Please enter a valid number.');
            return false;
        }
        if (objRegExp.test(roomHeight) == false) 
        {
            alert('Please enter a valid number.');
            return false;
        }
        
        return true;
    }
}
function validateStockGarageRolls()
{
    if (document.getElementById('ctl00_ContentPlaceHolder1_Sku_StockQty'))
    {
        if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked')) {
            if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked').value == "0") {
                alert('Please select a color.');
                return false;
            }
        }
        var qty = Math.ceil(document.getElementById('ctl00_ContentPlaceHolder1_Sku_StockQty').value);
        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(qty) == false)
        {
            alert('Please enter a valid number.');
            return false;
        }
        if (qty < 1)
        {
            alert('You must order a minimum of 1 roll.');
            return false;
        }
        return true;
    }
}
function validateGridLocEdges()
{
    var qty = 0;
    var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
    if (document.getElementById('ctl00_ContentPlaceHolder1_SkuCorner_StockQty'))
    {
        qty = document.getElementById('ctl00_ContentPlaceHolder1_SkuCorner_StockQty').value;
        if (qty != "")
        {
            if (objRegExp.test(qty) == false)
            {
                alert('Please enter a valid number.');
                return false;
            }
            if (qty < 1)
            {
                alert('You must order a minimum of 1 piece.');
                return false;
            }
        }
    }
    if (document.getElementById('ctl00_ContentPlaceHolder1_SkuFemale_StockQty'))
    {
        qty = document.getElementById('ctl00_ContentPlaceHolder1_SkuFemale_StockQty').value;
        if (qty != "")
        {
            if (objRegExp.test(qty) == false)
            {
                alert('Please enter a valid number.');
                return false;
            }
            if (qty < 1)
            {
                alert('You must order a minimum of 1 piece.');
                return false;
            }
        }
    }
    if (document.getElementById('ctl00_ContentPlaceHolder1_SkuMale_SkuColorList'))
    {
        qty = document.getElementById('ctl00_ContentPlaceHolder1_SkuMale_SkuColorList').value;
        if (qty != "")
        {
            if (objRegExp.test(qty) == false)
            {
                alert('Please enter a valid number.');
                return false;
            }
            if (qty < 1)
            {
                alert('You must order a minimum of 1 piece.');
                return false;
            }
        }
    }
    return true;
}
function validateFlexAccessories(productID)
{
    var objID = "";
    if (productID == "2613") objID = "ctl00_ContentPlaceHolder1_SkuCorner_StockQty";
    if (productID == "2614") objID = "ctl00_ContentPlaceHolder1_SkuEdge_StockQty";
    var qty = 0;
    var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
    if (document.getElementById(objID))
    {
        qty = document.getElementById(objID).value;
        if (qty != "")
        {
            if (objRegExp.test(qty) == false)
            {
                alert('Please enter a valid number.');
                return false;
            }
            if (qty < 1)
            {
                alert('You must order a minimum of 1 piece.');
                return false;
            }
        }
        else
        {
            alert('You must order a minimum of 1 piece.');
            return false;
        }
    }
    return true;
}
function validateSkuMats()
{
    if (document.getElementById('ctl00_ContentPlaceHolder1_Sku_StockQty'))
    {
        if (document.getElementById('ctl00_ContentPlaceHolder1_Sku_AddAccessories'))
        {
            if (document.getElementById('ctl00_ContentPlaceHolder1_Sku_AddAccessories').value == "1")
            {
                if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked')) {
                    if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked').value == "0") {
                        alert('Please select a color.');
                        return false;
                    }
                }
            }
        }
        qty = document.getElementById('ctl00_ContentPlaceHolder1_Sku_StockQty').value;

        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(qty) == false)
        {
            alert('Please enter a valid number.');
            return false;
        }
        if (qty < 1)
        {
            alert('You must order a minimum of 1 piece.');
            return false;
        }
        return true;
    }
}
function validateSkuMatsAccessories()
{
    if (document.getElementById('ctl00_ContentPlaceHolder1_SkuAccessories_StockQty'))
    {
        qty = document.getElementById('ctl00_ContentPlaceHolder1_SkuAccessories_StockQty').value;

        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(qty) == false)
        {
            alert('Please enter a valid number.');
            return false;
        }
        if (qty < 1)
        {
            alert('You must order a minimum of 1 piece.');
            return false;
        }
        return true;
    }
}
function validateSkuMatsCustom()
{
    if (document.getElementById('ctl00_ContentPlaceHolder1_SkuCustom_StockQty'))
    {
        qty = document.getElementById('ctl00_ContentPlaceHolder1_SkuCustom_StockQty').value;

        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(qty) == false)
        {
            alert('Please enter a valid number.');
            return false;
        }
        if (qty < 1)
        {
            alert('You must order a minimum of 1 piece.');
            return false;
        }
        return true;
    }
}
function validatePaverRamp() {
    if (document.getElementById('ctl00_ContentPlaceHolder1_Ramp_StockQty')) {
        qty = document.getElementById('ctl00_ContentPlaceHolder1_Ramp_StockQty').value;

        var objRegExp = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(qty) == false) {
            alert('Please enter a valid number.');
            return false;
        }
        if (qty < 1) {
            alert('You must order a minimum of 1 piece.');
            return false;
        }
        return true;
    }
}
function safeTileGetClipTotal()
{
    var priceper = document.getElementById('ctl00_ContentPlaceHolder1_Discount').value;
    var regularpriceper = document.getElementById('ctl00_ContentPlaceHolder1_Clip_SkuPrice').value;
    if (document.getElementById('ctl00_ContentPlaceHolder1_Clip_ExactTotalPrice')) 
    {
        var customTiles = Math.abs(document.getElementById('ctl00_ContentPlaceHolder1_Clip_StockQty').value);
        
        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(customTiles) == false) customTiles = 0;
        
        var qty = customTiles;
        document.getElementById('ctl00_ContentPlaceHolder1_Clip_ExactTotalPrice').innerHTML = "$" + (regularpriceper * qty).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Clip_ExactDiscountedTotalPrice').innerHTML = "$" + (priceper * regularpriceper * qty).toFixed(2);
    }
}
function safeTileGetAdhesiveTotal()
{
    var priceper = document.getElementById('ctl00_ContentPlaceHolder1_Discount').value;
    var regularpriceper = document.getElementById('ctl00_ContentPlaceHolder1_Glue_SkuPrice').value;
    if (document.getElementById('ctl00_ContentPlaceHolder1_Glue_ExactTotalPrice')) 
    {
        var customTiles = Math.abs(document.getElementById('ctl00_ContentPlaceHolder1_Glue_StockQty').value);
        
        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(customTiles) == false) customTiles = 0;
        
        var qty = customTiles;
        document.getElementById('ctl00_ContentPlaceHolder1_Glue_ExactTotalPrice').innerHTML = "$" + (regularpriceper * qty).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Glue_ExactDiscountedTotalPrice').innerHTML = "$" + (priceper * regularpriceper * qty).toFixed(2);
    }
}
function safeTileGetRampTotal() {
    var priceper = document.getElementById('ctl00_ContentPlaceHolder1_Discount').value;
    var regularpriceper = document.getElementById('ctl00_ContentPlaceHolder1_Ramp_SkuPrice').value;
    if (document.getElementById('ctl00_ContentPlaceHolder1_Ramp_ExactTotalPrice')) {
        var customTiles = Math.abs(document.getElementById('ctl00_ContentPlaceHolder1_Ramp_StockQty').value);

        var objRegExp = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(customTiles) == false) customTiles = 0;

        var qty = customTiles;
        document.getElementById('ctl00_ContentPlaceHolder1_Ramp_ExactTotalPrice').innerHTML = "$" + (regularpriceper * qty).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Ramp_ExactDiscountedTotalPrice').innerHTML = "$" + (priceper * regularpriceper * qty).toFixed(2);
    }
}
function CopySampleBillingInfo()
{
    if (document.getElementById('BillingShipping'))
	{
		if (document.getElementById('BillingShipping').checked == true)
		{
			if (document.getElementById('FirstName')) document.getElementById('BillingFirstName').value = document.getElementById('FirstName').value;
			if (document.getElementById('LastName')) document.getElementById('BillingLastName').value = document.getElementById('LastName').value;
			if (document.getElementById('Address')) document.getElementById('BillingAddress').value = document.getElementById('Address').value;
			if (document.getElementById('Address2')) document.getElementById('BillingAddress2').value = document.getElementById('Address2').value;
			if (document.getElementById('City')) document.getElementById('BillingCity').value = document.getElementById('City').value;
			if (document.getElementById('State')) document.getElementById('BillingState').value = document.getElementById('State').value;
			if (document.getElementById('Zip')) document.getElementById('BillingZip').value = document.getElementById('Zip').value;
		}
		else
		{
			if (document.getElementById('FirstName')) document.getElementById('BillingFirstName').value = "";
			if (document.getElementById('LastName')) document.getElementById('BillingLastName').value = "";
			if (document.getElementById('Address')) document.getElementById('BillingAddress').value = "";
			if (document.getElementById('Address2')) document.getElementById('BillingAddress2').value = "";
			if (document.getElementById('City')) document.getElementById('BillingCity').value = "";
			if (document.getElementById('State')) document.getElementById('BillingState').value = "";
			if (document.getElementById('State')) document.getElementById('BillingState').selectedIndex = -1;
			if (document.getElementById('Zip')) document.getElementById('BillingZip').value = "";
		}
	}
}
function validateFloorDimension()
{
    if (document.getElementById('ctl00_ContentPlaceHolder1_roomwidth') && document.getElementById('ctl00_ContentPlaceHolder1_roomheight'))
    {
        var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(document.getElementById('ctl00_ContentPlaceHolder1_roomwidth').value) == false || objRegExp.test(document.getElementById('ctl00_ContentPlaceHolder1_roomheight').value) == false)
        {
            alert('Maximum room length is 50 ft long, please enter an alternate room dimension.');
            return false;
        }
        if (document.getElementById('ctl00_ContentPlaceHolder1_roomwidth').value > 50 || document.getElementById('ctl00_ContentPlaceHolder1_roomheight').value > 50)
        {
            alert('Maximum room length is 50 ft long, please enter an alternate room dimension.');
            return false;
        }
        if (document.getElementById('ctl00_ContentPlaceHolder1_roomwidth').value.trim() == "" || document.getElementById('ctl00_ContentPlaceHolder1_roomheight').value.trim() == "")
        {
            alert('Please enter a valid dimension.');
            return false;
        }
    }
    return true;
}
function CloseShippingPopup() {
    document.getElementById('divShippingPreference').style.display = 'none';
}
function ShowShippingCarriers() {
    if (document.getElementById('ShipFromEastCoast')) {
        if (document.getElementById('ShipFromEastCoast').checked == true) {
            document.getElementById('divShippingPreference').style.display = 'none';
            document.getElementById('divShippingCarrierEast').style.display = 'block';
        }
    }
    if (document.getElementById('ShipFromMidWest')) {
        if (document.getElementById('ShipFromMidWest').checked == true) {
            document.getElementById('divShippingPreference').style.display = 'none';
            document.getElementById('divShippingCarrierEast').style.display = 'block';
        }
    }
    if (document.getElementById('ShipFromWestCoast')) {
        if (document.getElementById('ShipFromWestCoast').checked == true) {
            document.getElementById('divShippingPreference').style.display = 'none';
            document.getElementById('divShippingCarrierWest').style.display = 'block';
        }
    }
    
    return false;
}
function ShowShippingLocations() {
    if (document.getElementById('divShippingCarrierEast')) document.getElementById('divShippingCarrierEast').style.display = 'none';
    if (document.getElementById('divShippingCarrierWest')) document.getElementById('divShippingCarrierWest').style.display = 'none';
    document.getElementById('divShippingPreference').style.display = 'block';
}
function IsBusinessAddress() {
    if (document.getElementById('IsResidentialAddressYes') && document.getElementById('HasLiftGateYes') && document.getElementById('HasLiftGateNo')) {
        if (document.getElementById('IsResidentialAddressYes').checked == true) {
            document.getElementById('HasLiftGateYes').checked = true;
        }
        else {
            document.getElementById('HasLiftGateYes').checked = false;
        }
    }
}
function NeedLiftGate() {
    if (document.getElementById('IsResidentialAddressYes') && document.getElementById('HasLiftGateNo')) {
        if (document.getElementById('IsResidentialAddressYes').checked == true && document.getElementById('HasLiftGateNo').checked == true) {
            alert('Lift gate is included for residential address.');
            document.getElementById('HasLiftGateYes').checked = true;
        }
    }
}
function EmailQuote() {
    grayOut(true);
    document.getElementById('divEmailQuote').style.display = 'block';
}
function ApplyDiscount() {
    document.getElementById('p').value = 'discount';
    document.getElementById('shoppingcart').submit();
}
function ContinueCheckout() {
    document.checkoutform.action = 'shoppingcart.aspx';
}
function PaypalCheckout() {
    document.checkoutform.action = 'paypal.aspx';
}
function StockQtyChanged() {
    if (document.getElementById('ctl00_ContentPlaceHolder1_Sku_StockQty')) {
        if (document.getElementById('ctl00_ContentPlaceHolder1_Sku_AddAccessories')) {
            if (document.getElementById('ctl00_ContentPlaceHolder1_Sku_AddAccessories').value == "1") {
                if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked')) {
                    if (document.getElementById('ctl00_ContentPlaceHolder1_ColorIDPicked').value == "0") {
                        alert('Please select a color.');
                        return false;
                    }
                }
            }
        }
        qty = document.getElementById('ctl00_ContentPlaceHolder1_Sku_StockQty').value;

        var objRegExp = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
        //check for numeric characters
        if (objRegExp.test(qty) == false) {
            alert('Please enter a valid number.');
            return false;
        }
        if (qty < 1) {
            alert('You must order a minimum of 1.');
            return false;
        }

        var preDiscountPrice = document.getElementById('ctl00_ContentPlaceHolder1_Sku_PreDiscountPrice').value;
        var discountPrice = document.getElementById('ctl00_ContentPlaceHolder1_Sku_DiscountPrice').value;
        var productWeight = document.getElementById('ctl00_ContentPlaceHolder1_Sku_ProductWeight').value;
        document.getElementById('ctl00_ContentPlaceHolder1_Sku_ExactTotalPrice').innerHTML = '$' + (preDiscountPrice * qty).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Sku_ExactDiscountedTotalPrice').innerHTML = '$' + (discountPrice * qty).toFixed(2);
        document.getElementById('ctl00_ContentPlaceHolder1_Sku_ExactWeight').innerHTML = (productWeight * qty) + 'lbs';
        return true;
    }
}