j$(function() {
  rrEvents("div#spTools div.events div.container ul.events");
  mediaSlide("div#mediaslide");
  promotions("div#promotions");
	spToolsJ('spTools');
	clickDrawer("spArticleDrawer");
	clickDrawer("spRecipeDrawer");
	aDrawer("spRecipeDrawer");
	aDrawer("featuredArticle");
	newline_store();
});

var getN = j$(document).getUrlParam("N");
var videoCats = [];
var themedVideoCats = [];
var themeVideos = '';
var themeVideos = [];
var videoProducts = [];

function aDrawer(parentDiv) {
	if(j$("div."+parentDiv).length > 0)
	{
		var contentDrawer = j$("div#"+parentDiv+'.contentDrawer');
		contentDrawer.hide();
		j$("div."+parentDiv+' a.faToggle').css('background-image','url(/lowes2/Promos/spring/images/arrow_GR_DN.gif)');
		j$("div#"+parentDiv+'.contentDrawer').html(j$("div."+parentDiv+' div.hiddenDrawer').html(''));
		j$("div."+parentDiv+' div.hiddenDrawer').empty();
		j$("div."+parentDiv+' a.faToggle').bind('click', function() {
			j$("div#"+parentDiv+'.contentDrawer').slideToggle();
			if("div#"+j$(parentDiv+'.contentDrawer').css('display') == 'block')
			{
				j$("div."+parentDiv+' a.faToggle').text('Close');
				j$("div."+parentDiv+' a.faToggle').css('background-image','url(/lowes2/Promos/spring/images/arrow_GR_UP.gif)');
				j$("div#"+parentDiv+'.contentDrawer').css('display','hidden');
			}
			else
			{
				j$("div#"+parentDiv+' a.faToggle').text('Read More');
				j$("div#"+parentDiv+' a.faToggle').css('background-image','url(/lowes2/Promos/spring/images/arrow_GR_DN.gif)');
			}
			return false;
		});
	}
}

function clickDrawer(parentDiv) {
  if(parentDiv.length > 0) {
    content = j$("div.hiddenDrawer."+parentDiv).html();
    j$("div#"+parentDiv+".contentDrawer").html(content);
    j$("div.hiddenDrawer."+parentDiv).remove();
    j$("div.footerDrawer."+parentDiv+" a").bind("click.toggleDrawer", function() {      
      if(j$(this).hasClass('arrowblue_closed'))
      {
		j$(this).text('Close');
        j$(this).removeClass('arrowblue_closed').addClass('arrowblue_open').ready(function() {
          j$("div#"+parentDiv+".contentDrawer").slideDown('slow');
        });
      }
      else if(j$(this).hasClass('arrowblue_open'))
      {
		 j$(this).text('Related Videos')
        j$(this).removeClass('arrowblue_open').addClass('arrowblue_closed').ready(function() {
          j$("div#"+parentDiv+".contentDrawer").slideUp('slow');
        });
      }
      return false;
    });
  }
}

//GET VIDEO CATEGORIES AND ASSOCIATE VIDEOS
function getVideoCategories(theme,playlist) {
  j$.ajax({
    type: 'GET',
    dataType: 'jsonp',
    url: 'http://gdata.youtube.com/feeds/api/users/lowes/playlists?alt=json-in-script',
    cache: false,
    success: function(data) {
      var feed = data.feed;
      var entries = feed.entry || [];
      var vcount = 0;

      j$(entries).each(function(i) {
        catID = entries[i].yt$playlistId.$t;
        if(j$.inArray(catID, themedVideoCats) != -1)
        {
          videoCats[vcount] = [];
          videoCats[vcount].videos = []
          videoCats[vcount].id = catID;
          videoCats[vcount].title = entries[i].title.$t;
          videoCats[vcount].videoCount = entries[i].gd$feedLink.countHint;
          getVideos(vcount);
          vcount++;
        }
      });
    }
  });
}

