// JavaScript Document

var CSSFileVersion = 1; // Points to main_*.css file where * is the CSSFileVersion

var ITexts = Class.create({

  Languages: ['et', 'en'], // first item is the default language
  LanguageTitles: ['eesti keeles', 'In English'], // keep it synchronized with Languages array
	
	Set: function(nName, nTexts) {
		this[nName] = nTexts[this.Language];
	},
	
	initialize: function(nLanguage) {
		this.Language = this.Languages[0];
		for (var i = 0; i < this.Languages.length; i++) {
			if (this.Languages[i] == nLanguage) {
				this.Language = nLanguage;
				break;
			}
		}
		
/* Pages: */

this.Pages = new Array(
	{ et: 'Telli siit',
		en: 'Click to Order' },
	{ et: 'Programmi demo',
		en: 'Demo' },
	{ et: 'Miks kasulik?',
		en: 'How Useful?' },
	{ et: 'Matemaatikat',
		en: 'Calculations' },
	{ et: 'Konkurendid',
		en: 'Competition' },
	{ et: 'Küsimusi',
		en: 'Questions' },
	{ et: 'Tehnilist infot', // toetab ka "Tehnilist inffi", aga panin siiski keelelisemalt korrektsema
		en: 'Technical' },
	{ et: 'Üldtingimused',
		en: 'General Terms' },
	{ et: 'Mis maksab?',
		en: 'Costs and Prices' },
	{ et: 'Lisalugemist',
		en: 'More Reading' },
	{ et: 'Privaatsus',
		en: 'Privacy' },
	{ et: 'Allalaadimised',
		en: 'Downloads' },
	{ et: 'Partnerid',
		en: 'Partners' },
	{ et: 'Lepingu lõpetamine',
		en: 'Termination' },
	{ et: 'Kodu',
		en: 'Home',
		Default: true },
	{ et: 'Kontakt',
		en: 'Contact' }
);

/* Put all language-dependent texts here: */

this.Set('Month0', {
				 et: 'jaanuaril',
				 en: 'January' });
this.Set('Month1', {
				 et: 'veebruaril',
				 en: 'February' });
this.Set('Month2', {
				 et: 'märtsil',
				 en: 'March' });
this.Set('Month3', {
				 et: 'aprillil',
				 en: 'April' });
this.Set('Month4', {
				 et: 'mail',
				 en: 'May' });
this.Set('Month5', {
				 et: 'juunil',
				 en: 'June' });
this.Set('Month6', {
				 et: 'juulil',
				 en: 'July' });
this.Set('Month7', {
				 et: 'augustil',
				 en: 'August' });
this.Set('Month8', {
				 et: 'septembril',
				 en: 'September' });
this.Set('Month9', {
				 et: 'oktoobril',
				 en: 'October' });
this.Set('Month10', {
				 et: 'novembril',
				 en: 'November' });
this.Set('Month11', {
				 et: 'detsembril',
				 en: 'December' });
		
this.Set('LogInWithPassword', {
				 et: 'Logi sisse salasõnaga',
				 en: 'Login with password'});
this.Set('LogInWithLiveID', {
				 et: 'Logi sisse Windows Live ID abil',
				 en: 'Login with Windows Live ID' });
this.Set('LogInWithIDCard', {
				 et: 'Logi sisse ID-kaardiga',
				 en: 'Login with Estonian ID' });
this.Set('TryOutText', {
				 et: 'Pärast liitumislepingu sõlmimist saadame sulle Minitaxi GPSi ja midagi maksta ei ole vaja.|Kui sa allkirjastad täna, saad GPSi kulleriga kahe tööpäeva jooksul.|Kui Minitax sulle ei sobi ja seadmed on meile tagasi jõudnud hiljemalt {d1}, ei maksa sa meile mitte midagi.|Kui GPSi pole tagastatud, tuleb {d2} esimene 7,67-eurone arve.|Seadmeid saab vabalt tagastada edaspidigi ja see lõpetab lepingu.',
				 en: "After signing the contract, we will send you your Minitax GPS and you don't need to pay yet.|If you sign today, your GPS will arrive in two business days.|If Minitax does not suit you and it has been returned by {d1}, you pay nothing.|If the GPS has not been returned, a €7.67 invoice will be issued at {d2}.|You can freely return the devices and that will finish your contract automatically." }); // use | for line break
this.Set('TryOutButton', {
				 et: 'Tellin',
				 en: 'Click to Order' });
this.Set('TryOutTitle', {
				 et: 'Proovi tasuta!',
				 en: 'Try Free!' });
this.Set('FeedbackTitle', {
				 et: 'Kliendid meist',
				 en: 'Clients About Us' });
this.Set('FacebookTitle', {
         et: 'Sina lihtsalt sõida',
         en: 'You Just Drive' });
this.Set('OrderButtonCaption', {
				 et: 'Tellin',
				 en: 'Order Here' });
this.Set('WebDesignBy', {
				 et: 'Veebilehe on loonud',
				 en: 'Web page created by' });
this.Set('CustomerService', {
				 et: 'Klienditeenindus',
				 en: 'Customer Service' });

// Feedback:
//   It supports up to 100 lines atm. Start with 'Feedback0', increment by 1.
this.Set('Feedback0', {
				 et: 'H.S., Tallinn, 09.08.2010|Suurepärane|Teie Minitax teenus on| suurepärane. Hindan seda väga.',
				 en: 'H.S., Tallinn, 09.08.2010|Just Great|Your Minitax-service is just| great. I really appreciate it.' });
this.Set('Feedback1', {
				 et: 'Indrek Kraas, 22.03.2010|Intelligentne teenus|Olen tänulik selle hea| emotsiooni eest, mis see teenus peale ärilise kasu mulle pakub. Ei ole igapäevane, et tehakse koostööd. See teenus aga õhkab koostöövalmidust. Olen selle eest väga tänulik!',
				 en:'Indrek Kraas, 22.03.2010|Intelligent Service|I am grateful for the good feel| your service gives me besides its business usability. You have unusually good co-operation spirit. I am very grateful for that!' });
this.Set('Feedback2', {
				 et: 'Kuno, 21.01.2010|Super teenus|Igatahes väärt teenus| minemiseks isegi välisturgudele, jõudu ja jaksu edaspidiseks. Leidke väärt investorid ja promoge kõikjal, toote Nokia Eestisse.',
				 en:'Kuno, 21.01.2010|Super Service|This is a good thing even for| exporting. I wish you the best for the future. Find investors and sell around the world.' });

/* end of texts */

	}
});

