');
gamehtml = '';
var catarrlen = 5;
for (var i = 0; i < catarrlen; i++) {
var topfive = ["9P0Q1F7P0KR1", "C496CLVXMJP8", "9NX3P62G0WNC", "BV9CWVQWNS4P", "BPQZT43FWD49"]
var thebigid = allsalegames[i];
if (urlRegion !== "ar-sa" && urlRegion !== "ar-ae") {
var msrpshown = allGames[thebigid]["msrpprice"].toLocaleString(urlRegion, { style: 'currency', currency: allGames[thebigid]["currencycode"] });
var listshown = allGames[thebigid]["listprice"].toLocaleString(urlRegion, { style: 'currency', currency: allGames[thebigid]["currencycode"] });
} else {
if (urlRegion === "ar-sa") {
currregion = "en-us";
} else {
currregion = "en-ca";
}
var msrpshown = allGames[thebigid]["msrpprice"].toLocaleString(currregion, { style: 'currency', currency: allGames[thebigid]["currencycode"] });
var listshown = allGames[thebigid]["listprice"].toLocaleString(currregion, { style: 'currency', currency: allGames[thebigid]["currencycode"] });
}
if (allGames[thebigid]["listprice"] !== 100000000) {
if (allGames[thebigid]["msrpprice"] !== allGames[thebigid]["listprice"] && allGames[thebigid]["gameswithgold"] === "false") {
var priceshown = '
' + allGames[thebigid]["starcount"] + ''
// $("body").append('' +
//'", msrpshown) + '">' + msrpshown + '' +
'' + regionContent["keyFullprice"] + ' ' + msrpshown + '' +
'' +
'' + regionContent["keyNewprice"] + ' ' + listshown + '' +
'
';
} else {
var priceshown = '' +
'' +
'' + msrpshown + '' +
'
';
}
} else {
var priceshown = "";
}
var pricestartingat = "";
if (gameIdArrays["startingat"].indexOf(thebigid) !== -1) {
pricestartingat = '' + regionContent["keyStartingat"] + '
';
}
badges = '';
if (allGames[thebigid]["gameswithgold"] === "true") {
badges+= '' + regionContent["keyBadgegwg"] + ''
}
var lang = urlRegion.split("-")[0].toLowerCase();
if (lang === "en") {
if (dealsArray.indexOf(thebigid) !== -1) {
badges+= '' + "DEAL OF THE WEEK" + ''
}
}
// } else if (allGames[thebigid]["onsale"] === "true") {
// badges+= '' + regionContent["keyBadgeonsale"] + ''
// }
// if (allGames[thebigid]["newrelease"] === "true") {
// badges+= '' + regionContent["keyBadgenewrelease"] + ''
// }
// if (allGames[thebigid]["upcoming"] === "true" && allGames[thebigid]["purchasable"] === "false") {
// badges+= '' + regionContent["keyBadgecomingsoon"] + ''
// }
if (allGames[thebigid]["title"].toLowerCase().indexOf("preview") !== -1 || allGames[thebigid]["description"].toLowerCase().indexOf("game preview") !== -1) {
badges+= ''
} else if (allGames[thebigid]["upcoming"] === "true" && allGames[thebigid]["purchasable"] === "true" && allGames[thebigid]["title"].toLowerCase().indexOf("game preview") === -1) {
badges+= '' + regionContent["keyBadgepreorder"] + ''
}
if (docwidth < 768) {
var theboxshot = allGames[thebigid]["boxshotsmall"]
} else {
var theboxshot = allGames[thebigid]["boxshot"]
}
var disprelease = "-"
if (allGames[thebigid]["releasedate"] !== 0) {
var d = new Date(allGames[thebigid]["releasedate"]);
if (d.getFullYear() < 2027) {
disprelease = d.toLocaleDateString(urlRegion, {year: 'numeric', month: 'long', day: 'numeric'});
}
}
var thestars = '';
if (allGames[thebigid]["starcount"] > 4) {
var totalratings = allGames[thebigid]["starcount"];
var avgrating = allGames[thebigid]["stars"];
var percentfilled = (avgrating / 5) * 100;
var offset;
if (percentfilled <= 20) {
offset = 0;
} else if (percentfilled > 20 && percentfilled <= 40) {
offset = 12;
} else if (percentfilled > 40 && percentfilled <= 60) {
offset = 24;
} else if (percentfilled > 60 && percentfilled <= 80) {
offset = 36;
} else if (percentfilled > 80 && percentfilled <= 100) {
offset = 48;
}
var starsfilled = ((percentfilled / 100) * 90) + offset;
thestars = '' +
'' +
'' + specialshown + '' +
'
' +
'' + regionContent["keyPopgpgame"] + '
' + regionContent["keyPopeagame"].replace("
' +
'' + regionContent["keyBadgecomingsoonlower"] + '' +
'
';
popgoldprice = '';
popservices = '';
priceButtons = 'learn-more>click" class="c-call-to-action f-lightweight c-glyph poplastbutton" target="_blank">' +
'' + regionContent["keyLearnmore"] + '' +
''
}
var qlbutclass = '';
if (allGames[thebigid]["physical"] === "true") { qlbutclass = ' physgame'}
var datatrack = 'data-retailer="ms store"'
if (allGames[thebigid]["gameurl"].toLowerCase().indexOf("xbox.com") !== -1) {
datatrack = 'data-cta="learn"'
}
var eachgameA = '' +
'click" ' + datatrack + '>' +
'' +
' ' +
badges +
' ' +
'
';
if (docwidth > 1083) {
gamehtml += eachgameA + quickLookButton + eachgamePopup + eachgameB;
} else {
gamehtml += eachgameA + eachgameB;
}
}
$(".fivegames .gameDivsWrapper").append(gamehtml);
// popup
$(document).on("mouseenter", ".gameDiv a.gameDivLink", function(e) {
$(e.target).off("mouseleave");
var buttontoshow = $(e.target).closest(".gameDiv").find(".qlButton");
$(".popupShow").removeClass("popupShow");
$(buttontoshow).addClass("popupShow");
})
$(document).on("focus", ".gameDiv a.gameDivLink", function(e) {
$(".qlButton").removeClass("popupShow");
var buttontoshow = $(e.target).closest(".gameDiv").find(".qlButton");
$(".popupShow").removeClass("popupShow");
$(buttontoshow).addClass("popupShow");
})
$(document).on("click", ".qlButton a", function(e) {
e.preventDefault();
var poptoopen = $(this).closest(".gameDiv").find(".gameMoreInfo");
var starperc = $(poptoopen).find(".ratingstars").attr("data-starpercent") || "0";
$(poptoopen).find(".c-rating[data-value].f-individual.filledstars div").css("width", starperc + "px");
$(poptoopen).addClass("popupShow");
// var rightside = $(".gameMoreInfo.popupShow").offset().left + $(".gameMoreInfo.popupShow").width();
// if (rightside > $(window).width()) {
// var dif = (rightside - $(window).width()) + 50;
// $(poptoopen).css("margin-left", "-" + dif + "px");
// }
$(poptoopen).find(".qclosebutton").focus();
//$(poptoopen).find("h3").eq(0).focus();
// populate rotator
var thebigid = $(this).closest(".gameDiv").attr("data-bigid");
if (allGames[thebigid]["physical"] === "true") {
therotator = '' +
'
' +
'';
var quickLookButton = '' + allGames[thebigid]["title"] + '
' + priceshown + '' +
'' + regionContent["keyQuicklook"] + '' +
'
';
var eachgamePopup = '' +
'
';
var eachgameB = ' ' +
'' +
//therotator +
'
' +
'' +
'
' +
'' +
'
' +
'' + allGames[thebigid]["title"] + '
' + thestars + '' +
// popiconRating +
// popiconEnhanced + popiconXpa + popicon4k + popiconHdr +
'
' +
'' +
'
' +
'' + regionContent["keyDescription"] +
': ' + allGames[thebigid]["description"] + '
' +
'' +
'
' +
'' +
//badges +
popbadges +
pricestartingat +
priceshown +
popgoldprice +
popservices +
'
' +
'' +
priceButtons +
'
' +
'