//GET VIDEOS
function getVideos(playlistID) {
  var url = "http://gdata.youtube.com/feeds/api/playlists/"+playlistID+"?alt=json-in-script";
  j$.ajax({
    type: 'GET',
    dataType: 'jsonp',
    url: url,
    cache: false,
    success: function(data) {
      var feed = data.feed;
      var vfeed = feed.entry || [];
      j$(vfeed).each(function(i) {
        themeVideos[i] = [];
        themeVideos[i].id = vfeed[i].link[0].href.substring(vfeed[i].link[0].href.indexOf('=')+1,vfeed[i].link[0].href.length);
        themeVideos[i].url = vfeed[i].link[0].href;
        themeVideos[i].title = vfeed[i].title.$t;
        themeVideos[i].thumbnail = vfeed[i].media$group.media$thumbnail[0].url;
        themeVideos[i].description = vfeed[i].media$group.media$description.$t;
      }).ready(function() {
        appendVideo(themeVideos[0].id, themeVideos[0].title,themeVideos[0].description);
      });
    }
  });
}

//Add video HTML
function appendVideo(videoID,videoTitle,videoDescription) {
  embedHTML = "<div class=\"vid\">"+
                "<object width=\"350\" height=\"230\">"+
                	"<param name=\"movie\" value=\"http://www.youtube.com/v/"+videoID+"&autoplay=0&rel=0&fs=1&color1=0xcccccc&color2=0xffffff&border=0&loop=0\">"+
                	"<param name=\"allowFullScreen\" value=\"true\">"+
                	"<embed wmode=\"opaque\" src=\"http://www.youtube.com/v/"+videoID+"&autoplay=0&rel=0&fs=1&color1=0xcccccc&color2=0xffffff&border=0&loop=0\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"350\" height=\"215\"></embed>"+
                "</object>"+
              "</div>";

  j$("div#spVideo div.videoBody div.vid").removeClass('loading').replaceWith(embedHTML);
  j$("div#spVideo div.videoBody div.left").replaceWith("<div class=\"left\"><h3>"+videoTitle+"</h3><p>"+videoDescription+"</p></div>");
  updateRelatedProducts(videoID);
  (themeVideos.length > 1) ? appendRelatedVideos(videoID) : j$("div.spVideoDrawer").remove();
}

//Add related videos HTML
function appendRelatedVideos(currentID) {
  fullWidth = 0;
  j$("div.contentDrawer.spVideo div.slider_content ul.videos").empty();
  j$(themeVideos).each(function(i) {
    if(themeVideos[i].id != currentID)
    {
      j$("div.contentDrawer.spVideo div.slider_content ul.videos").append("<li><a id=\""+themeVideos[i].id+"\" href=\"http://www.youtube.com/watch?v="+themeVideos[i].id+"\"><img width='100' height='74' src=\""+themeVideos[i].thumbnail+"\" alt=\""+themeVideos[i].title+"\" /><span>"+themeVideos[i].title+"</span></a></li>").ready(function() {
		    if($defined(j$("div.contentDrawer.spVideo div.slider_content ul.videos li:last").css('width'))){
				fullWidth += j$("div.contentDrawer.spVideo div.slider_content ul.videos li:last").css('width').toInt();
		    	fullWidth += j$("div.contentDrawer.spVideo div.slider_content ul.videos li:last").css('padding-left').toInt();
		    	fullWidth += j$("div.contentDrawer.spVideo div.slider_content ul.videos li:last").css('padding-right').toInt();
			}
      });
      
      j$("div.contentDrawer.spVideo div.slider_content ul.videos li a#"+themeVideos[i].id).bind("click", function() {
        appendVideo(themeVideos[i].id, themeVideos[i].title,themeVideos[i].description);
        return false;
      });
    }
  }).ready(function() {
    j$("div.contentDrawer.spVideo div.slider_content ul.videos").css('width',fullWidth);
    videoSlider("div.contentDrawer.spVideo");
  });
}

var set_up_already = 0;