// The code below this line must support all languages automatically.

var Texts = null;

var IImplementer = Class.create({
																
  initialize: function() {
		if (!document.head) document.head = document.getElementsByTagName("head")[0];
	},
	
	TitleToName: function(nTitle) {
		return nTitle.replace(/\W/g, '').toLowerCase();
	},
	
  Navigate: function(nURL) {
		window.location.assign(nURL);
	},
	
	Get: function(nURL, nGetResponseName) {
		if (!nGetResponseName) nGetResponseName = 'GetResponse';
		var self = this;
		new Ajax.Request(nURL, {
			method: 'get',
			onSuccess: function(transport) {
				self[nGetResponseName](transport.responseText);
			},
			onFailure: function() {
				self[nGetResponseName]();
			}
		});
	},
	
	HTMLPos: function(ho) { // returns { Left, Top } object
		if (!ho) return;
		var r = { 
		  Left: 0,
			Top: 0
		}
		while (ho) {
			r.Left += ho.offsetLeft;
			r.Top += ho.offsetTop;
			ho = ho.offsetParent;
		}
		return r;
	},
	
	RenderBox: function(nIndex, nContent, nTitle, nColor) { // nColor supports "Blue" (default) and "Orange"
		if (!nColor) nColor = 'Blue';
		var a = new Array();
		a.push('<table class="Box" style="position: relative; top: -', (18 * nIndex), 'px;" cellspacing="0" cellpadding="0">');
		a.push('<tr><td class="BoxTL"><img src="pixel.gif" width="14" height="1" alt="" border="0" /></td>');
		a.push('<td class="BoxTC">');
		if (nTitle) {
		  a.push('<table class="BoxTitle" cellspacing="0" cellpadding="0"><tr><td class="BoxTitleL"><img src="pixel.gif" width="12" height="1" alt="" border="0" /></td><td class="BoxTitleC ', nColor, 'Title">', nTitle, '</td><td class="BoxTitleR"><img src="pixel.gif" width="12" height="1" alt="" border="0" /></td></tr></table>');
		}
		else {
			a.push('&nbsp;');
		}
		a.push('</td>');
		a.push('<td class="BoxTR"><img src="pixel.gif" width="14" height="1" alt="" border="0" /></td></tr>');
		a.push('<tr><td class="BoxML">&nbsp;</td><td class="BoxMC', ((nTitle) ? ' BoxMCTitle' : ''), '">', nContent, '</td><td class="BoxMR">&nbsp;</td></tr>');
		a.push('<tr><td class="BoxBL">&nbsp;</td><td class="BoxBC">&nbsp;</td><td class="BoxBR">&nbsp;</td></tr>');
		a.push('</table>');
		return a.join('');
	},
	
	RenderLinkButton: function(a, nHref, nCaption, nIcon) {
		a.push('<div class="LinkButton"><table class="Button" cellspacing="0" cellpadding="0"><tr><td class="LinkButtonL"><img src="pixel.gif" width="6" height="19" alt="" border="0" /></td><td class="LinkButtonC LinkButtonCaption">');
		if (nIcon) {
		  a.push('<table cellspacing="0" cellspadding="0"><td class="LinkButtonIcon"><a href="', nHref, '"><img src="images/icons/', nIcon, '.png" alt="" border="0" /></a></td><td class="LinkButtonCaption"><a href="', nHref, '">' + nCaption + '</a></td></table>');
		}
		else {
		  a.push(nCaption);
		}
		a.push('</td><td class="LinkButtonR"><img src="pixel.gif" width="6" height="19" alt="" border="0" /></td></tr></table></div>');
	},
	
	RenderButton: function(a, nHref, nCaption, nColor) { // nColor supports "Blue" (default) and "Orange"
		if (!nColor) nColor = 'Blue';
		a.push('<div class="Button"><a href="', nHref, '"><table class="Button" cellspacing="0" cellpadding="0"><tr><td class="Button', nColor, 'L"><img src="pixel.gif" width="11" height="36" alt="" border="0" /></td><td class="Button', nColor, 'C">');
	  a.push(nCaption);
		a.push('</td><td class="Button', nColor, 'R"><img src="pixel.gif" width="11" height="36" alt="" border="0" /></td></tr></table></a></div>');
	},
	
	RenderBoxText: function(a, nText, nColor) { // nColor supports "Blue" (default) and "Orange"; in nText use | for line break
		if (!nColor) nColor = 'Blue';
		a.push('<table class="MaxWidth" cellspacing="0" cellpadding="0"><tr>');
		a.push('<td class="BoxVerticalLine"><img src="images/box/BoxVerticalLine', nColor, '.png" width="1" height="100%" alt="" border="0" /></td>');
		a.push('<td class="BoxLongText MaxWidth">');
		nText = nText.split('|');
		for (var i = 0; i < nText.length; i++) {
			a.push('<div>', nText[i], '</div>');
		}
		a.push('</td>');
		a.push('</tr></table>');
	},

	RenderBoxContent_LogIn: function() {
		var a = [];
		this.RenderLinkButton(a, 'http://s3.minitax.net/', Texts.LogInWithPassword, 'Password');
		this.RenderLinkButton(a, 'http://login.live.com/wlogin.srf?appid=0000000048040531&alg=wsignin1.0', Texts.LogInWithLiveID, 'Windows');
		this.RenderLinkButton(a, 'https://cloud.minitax.net/id.aspx', Texts.LogInWithIDCard, 'IDCard');
		return a.join('');
	},
	
	Date_FirstDayNextMonth: function(d) {
		d.setDate(1);
		if (d.getMonth() < 11) {
			d.setMonth(d.getMonth() + 1);
		}
		else {
			d.setFullYear(d.getFullYear() + 1);
			d.setMonth(0);
		}
	},

	RenderBoxContent_TryOut: function(nColor) {
		var a = [];
		var d2 = new Date();
		this.Date_FirstDayNextMonth(d2);
		this.Date_FirstDayNextMonth(d2);
		var d1 = new Date(d2.getTime() - (1000 * 60 * 60 * 24));
    this.RenderBoxText(a, Texts.TryOutText.replace('{d1}', '' + d1.getDate() + '. ' + Texts['Month' + d1.getMonth()]).replace('{d2}', '' + d2.getDate() + '.&nbsp;' + Texts['Month' + d2.getMonth()]), 'Orange');
		this.RenderButton(a, Texts.Pages[0].Name + '.html', Texts.TryOutButton, 'Orange');
		return a.join('');
	},

	RenderBoxContent_Feedback: function() {
		var lines = [];
		var s, a;
		for (var i = 0; i < 100; i++) {
			s = Texts['Feedback' + i];
			if (!s) break;
			a = s.split('|');
		  lines.push('<span ><span id="Feedback' + i + '" class="FeedbackTitle">' + a[1] + '</span><br />' + a[2] + '...</span>'); // must use + here
		}
		var a = [];
	  for (var i = 0; i < lines.length; i++) {
			if (i > 0) a.push('<div class="BoxHorizontalLine"><img src="images/box/BoxHorizontalLineBlue.png" width="100%" height="1" alt="" border="0" /></div>');
			a.push('<div class="MaxWidth" onmouseover="Implementer.FeedbackOver(', i, ');" onmouseout="Implementer.FeedbackOver(false);">', lines[i], '</div>');
		}
		lines = [];
		this.RenderBoxText(lines, a.join(''), 'Blue');
		return lines.join('');
	},

  RenderBoxContent_Facebook: function ()
  {
    var lines = [];
    this.RenderBoxText(lines, '<iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FMinitax%2F113133095447145&amp;width=205&amp;locale=et_EE&amp;colorscheme=light&amp;show_faces=true&amp;border_color=white&amp;stream=false&amp;header=false&amp;height=164" scrolling="no" frameborder="0" style="margin-left: -10px; border:none; overflow:hidden; width:195px; height:140px;" allowTransparency="true"></iframe>', 'Orange');
    return lines.join('');
  },

  FeedbackOver: function (nIndex, nSecondTry)
  {
		if (nIndex !== false) {
			var m = $('Feedback' + nIndex);
			if (!m) nIndex = false;
			if (nIndex !== false) {
				var s = Texts['Feedback' + nIndex];
				if (!s) nIndex = false;
			}
    }
		if (nIndex === false) {
			var o = $('FeedbackBalloon');
			if (o) o.className = 'Hidden';
			return;
		}
		var o = $('FeedbackBalloon');
		if (!o) {
			if (nSecondTry) return;
			var e = $('FeedbackBalloon.Container');
			if (!e) return;
			var a = [];
			a.push('<table id="FeedbackBalloon" cellspacing="0" cellpadding="0">');
			a.push('<tr><td id="FeedbackBalloonT"><img src="pixel.gif" width="217" height="20" alt="" border="0" /></td>');
			a.push('<td id="FeedbackBalloonBR" rowspan="3"><img src="images/balloon/BR.png" width="61" height="34" /></tr>');
			a.push('<tr><td id="FeedbackBalloonM"><div id="FeedbackBalloonTitle">&nbsp;</div><div id="FeedbackBalloonAuthor">&nbsp;</div><div id="FeedbackBalloonText">&nbsp;</div></td></tr>');
			a.push('<tr><td id="FeedbackBalloonB"><img src="pixel.gif" width="217" height="20" alt="" border="0" /></td></tr>');
			a.push('</table>');
			e.innerHTML = a.join('');
			this.FeedbackOver(nIndex, true);
			return;
		}
		o.className = 'Visible';
		a = s.split('|');
		var e = $('FeedbackBalloonTitle');
		if (e) e.innerHTML = a[1];
		e = $('FeedbackBalloonAuthor');
		if (e) e.innerHTML = a[0];
		e = $('FeedbackBalloonText');
		if (e) e.innerHTML = a[2] + a[3];
		e = $('FeedbackBalloonM');
		var mpos = this.HTMLPos(m);
		var i = mpos.Left - 272;
		o.style.left = '' + i + 'px';
		i = mpos.Top - e.offsetHeight - 22;
		o.style.top = '' + i + 'px';
	},
	
	MenuHover: function(nIndex) {
		var td = $('Menu.' + nIndex + '.Text');
		if (!td) return;
		var p = Texts.Pages[nIndex];
		if (!p) return;
		td.style.backgroundImage = "url('images/menu/" + p.Name + "_h.png')";
	},
	
	MenuOut: function(nIndex) {
		var td = $('Menu.' + nIndex + '.Text');
		if (!td) return;
		var p = Texts.Pages[nIndex];
		if (!p) return;
		td.style.backgroundImage = "url('images/menu/" + p.Name + "_i.png')";
	},
	
	MenuClick: function(nIndex) {
		var p = Texts.Pages[nIndex];
		if (!p) return;
		this.Navigate(p.Name + '.html');
	},
	
	LanguageClick: function(nIndex) {
		if (!this.ActivePage) return;
		if (!Texts.Languages[nIndex]) return;
		this.Navigate(this.TitleToName(this.ActivePage[Texts.Languages[nIndex]]) + '.html');
	},
	
	CalculationsGroupClick: function(nGroup) {
		var names = ['Private', 'FIE', 'Small', 'Big'];
		var a, i, classname;
		for (var n = 0; n < names.length; n++) {
			classname = ((names[n] == nGroup) ? 'Visible' : 'Hidden');
			a = document.getElementsByName('Calculations' + names[n]);
			for (i = 0; i < a.length; i++) {
				a[i].className = classname;
			}
			
		}
	},
	
	CalculationsCarClick: function(nGroup, nIndex) {
		var a = document.getElementsByName('Calculations.' + nGroup + '.Image');
		for (var i = 0; i < a.length; i++) {
			a[i].src = 'images/articles/calculations' + nGroup + nIndex + '.png';
		}
		var classname = ((nIndex == 1) ? '' : ' Hidden');
		a = document.getElementsByName('Calculations' + nGroup + 'Numbers1');
		for (var i = 0; i < a.length; i++) {
			a[i].className = 'Borders AllNumbers' + classname;
		}
		classname = ((nIndex == 2) ? '' : ' Hidden');
		a = document.getElementsByName('Calculations' + nGroup + 'Numbers2');
		for (var i = 0; i < a.length; i++) {
			a[i].className = 'Borders AllNumbers' + classname;
		}
	},
	
	Mail: function(nAddress) {
		if (!nAddress) {
			nAddress = 'info';
			nAddress += '@';
			nAddress += 'minitax.net';
		}
		nAddress = ':' + nAddress;
		nAddress = 'lto' + nAddress;
		nAddress = 'mai' + nAddress;
		this.Navigate(nAddress);
	},
	
	PreloadImage: function(nSrc) {
		// Note that for optimization reason the Queue list processed in a backward order, i.e. the last asked item has the highest priority and will be loaded for next.
		// The image size must not exceed 1000px in either direction.
		// Does not automatically search for duplicates, again, for optimization.
		// Add new item:
		if (nSrc) {
	    if (this.PreloadQueue) {
				this.PreloadQueue.push(nSrc);
				return;
			}
			else {
				this.PreloadQueue = [];
			}
		}
		else {
			if (!this.PreloadQueue) return; // should never happen, I guess
			if (this.PreloadQueue.length < 1) {
				this.PreloadQueue = null;
				return; // done with the queue
			}
			nSrc = this.PreloadQueue.pop();
		}
		if (nSrc) { // preload the next item
			var o = $('ImagePreloader');
			if (!o) return;
			o.src = nSrc;
		}
	},

	Run_TV: function(nIndex, nPreloadAll) {
		if (nPreloadAll) {
			for (var i = 2; i < 7; i++) { // preload all images but first
				this.PreloadImage('images/articles/TV' + i + '_' + Texts.Language + '.png');
			}
	  }
		var a = document.getElementsByName('ArticleTV');
		for (var i = 0; i < a.length; i++) {
			a[i].src = 'images/articles/TV' + nIndex + '_' + Texts.Language + '.png';
		}
		nIndex++;
		if (nIndex <= 6) {
			window.setTimeout(function() { Implementer.Run_TV(nIndex) }, 7000);
		}
		else {
			window.setTimeout(function() { Implementer.Run_TV(1) }, 30000);
		}
	},
	
	Run_AddCSS: function(nURL) {
		var css = document.createElement('link');
		css.setAttribute('href', nURL);
		css.setAttribute('rel', 'stylesheet');
		css.setAttribute('type', 'text/css');
		document.head.appendChild(css);
	},
	
	Run_CreateBody: function() {
		var c = $('ArticleTitle');
		var title = ((c) ? c.innerHTML : null);
		var c = $('ArticleContent');
		if (!c) return;
		var content = c.innerHTML;
		var a = [];
		//
		a.push('<img id="ImagePreloader" src="pixel.gif" alt="" border="0" onload="Implementer.PreloadImage();" />');	
		// Force vertical scrollbar:
  	a.push('<table id="BgForceScrollbar" cellspacing="0" cellpadding="0"><tr><td>&nbsp;</td></tr></table>');	
		a.push('<table id="BgBottom" cellspacing="0" cellpadding="0"><tr><td>&nbsp;</td></tr></table> <table id="BgTop" cellspacing="0" cellpadding="0"><tr><td>&nbsp;</td></tr></table>');
		a.push('<table id="Contents" cellspacing="0" cellpadding="0"><tr>');
		// Article:
		a.push('<td id="ContentsArticle"> <div style="text-align: right; margin-bottom: 11px"><g:plusone size="medium"></g:plusone></div> <table id="Article" cellspacing="0" cellpadding="0"> <tr><td id="ArticleTL"><img src="pixel.gif" width="24" height="1" alt="" border="0" /></td><td id="ArticleTC">&nbsp;</td><td id="ArticleTR"><img src="pixel.gif" width="24" height="1" alt="" border="0" /></td></tr> <tr><td id="ArticleML">&nbsp;</td><td id="ArticleMC"> <table class="ArticleTitle" cellspacing="0" cellpadding="0"> <tr><td><img id="Article.Icon" src="pixel.gif" alt="" border="0" /></td><td id="Article.Title">&nbsp;</td></tr> </table> <div id="Article.Content" class="AdjustedContentSize">&nbsp;</div> </td><td id="ArticleMR">&nbsp;</td></tr> <tr><td id="ArticleBL">&nbsp;</td><td id="ArticleBC">&nbsp;</td><td id="ArticleBR">&nbsp;</td></tr> <tr><td>&nbsp;</td><td id="Copyright">Semitar OÜ &middot; Tornimäe 5, Tallinn 10145 &middot; ', Texts.CustomerService, ': <a href="callto://+3726621984">662&nbsp;1984</a> &middot; <a href="javascript:Implementer.Mail();">info&#0064;minitax.net</a> &middot; <a href="http://nerva.', ((Texts.Language == 'et') ? 'ee' : 'eu'), '/?wi=15" target="_blank"><img src="images/designbynerva.gif" alt="" border="0" title="', Texts.WebDesignBy, ' Nerva&reg;" /></a></td><td>&nbsp;</td></tr> </table> </td>');
		// Ads:
    a.push('<td id="ContentsRight"><table cellpadding="0" cellspacing="0"> <tr><td><img src="pixel.gif" width="260" height="1" alt="" border="0" /></td></tr> <tr><td id="ContentsAds">&nbsp;</td></tr> </table> </td> </tr> </table>');
    // Logo:
    a.push('<table id="BgLogo" cellspacing="0" cellpadding="0"><tr><td onclick=\'Implementer.Navigate("/");\'>&nbsp;</td></tr></table>');
    // Menu:
    a.push('<div id="Menu.Container">&nbsp;</div>');
		// Feedback balloon:
    a.push('<div id="FeedbackBalloon.Container">&nbsp;</div>');
		var c = $('JSContent');
		if (!c) {
			c = document.createElement('div');
			c.id = 'JSContent';
			c.className = 'JS Screen';
			document.body.appendChild(c);
		}
		c.innerHTML = a.join('');
		var e = $('Article.Title');
		if (e) e.innerHTML = title || this.ActivePage.Title;
		e = $('Article.Icon');
		if (e) e.src = 'images/articles/' + this.TitleToName(this.ActivePage.en) + '.png';
		var e = $('Article.Content');
		if (!e) return;
		e.innerHTML = content;
		if (this.ActivePage.en == 'Home') this.Run_TV(1, true);
	},
	
	Run_CreateLanguageButtons: function() {
		var c = $('ArticleTC');
		if (!c) return;
		var a = [];
		a.push('<table class="LanguageButton" cellspacing="0" cellpadding="0" align="right"><tr>');
		for (var i = 0; i < Texts.Languages.length; i++) {
			a.push(((Texts.Language == Texts.Languages[i]) ? '<td class="Selected">' : '<td onclick="Implementer.LanguageClick(' + i + ');" title="' + Texts.LanguageTitles[i] + '">') + Texts.Languages[i] + '</td>');
		}
		a.push('</tr></table>');
    c.innerHTML = a.join('');
  },

	Run_CreateMenu: function() {
		var c = $('Menu.Container');
		if (!c) return;
		var a = new Array();
		a.push('<table id="Menu" cellspacing="0" cellpadding="0">');
		var i, p, tr, td;
		for (i = 0; i < Texts.Pages.length; i++) {
			p = Texts.Pages[i];
			a.push(((this.ActivePage == p) ? '<tr><td class="MenuLeftActive">&nbsp;</td><td class="MenuCenterActive"><table cellspacing="0" cellpadding="0"><tr><td class="MenuIcon"></td><td class="MenuText" style="background-image: url(images/menu/' + p.Name + '_a.png);">&nbsp;</td></tr></table></td><td class="MenuRightActive">&nbsp;</td></tr>' : '<tr><td class="MenuLeft">&nbsp;</td><td class="MenuCenter" onclick="Implementer.MenuClick(' + i + ');" onmouseover="Implementer.MenuHover(' + i + ');" onmouseout="Implementer.MenuOut(' + i + ');"><table cellspacing="0" cellpadding="0"><tr><td class="MenuIcon"></td><td id="Menu.' + i + '.Text" class="MenuText" style="background-image: url(images/menu/' + p.Name + '_i.png);">&nbsp;</td></tr></table></td><td class="MenuRight">&nbsp;</td></tr>'));
			this.PreloadImage('images/menu/' + p.Name + '_h.png');
		}
		a.push('<tr><td class="MenuOrderButtonContainer" colspan="3"><table cellspacing="0" cellpadding="0"><tr><td></td><td><img src="pixel.gif" width="146" height="1" alt="" border="0" /></td><td></td></tr><tr><td><img src="pixel.gif" width="1" height="63" alt="" border="0" /></td><td class="MenuOrderButton" onclick="Implementer.MenuClick(0);">', Texts.OrderButtonCaption, '</td><td></td></tr><tr><td></td><td></td><td><img src="pixel.gif" width="1" height="1" /></td></tr></table></td></tr>');
		a.push('</table>');
		c.innerHTML = a.join('');
	},

  Run_CreateBoxes: function() {
		var td = $('ContentsAds');
		var a = new Array();
		a.push(this.RenderBox(0, this.RenderBoxContent_LogIn()));
		a.push(this.RenderBox(1, this.RenderBoxContent_TryOut(), Texts.TryOutTitle, 'Orange'));
		a.push(this.RenderBox(2, this.RenderBoxContent_Feedback(), Texts.FeedbackTitle, 'Blue'));
		a.push(this.RenderBox(3, this.RenderBoxContent_Facebook(), Texts.FacebookTitle, 'Orange'));
		td.innerHTML = a.join('');
	},
	
	Run_PreloadImages: function() {
		// If any...
	},
	
	Run: function(nLanguage, nPageTitleEn) {
		// nLanguage must be one of supported languages (see ITexts.Languages array), otherwise the argument will be replaced by default language
		// nPageTitleEn must be one of the page titles in English, defaults to 'Home'
		if (location.href.indexOf('&plain') >= 0) return;
		Texts = new ITexts(nLanguage);
		var p;
	  for (var i = 0; i < Texts.Pages.length; i++) {
			p = Texts.Pages[i];
			if ((p.en == nPageTitleEn) || ((!this.ActivePage) && (p.Default))) this.ActivePage = p;
			p.Title = p[Texts.Language];
			p.Name = this.TitleToName(p.Title);
		}
		this.Run_AddCSS('main_' + CSSFileVersion + '.css');
		this.Run_CreateBody();
		this.Run_CreateLanguageButtons();
		this.Run_CreateMenu();
		this.Run_CreateBoxes();
		this.Run_PreloadImages();
	},

  end: null
});

var Implementer = new IImplementer();

