	
	/* 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 change_img(img, fn) {
		img.src = "/_images/" + fn;
	}
	
	
	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 emailpage(page_url) {
		wnd = window.open('/email_page.php?page_url='+page_url,'TwoStoned','width=450,height=550,menubar=no,statusbar=yes,resizable=no,scrollbars=no');
	}
	
	
	function newsletter_signup() {
		
		document.newsletter_signup.submit();
		
		var usr_email = document.newsletter_signup.usrfrm_newsletter.value.replace(/,/g, '.').replace(/\s/g,'').replace(/'/g,'@');	
		
		alert("--"+usr_email+"--");
		if (ea_syntax(usr_email) == false) {
			alert('The email address you entered seems to be invalid.  Please check it and try again.');
			document.newsletter_signup.usrfrm_newsletter.select();}
		else {
			document.newsletter_signup.usrfrm_newsletter.value = usr_email;
			document.newsletter_signup.submit();
		} // end if
		
	}


	function purchase() {
		//location.href = 'http://www.twostoned.co.uk/shop/purchase_logic.php?op=np';
		location.href = '/shop/customer.php';
	}


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


	function set_brand_cookie() {
		var brand_option_string = '';			
					
		for (i=0; i < document.product_filters.length; i++) {			
			if (document.product_filters.elements[i].id.substr(0,6) == 'brand_') {
				brand_id = document.product_filters.elements[i].id.substr(6);
				
				if (document.getElementById('brand_'+brand_id).checked == true) {brand_option_string += brand_id + ';';}
			}
		}
		
		document.product_filters.brand_option_string.value = brand_option_string;
		SetCookie('___brand_option_string___', brand_option_string, '1');
	}
		

	function set_size_cookie() {
		var size_option_string = '';			
					
		for (i=0; i < document.product_filters.length; i++) {			
			if (document.product_filters.elements[i].id.substr(0,5) == 'size_') {
				size_id = document.product_filters.elements[i].id.substr(5);
				
				if (document.getElementById('size_'+size_id).checked == true) {size_option_string += size_id + ';';}
			}
		}
		
		document.product_filters.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');
	}
		

