function submitSearch() {
	var searchTerm = trim(document.CatalogSearchForm.searchTerm.value);
		document.CatalogSearchForm.searchTerm.value = document.CatalogSearchForm.searchTerm.value.replace(/s+$/g, '');
	if (searchTerm.match(/^([A-Za-z]{3,4})?[0-9]+$/)) {
		document.CatalogSearchForm.sku.value = searchTerm;
		document.CatalogSearchForm.searchTerm.value = '';
	}
	document.CatalogSearchForm.submit();
}

	coreworkoutON = new Image();
	coreworkoutON.src = "images/nav/3n1workout_on.jpg";
	coreworkoutOFF = new Image();
	coreworkoutOFF.src = "images/nav/3n1workout_off.jpg";

	spinedesignON = new Image();
	spinedesignON.src = "images/nav/spinedesign_on.jpg";
	spinedesignOFF = new Image();
	spinedesignOFF.src = "images/nav/spinedesign_off.jpg";

	resultsON = new Image();
	resultsON.src = "images/nav/scientific_on.jpg";
	resultsOFF = new Image();
	resultsOFF.src = "images/nav/scientific_off.jpg";

	workoutdvdON = new Image();
	workoutdvdON.src = "images/nav/workoutdvd_on.jpg";
	workoutdvdOFF = new Image();
	workoutdvdOFF.src = "images/nav/workoutdvd_off.jpg";

	reviewsON = new Image();
	reviewsON.src = "images/nav/reviews_on.jpg";
	reviewsOFF = new Image();
	reviewsOFF.src = "images/nav/reviews_off.jpg";

	accessoriesON = new Image();
	accessoriesON.src = "images/nav/accessories_on.jpg";
	accessoriesOFF = new Image();
	accessoriesOFF.src = "images/nav/accessories_off.jpg";

function brillar(x, y){
	document.images[x].src=eval(y+'.src');
}

var busy = false;
function Add2ShopCartProduct(form) {
	if (!busy) {
		busy = true;
		form.action = 'http://www.proform.com/webapp/wcs/stores/servlet/OrderItemAdd';
		form.URL.value = 'OrderCalculate?doPrice=Y&updatePrices=1&calculationUsageId=-1&calculationUsageId=-2&calculationUsageId=-3&calculationUsageId=-4&calculationUsageId=-5&calculationUsageId=-6&calculationUsageId=-7&orderItemId*=&quantity*=&URL=OrderItemDisplay';
		form.submit();
	}
}
function Add2ShopCartURL(url) {
   if (!busy) {
      busy = true;
      window.location = url;
   }
}
function Add2WishList(form) {
   if (!busy) {
          busy = true;
          form.action="InterestItemAdd"
          form.URL.value='InterestItemDisplay'
          form.submit()
   }
}

// POPUP WINDOW FUNCTION
function popWindow (url,myWidth,myHeight,myScrollbars,myTop,myLeft,myMenubar,myResize) {
window.open (url, "name","width="+myWidth+",height="+myHeight+",scrollbars="+myScrollbars+",top="+myTop+",left="+myLeft+",menubar="+myMenubar+",resizable="+myResize+",bgcolor=#ffffff");
}

function setEmail() {
	$('input[name=\'emailConfirm\']').val($('input[name=\'emailAddress\']').val());
}

function Discount1() {
	this.categoryDiscount = new Array();  	// Array of all category IDs on the page to store category discounts
	this.productDiscount = new Array();	// Array of all product IDs on the page to store product discounts
	this.itemDiscount = new Array();		// Array of all item IDs on the page to store item discounts
	this.thisCategoryDiscount = '';		// String to store discount for the current category
	this.foundDiscount = false;
	// Initialize the discount string
	this.productDiscount[59651] = '';
} // end function Discount1

// Function getThisCategoryDiscountText();
Discount1.prototype.getThisCategoryDiscountText = function()
{
	return this.thisCategoryDiscount;
}

// Function getCategoryDiscountText(categoryId);
Discount1.prototype.getCategoryDiscountText = function(categoryId)
{
	if (this.categoryDiscount[categoryId] == null || typeof(this.categoryDiscount[categoryId]) == 'undefined') {
		return '';
	}else {
		return this.categoryDiscount[categoryId];
	}
} // End getCategoryDiscountText(categoryId)

