function add2cart(id) {
	var type = $('p_type_' + id);
	var color = $('p_color_' + id);
	new Ajax.Request(jBASE_URL + '/shopcart/add.html', {
		method: 'post',
		parameters: {
			'id'   : id,
			'type' : type.value,
			'color': color.value
		},
		onSuccess: function(t) {
			var r = t.responseText.evalJSON();
			$('shopcart_count').update(r.count);
      
      
      
      jQuery("#p_img_"+id).effect("transfer", { className: "transfer2", to: "#shopcart_block" }, 1200);
      var image = jQuery("#p_img_"+id).attr('src')
      jQuery('.transfer2').css('border', '1px solid #000000');
      jQuery('.transfer2').html('<img width="100%" src="'+image+'">');
      
      /*
			$('cart_message').setStyle({opacity: 0.95});
			new TransparentMenu('cart_message', {showMode: 'now'});*/
		}
	});
	return false;
}

Event.observe(window, 'load', function(div) {
	$$('.product_type2 a').each(function(a) {
		Event.observe(a, 'click', function(event){
			Event.stop(event);
			if ('selected' == a.className || 'inactive' == a.className) {
				return ;
			}			
			
			var type = $(a).previous('input');	
			var img = $(a).up().down('img');
			var colors = $(type.name.replace('_type_', '_color_'));
			
			// if (a.name == 'man' || color.
			if (a.name == 'woman' && colors.value == 'yellow') {
				colors.options[0].selected = true;
				// return;
			}
			
			type.value = a.name == 'man' ? 1 : 2;			
			img.src = img.src.sub('(man|woman)', a.name);
			
			if (a.name == 'man') {
				img.previous('a').className = 'selected';
				img.next('a').className = '';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Красная';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).show();
						break;
					}
				}	
			} else {
				img.previous('a').className = '';
				img.next('a').className = 'selected';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Красная';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).hide();
						break;
					}
				}
			}
			var id = type.name.replace('p_type_', '');
			var price = $('p_price_' + id);
			price.update(a.name == 'man' ? m_prices[id] : w_prices[id]);			
			
			changeColor(type.id.replace('_type_', '_id_'), $(type.id.replace('_type_', '_color_')).value);			
		});
	});
	
	$$('select.product_colors').each(function(s) {
		Event.observe(s, 'change', function(event) {
			changeColor(s.id.replace('_color_', '_id_'), s.value);
		});
	});
	
	$$('a.zoom').each(function(a) {
		Event.observe($(a), 'click', function() {
			$(a).href = $(a).up().previous('a').href;
		});
	});
});














