function show_product_images(prod_id,def_size) {
	if ($j('#prod_color_popup').length == 0) {
		$j('body').prepend('<div class="prod_image_popup" id="prod_color_popup"></div>');
	}

	var ajax_url = "/productdata/index/colorjson/id/" + prod_id;
	if (def_size.length > 0) {
		ajax_url += '/size/' + def_size;
	}
	$j.getJSON(ajax_url, function (data) {
		
		if (data.num_found > 0) {
			var html_code = '<ul>';
			var len = data.response.length;
			
				var cnt = 1;
				for (var i = 0; i < len; i++) {
					html_code += '<li><a href="' + data.prod_url + '?c=' + data.response[i].color_id + '">';
					html_code += '<img src="' + data.response[i].image + '">';
					//html_code += '<br/>' + data.response[i].color_name;
					html_code += '</a></li>';
					
					if (cnt == 4) {
						cnt = 0;
						html_code += '<div class="cl"><!-- --></div>';
					}
					cnt++;
				}
				html_code += '</ul>';
				
				if (data.comp_size.length > 0) {
					html_code += '<br/>' + data.comp_size;
				}
				
				$j('.prod_image_popup').html(html_code);
				
				var pos = $j('.prod_img[rel=prod_img' + prod_id + ']').offset();
						
				if ($j.browser.msie && $j.browser.version < 7) {
					if (len >= 4) {
						$j('.prod_image_popup').css('width','330px');
					} else {
						$j('.prod_image_popup').css('width',len * 85 + 'px');
					}
				}
				
				var width = $j('.prod_image_popup').width();
				var height = $j('.prod_image_popup').height();
				
				var left_offset = (width-130) / 2;
				var top_offset = (height/2)+54;
				if (height < 107) {
					top_offset = 80+(107-height);
				}
				
				
				$j('.prod_image_popup').css({'z-index':100, 'left':(pos.left - left_offset) + 'px','top':(pos.top - top_offset) + 'px'});
				
				$j('.prod_image_popup li').mouseover(function() {
					$j(this).css('background-color','#d1cbbd');
				}).mouseout(function() {
					$j(this).css('background','none');
				});			
				
				$j('.prod_image_popup').mouseout(function() {
					$j('.prod_image_popup').hide();
				});
				$j('.prod_image_popup').mouseover(function() {
					$j('.prod_image_popup').show();
				});
				$j('.prod_image_popup').show();
			
			
			if (data.comp_size.length > 0) {
				tb_init('.cs_popup');
			}
		}
	});
}

$j(document).ready(function() {
	if (window.location.toString().indexOf("bags") != -1) { $j("div#subnav .padder ul li a:eq(0)").attr("class","active"); }
	if (window.location.toString().indexOf("apparel") != -1) { $j("div#subnav .padder ul:eq(2) li a:eq(0)").attr("class","active"); }
	if (window.location.toString().indexOf("shoes") != -1) { $j("div#subnav .padder ul:eq(4) li a:eq(0)").attr("class","active"); }
	if (document.location.href.indexOf('limited-colors.html') == -1) {
		$j('.prod_img').click(function(e) {
			e.preventDefault();
			var pid = $j(this).attr('rel').replace('prod_img','');
			var def_size = $j(this).attr('title');
			show_product_images(pid,def_size);
		});
	}
});