// Function getProductDiscountText(productId);
Discount1.prototype.getProductDiscountText = function(productId)
{
	if (this.productDiscount[productId] == null || typeof(this.productDiscount[productId]) == 'undefined') {
		return '';
	}else {
		return this.productDiscount[productId];
	}
} // End getProductDiscountText(productId)

// Function getItemDiscountText(itemId)
Discount1.prototype.getItemDiscountText = function(itemId)
{
	if (this.itemDiscount[itemId] == null || typeof(this.itemDiscount[itemId]) == 'undefined') {
		return '';
	}else {
		return this.itemDiscount[itemId];
	}
} // End getItemDiscountText(itemId)

// Function getAreThereAnyDiscounts();
// Returns true if any discounts were found 
Discount1.prototype.getAreThereAnyDiscounts = function() {
	return this.foundDiscount;
}
var Discount = new Discount1();

function printSidebar(pagename) {
var sideNav = '';
	sideNav += '<div id="sidenav">';
	sideNav += '<ul id="sidenavlist">';
	sideNav += '<li id="coreworkoutitem"><a href="index.html"';
	if(!(pagename == 'coreworkout')) {sideNav += ' onmouseover="brillar(\'coreworkout\', \'coreworkoutON\')" onmouseout="brillar(\'coreworkout\', \'coreworkoutOFF\')"';}
	sideNav += '><img src="images/nav/3n1workout_off.jpg" alt="3in1 CORE WORKOUT" name="coreworkout" /></a></li>';
	sideNav += '<li id="spinedesignitem"><a href="spinedesign.html"';
	if(!(pagename == 'spinedesign')) {sideNav += ' onmouseover="brillar(\'spinedesign\', \'spinedesignON\')" onmouseout="brillar(\'spinedesign\', \'spinedesignOFF\')"';}
	sideNav += '><img src="images/nav/spinedesign_off.jpg" alt="SPINE DESIGN" name="spinedesign" /></a></li>';
	sideNav += '<li id="resultsitem"><a href="results.html"';
	if(!(pagename == 'results')) {sideNav += ' onmouseover="brillar(\'results\', \'resultsON\')" onmouseout="brillar(\'results\', \'resultsOFF\')"';}
	sideNav += '><img src="images/nav/scientific_off.jpg" alt="SCIENTIFIC RESULTS" name="results" /></a></li>';
	sideNav += '<li id="workoutdvditem"><a href="workoutdvd.html"';
	if(!(pagename == 'workoutdvd')) {sideNav += ' onmouseover="brillar(\'workoutdvd\', \'workoutdvdON\')" onmouseout="brillar(\'workoutdvd\', \'workoutdvdOFF\')"';}
	sideNav += '><img src="images/nav/workoutdvd_off.jpg" alt="WORKOUT DVD & GUIDE" name="workoutdvd" /></a></li>';
	sideNav += '<li id="reviewsitem"><a href="reviews.html"';
	if(!(pagename == 'reviews')) {sideNav += ' onmouseover="brillar(\'reviews\', \'reviewsON\')" onmouseout="brillar(\'reviews\', \'reviewsOFF\')"';}
	sideNav += '><img src="images/nav/reviews_off.jpg" alt="REVIEWS & TESTIMONIALS" name="reviews" /></a></li>';
	sideNav += '<li id="accessoriesitem"><a href="accessories.html"';
	if(!(pagename == 'accessories')) {sideNav += ' onmouseover="brillar(\'accessories\', \'accessoriesON\')" onmouseout="brillar(\'accessories\', \'accessoriesOFF\')"';}
	sideNav += '><img src="images/nav/accessories_off.jpg" alt="ACCESSORIES" name="accessories" /></a></li>';
	sideNav += '</ul>';
	sideNav += '</div>';
	sideNav += '<div class="clear">&nbsp;</div>';
	sideNav += '<div id="left-content">';
	sideNav += '<a href="javascript:Add2ShopCartProduct(document.OrderItemAddForm);">';
	sideNav += '<img src="images/PF-abs.jpg" /></a>';
	sideNav += '</div>';
	sideNav += '<div class="clear">&nbsp;</div>';
	document.write(sideNav);
	
	brillar(pagename, pagename+'ON');
var orderForm = '';
	orderForm += '<form name="OrderItemAddForm" action="OrderItemAdd" method="post" id="OrderItemAddForm">';
	orderForm += '<input type="hidden" name="langId" value="-1" />';
	orderForm += '<input type="hidden" name="storeId" value="14201" />';
	orderForm += '<input type="hidden" name="orderId" value="." />';
	orderForm += '<input type="hidden" name="catalogId" value="16002" />';
	orderForm += '<input type="hidden" name="URL" value="" />';
	orderForm += '<input type="hidden" name="errorViewName" value="ProductDisplayErrorView" />';
	orderForm += '<input type="hidden" name="catEntryId" value="59651" />';
	orderForm += '<input type="hidden" name="productId" value="59651" />';
	orderForm += '<input type="hidden" name="calculationUsageId" value="-1" />';
	orderForm += '<input type="hidden" name="shouldCachePage" value="false" />';
	orderForm += '<input type="hidden" name="quantity" value="1" />';
	orderForm += '</form>';
	document.write(orderForm);
}

