﻿function LoadPackage()
{
	if(typeof(ArrayHotPackages) == "undefined")
	{
		return;
	}
	var htmlPackage = "";
	var itemTemplate = "<div style=\"padding:5px 5px 0 5px;\"><div style=\"$Style$\"><a style=\"cursor:pointer;color:#000;font-weight:bold;\" onclick=\"DisplayHidden(this.id,'$aID$',true)\" onmouseover=\"DisplayHidden(this.id,'$aID$',false)\" onmouseout=\"InfoHidden(false)\" id=\"$aDetail$\">$PackName$</a><br/><div style=\"float:left;width:80px;height:20px;line-height:20px;\">Time:$RequestDays$</div><div style=\"float:left;height:20px;line-height:20px;\">Price$PackPrice$</div><div style=\"clear:both;\"></div><div style=\"padding-top:5px;\">$star$</div><div style=\"float:right;padding-top:5px;\"><img style=\"cursor:pointer;\" onclick=\"GoCart('$game$','$cartName$','$cartMoneyCode$','$cartPrice$','$cartWebtime$','$cartStartLevel$','$cartEndLevel$','$cartLevelType$','$cartChooseType$','$itemID$','$hash$')\" onmouseout=\"this.src='../powerlevel/images/addtocart.gif'\" onmouseover=\"this.src='../powerlevel/images/addtocart1.gif'\" src=\"../powerlevel/images/addtocart.gif\" style=\"cursor: pointer;\"/></div></div></div>";
	var arrayPack = ArrayHotPackages;
	for(var i = 0; i < arrayPack.length; i++)
	{
		var tempHtml = itemTemplate;						
		tempHtml = tempHtml.replace("$game$", arrayPack[i][15]);
		tempHtml = tempHtml.replace(/\$PackName\$/g, arrayPack[i][1].replace("new.gif","/Images/Common/new.gif"));
		tempHtml = tempHtml.replace("$RequestDays$", arrayPack[i][7]);
		tempHtml = tempHtml.replace("$PackPrice$", arrayPack[i][3] + arrayPack[i][4]);
		tempHtml = tempHtml.replace("$cartName$", arrayPack[i][1].replace("\"","\\\"").replace("'", "\\'").replace("new.gif","/Images/Common/new.gif"));
		tempHtml = tempHtml.replace("$cartMoneyCode$", arrayPack[i][2]);
		tempHtml = tempHtml.replace("$cartPrice$", arrayPack[i][4]);
		tempHtml = tempHtml.replace("$cartWebtime$", arrayPack[i][11]);
		tempHtml = tempHtml.replace("$cartStartLevel$", arrayPack[i][5]);
		tempHtml = tempHtml.replace("$cartEndLevel$", arrayPack[i][6]);
		tempHtml = tempHtml.replace("$cartLevelType$", arrayPack[i][0]);
		tempHtml = tempHtml.replace("$cartChooseType$", arrayPack[i][9]);
		tempHtml = tempHtml.replace("$aDetail$", "aDetail_1" + "right_" + i);
		tempHtml = tempHtml.replace(/\$aID\$/g, arrayPack[i][10]);
		tempHtml = tempHtml.replace("$itemID$", arrayPack[i][10]);
		tempHtml = tempHtml.replace("$hash$", arrayPack[i][13]);	
		tempHtml = tempHtml.replace(/\$Style\$/g, (i % 2 == 1 ? "padding:5px;background-color:#B8D9FA;margin-left:auto;margin-right:auto;word-wrap:break-word;word-break:break-all;width:190px !important;width:200px;overflow:hidden;" : " padding:5px;background-color:#B8D9FA;margin-left:auto;margin-right:auto;word-wrap:break-word;word-break:break-all;width:190px !important;width:200px;overflow:hidden;"));
		tempHtml = tempHtml.replace("$star$", GetStar(arrayPack[i][14]));
		htmlPackage = htmlPackage + tempHtml;
		//htmlPackage = tempHtml;
	}
	document.getElementById("rightPackage").innerHTML = htmlPackage;
}
function GetStar(level)
{
	var starHtml = "";
	for(var i = 1; i<= 5; i++)
	{
		starHtml = starHtml + (i <= level ? "<img src=\"/Images/Common/star.gif\" />&nbsp;" : "<img src=\"/Images/Common/star_.gif\" />&nbsp;");
	}
	return starHtml;
}
function NewPackageCheckOut(name,moneycode,price,webtime,startlevel,endlevel,leveltype,choosetype)
{
	var result = G4P.PowerLevel.PowerLevel_Common.SaveForm('WOW', "", name, moneycode, price, webtime, startlevel, endlevel, leveltype, choosetype);
	Main("PL_CheckOut");
	window.location="confirmstep1.aspx"; 
}
$(document).ready(function(){
	LoadPackage();
});
