﻿
function getWindowsVersion()
{
	var nav = navigator.userAgent.toLowerCase();
	if (nav.indexOf("windows nt 5.0") > -1) return 0; //2000
	if (nav.indexOf("windows nt 5.1") > -1) return 1; //XP;
	if (nav.indexOf("windows nt 5.2") > -1) return 2; //Server 2003 or XP 64;
	if (nav.indexOf("windows nt 6.0") > -1) return 3; //Vista or Server 2008 ;
	if (nav.indexOf("windows nt 6.1") > -1) return 4; //Windows 7;
	return -1;
}

function getLanguage()
{
	var app = navigator.userAgent.toLowerCase();
	return (app.indexOf('msie') > 0) ?
		navigator.userLanguage.toLowerCase():
		navigator.language.toLowerCase();
}

function isWin32()
{
	return (navigator.platform.toLowerCase() == 'win32');
}

function loadBrowserInfo()
{
	var lblBrowserInfo = document.getElementById('lblBrowserInfo');
	var infoLink = document.getElementById('others_lang');
	var pnlInfo = document.getElementById('pnlInfo');
	var version = getWindowsVersion();
	var language = getLanguage();
	var osname, ielang;
	switch (version)
	{
		case -1:
			lblBrowserInfo.innerHTML = 'У Вас не Windows.';
			break;

		case 0:
			lblBrowserInfo.innerHTML = 'У Вас застаріла Windows.';
			break;

		case 1:
		case 2:
			osname = isWin32() ? 'Windows XP' : 'Windows XP 64';
			ielang = (language == 'ru' || language == 'uk' || language == 'ua') ? 'російська' : 'англійська';
			lblBrowserInfo.innerHTML = osname + ', ' + ielang + ', 16,2МБ.';
			break;

		case 3:
			osname = isWin32() ? 'Windows Vista' : 'Windows Vista 64';
			ielang = (language == 'ru' || language == 'uk' || language == 'ua') ? 'російська' : 'англійська';
			lblBrowserInfo.innerHTML = osname + ', ' + ielang + ', 17,6МБ.';
			break;

		case 4:
			lblBrowserInfo.innerHTML = 'Ви вже встановили ІЕ8.';
			break;
	}

	if (version > 0 && version < 4) {
		infoLink.innerHTML = '<a target="_blank" href="/ukraine/windows/internet-explorer/worldwide-sites.aspx" style="display: block; margin-top: 2px; font-family: Arial; font-size: 10px; color: #4eb0e9 !important;; text-decoration: underline !important; ">Інші версії та мови</a>';
	} else if (version == 4) {
		infoLink.innerHTML = '<a target="_blank" href="http://ieaddons.com/ru " style="display: block; margin-top: 2px; font-family: Arial; font-size: 10px; color: #4eb0e9; text-decoration: underline !important; ">Додайте доповнення</a>';
	}

	pnlInfo.style.display = 'block';
}

function onDownloadClick() {
	var os = getWindowsVersion();
	var lang = getLanguage();

	if (os <= 0) {
		// alert('Ми помітили, що ви користуєтеся операційною системою, відмінною від Windows. На жаль, неможливо установити Internet Explorer 8.');
		// alert('Ми помітили, що ви користуєтеся застарілою версією операційної системи Windows. На жаль, неможливо установити Internet Explorer 8.');
		location.href = '/ukraine/windows/internet-explorer/worldwide-sites.aspx';
		return false;
	}

	if (os == 4) {
		window.open('/ukraine/windows/internet-explorer/win_7.html', null, 'height=240, width=540', null);
		return false;
	}

	if (isWin32()) {
		if (os == 1 || os == 2) {
			if (lang == 'ru' || lang == 'uk' || lang == 'ua')
				// window.open('http://download.microsoft.com/download/D/6/9/D693B7D9-C8E3-4D15-B3D2-59843A8DE90B/IE8-WindowsXP-x86-RUS.exe', null, 'height=100, width=100', null);
				location. href = 'http://download.microsoft.com/download/D/6/9/D693B7D9-C8E3-4D15-B3D2-59843A8DE90B/IE8-WindowsXP-x86-RUS.exe';
			else
				// window.open('http://download.microsoft.com/download/C/C/0/CC0BD555-33DD-411E-936B-73AC6F95AE11/IE8-WindowsXP-x86-ENU.exe', null, 'height=100, width=100', null);
				location. href = 'http://download.microsoft.com/download/C/C/0/CC0BD555-33DD-411E-936B-73AC6F95AE11/IE8-WindowsXP-x86-ENU.exe';
		}

		if (os == 3) {
			if (lang == 'ru' || lang == 'uk' || lang == 'ua')
				// window.open('http://download.microsoft.com/download/D/0/5/D0506F22-0081-47AD-9EBE-9C4EBC0640B7/IE8-WindowsVista-x86-RUS.exe', null, 'height=100, width=100', null);
				location. href = 'http://download.microsoft.com/download/D/0/5/D0506F22-0081-47AD-9EBE-9C4EBC0640B7/IE8-WindowsVista-x86-RUS.exe';
			else
				// window.open('http://download.microsoft.com/download/F/8/8/F88F09A2-A315-44C0-848E-48476A9E1577/IE8-WindowsVista-x86-ENU.exe', null, 'height=100, width=100', null);
				location. href = 'http://download.microsoft.com/download/F/8/8/F88F09A2-A315-44C0-848E-48476A9E1577/IE8-WindowsVista-x86-ENU.exe';
		}
	}
	else {
		if (os == 1 || os == 2) {
			if (lang == 'ru' || lang == 'uk' || lang == 'ua')
				// window.open('http://download.microsoft.com/download/1/2/E/12E9B74E-9099-4922-B313-220C45ACDDA2/IE8-WindowsServer2003-x64-RUS.exe', null, 'height=100, width=100', null);
				location. href = 'http://download.microsoft.com/download/1/2/E/12E9B74E-9099-4922-B313-220C45ACDDA2/IE8-WindowsServer2003-x64-RUS.exe';
			else
				// window.open('http://download.microsoft.com/download/7/5/4/754D6601-662D-4E39-9788-6F90D8E5C097/IE8-WindowsServer2003-x64-ENU.exe', null, 'height=100, width=100', null);
				location. href = 'http://download.microsoft.com/download/7/5/4/754D6601-662D-4E39-9788-6F90D8E5C097/IE8-WindowsServer2003-x64-ENU.exe';
		}

		if (os == 3) {
			if (lang == 'ru' || lang == 'uk' || lang == 'ua')
				// window.open('http://download.microsoft.com/download/B/B/3/BB35C235-BAA3-43C6-885E-237290E23533/IE8-WindowsVista-x64-RUS.exe', null, 'height=100, width=100', null);
				location. href = 'http://download.microsoft.com/download/B/B/3/BB35C235-BAA3-43C6-885E-237290E23533/IE8-WindowsVista-x64-RUS.exe';
			else
				// window.open('http://download.microsoft.com/download/D/C/F/DCF5DACB-313F-40C6-889C-AD1F8546099D/IE8-WindowsVista-x64-ENU.exe', null, 'height=100, width=100', null);
				location. href = 'http://download.microsoft.com/download/D/C/F/DCF5DACB-313F-40C6-889C-AD1F8546099D/IE8-WindowsVista-x64-ENU.exe';
		}
	}

	// setTimeout(showWorldwideSites, 8000);

	return false;
}

function showWorldwideSites() {
	window.open('/ukraine/windows/internet-explorer/worldwide-sites.aspx', null, 'height=600, width=800, location=1, menubar=1, resizable=1, scrollbars=1, status=1, menubar=1', null);
}
