function get_image(type) {
	var val;
	val=1;
	if (type==1) {
		var s = window.showModalDialog("preview/dls.php4", val, "dialogHeight:600px;dialogWidth:800px;center:yes;resizable:yes;status:yes;help:yes;scroll:yes");
	}
	if (type==2) {
		var s = window.showModalDialog("preview/menu.php4", val, "dialogHeight:400px;dialogWidth:800px;center:yes;resizable:yes;status:yes;help:yes;scroll:yes");
	}
	if (type==3) {
		var s = window.showModalDialog("preview/list.php4", val, "dialogHeight:600px;dialogWidth:800px;center:yes;resizable:yes;status:yes;help:yes;scroll:yes");
	}
	if (s && s != '') {
		document.forms['act'].elements['image'].value=s;
	}
}

function user_logout() {
	if (event.clientX <0 && event.clientY < 0) { 
		document.location.href='logout.php?exit=true';
	}
}

window.onunload = user_logout;

var Class = {
	create: function() {
		return function() {
			this.initialize.apply(this, arguments);
		};
	}
};
var version = Class.create();
version.prototype = {
	initialize: function(versionArray){
		this.major = versionArray[0] != null ? parseInt(versionArray[0], 10) : 0;
		this.minor = versionArray[1] != null ? parseInt(versionArray[1], 10) : 0;
		this.rev   = versionArray[2] != null ? parseInt(versionArray[2], 10) : 0;
	},
	compare: function(flashVersion){
		if (this.major < flashVersion.major) return -1;
		if (this.major > flashVersion.major) return  1;
		if (this.minor < flashVersion.minor) return -1;
		if (this.minor > flashVersion.minor) return  1;
		if (this.rev   < flashVersion.rev)   return -1;
		if (this.rev   > flashVersion.rev)   return  1;
		return 0;
	},
	major: -1,
	minor: -1,
	rev: -1,
	toString: function(){
		return [this.major, this.minor, this.rev].join('.');
	}
};
EUDetection = {
	BrowserDetect: {
		detect: function() {
			var browser = this.searchString(this.dataBrowser) || "EU_UNKNOWN_BROWSER";
			var ver = new version([0,0,0]);
			ver = this.searchVersion(navigator.userAgent)
				|| this.searchVersion(navigator.appVersion)
				|| "EU_UNKNOWN_VERSION";
			return {
				name: browser.toLowerCase(),
				appName: browser,
				version: ver
			};
		},
		searchString: function(data) {
			for (var i=0;i<data.length;i++)	{
				var dataString = data[i].string;
				var dataProp = data[i].prop;
				this.versionSearchString = data[i].versionSearch || data[i].identity;
				if (dataString) {
					if (dataString.indexOf(data[i].subString) != -1)
						return data[i].identity;
				}
				else if (dataProp)
					return data[i].identity;
			}
		},
		searchVersion: function (dataString) {
			var index = dataString.indexOf(this.versionSearchString);
			if (index == -1) return new version([0,0,0]);
			return new version(dataString.substring(index+this.versionSearchString.length+1).split('.'));
		},
		dataBrowser: [{
				string: navigator.vendor,
				subString: "Apple",
				identity: "Safari"
			},{
				prop: window.opera,
				identity: "Opera"
			},{
				string: navigator.vendor,
				subString: "Konqueror",
				identity: "Konqueror"
			},{
				string: navigator.userAgent,
				subString: "Firefox",
				identity: "Firefox"
			},{
				string: navigator.userAgent,
				subString: "SeaMonkey",
				identity: "SeaMonkey"
			},{
				string: navigator.vendor,
				subString: "Camino",
				identity: "Camino"
			},{// for newer Netscapes (6+)
				string: navigator.userAgent,
				subString: "Netscape",
				identity: "Netscape"
			},{
				string: navigator.userAgent,
				subString: "MSIE",
				identity: "Explorer",
				versionSearch: "MSIE"
			},{
				string: navigator.userAgent,
				subString: "Gecko",
				identity: "Mozilla",
				versionSearch: "rv"
			}]
	},
	MSXMLVersion: function(){
		var MSXMLVersion = new version([0,0,0]);
		var progIDs = [{
				ID:      'Msxml2.DOMDocument.6.0',
				version: [6,0,0]
			},{
				ID:      'Msxml2.DOMDocument.3.0',
				version: [3,0,0]
			},{
				ID:      'Msxml2.DOMDocument.4.0',
				version: [4,0,0]
			},{
				ID:      'Msxml2.DOMDocument.5.0',
				version: [5,0,0]
			}];
		var axo;
		for (var i = 0; i < progIDs.length; ++i) {
			try {
				axo = new ActiveXObject(progIDs[i].ID);
				return new version(progIDs[i].version);
			} catch (e) {}
		}
		return MSXMLVersion;
	},
	/** This code has been taken from SWFObject Library
	 * ========================================================================================
	 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
	 *
	 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
	 * http://www.opensource.org/licenses/mit-license.php
	 * ========================================================================================
	 */
	adobeFlashPlayerVersion: function(){
		var playerVersion = new version([0,0,0]);
		if (navigator.plugins && navigator.mimeTypes.length) {
			var x = navigator.plugins["Shockwave Flash"];
			if (x && x.description) {
				playerVersion = new version(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
			}
		} else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0) { // if Windows CE
			var axo = 1;
			var counter = 3;
			while(axo) {
				try {
					counter++;
					axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
					// document.write("player v: "+ counter);
					playerVersion = new deconcept.PlayerVersion([counter,0,0]);
				} catch (e) {
					axo = null;
				}
			}
		} else { // Win IE (non mobile)
			// do minor version lookup in IE, but avoid fp6 crashing issues
			// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
			} catch(e) {
				try {
					var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
					playerVersion = new version([6,0,21]);
					axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
				} catch(e) {
					if (playerVersion.major == 6) {
						return playerVersion;
					}
				}
				try {
					axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				} catch(e) {}
			}
			if (axo != null) {
				playerVersion = new version(axo.GetVariable("$version").split(" ")[1].split(","));
			}
		}
		return playerVersion;
	},
	_cache: {},
	_checkBrowser: function(){
		if (!this._cache.require.browser[this._cache.available.browser.name])
			return false;
		if (this._cache.available.browser.name == 'explorer')
			return (
				   this._cache.available.browser.version.compare(this._cache.require.browser.explorer) >= 0
				&& this._cache.available.msxml.compare(this._cache.require.msxml) >= 0
			);
		return (this._cache.available.browser.version.compare(
			this._cache.require.browser[this._cache.available.browser.name]
		) >= 0);
	},
	_check: function(){
		if (!this._cache.require) {
			this._cache.require = {
				browser: {
					explorer: new version([5,5,0]),
					opera: new version([9,0,0]),
					safari: new version([2,0,0]),
					firefox: new version([1,5,0]),
					camino: new version([1,0,0]),
					seamonkey: new version([1,0,0]),
					mozilla: new version([1,8,0]),
					netscape: new version([7,0,0])
				},
				fp:    new version([9,0,0]),
				msxml: new version([3,0,0])
			};
		}
		if (!this._cache.available) {
			var cObj = this;
			this._cache.available = {
				fp:    cObj.adobeFlashPlayerVersion(),
				msxml: cObj.MSXMLVersion()
			};
			this._cache.available.browser = this.BrowserDetect.detect();
		}
		if (typeof this._cache.passed == 'undefined') {
			this._cache.browserPassed = this._checkBrowser();
			this._cache.passed = (
				   this._cache.browserPassed
				&& (this._cache.available.fp.compare(this._cache.require.fp) >= 0)
			);
			this._cache.iePassed = (
				   this._cache.passed
				&& this._cache.available.browser.name == 'explorer'
			);
		}
	},
	ieFeedback: false,
	check: function(){
		this._check();
		this.ieFeedback = false;
		return this._cache.passed
	},
	courseCheck: function(){
		this._check();
		this.ieFeedback = true;
		return this._cache.iePassed;
	},
	checkWithFeedback: function(passed){
		var testTableCell = function(data){
			return '<tr class="'+(data.passed ? 'passed' : 'failed')+'"><td class="app-name">'+ data.appName +'</td><td class="app-version">'+(data.version == '0.0.0' ? '<span class="failed">не установлен</span>' : data.version)+'</td><td class="app-require">'+data.require+'</td><td class="app-passed">'+(data.passed ? '<span class="passed">Тест пройден</span>' : '<span class="failed">Тест НЕ пройден</span>')+'</td></tr>';
		}
		this._check();
		var feedback = '';
		if (!this._cache.require.browser[this._cache.available.browser.name])
			return '<div class="EUDetectionCheck"><div class="failed"><h1>Ваш браузер не поддерживается</h1></div>';
		if ((this.ieFeedback && this._cache.iePassed) || (!this.ieFeedback && this._cache.passed)) {
			feedback = '<div class="EUDetectionCheck"><h1 class="passed">Ваша система содержит все необходимые компоненты</h1>';
		} else {
			feedback = '<div class="EUDetectionCheck"><div class="failed"><h1>Ваша система не содержит всех необходимых компонент для корректного отображения содержимого</h1>';
		}
		var browser = {
			passed:  null,
			version: null,
			require: null,
			appName: null
		};
		var fp = {
			passed:  null,
			version: null,
			require: null,
			appName: 'Adobe Flash Player'
		};
		var msxml = {
			passed:  null,
			version: null,
			require: null,
			appName: 'MSXML'
		};
		browser.passed = this._cache.browserPassed;
		fp.passed = (this._cache.available.fp.compare(this._cache.require.fp) >= 0);
		msxml.passed = (this._cache.available.msxml.compare(this._cache.require.msxml) >= 0);

		browser.version = this._cache.available.browser.version.toString();
		fp.version = this._cache.available.fp.toString();
		msxml.version = this._cache.available.msxml.toString();

		browser.require = this._cache.require.browser[this._cache.available.browser.name].toString();
		fp.require = this._cache.require.fp.toString();
		msxml.require = this._cache.require.msxml.toString();
		
		browser.appName = this._cache.available.browser.appName;

		feedback += '<br /><table cellpadding="3" cellspacing="0">';
		feedback += '<tr><th class="app-name">Название продукта</th><th class="app-version">Установленная Версия</th><th class="app-require">Необходимая версия</th><th class="app-passed">Тест</th></tr>';
		feedback += testTableCell(browser);
		if (this._cache.available.browser.name == 'explorer')
			feedback += testTableCell(msxml);
		feedback += testTableCell(fp);
		feedback += '</table>';
		feedback += '<br /><div class="comment"><b>Примечание 1:</b> Adobe Flash Player не обязателен для корректной работы сервера, но может понадобиться при отображении курсов.</div>'
		feedback += '<div class="comment"><b>Примечание 2:</b> Курсы eAuthor работают только в Microsoft Internet Explorer версии 5.5 или старше.</div>'
		feedback += '</div></div>';
		return feedback;
	}
// Добавлена возможность проверки установленного ПО
};


