$(function(){
		   
		  //This counter is a controller to spot every fourth TopOffer in the each() loop down the page 
		  var counter = 0;
		   
		   
		  //Gets all the div elements in offerWrapper and compares their ID's to each other and if they need to switch place, they do so.
		  var mylist = $('#offersWrapper');
			var listitems = mylist.children('a').get();
			listitems.sort(function(a, b) {
			   var compA = $(a).attr("id").toUpperCase();
			   var compB = $(b).attr("id").toUpperCase();
			   return (compA < compB) ? -1 : (compA > compB) ? 1 : 0;
			})
			//Appends
			$.each(listitems, function(idx, itm) { mylist.append(itm); });


			//Loop - foe each div in mylist(offersWrapper) it removes the topofferens class and after that checks if it's on every other fourth - if so, it adds the topofferend class
			jQuery.each(mylist.children('a'), function(){
							$(this).removeClass('offersEnd');
							
							if(counter == 3 || counter == 7 || counter == 11 || counter == 15 || counter == 19 || counter == 23 || counter == 27 || counter == 31 || counter == 35 || counter == 39 || counter == 41 || counter == 45)
							{
								$(this).addClass('offersEnd');
							}
							
							counter++
														 });
		

		   });