jQuery.fn.createLateralGamesList = function(options) {
	var settings = jQuery.extend({
		url: "/shop/news-ALL-1.html",
		title: "Nyhed Produkter",
		moreUrl: null,
		moreText:"Flere"
	}, options);
	
	var $this = $(this);
	$this.addClass("lateral-panel");
	$this.addClass("lateral-game-list");
	$this.html('<div style="background:url(\'/images/CyklopStudio/prodMenuTop.png\') no-repeat scroll 0 0 transparent"><span class="Heading_Productmenu">'+settings.title+'</span></div>');
	
	context = this;
	$.ajax({
		url:settings.url,
		dataType:"xml",
		data:{'rawxml': '1'},
		context:context,
		success:function(data, textStatus, XMLHttpRequest){
			var $this = $(this);
			var $xml = $(data);
			//$this.append($xml.text());
			
			$Products = $xml.children().children("Product");
			if ($Products.length > 0) {
				var $ul = $("<table class='content' cellspacing='0' cellpadding='0' border='0' width='100%'></table>");
				$this.append($ul);
				$Products.each(function(index, element) {
					var count = index+1;
					var $product = $(element);
					var link = $product.children("FramelessProductLnk").text();
					var liStr = '<tr>';
					liStr += '<td style="width:30px;text-align:center;font-size:11px;color:#666666;font-weight:bold;border-left:1px solid #e8e8e8;border-bottom:1px solid #e8e8e8;">'+count+'</div>';
					liStr += '<td style="width:160px;border-right:1px solid #e8e8e8;border-bottom:1px solid #e8e8e8;"><a href="'+link+'" class="game-title">'+$product.children("ProductName").text()+'</a><br />'+$product.children("Price").text()+' DKK</td>';
					liStr += '</tr>';
					$ul.append(liStr);
				});
				
				var moreUrl = settings.moreUrl;
				if (moreUrl === null) {
					moreUrl = settings.url;
				}
				//$ul.append("<li class='more'><a href='"+moreUrl+"'>"+settings.moreText+"</a></li>");
			} else {
				$this.append("No products");
			}
		}
	});
};