function videoSlider(parentDiv) {
	if(set_up_already == 0) {
	if(j$(parentDiv).length > 0) {
		var slides = [];
		j$(parentDiv+" div.slider_content ul li").each(function() {
		  slides.push(j$(this));
		});
		var slides_container = j$(parentDiv+" div.slider_content");
		var move_increment = slides[0].css('width').toInt()+slides[0].css('padding-right').toInt()+slides[0].css('padding-left').toInt();
		var current_slide = 0;
		var prev_arrow = j$(parentDiv+' div.controls a.prevbtn');
		var next_arrow = j$(parentDiv+' div.controls a.nextbtn');
		
		if(current_slide < slides.length-2) next_arrow.css('display','block');

		next_bind = function(){
			next_arrow.unbind('click.slideNext');
			next_arrow.bind('click.slideNext',function(){
				current_slide++;
				slide_items(parentDiv,0);
				return false;
			});
		}

		prev_bind = function(){
			prev_arrow.unbind('click.slidePrev');
			prev_arrow.bind('click.slidePrev',function(){
				current_slide--;
				slide_items(parentDiv,1);
				return false;
			});
		}
		
		prev_bind();
		next_bind();

		var groupInc = 3;
		var end = 0;

		function check_arrows() {
		  num_leftx = (current_slide+1) * 3;
		  
		  if(current_slide == 0 || slides.length <=3)
		  {
		    prev_arrow.css('display','none');
		  }
		  else if(current_slide > 0)
		  {
		    prev_arrow.css('display','block');
		  }
		  
      if(end == 1 || slides.length <=3 || num_leftx == slides.length)
		  {
		    next_arrow.css('display','none');
		  }
		  else   {
		    next_arrow.css('display','block');
		  }
		}
		
		check_arrows();
		
		function slide_items(parentDiv,which) {
			prev_arrow.unbind('click');
			next_arrow.unbind('click');

			num_left = slides.length - (current_slide * 3) ;
			if(num_left >= 3){
				end = 0;
				num_left = 3;
			}else{
				end = 1;
			}			
			my_obj = j$(parentDiv+" div.slider_content ul.videos");
			if(which == 0){
					move_to = (my_obj.css('left').toInt())-(move_increment*num_left);
			}
			if(which == 1){
				if(current_slide == 0){
					move_to = 0;
				}else{
					move_to = (my_obj.css('left').toInt())+(move_increment*num_left);
				}
			}
			my_obj.animate({left: move_to+"px"}, { queue:false, duration:400, complete:function() {
  			prev_bind();
  			next_bind();
			}});
			check_arrows();
		}
	}
	set_up_already = 1;
	}
}

function getThemes() {
  j$.ajax({
    type: 'GET',
    dataType: 'xml',
    cache: false,
    url: '/lowes2/Promos/spring/feed/themes.xml',
    success: function(xml) {
      j$(xml).each(function() {
        j$(this).find('theme').each(function(i) {
          themedVideoCats[i] = [];
          themedVideoCats[i].getN = j$(this).attr('getN');
          themedVideoCats[i].playlist_id = j$(this).find('playlist_id').text();
          if(getN == j$(this).attr('getN')  || getN == j$(this).attr('getN2') || getN == '0+'+j$(this).attr('getN') || getN == '0+'+j$(this).attr('getN2'))
          {
            getVideos(j$(this).find('playlist_id').text());
          }
        });
      });
    }
  });
}

function updateRelatedProducts(videoID) {
videoProducts = [];
j$("div#spVideo div.videoBody div.right").empty();
j$.ajax({
    type: 'GET',
    dataType: 'xml',
    cache: false,
    url: '/lowes2/Promos/spring/feed/videoproducts.xml',
    success: function(xml) {
      j$(xml).each(function() {
        j$(this).find('video').each(function(i) {
          if(j$(this).attr('id') == videoID)
          {
      			if($defined(j$(this).attr('pdf')))
      			{
      				j$("div#spVideo div.videoBody div.right").append("<a target=\"blank\" class=\"viewinstructions\" href=\""+j$(this).attr('pdf')+"\">View Instructions</a>");
      			}
      			
      			j$(this).find('product').each(function(i) {
      				videoProducts[i] = [];
      				videoProducts[i].video = videoID;
      				videoProducts[i].name = j$(this).find('name').text();
      				videoProducts[i].image = j$(this).find('image').text();
      				videoProducts[i].url = j$(this).find('url').text();
      			});
          }
        }).ready(function() {
			 if(videoProducts.length == 0){
				 j$("div#spVideo div.relatedproducts").css('display','none');
				 j$('div#spVideo div.videoBody div.relatedproducts ul').empty();
			 }
			  else if(videoProducts.length > 0){
				j$("div#spVideo div.relatedproducts").css('display','block');
				if(j$("div#spVideo div.relatedproducts h3").length>0){
				  j$("div#spVideo div.relatedproducts h3").remove();
				}
				j$("<h3>Related Products</h3>").insertBefore("div#spVideo div.relatedproducts ul");
			  }
         	 j$('div#spVideo div.videoBody div.relatedproducts ul').empty();
          	j$(videoProducts).each(function(i) {
           	 j$("div#spVideo div.videoBody div.relatedproducts ul").append("<li><a href=\""+videoProducts[i].url+"\"><img width=\"100\" height=\"100\" src=\""+videoProducts[i].image+"\" alt=\""+videoProducts[i].name+"\" /><span>"+videoProducts[i].name+"</span></a></li>");
         	 });
        });
      });
    }
  });
}

