---------------------------------------------------------------------------------------------------
--  Copyright © 2009 PoBros, Incorporated. All Rights Reserved.
--
--  This source code is the proprietary confidential property of PoBros Incorporated.
--  Modification, reproduction, publication, or distribution in any form to any party 
--  other than the licensee is strictly prohibited.
--
--  FOR USE BY AUTHORIZED PERSONS ONLY
---------------------------------------------------------------------------------------------------

require( "scripts/style.lua" );

local textBoxSpace = 80;
local buttonXGap = 255;
local buttonY = kCenter + 280;
local textboxY = kCenter + 245;

---------------------------------------------------------------------------------------------------

function DisplayStatus( error )
	EnableWindow( "keystatus", true );
	SetLabel( "keystatus", "<b>" .. GetString( "keystatus" .. error ) .. "</b>" );
end

-------------------------------------------------

function KeyVerified()
	WindowReturn( "valid" );
end

---------------------------------------------------------------------------------------------------

MakeDialog
{
	name = "licensekey";
	SetStyle( GameWindowStyle );
	
	LicenseKey
	{
		SetStyle( DialogWindowStyle );
		
		texteditstring = "keyentry%02d";
		
		DialogWindow
		{
			image = "dialogs/upsell";
			
			SetStyle( DialogBodyText );
			
			Text
			{
				name = "thanksforplayingbuynow";
				label = "#<b>" .. GetString( "thanksforplayingbuynow" ) .. "</b>";
				y = kCenter + 210;
				h = 150;
				font = LicenseBodyFont;
			};
			
			Text
			{
				name = "keystatus";
				x = kCenter + 300;
				y = kCenter + 150;
				w = 200;
				flags = kVAlignBottom + kHAlignLeft;
				font = LicenseBodyFont;
			};
			
			Text
			{
				name = "enterkeyhere";
				label = "#<b>" .. GetString( "enterkeyhere" ) .. "</b>";
				x = kCenter - 400;
				y = kCenter + 245;
				flags = kVAlignCenter + kHAlignRight;
				font = LicenseBodyFont;
			};
		
			-- Text Entry for boxes
			SetStyle( LicenseKeyStyle );
			
			TextEdit
			{ 
				name = "keyentry00"; 
				x = kCenter - ( textBoxSpace * 2 );
				y = textboxY;
			};
						
			TextEdit
			{ 
				name = "keyentry01"; 
				x = kCenter - ( textBoxSpace * 1 );
				y = textboxY;
			};		
				
			TextEdit
			{ 
				name = "keyentry02"; 
				x = kCenter;
				y = textboxY;
			};			
			
			TextEdit
			{ 
				name = "keyentry03"; 
				x = kCenter + ( textBoxSpace * 1 );
				y = textboxY;
			};		
				
			TextEdit
			{ 
				name = "keyentry04"; 
				x = kCenter + ( textBoxSpace * 2 );
				y = textboxY;
			};
			
			SetStyle( ButtonStyle );
			
			Button
			{
				name = "buynow";
				text = "buynow";
				x = kCenter - buttonXGap;
				y = buttonY;
				buttongraphics = MediumButtonGraphics;

				command =
					function()
						OpenBrowser( "https://www.regnow.com/softsell/nph-softsell.cgi?item=15810-8" );
					end
			};
			
			Button
			{
				name = "quit";
				text = "quit";
				x = kCenter + buttonXGap;
				y = buttonY;
				buttongraphics = MediumButtonGraphics;

				command =
					function()
						WindowReturn( "invalid" );
					end
			};

			Button
			{
				name = "validatekey";
				text = "validatekey";
				default = true;
				x = kCenter;
				y = buttonY;
				buttongraphics = MediumButtonGraphics;

				command =
					function()
						CheckKey();
					end
				
			};
		};
	};
};

---------------------------------------------------------------------------------------------------

EnableWindow( "keystatus", false );
SetFocus( "keyentry00" );