// HEADER
var header = '';
	header += '<div id="top">';
		header += '<div id="header">';
			header += '<h1><a class="logo" title="ProForm" href="http://www.proform.com/webapp/wcs/stores/servlet/TopCategories_-1_14201_16002"><img src="images/proform.png" alt="ProForm"></a></h1>';
		header += '</div>';
		
		header += '<div id="info">';
			header += '<div id="search">&nbsp;';
			header += '</div>';
			header += '<div id="sales"><h3>Sales: 1.888.742.0128</h3></div>';
		header += '</div>';	
			
		header += '<ul id="nav">';
		header += '<li id="n_TREADMILLS"><a href="http://www.proform.com/webapp/wcs/stores/servlet/Category_-1_14201_16002_29509_Y" title="Treadmills"><span>Treadmills</span></a></li>';
		header += '<li id="n_ELLIPTICALS"><a href="http://www.proform.com/webapp/wcs/stores/servlet/Category_-1_14201_16002_29510_Y"><span>Ellipticals</span></a></li>';
		header += '<li id="n_EXERCISEBIKES"><a href="http://www.proform.com/webapp/wcs/stores/servlet/Category_-1_14201_16002_29511_Y"><span>Exercise Bikes</span></a></li>';
		header += '<li id="n_STRENGTH"><a href="http://www.proform.com/webapp/wcs/stores/servlet/Category_-1_14201_16002_29512_Y"><span>Strength Equipment</span></a></li>';
		header += '<li id="n_VIBRATION"><a href="http://www.proform.com/webapp/wcs/stores/servlet/Category_-1_14201_16002_29513_Y"><span>Vibration</span></a></li>';
		header += '<li id="n_AB_MACHINES"><a href="http://www.proform.com/webapp/wcs/stores/servlet/Category_-1_14201_16002_29514_Y"><span>Ab Machines</span></a></li>';
		header += '<li id="n_ACCESSORIES"><a href="http://www.proform.com/webapp/wcs/stores/servlet/Category_-1_14201_16002_29515_Y"><span>Fitness Accessories</span></a></li>';		
		header += '<li id="n_IFIT_CARDS"><a href="http://www.proform.com/webapp/wcs/stores/servlet/Category_-1_14201_16002_49501_Y"><span>iFit Cards</span></a></li>';
		header += '</ul>';	
	header += '</div>';

