$(document).ready(function(){

		/*OnClick changes selected row*/
		$(".products_table tbody tr.in-stock").click(function (){
			var ter=$(this).parent();
			$(this).find("input:radio").attr("checked","checked");
			$(ter).find("tr.selected-row").removeClass("selected-row");
			$(this).addClass("selected-row");
		});
		
		/*on each Products_table:
			If there RadioButton selcted from smarty (.dif-ch) adds class ".selected-row" to TR.
			If no ".selcted_row" class in hole table (".Products_table" )
				looks for last TR with ".in-stosk" class and add to this class ".selcted_row"
				
		  var tr_lect = TR which contens radio button (".dif-ch"), selected by smarty
		  var def_row = total TRs with class ".selected-row", to check if smarty have selected any row*/
		  
		$(".products_table").each(function(i){
			var tr_lect = $(this).find(".dif-ch").closest("tr");
			$(tr_lect).addClass("selected-row");
			
			var def_row = $(this).find(".selected-row").size();
			if (!def_row){
				var tr_def_row = $(this).find(".in-stock:last");
				$(tr_def_row).find("input:radio").attr("checked","checked");
				$(tr_def_row).addClass("selected-row");
			}
		});
		
		if ($('.christmas_banner').length) {
			// The link with ID "copy_button" will copy
            // the coupon number
            $('a#copy_button').zclip({
            path:'images/general/ZeroClipboard.swf',
            copy:$('em#coupon_code').text(),
            afterCopy:function(){
                $('a#copy_button').text('Number copied!');
            }
            });
		
            // tooltip when user hovers coupon number
            $('em#coupon_code').mouseover(function(){
                 $('div#tooltip').animate({"height":"110px"}, 100,function(){
						$('em#coupon_code').mouseleave(function(){
							$('div#tooltip').animate({"height":"0px"}, 100);
						});
					});
            });
		}

        ///////////////////////


});