//Right rail events list
function rrEvents(parentDiv) {
  var events = [];
  
  j$.ajax({
    type: 'GET',
    dataType: 'xml',
    cache: false,
    url: '/lowes2/Promos/spring/feed/rrevents.xml',
    success: function(xml) {
      j$(xml).find('events').find('event').each(function(i) {
        events[i] = [];
        events[i].date = j$(this).attr('date');
        events[i].title = j$(this).find('title').text();
      });
    },
    complete: function(xhr) {
      if(xhr.readyState == 4 && xhr.status == 200)
      {
        appendEvents(parentDiv);
      }
    }
  })
  
  function appendEvents(parentDiv) {
    j$(parentDiv).empty().ready(function() {
      j$(events).each(function(i) {
        var eventDateArr = []
        eventDateArr = events[i].date.split('/');
        var eventDate = new Date();
        eventDate.setFullYear(eventDateArr[2],eventDateArr[0]-1,eventDateArr[1]);
        var today = new Date();
        if (eventDate >= today) j$(parentDiv).append("<li"+((i+1==events.length) ? " class=\"last\" " : "")+"><span class=\"date\">"+eventDateArr[0]+"/"+eventDateArr[1]+" - </span>"+events[i].title+"</li>");
      });
    });
  }
}

//Right rail promotions
function promotions(parentDiv) {
  var fullWidth = 0;
  var title = '';
  var description = '';
  var image = '';
  var buynow_link = '';
  var details_link = '';

  j$.ajax({
    type: 'GET',
    dataType: 'xml',
    cache: false,
    url: '/lowes2/Promos/spring/feed/promotions.xml',
    success: function(xml) {
      j$(xml).find('promo').each(function() {
        title = j$(this).find('title').text();
        description = j$(this).find('description').text();
        image = j$(this).find('image').text();
        buynow_link = j$(this).find('buynow_link').text();
        details = j$(this).find('details').text();
        if(description.length > 170) description = description.substring(0,166) + '...';

        var html = "<div class=\"slide_item\">"+
                       "<img src=\"/lowes2/Promos/spring/content/images/promotions/"+image+"\"/>" +
                       "<p>"+title+"</p>"+
                       "<ul class=\"foot-options\">"+
                         ((details != '') ? "<li class=\"moredetails\"><a rel=\""+details+"\" href=\"#\">More Details</a></li>" : '') +
                         ((buynow_link.contains('stores.lowes.com')) ? "<li class=\"find_a_store\"><a href=\""+buynow_link+"\">Find a store</a></li>" : (($defined(buynow_link)) ? "<li class=\"buynow\"><a href=\""+buynow_link+"\">Buy Now</a></li>" : '' )) +
                       "</ul>"+
      				     "</div>"; 
				j$(html).appendTo(parentDiv+" div#promoItems").ready(function() {
					if($defined(j$(parentDiv+" div#promoItems div.slide_item:last").css('width'))){
  		    				fullWidth += j$(parentDiv+" div#promoItems div.slide_item:last").css('width').toInt()+20;
  		    				fullWidth += j$(parentDiv+" div#promoItems div.slide_item:last").css('padding-left').toInt();
  		    				fullWidth += j$(parentDiv+" div#promoItems div.slide_item:last").css('padding-right').toInt();
					}
				});
					
      }).ready(function() {
        j$(parentDiv+" div#promoItems").css('width',fullWidth);
        promoSliderJ(parentDiv);
      });
    }
  });
}