// FOOTER
var footer = '';
		footer += '<div id="bottom">';
			footer += '<div id="promo">';
				footer += '<img src="images/freeshipping.jpg" alt="Free Shipping"/>';
				footer += '<div id="bml-footer">';
					footer += '<span class="title">No Wallet, No Wait, No Worries&reg;</span>';
					footer += '<a href="javascript:popWindow(\'https://www.securecheckout.billmelater.com/paycapture-content/fetch?hash=48B27T8B&content=/bmlweb/coreiw.html\',\'520\',\'400\',\'yes\',\'0\',\'20\',\'no\',\'yes\');"><img src="images/BMLhomepage.jpg" alt="Bill Me Later" /></a>';
					footer += '<span class="small">Minimum purchase required. Subject to credit approval. <a href="javascript:popWindow(\'https://www.securecheckout.billmelater.com/paycapture-content/fetch?hash=48B27T8B&content=/bmlweb/coreiw.html\',\'520\',\'400\',\'yes\',\'0\',\'20\',\'no\',\'yes\');">Details&gt;</a></span>';										
				footer += '</div>';
			footer += '</div>';
			
				footer += '<div class="spot" id="support">';
					footer += '<p>Media Support</p>';
					footer += '<ul class="color-text media-support">';
					footer += '<li><a href="http://twitter.com/ProFormFitness"><img src="images/twitter.jpg" alt="Twitter" /><span class="underline color-text">Follow us on Twitter</span></a></li>';
					footer += '</ul><p>Product Support</p>';
					footer += '<ul>';
					footer += '<li><a href="https://www.iconservice.com/prodreg/ProFormProdReg.jsp">Register you product</a></li>';
					footer += '<li><a href="http://www.iconservice.com/proform/">Help with your product</a></li>';
					footer += '<li class="bold"><a href="http://www.proform.com/webapp/wcs/stores/servlet/BuyersGuideDisplayView?langId=-1&amp;storeId=17551&amp;catalogId=18052&amp;pageName=BuyersGuideTreadmill">Buyers guide</a></li>';
					footer += '</ul>';
				footer += '</div>';
				
																																				
				footer += '<div class="spot" id="sale-spot">';
					footer += '<a href="http://www.proform.com/webapp/wcs/stores/servlet/Product_-1_14201_16002_29515_93203"><img src="images/abs-footer.jpg" alt="Technology!" /></a>';
				footer += '</div>';
				
				footer += '<div id="email-exclusive">';
					footer += '<a id="media" href="http://www.proform.com/webapp/wcs/stores/servlet/EmailSubscribe_-1_14201_16002">&nbsp;</a>';
				//	footer += '<h3>Email Exclusives</h3>';
				//	footer += '<p>We\'ll send new product announcements, the occasional fitness tips, and special promotions.</p>';
				//		footer += '<form method="post" action="http://www.proform.com/webapp/wcs/stores/servlet/ClubReg?langId=-1&amp;storeId=14201&amp;catalogId=16002" onsubmit="setEmail();">';
				//		footer += '<input type="hidden" name="source" value="PFUSAW" />';
				//		footer += '<input type="hidden" name="keyCode" value="PF" />';
				//		footer += '<input type="hidden" name="langId" value="-1" />';
				//		footer += '<input type="hidden" name="storeId" value="14201" />';
				//		footer += '<input type="hidden" name="errorViewName" value="CRSubscribeView" />';
				//		footer += '<input type="hidden" name="areaCode" value="000" />';
				//		footer += '<input type="hidden" name="prefix" value="000" />';
				//		footer += '<input type="hidden" name="suffix" value="0000" />';
				//		footer += '<input type="hidden" name="productLines[]" value="TRM" />';
				//		footer += '<input type="hidden" name="productLines[]" value="ELL" />';
				//		footer += '<input type="hidden" name="emailConfirm" value="" />';
				//		footer += '<label for="emailAddress" class="bold">Enter your E-mail Address:</label>';
				//		footer += '<input type="text" name="emailAddress" id="emailAddress" value="" />';
				//		footer += '<input type="submit" name="submitAction" value="Sign Up!" />';
				//	footer += '</form>';
				footer += '</div>';
				
			footer += '<div class="clear">&nbsp;</div>';
		footer += '</div>';
			footer += '<div id="footer">';
				footer += '<ul>';
					footer += '<li><a href="http://www.proform.com/webapp/wcs/stores/servlet/AboutUs_-1_14201_16002">About Us</a></li>';
					footer += '<li><a href="http://www.proform.com/webapp/wcs/stores/servlet/PrivacyPolicy_-1_14201_16002">Policies</a></li>';
					footer += '<li><a href="http://www.proform.com/webapp/wcs/stores/servlet/MediaRelationsDisplay?langId=-1&amp;storeId=14201&amp;catalogId=16002">Media Relations</a></li>';
					footer += '<li><a href="http://www.proform.com/webapp/wcs/stores/servlet/SiteMap_-1_14201_16002">Site Map</a></li>';
					footer += '<li><a href="http://www.proform.com/webapp/wcs/stores/servlet/AffiliatesSignUp_-1_14201_16002">Affiliate Program</a></li>';
					footer += '<li><a href="http://www.iconservice.com/proform/">Customer Service</a></li>';
					footer += '<li><a href="http://www.proform.com/webapp/wcs/stores/servlet/EmailSubscribe_-1_14201_16002">Register for Special Deals</a></li>';
				footer += '</ul>';
				
				footer += '<div style="clear: right;"></div>';
				
				footer += '<div id="footer-copyright" class="color-text>';
					footer += 'Copyright<sup class="color-text">&copy;</sup>2009 ProForm.com All Rights Reserved.';
					footer += 'Pricing valid only in the Continental U.S.';
				footer += '</div>';
			footer += '</div>';	
	
	
