
/*main menu*/
function __RefreshLanguage(args)
{
	RefreshLanguage(args);
	refreshbuymenu();
	changelang();
}

InitBuyMenu();

function InitBuyMenu()
{
	var helpmenu = dcmain.menubar.menuophelp;
	var localbuymenu = dcmain.buymenu;
	var startpos = 3;
	
	var packnum = Product.GetPacketNum(5);
	if(packnum >= 1)
	{
		helpmenu.InsertMenu(localbuymenu.buy1,startpos++);
	}
	if(packnum >= 2)
	{		
		helpmenu.InsertMenu(localbuymenu.buy2,startpos++);
	}
	if(packnum >= 3)
	{		
		helpmenu.InsertMenu(localbuymenu.buy3,startpos++);
	}
	if(packnum >= 4)
	{		
		helpmenu.InsertMenu(localbuymenu.buy4,startpos++);
	}
	if(packnum >= 5)
	{		
		helpmenu.InsertMenu(localbuymenu.buy5,startpos++);
	}
}
function GoBuy1(args)
{
	var packurl = Product.GetBuyPacketUrl(args,5);
	GotoUrl(packurl);
}
function refreshbuymenu(args)
{
	var helpmenu = dcmain.menubar.menuophelp;
	var localbuymenu = dcmain.buymenu;
	var originbuy = helpmenu.menuophelpbuy;
	
	var packnum = Product.GetPacketNum(5);
	if(packnum >= 1)
	{		
		var packname = Product.GetPacketName(0,5);
		localbuymenu.buy1.SetText(LanguageStr("dobuy") +" "+ packname);
		originbuy.SetText(LanguageStr("dobuy") +" " +Product.GetProductName());
	}
	if(packnum >= 2)
	{		
		var packname = Product.GetPacketName(1,5);
		localbuymenu.buy2.SetText(LanguageStr("dobuy") +" "+ packname);
	}
	if(packnum >= 3)
	{		
		var packname = Product.GetPacketName(2,5);
		localbuymenu.buy3.SetText(LanguageStr("dobuy") +" "+ packname);
	}
	if(packnum >= 4)
	{		
		var packname = Product.GetPacketName(3,5);
		localbuymenu.buy4.SetText(LanguageStr("dobuy") +" "+ packname);
	}
	if(packnum >= 5)
	{		
		var packname = Product.GetPacketName(4,5);
		localbuymenu.buy5.SetText(LanguageStr("dobuy") +" "+ packname);
	}
}

/*Regsiter Window*/

function initreg()
{
	var localwin = dcregister;
	var localoneurl = dcregister.oneurl;
	var localpackagehode = dcregister.packagehode;
	var packnum = Product.GetPacketNum(5);

	if(packnum >= 1)
	{
		localoneurl.height=0;
		localoneurl.SetVisible(false);
		localpackagehode.packet0.SetVisible(true);
		localpackagehode.packet1.SetVisible(true);
		
		localpackagehode.packet0.SetLink(Product.GetBuyUrl());
		localpackagehode.packet1.SetLink(Product.GetBuyPacketUrl(0,5));
		
		localpackagehode.height = 55 + 25 *packnum;
		localwin.height = localwin.height + 25*packnum +30;
	}
	else
	{
		localpackagehode.SetVisible(false);
		localpackagehode.height = 0;
	}
	
	if(packnum >= 2)
	{
		localpackagehode.packet2.SetVisible(true);
		localpackagehode.packet2.SetLink(Product.GetBuyPacketUrl(1,5));
	}
	if(packnum >= 3)
	{
		localpackagehode.packet3.SetVisible(true);
		localpackagehode.packet3.SetLink(Product.GetBuyPacketUrl(2,5));
	}
	if(packnum >= 4)
	{
		localpackagehode.packet4.SetVisible(true);
		localpackagehode.packet4.SetLink(Product.GetBuyPacketUrl(3,5));
	}
	if(packnum >= 5)
	{
		localpackagehode.packet5.SetVisible(true);
		localpackagehode.packet5.SetLink(Product.GetBuyPacketUrl(4,5));
	}

}

function changelang()
{
	var localpackagehode = dcregister.packagehode;
	
  var includestr = "("+LanguageStr("Include")+" "+Product.GetProductName()+")"+" "+LanguageStr("favourable");
	var packnum = Product.GetPacketNum(5);
	if(packnum >= 1)
	{
		localpackagehode.packet0.SetText(Product.GetProductName());
		localpackagehode.packet1.SetText(Product.GetPacketName(0,5)+includestr);
	}
	if(packnum >= 2)
	{
		localpackagehode.packet2.SetText(Product.GetPacketName(1,5)+includestr);
	}
	if(packnum >= 3)
	{
		localpackagehode.packet3.SetText(Product.GetPacketName(2,5)+includestr);
	}
	if(packnum >= 4)
	{
		localpackagehode.packet4.SetText(Product.GetPacketName(3,5)+includestr);
	}
	if(packnum >= 5)
	{
		localpackagehode.packet5.SetText(Product.GetPacketName(4,5)+includestr);
	}
}