$(document).ready(function(){
	$("#ShopLayOut_Basket_TD").parent().remove();

	//$("#ShopMainLayOutTable #ShopLayOut_Topmenu_TD a").wrap('<div class="topMenu" />');
	$("#ShopMainLayOutTable #ShopLayOut_Topmenu_TD a").each(function(){
		$(this).wrap('<div class="topMenu" onclick="location.href=\''+$(this).attr("href")+'\'">');
	});
	$("#ShopMainLayOutTable .topMenu:eq(0)").addClass("topMenuFirst");
	$("#ShopMainLayOutTable .topMenu:eq(0)").removeClass("topMenu");
	
	// move basket
	$("#basketDest").html($("#showBasketCont"));
	
	// grab menu
	var bHtml = $("#ShopLayOut_Topmenu_TD").html();
	$("#menuBot").html(bHtml);
	$("#menuBot .searchDiv").remove();
	$("#menuBot div").addClass("botMenu");
	$("#menuBot div").removeClass("topMenuFirst");
	$("#menuBot div").removeClass("topMenu");
	$("#menuBot .botMenu").append('<span class="spacerCyk">&nbsp;|&nbsp;</span>');
	$(".spacerCyk").last().remove();
	
	//fix prodSubPage last prod margin
	$("#ShopMainLayOutTable .prodCont").each(function(index){
		var index2 = parseInt(index)+1;
		if ( Math.round(index2/3) == index2/3 && index2/3 != 0){
			$(this).css("margin-right","0");
		}
	});
	
	//fix prodList
	$("#ProductList_TD table:eq(0)").css("height","0");

	$("#ShopMainLayOutTable #ProductList_TD .prices").each(function(){
		if ($(this).text() == ""){
			$(this).next().text("");
		}
	});
	//fix prodList
	$("#ShopMainLayOutTable .SubCats_Categories_TD .prodListCont").each(function(index){
		var index2 = parseInt(index)+1;
		if ( Math.round(index2/3) == index2/3 && index2/3 != 0){
			$(this).css("margin-right","0");
		}
	});

	//fix prodMenu
	$(".SubCategory1_Productmenu:eq(0)").parent().parent().parent().parent().css("background","none");
	
	// active to topMenu
	var last;
	var loc = location.href.toUpperCase();
	var link;
	var bHtml = $("#ShopLayOut_Topmenu_TD").html();
	
	$("#ShopLayOut_Topmenu_TD a").each(function(index){
		link = $(this).attr("href").toUpperCase();
		if( loc.search(link) != -1 && link != "/"){
			$(this).parent().attr("id","selected");
		}
		if( loc.search("FRONTPAGE.HTML") != -1 ){
			$("#ShopLayOut_Topmenu_TD a:eq(0)").parent().attr("id","selectedFront");
		}
		last = $(this);
	});
	$(last).next().remove();

	//hack the prod card
	$("#ShopMainLayOutTable #buySec #BUYSECTION tbody tr td br").remove();
	$(".Related_BuyButton_IMG").attr('src','/images/CyklopStudio/rPbuyBut.png');
	$("#kkO").parent().next().next().remove();
	
	/*
	$("#ShopMainLayOutTable #xx img").each(function(){
		if ($(this).attr("class") != "Productinfo_Specialoffer_Overlay_IMG" && $(this).attr("class") != "Specialoffer_Overlay_IMG"){
			if ( $(this).height() > 280 ){
				$(this).height(280);
			}
			if ( $(this).width() > 280 ){
				$(this).width(280);
			}
			if ($(this).parent().attr("id") != "Selector"){
				$("#newsOimg").css("top",$(this).height()-49);
			}
		}
	});
	
	$("#ShopMainLayOutTable #Selector img").hover(function(){
		$("#ShopMainLayOutTable #xx img").each(function(){
			if ($(this).attr("class") != "Productinfo_Specialoffer_Overlay_IMG" && $(this).attr("class") != "Specialoffer_Overlay_IMG"){
				if ( $(this).height() > 180 ){
					$(this).height(180);
				}
				if ( $(this).width() > 180 ){
					$(this).width(180);
				}
				$("#newsOimg").css("top",180-49);
			}
		});
	});
	
	if ( $("#Selector").html() != "" ){
		$("#Selector").css("margin-top","10px")
	}*/
	
	$("#ShopMainLayOutTable .prodImg a img").each(function(){
		if($(this).height() > 150){
			$(this).height(150)
		}
		if($(this).width() > 150){
			$(this).width(150)
		}
	});
	
	var imgHeight = $("#ShopMainLayOutTable #xx #Canvas div img").css("height");
	$("#ShopMainLayOutTable #xx div:eq(0)").height(imgHeight);
	$("#ShopMainLayOutTable .ProductInfo_TD .CustomersAlsoBought_Custom_TBL .prices").each(function(){
		if ($(this).text() == ""){
			$(this).next().text("");
		}
	});
	//var noget = $("#ShopMainLayOutTable .PriceBefore_ProductInfo_TD").remove();
	//$("#ShopMainLayOutTable .PriceBefore_ProductInfo_TD").html(noget);
	$("#ShopMainLayOutTable #tPbefore").html( $("#ShopMainLayOutTable .PriceBefore_ProductInfo_TD .PriceStriked_Productinfo").html() );
	$("#ShopMainLayOutTable .PriceBefore_ProductInfo_TD").remove()
	if ( $("#ShopMainLayOutTable #pInfoCont .bStroke #tPbefore").text() == "" ){
		$("#ShopMainLayOutTable #pInfoCont .bStroke:eq(1)").prev().remove();
		$("#ShopMainLayOutTable #pInfoCont .bStroke:eq(1)").remove();
	}
	
	//fix show basket
	$("#ShopMainLayOutTable #ShowBasket_TD.ShowBasket_TD table table:eq(0)").width(700);
	$("#ShopMainLayOutTable #ShowBasket_TD.ShowBasket_TD table table:eq(1)").width(700);
	$("#ShopMainLayOutTable #ShowBasket_TD.ShowBasket_TD table table:eq(2)").width(700);
	$("#ShopMainLayOutTable #ShowBasket_TD.ShowBasket_TD table table:eq(4)").width(700);
	
	//fix orderstep
	$("#ShopMainLayOutTable .CustomerData_Orderstep1_TBL tr:eq(1) td:eq(0) table").css('width','98%');
	$("#ShopMainLayOutTable .OrderStep3_Next_TD .SubmitButton_OrderStep3").attr("value","");
	
	getNewItems();
	
	$("#OrderStep3_TD .BackGroundColor1_OrderStep3 td br:eq(0)").remove();
	$("#OrderStep3_TD .BackGroundColor1_OrderStep3 td br:eq(1)").remove();
	$("#OrderStep3_TD .BackGroundColor1_OrderStep3 td br:eq(2)").remove();
});

function getNewItems(){
	$("#top10List").createLateralGamesList({
		url:"/shop/toplist-2-10-1.html",
		title:"Mest solgte",
		moreUrl: "/shop/toplist-2-10-1.html"
	});
	return false;
}