//Promo slider
function promoSliderJ(parentDiv) {
	if(j$(parentDiv).length>0) {
		var slides = [];
		j$(parentDiv+" div.slide_item").each(function() {
      var popBoxContent = j$(this).find('div.moredetails').text();
		  slides.push(j$(this));
		  j$(this).find('ul.foot-options li.moredetails a').each(function() {
		    j$(this).bind('click', function(e) {
		      popBoxJ(j$(this).attr('rel'),e.pageX,e.pageY);
          j$(document).bind("click.popBox", function(e){
            j$("#spring_popbox").remove();
            j$(document).unbind('click.popBox');
            return false;
          });
          j$("#spring_popbox").bind("mouseenter", function(e){
            j$(document).unbind('click.popBox');
		  clearInterval(autoSlideTimer);
          });
          j$("#spring_popbox").bind("mouseleave", function(e){
			auto_slide(parentDiv);
            if(j$("#spring_popbox").length > 0)
            {
              j$(document).bind("click.popBox", function(e){
                j$("#spring_popbox").remove();
                j$(document).unbind('click.popBox');
                return false;
              });
            }
          });
		      return false;
		    });
		  });
		});
		var slides_container = j$(parentDiv+" div#promoItems");
		var move_increment = slides[0].css('width').toInt()+slides[0].css('padding-right').toInt()+slides[0].css('padding-left').toInt();
		var current_slide = 0;
		var prev_arrow = j$(parentDiv+' a#prevbtn');
		var next_arrow = j$(parentDiv+' a#nextbtn');
		
		if(current_slide < slides.length) next_arrow.css('display','block');

		next_arrow.bind('click.slideNext',function(){
			current_slide++;
			slide_items(parentDiv);
		});
		
		prev_arrow.bind('click.slidePrev',function(){
			current_slide--;
			slide_items(parentDiv);
		});
		
		function check_arrows() {
			if(current_slide == slides.length-1)
			{
				next_arrow.css('display','none');
				prev_arrow.css('display','block');
			}
			else if (current_slide == 0)
			{
				prev_arrow.css('display','none');
				next_arrow.css('display','block');
			}
			else
			{
				prev_arrow.css('display','block');
				next_arrow.css('display','block');
			}
		}
		
		function slide_items(parentDiv) {
			check_arrows();
			move_to = move_increment*current_slide*-1;
			j$(parentDiv+" div#promoItems").animate({left: move_to+"px"}, { queue:false, duration:400 });
		}
		
		j$(parentDiv).bind("mouseover", function() {
		  clearInterval(autoSlideTimer);
		});
		
		j$(parentDiv).bind("mouseout", function() {
      auto_slide(parentDiv);
		});
		
		function auto_slide(parentDiv) {
      autoSlideTimer = setInterval(function() {
								    j$("#spring_popbox").remove();
        if(current_slide < slides.length-1)
        {
          current_slide++
          slide_items(parentDiv);
        }
        else
        {
          current_slide = 0;
          slide_items(parentDiv);
        }
      },4000);
		}
		auto_slide(parentDiv);
	}
}

//Message Box Popup
function popBoxJ(html, x, y) {
  var popbox = j$("#spring_popbox");
  popbox.remove();
  
  var content = 	"<div id=\"spring_popbox\">\n\t<div>"+html+
					"\n"+"<a id=\"close\" href=\"javascript://\">close</a>\n\t</div>\n</div>";
                    
  j$(content).appendTo("#container");
  	j$("#close").bind("click",function(){
		j$("#spring_popbox").remove();		
	});

  popbox.fadeIn('slow', function() {
    popbox.animate({opacity: 1.0},4000).fadeOut('slow', function() {
      j$(this).remove();
    });
  });
}

//Right rail Spring Tool Boxes
function spTools(parentDiv) {
  if($chk($(parentDiv)))
  {
    $$('#'+parentDiv+' ul li a').each(function(aEl) {
      aEl.addEvent('click', function() {
        $$('#'+parentDiv+' div.boxgray1').each(function(divEl) {
          if(divEl.getProperty('class') != aEl.getProperty('class'))
            if(divEl.hasClass('show'))
              divEl.removeClass('show');
        });
        if($chk($$("#"+parentDiv+" div."+aEl.getProperty('class'))[0]))
          $$("#"+parentDiv+" div."+aEl.getProperty('class'))[0].toggleClass('show');
        return false;
      });
    });
  }
}

