// JavaScript Document
/* Copyright Novusweb. All rights reserved. No part of this code may be duplicated or used without permission. */

LoadFunctions = function() {

	// Substitute copyright year for current year.
	
	var CopyDate = new Date();
	yy = CopyDate.getYear();
	
	var CopyYear = (yy < 1000) ? yy + 1900 : yy;
	
	$j("#CopyrightYear").replaceWith("<span>" + CopyYear + "</span>");
	
	// Activate jQuery UI buttons
	
	$j("button", "#HeaderSearch").button({
		icons: {
			primary: 'ui-icon-search'
		},
		text: false
	});

	$j("button", "#ProductSearch").button({
		icons: {
			primary: 'ui-icon-search'
		}
	});

	$j(".jButton-e").button({
	icons: {
		primary: 'ui-icon-arrow-1-e'
		}
	});
	
	$j("a", "#TellAFriend").button( {
														 
	 icons: {
		 primary: 'ui-icon-mail-closed'
	 }
	 
	 });
	
	$j("button", ".comment-list").button({
		
			icons: {
				primary: 'ui-icon-check'
			}
			
		});
	
	$j("button", "#ContactForm").button({
		
			icons: {
				primary: 'ui-icon-check'
			}
			
		});
	
	$j("#AddSubmit").button({
		
			icons: {
				primary: 'ui-icon-plus'
			},
			label: 'Add to Cart'
			
		});
		
	$j(".login_button").button({
		
			icons: {
				primary: 'ui-icon-locked'
			}
			
		});
	
	$j(".DialogAddBtn").button(
			
		{
			icons: {
				primary: 'ui-icon-cart'
			}
				
		});
	
	//	Product List Button Group

	ButtonGroupSet = function() {
	
		$j(".MoreDetailsBtn").button(
		
			{
				icons: {
					primary: 'ui-icon-arrow-1-e'
				}
			})
			
		.next()
		.button(
			
			{
				icons: {
					primary: 'ui-icon-cart'
				}
			})
		
		.parent()
		.buttonset();
		
	};
	
	ButtonGroupSet();
	
	// Set various sections to show/hide based on conditions
	
	var ErrorTest = $j('span.error').text();
	
	if(ErrorTest == "") {
		$j('span.error').hide();
	};
	
	var SubmitErrorTest = $j('div#SubmitError').text();
	
	if(SubmitErrorTest != "") {
		$j('div#SubmitError').show();
	};
	
	var InStockTest = $j('div#InStock').text();
	
	if(InStockTest != "In Stock: N/A") {
		$j('div#InStock').show();
	};
	
	var CrossSellTest = $j('div#CrossSell').text();
	
	if(CrossSellTest.indexOf('This product has no related products.') < 0) {
		$j('div#CrossSell').show();
	};
	
	//	Add corners to BC elements
	
	$j('.comment-container').addClass('ui-corner-all');
	$j('.blog-comment-container').addClass('ui-corner-all');
	$j('table.productPoplets img').addClass('ui-corner-all');
	$j('.button').addClass('ui-corner-all');
	
	//	Add corners to Slider wrapper
	
	$j('.SliderWrapper *').addClass('ui-corner-all');
	

}