//table of tshirt types and sizes.  Later it will be pulled from the server.
tshirt_table = new Object();
for(i=0;i<8;i++) {
  for(j=0;j<7;i++) {
     tshirt_table[i][j] = 1;
  }
}
// set sage, apple_gr, and phenoms to 0 for size xs
tshirt_table[1][0] = 0;
tshirt_table[3][0] = 0;
tshirt_table[6][0] = 0;
tshirt_table[7][0] = 0;
console.debug(tshirt_table[3][0],tshirt_table[3][4]);

$("div.productImage").mouseover(
	function() {
	    $(this).text("slow");
});
function show_quickbuy(id) {
	    $('#qc-'+id).show();
}
function hide_quickbuy(id) {
	    $('#qc-'+id).hide();
	    
}
function reset_ticks(id) {
	    $('#'+id+'_white').attr('src',  "http://images.weadmire.net/quick_checkout/white.jpg");
	    $('#'+id+'_sage').attr('src', "http://images.weadmire.net/quick_checkout/sage.jpg");
	    $('#'+id+'_apple_white').attr('src', "http://images.weadmire.net/quick_checkout/apple_white.jpg");
	    $('#'+id+'_dapple_grey').attr('src' , "http://images.weadmire.net/quick_checkout/dapple_grey.jpg");
	    $('#'+id+'_blue').attr('src' , "http://images.weadmire.net/quick_checkout/blue.jpg");
	    $('#'+id+'_phenom_black').attr('src' , "http://images.weadmire.net/quick_checkout/phenom_black.jpg");
	    $('#'+id+'_phenom_blue').attr('src' , "http://images.weadmire.net/quick_checkout/phenom_blue.jpg");
	    $('#'+id+'_titanium').attr('src',  "http://images.weadmire.net/quick_checkout/titanium.jpg");
}

function qc_tick(icon, newcolor) {
	    mycolor = '_'+newcolor;
	    design = (icon.id).replace(mycolor, '');
	    reset_ticks(design);
	    icon.src = icon.src.replace('.jpg', '_tick.jpg');
	    $('#'+design+'_tshirtcolor').attr('value', newcolor);
	    if (newcolor=='apple_white'||newcolor=='sage'||newcolor=='phenom_blue'||newcolor=='phenom_black')  {
	      $('#'+design+"_xs").hide();
	    }
	    else {
	      $('#'+design+"_xs").show();
            }  
}

function tshirt_color(id, color) {
	    tshirt = id.replace('_'+color, '');
	    $('#'+tshirt).css({backgroundImage: 'url(http://images.weadmire.net/tshirt_jpegs/'+color+'.jpg)'});
}
function reset_sizes(tid) {
	    $('#'+tid+'_xs').attr('src',  "http://images.weadmire.net/quick_checkout/tshirt_sizes/greyed_out/xs.jpg");
	    $('#'+tid+'_s').attr('src', "http://images.weadmire.net/quick_checkout/tshirt_sizes/greyed_out/s.jpg");
	    $('#'+tid+'_m').attr('src', "http://images.weadmire.net/quick_checkout/tshirt_sizes/greyed_out/m.jpg");
	    $('#'+tid+'_l').attr('src', "http://images.weadmire.net/quick_checkout/tshirt_sizes/greyed_out/l.jpg");
	    $('#'+tid+'_xl').attr('src', "http://images.weadmire.net/quick_checkout/tshirt_sizes/greyed_out/xl.jpg");
	    $('#'+tid+'_2xl').attr('src', "http://images.weadmire.net/quick_checkout/tshirt_sizes/greyed_out/2xl.jpg");
	    $('#'+tid+'_3xl').attr('src', "http://images.weadmire.net/quick_checkout/tshirt_sizes/greyed_out/3xl.jpg");
}
function select_size(button, size) {
	    tid = button.id.replace('_'+size, '');
	    reset_sizes(tid);
	    $(button).attr('src', "http://images.weadmire.net/quick_checkout/tshirt_sizes/highlighted/"+size+'_s.jpg');
	    $('#'+tid+'_tsize').attr('value', size);
	    checkout_ready(tid);
            if (size=='xs')  {
	      $('#'+tid+"_sage").hide();
	      $('#'+tid+"_apple_white").hide();
	      $('#'+tid+"_phenom_black").hide();
	      $('#'+tid+"_phenom_blue").hide();
	    }
	    else {
	      $('#'+tid+"_sage").show();
	      $('#'+tid+"_apple_white").show();
	      $('#'+tid+"_phenom_blue").show();
	      $('#'+tid+"_phenom_black").show();
            }
}
function tdefault(tshirtid, defcolor) {
	 tshirt = tshirtid.replace('_'+defcolor, '');
         background = $('#'+tshirt+'_tshirtcolor').attr('value');
	 $('#'+tshirt).css({backgroundImage: 'url(http://images.weadmire.net/tshirt_jpegs/'+background+'.jpg)'});
}
function checkout_ready(elemid) {
	$('#'+elemid+'_addtocart').show();
	$('#'+elemid+'_buybutton').show();
}
function setbuynow(button) {
	    redirect = (button.id).repleace('_buynow', '_redirect');
	    $(redirect).attr('value', 'buynow');
}