//Right rail Spring Tool Boxes rewritten in jQuery
function spToolsJ(parentDiv)
{
  if(j$('#'+parentDiv).length>0)
  {
    j$('#'+parentDiv+' ul li a').each(function(aE1) {
      bindShowBox(j$('#'+parentDiv+' ul li a:eq('+aE1+')'),parentDiv);
    });
  }
  function bindShowBox(aE1,parentDiv)
  {
    j$(aE1).bind('click.showBox', function() {
      j$('#'+parentDiv+' div.boxgray1').each(function() {
        if(j$(this).hasClass(aE1.attr('class')) == false)
        if(j$(this).hasClass('show')){
          j$(this).removeClass('show').css('display','none');
        }
      });
      var className = j$(this).attr('class');
      if(j$('#'+parentDiv+' div.boxgray1.'+className).hasClass('show')==false)
      {
        j$('#'+parentDiv+' ul li a').unbind('click.showBox');

        j$('#'+parentDiv+' div.boxgray1.'+className).slideDown('slow',function(){
          j$('#'+parentDiv+' ul li a').each(function(aE1) {
            bindShowBox(j$('#'+parentDiv+' ul li a:eq('+aE1+')'),parentDiv);
          });

        }).addClass('show');
      }else{
        j$('#'+parentDiv+' ul li a').unbind('click.showBox');

        j$('#'+parentDiv+' div.boxgray1.'+className).slideUp('slow',function(){
          j$('#'+parentDiv+' ul li a').each(function(aE1) {
            bindShowBox(j$('#'+parentDiv+' ul li a:eq('+aE1+')'),parentDiv);
          });

        }).removeClass('show');
      }
      return false;
    });
  };
}

clickDrawer("spVideoDrawer");
getThemes();
//Youtube video player
function YTVPlayer(elm,when) {
//  if(store_check() == "false") {
    var embedHTML = "<div id=\"spVideo\">"+
                  		"<div class=\"videoHeader\"> <img src=\"http://www.lowes.com/lowes2/Promos/spring/images/videoheader.gif\" width=\"380\" height=\"60\" /> </div>"+
                  		"<div class=\"videoBody\">"+
                  			"<div class=\"vid\">"+
                  			"</div>"+
                  			"<div class=\"left\">"+
                  			"</div>"+
                  			"<div class=\"right\">"+
                  			"</div>"+
                  			"<div class=\"relatedproducts\">"+
                  				"<ul>"+
                  				"</ul>"+
                  			"</div>"+
                  		"</div>"+
                  		"<div class=\"videoFooter\"> <img src=\"http://www.lowes.com/lowes2/Promos/spring/images/contRoundBottom.gif\" width=\"380\" height=\"10\" /> </div>"+
                  	"</div>"+
                  	"<div id=\"spVideoDrawer\" class=\"contentDrawer spVideo\"></div>"+
                  	"<div class=\"footerDrawer spVideoDrawer\"> <a href=\"#Related_Videos\" class=\"arrowblue_closed\" id=\"faToggle\">Related Videos</a> </div>"+
                  	"<div class=\"hiddenDrawer spVideoDrawer\">"+
                  		"<h3>Related Videos</h3>"+
                  		"<div class=\"controls\"><a class=\"prevbtn\" href=\"#back\">Previous</a> <a class=\"nextbtn\" href=\"#next\">Next</a></div>"+
                  		"<div class=\"slider_content\">"+
                  			"<ul class=\"videos productsItems\"></ul>"+
                  		"</div>"+
                  	"</div>";

    switch(when)
    {
      case 'before':
        j$(embedHTML).insertBefore(elm).ready(function() {
          clickDrawer("spVideoDrawer");
          j$("div#spVideo div.vid").addClass('loading');
          getThemes();
        });
        break;
      case 'after':
        j$(embedHTML).insertAfter(elm).ready(function() {
          clickDrawer("spVideoDrawer");
          j$("div#spVideo div.vid").addClass('loading');
          getThemes();
        });
        break;
    }
 // }
}

function newline_store() {
	/*j$(".spCatContainer li.end").each(function(i) {
    	j$("<li class=\"new_line\">&nbsp;</li>").insertAfter(j$(this)); //.find('li.end')
		
	});*/
	
	var new_code = {
		'display' : 'table-cell',
		'width' : '100px'
	}
	
	var check = store_check();
	if(check == 'true') {
		j$('.spCatContainer li').each(function(i) {
			//j$('.spCatContainer').css('display', 'table');
			j$(this).css(new_code);
		});
	}
}