SET NOCOUNT ON
DECLARE @TheCountryCode VARCHAR(3)

DECLARE @DistributorName VARCHAR(60)
DECLARE @DistributorAddress VARCHAR(60)
DECLARE @DistributorZIP VARCHAR(60)
DECLARE @DistributorCountry VARCHAR(60)
DECLARE @DistributorWWW VARCHAR(60)
DECLARE @DistributorPhone VARCHAR(60)
DECLARE @DistributorFax VARCHAR(60)

DECLARE @SupportEmail VARCHAR(60)
DECLARE @SupportPhone VARCHAR(60)

DECLARE @HSDistributorName VARCHAR(60)
DECLARE @HSDistributorAddress VARCHAR(60)
DECLARE @HSDistributorZIP VARCHAR(60)
DECLARE @HSDistributorCountry VARCHAR(60)
DECLARE @HSDistributorWWW VARCHAR(60)
DECLARE @HSDistributorPhone VARCHAR(60)
DECLARE @HSDistributorFax VARCHAR(60)

DECLARE @HSSupportEmail VARCHAR(60)
DECLARE @HSSupportPhone VARCHAR(60)

SELECT @TheCountryCode = CountryCode FROM Countries WITH (NOLOCK) 
WHERE CountryNumber = (SELECT KeyValue FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'COUNTRYCODE')

SELECT @HSDistributorName    = KeyValue FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'DistributorName'
SELECT @HSDistributorAddress = KeyValue FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'DistributorAddress'
SELECT @HSDistributorZIP     = KeyValue FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'DistributorZIP'
SELECT @HSDistributorCountry = KeyValue FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'DistributorCountry'
SELECT @HSDistributorWWW     = KeyValue FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'DistributorWWW'
SELECT @HSDistributorPhone   = KeyValue FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'DistributorPhone'
SELECT @HSDistributorFax     = KeyValue FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'DistributorFax'

SELECT @HSSupportEmail = KeyValue FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'SupportEmail'
SELECT @HSSupportPhone = KeyValue FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'SupportPhone'

IF @TheCountryCode = 'DK'
BEGIN
  SET @DistributorName = 'AK Techotel A/S'
  SET @DistributorAddress = 'Sandager 8'
  SET @DistributorZIP = '2605 Brøndby'
  SET @DistributorCountry = 'Denmark'
  SET @DistributorWWW = 'www.techotel.dk'
  SET @DistributorPhone = '+45 3646 1155'
  SET @DistributorFax = '+45 3644 2006'

  SET @SupportEmail = 'picassosupport@techotel.dk'
  SET @SupportPhone = '+45 2925 0101'
END
ELSE IF (@TheCountryCode = 'S' OR @TheCountryCode = 'SE')
BEGIN
  SET @DistributorName = 'AK Techotel AB'
  SET @DistributorAddress = 'Bergkällavägen 31C'
  SET @DistributorZIP = '192 79 Sollentuna'
  SET @DistributorCountry = 'Sweden'
  SET @DistributorWWW = 'www.techotel.com'
  SET @DistributorPhone = '+46 (0)8 50661400'
  SET @DistributorFax = '+46 (0)8 50661450'

  SET @SupportEmail = 'support@techotel.se'
  SET @SupportPhone = '+46 (0)70 5189297'
END
ELSE IF @TheCountryCode = 'N'
BEGIN
  SET @DistributorName = 'Techotel Norge AS'
  SET @DistributorAddress = 'Stasjonsveien 18'
  SET @DistributorZIP = '1396 Billingstad'
  SET @DistributorCountry = 'Norway'
  SET @DistributorWWW = 'www.techotel.no'
  SET @DistributorPhone = '+47 66 77 69 00'
  SET @DistributorFax = '+47 66 77 69 01'

  SET @SupportEmail = 'picassosupport@techotel.no'
  SET @SupportPhone = '+45 2925 0101'
END

IF @TheCountryCode = 'DK' OR @TheCountryCode = 'S' OR @TheCountryCode = 'SE' OR @TheCountryCode = 'N' 
BEGIN
  IF @DistributorName <> @HSDistributorName 
    UPDATE HotelSetup SET KeyValue = @DistributorName    WHERE SearchKey = 'DistributorName'
  IF @DistributorAddress <> @HSDistributorAddress 
    UPDATE HotelSetup SET KeyValue = @DistributorAddress WHERE SearchKey = 'DistributorAddress'
  IF @DistributorZIP <> @HSDistributorZIP 
    UPDATE HotelSetup SET KeyValue = @DistributorZIP     WHERE SearchKey = 'DistributorZIP'
  IF @DistributorCountry <> @HSDistributorCountry 
    UPDATE HotelSetup SET KeyValue = @DistributorCountry WHERE SearchKey = 'DistributorCountry'
  IF @DistributorWWW <> @HSDistributorWWW 
    UPDATE HotelSetup SET KeyValue = @DistributorWWW     WHERE SearchKey = 'DistributorWWW'
  IF @DistributorPhone <> @HSDistributorPhone 
    UPDATE HotelSetup SET KeyValue = @DistributorPhone   WHERE SearchKey = 'DistributorPhone'
  IF @DistributorFax <> @HSDistributorFax 
    UPDATE HotelSetup SET KeyValue = @DistributorFax     WHERE SearchKey = 'DistributorFax'
  
  IF @SupportEmail <> @HSSupportEmail 
    UPDATE HotelSetup SET KeyValue = @SupportEmail WHERE SearchKey = 'SupportEmail'
  IF @SupportPhone <> @HSSupportPhone 
    UPDATE HotelSetup SET KeyValue = @SupportPhone WHERE SearchKey = 'SupportPhone'
END