Event.observe(window, 'load', function(div) {
	$$('.product_type3 a').each(function(a) {
		Event.observe(a, 'click', function(event){
			Event.stop(event);
			if ('selected' == a.className || 'inactive' == a.className) {
				return ;
			}			
			
			var type = $(a).previous('input');	
			var img = $(a).up().down('img');
			var colors = $(type.name.replace('_type_', '_color_'));
			
			// if (a.name == 'man' || color.
			if (a.name == 'woman' && colors.value == 'yellow') {
				colors.options[0].selected = true;
				// return;
			}
			
			type.value = a.name == 'man' ? 1 : 2;			
			img.src = img.src.sub('(man|woman)', a.name);
			
			if (a.name == 'man') {
				img.previous('a').className = 'selected';
				img.next('a').className = '';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Зелёная';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).show();
						break;
					}
				}	
			} else {
				img.previous('a').className = '';
				img.next('a').className = 'selected';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Розовая';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).hide();
						break;
					}
				}
			}
			var id = type.name.replace('p_type_', '');
			var price = $('p_price_' + id);
			price.update(a.name == 'man' ? m_prices[id] : w_prices[id]);			
			
			changeColor(type.id.replace('_type_', '_id_'), $(type.id.replace('_type_', '_color_')).value);			
		});
	});
	
	$$('select.product_colors').each(function(s) {
		Event.observe(s, 'change', function(event) {
			changeColor(s.id.replace('_color_', '_id_'), s.value);
		});
	});
	
	$$('a.zoom').each(function(a) {
		Event.observe($(a), 'click', function() {
			$(a).href = $(a).up().previous('a').href;
		});
	});
});
Event.observe(window, 'load', function(div) {
	$$('.product_type4 a').each(function(a) {
		Event.observe(a, 'click', function(event){
			Event.stop(event);
			if ('selected' == a.className || 'inactive' == a.className) {
				return ;
			}			
			
			var type = $(a).previous('input');	
			var img = $(a).up().down('img');
			var colors = $(type.name.replace('_type_', '_color_'));
			
			// if (a.name == 'man' || color.
			if (a.name == 'woman' && colors.value == 'yellow') {
				colors.options[0].selected = true;
				// return;
			}
			
			type.value = a.name == 'man' ? 1 : 2;			
			img.src = img.src.sub('(man|woman)', a.name);
			
			if (a.name == 'man') {
				img.previous('a').className = 'selected';
				img.next('a').className = '';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Зелёная';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).show();
						break;
					}
				}	
			} else {
				img.previous('a').className = '';
				img.next('a').className = 'selected';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Розовая';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).hide();
						break;
					}
				}
			}
			var id = type.name.replace('p_type_', '');
			var price = $('p_price_' + id);
			price.update(a.name == 'man' ? m_prices[id] : w_prices[id]);			
			
			changeColor(type.id.replace('_type_', '_id_'), $(type.id.replace('_type_', '_color_')).value);			
		});
	});
	
	$$('select.product_colors').each(function(s) {
		Event.observe(s, 'change', function(event) {
			changeColor(s.id.replace('_color_', '_id_'), s.value);
		});
	});
	
	$$('a.zoom').each(function(a) {
		Event.observe($(a), 'click', function() {
			$(a).href = $(a).up().previous('a').href;
		});
	});
});
Event.observe(window, 'load', function(div) {
	$$('.product_type5 a').each(function(a) {
		Event.observe(a, 'click', function(event){
			Event.stop(event);
			if ('selected' == a.className || 'inactive' == a.className) {
				return ;
			}			
			
			var type = $(a).previous('input');	
			var img = $(a).up().down('img');
			var colors = $(type.name.replace('_type_', '_color_'));
			
			// if (a.name == 'man' || color.
			if (a.name == 'woman' && colors.value == 'yellow') {
				colors.options[0].selected = true;
				// return;
			}
			
			type.value = a.name == 'man' ? 1 : 2;			
			img.src = img.src.sub('(man|woman)', a.name);
			
			if (a.name == 'man') {
				img.previous('a').className = 'selected';
				img.next('a').className = '';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Зелёная';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).show();
						break;
					}
				}	
			} else {
				img.previous('a').className = '';
				img.next('a').className = 'selected';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Розовая';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).hide();
						break;
					}
				}
			}
			var id = type.name.replace('p_type_', '');
			var price = $('p_price_' + id);
			price.update(a.name == 'man' ? m_prices[id] : w_prices[id]);			
			
			changeColor(type.id.replace('_type_', '_id_'), $(type.id.replace('_type_', '_color_')).value);			
		});
	});
	
	$$('select.product_colors').each(function(s) {
		Event.observe(s, 'change', function(event) {
			changeColor(s.id.replace('_color_', '_id_'), s.value);
		});
	});
	
	$$('a.zoom').each(function(a) {
		Event.observe($(a), 'click', function() {
			$(a).href = $(a).up().previous('a').href;
		});
	});
});
Event.observe(window, 'load', function(div) {
	$$('.product_type6 a').each(function(a) {
		Event.observe(a, 'click', function(event){
			Event.stop(event);
			if ('selected' == a.className || 'inactive' == a.className) {
				return ;
			}			
			
			var type = $(a).previous('input');	
			var img = $(a).up().down('img');
			var colors = $(type.name.replace('_type_', '_color_'));
			
			// if (a.name == 'man' || color.
			if (a.name == 'woman' && colors.value == 'yellow') {
				colors.options[0].selected = true;
				// return;
			}
			
			type.value = a.name == 'man' ? 1 : 2;			
			img.src = img.src.sub('(man|woman)', a.name);
			
			if (a.name == 'man') {
				img.previous('a').className = 'selected';
				img.next('a').className = '';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Зелёная';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).show();
						break;
					}
				}	
			} else {
				img.previous('a').className = '';
				img.next('a').className = 'selected';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Розовая';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).hide();
						break;
					}
				}
			}
			var id = type.name.replace('p_type_', '');
			var price = $('p_price_' + id);
			price.update(a.name == 'man' ? m_prices[id] : w_prices[id]);			
			
			changeColor(type.id.replace('_type_', '_id_'), $(type.id.replace('_type_', '_color_')).value);			
		});
	});
	
	$$('select.product_colors').each(function(s) {
		Event.observe(s, 'change', function(event) {
			changeColor(s.id.replace('_color_', '_id_'), s.value);
		});
	});
	
	$$('a.zoom').each(function(a) {
		Event.observe($(a), 'click', function() {
			$(a).href = $(a).up().previous('a').href;
		});
	});
});
Event.observe(window, 'load', function(div) {
	$$('.product_type7 a').each(function(a) {
		Event.observe(a, 'click', function(event){
			Event.stop(event);
			if ('selected' == a.className || 'inactive' == a.className) {
				return ;
			}			
			
			var type = $(a).previous('input');	
			var img = $(a).up().down('img');
			var colors = $(type.name.replace('_type_', '_color_'));
			
			// if (a.name == 'man' || color.
			if (a.name == 'woman' && colors.value == 'yellow') {
				colors.options[0].selected = true;
				// return;
			}
			
			type.value = a.name == 'man' ? 1 : 2;			
			img.src = img.src.sub('(man|woman)', a.name);
			
			if (a.name == 'man') {
				img.previous('a').className = 'selected';
				img.next('a').className = '';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Зелёная';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).show();
						break;
					}
				}	
			} else {
				img.previous('a').className = '';
				img.next('a').className = 'selected';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Розовая';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).hide();
						break;
					}
				}
			}
			var id = type.name.replace('p_type_', '');
			var price = $('p_price_' + id);
			price.update(a.name == 'man' ? m_prices[id] : w_prices[id]);			
			
			changeColor(type.id.replace('_type_', '_id_'), $(type.id.replace('_type_', '_color_')).value);			
		});
	});
	
	$$('select.product_colors').each(function(s) {
		Event.observe(s, 'change', function(event) {
			changeColor(s.id.replace('_color_', '_id_'), s.value);
		});
	});
	
	$$('a.zoom').each(function(a) {
		Event.observe($(a), 'click', function() {
			$(a).href = $(a).up().previous('a').href;
		});
	});
});
Event.observe(window, 'load', function(div) {
	$$('.product_type8 a').each(function(a) {
		Event.observe(a, 'click', function(event){
			Event.stop(event);
			if ('selected' == a.className || 'inactive' == a.className) {
				return ;
			}			
			
			var type = $(a).previous('input');	
			var img = $(a).up().down('img');
			var colors = $(type.name.replace('_type_', '_color_'));
			
			// if (a.name == 'man' || color.
			if (a.name == 'woman' && colors.value == 'yellow') {
				colors.options[0].selected = true;
				// return;
			}
			
			type.value = a.name == 'man' ? 1 : 2;			
			img.src = img.src.sub('(man|woman)', a.name);
			
			if (a.name == 'man') {
				img.previous('a').className = 'selected';
				img.next('a').className = '';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Зелёная';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).show();
						break;
					}
				}	
			} else {
				img.previous('a').className = '';
				img.next('a').className = 'selected';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Розовая';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).hide();
						break;
					}
				}
			}
			var id = type.name.replace('p_type_', '');
			var price = $('p_price_' + id);
			price.update(a.name == 'man' ? m_prices[id] : w_prices[id]);			
			
			changeColor(type.id.replace('_type_', '_id_'), $(type.id.replace('_type_', '_color_')).value);			
		});
	});
	
	$$('select.product_colors').each(function(s) {
		Event.observe(s, 'change', function(event) {
			changeColor(s.id.replace('_color_', '_id_'), s.value);
		});
	});
	
	$$('a.zoom').each(function(a) {
		Event.observe($(a), 'click', function() {
			$(a).href = $(a).up().previous('a').href;
		});
	});
});
Event.observe(window, 'load', function(div) {
	$$('.product_type9 a').each(function(a) {
		Event.observe(a, 'click', function(event){
			Event.stop(event);
			if ('selected' == a.className || 'inactive' == a.className) {
				return ;
			}			
			
			var type = $(a).previous('input');	
			var img = $(a).up().down('img');
			var colors = $(type.name.replace('_type_', '_color_'));
			
			// if (a.name == 'man' || color.
			if (a.name == 'woman' && colors.value == 'yellow') {
				colors.options[0].selected = true;
				// return;
			}
			
			type.value = a.name == 'man' ? 1 : 2;			
			img.src = img.src.sub('(man|woman)', a.name);
			
			if (a.name == 'man') {
				img.previous('a').className = 'selected';
				img.next('a').className = '';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Зелёная';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).show();
						break;
					}
				}	
			} else {
				img.previous('a').className = '';
				img.next('a').className = 'selected';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Розовая';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).hide();
						break;
					}
				}
			}
			var id = type.name.replace('p_type_', '');
			var price = $('p_price_' + id);
			price.update(a.name == 'man' ? m_prices[id] : w_prices[id]);			
			
			changeColor(type.id.replace('_type_', '_id_'), $(type.id.replace('_type_', '_color_')).value);			
		});
	});
	
	$$('select.product_colors').each(function(s) {
		Event.observe(s, 'change', function(event) {
			changeColor(s.id.replace('_color_', '_id_'), s.value);
		});
	});
	
	$$('a.zoom').each(function(a) {
		Event.observe($(a), 'click', function() {
			$(a).href = $(a).up().previous('a').href;
		});
	});
});
Event.observe(window, 'load', function(div) {
	$$('.product_type10 a').each(function(a) {
		Event.observe(a, 'click', function(event){
			Event.stop(event);
			if ('selected' == a.className || 'inactive' == a.className) {
				return ;
			}			
			
			var type = $(a).previous('input');	
			var img = $(a).up().down('img');
			var colors = $(type.name.replace('_type_', '_color_'));
			
			// if (a.name == 'man' || color.
			if (a.name == 'woman' && colors.value == 'yellow') {
				colors.options[0].selected = true;
				// return;
			}
			
			type.value = a.name == 'man' ? 1 : 2;			
			img.src = img.src.sub('(man|woman)', a.name);
			
			if (a.name == 'man') {
				img.previous('a').className = 'selected';
				img.next('a').className = '';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Зелёная';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).show();
						break;
					}
				}	
			} else {
				img.previous('a').className = '';
				img.next('a').className = 'selected';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Розовая';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).hide();
						break;
					}
				}
			}
			var id = type.name.replace('p_type_', '');
			var price = $('p_price_' + id);
			price.update(a.name == 'man' ? m_prices[id] : w_prices[id]);			
			
			changeColor(type.id.replace('_type_', '_id_'), $(type.id.replace('_type_', '_color_')).value);			
		});
	});
	
	$$('select.product_colors').each(function(s) {
		Event.observe(s, 'change', function(event) {
			changeColor(s.id.replace('_color_', '_id_'), s.value);
		});
	});
	
	$$('a.zoom').each(function(a) {
		Event.observe($(a), 'click', function() {
			$(a).href = $(a).up().previous('a').href;
		});
	});
});
Event.observe(window, 'load', function(div) {
	$$('.product_type11 a').each(function(a) {
		Event.observe(a, 'click', function(event){
			Event.stop(event);
			if ('selected' == a.className || 'inactive' == a.className) {
				return ;
			}			
			
			var type = $(a).previous('input');	
			var img = $(a).up().down('img');
			var colors = $(type.name.replace('_type_', '_color_'));
			
			// if (a.name == 'man' || color.
			if (a.name == 'woman' && colors.value == 'yellow') {
				colors.options[0].selected = true;
				// return;
			}
			
			type.value = a.name == 'man' ? 1 : 2;			
			img.src = img.src.sub('(man|woman)', a.name);
			
			if (a.name == 'man') {
				img.previous('a').className = 'selected';
				img.next('a').className = '';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Зелёная';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).show();
						break;
					}
				}	
			} else {
				img.previous('a').className = '';
				img.next('a').className = 'selected';
				for (var i = 0; i < colors.options.length; i++) {
					if (colors.options[i].value == 'red') {
						colors.options[i].innerHTML = 'Розовая';
					}
				
					if (colors.options[i].value == 'yellow') {						
						$(colors.options[i]).hide();
						break;
					}
				}
			}
			var id = type.name.replace('p_type_', '');
			var price = $('p_price_' + id);
			price.update(a.name == 'man' ? m_prices[id] : w_prices[id]);			
			
			changeColor(type.id.replace('_type_', '_id_'), $(type.id.replace('_type_', '_color_')).value);			
		});
	});
	
	$$('select.product_colors').each(function(s) {
		Event.observe(s, 'change', function(event) {
			changeColor(s.id.replace('_color_', '_id_'), s.value);
		});
	});
	
	$$('a.zoom').each(function(a) {
		Event.observe($(a), 'click', function() {
			$(a).href = $(a).up().previous('a').href;
		});
	});
});




function changeColor(id, color) {	
	var img  = $(id.replace('_id_', '_img_'));
	var link = img.up();
	var ajax = link.next('div');
	
	Event.observe(img, 'load', function() {
		ajax.hide();
		img.show();
	});
		
	var src = img.src.sub('(white|red|black|yellow|pink|green|indigo|grey)', color);	
	var href = link.href.sub('(white|red|black|yellow|pink|green|indigo|grey)', color);
	
	src = src.replace('?is_woman=1', '');
	href = href.replace('?is_woman=1', '');
	src = src.replace('?hoodie=1', '');
	href = href.replace('?hoodie=1', '');
	
	if ($(id.replace('_id_', '_type_')).value == 2) {
		src += '?is_woman=1';
		href += '?is_woman=1';	
	}
	if ($(id.replace('_id_', '_type_')).value == 8) {
		src += '?hoodie=1';
		href += '?hoodie=1';	
	}
	
	ajax.show();
	img.hide();
	
	link.href = href;
	img.src = src;	
}
