	
	function apply_signup_action(ele, action_type) {
		switch (action_type) {
			case 'nls':
			ele.action = "/_include/signup_logic.php";
			break;
			
			case 'nls_header':
			ele.action = "/_include/signup_logic.php";
			break;
			
			case 'nls_small':
			ele.action = "/_include/signup_logic.php";
			break;
		}
	}
		
	
	/* Modified to support Opera */
	function bookmark(url, title){
	
		var agt = navigator.userAgent.toLowerCase(); 
		var app = navigator.appName.toLowerCase(); 
		var ieAgent = agt.indexOf('msie'); 
		var nsAgent = app.indexOf('netscape'); 
		var opAgent = app.indexOf('opera'); 
		
		if ( navigator.userAgent.indexOf("Safari") != -1 ) {
			alert ('Select Add Bookmarks from the Bookmarks menu, to store this link.');
		} else {
			if (window.sidebar) {// firefox
				window.sidebar.addPanel(title, url, "");
			} else if(window.opera && window.print) { // opera
				var elem = document.createElement('a');
				elem.setAttribute('href',url);
				elem.setAttribute('title',title);
				elem.setAttribute('rel','sidebar');
				elem.click();
			} else if(document.all) {// ie
				window.external.AddFavorite(url, title);
			}
		}
	}
	


	function change_filter(brand_name, style_name, price_range) {
		
		if (brand_name == 0) brand_name = 'all-brands';
		if (style_name == 0) style_name = 'all-styles';
		if (price_range == 0) price_range = 'any-price';
		
		document.filter.action = "/brands/"+brand_name+"/"+style_name+"/"+price_range;
		
		document.filter.submit();
	}
	
	
	function do_search(source) {
		if (source == 'nav_bar') { document.search_products.submit(); } else { document.search_products_main.submit();}
	}
	
	
	function ea_syntax(ea) {
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(ea)) {return true;} else {return false;}
	}
	

	function purchase() {
		location.href = '/_include/purchase_logic.php';
	}

	
	function roundNearest(num, acc){
		return ( acc < 0 ) ? Math.round(num*acc)/acc : Math.round(num/acc)*acc;
	}


	function set_size_cookie() {
		var size_option_string = '';			
					
		for (i=0; i < document.brand_styles_filter.length; i++) {			
			if (document.brand_styles_filter.elements[i].id.substr(0,5) == 'size_') {
				size_id = document.brand_styles_filter.elements[i].id.substr(5);
				
				if (document.getElementById('size_'+size_id).checked == true) {size_option_string += size_id + ';';}
			}
		}
		
		document.brand_styles_filter.size_option_string.value = size_option_string;
		SetCookie('___size_option_string___', size_option_string, '1');
	}
		

	function set_product_sort_cookie(sort_opt) {
		SetCookie('___sort_opt_string___', sort_opt, '1');
	}
		

	function set_price_range_cookie(price_opt) {
		SetCookie('___price_opt_string___', price_opt, '1');
	}
		
	
	function signup(ele, newsletter_action) {
		if (ea_syntax(ele.usrfrm_email.value) == false) {
			alert('The email address you entered seems to be invalid.  Please check it and try again.');
			ele.usrfrm_email.select();}
		else {
			apply_signup_action(ele, newsletter_action);
			ele.submit();
		} // end if
	}


