/***
	Author: Sergey Woitenko
	Date Start: 08.04.2002
	Descrption:

***/
function isBrowser(name){
	return (String(window.navigator.appName.match( new RegExp(name,"g") ))!="null")
}
function msieVersion(){
	var ie = String(window.navigator.appVersion.match(/MSIE(.*);/g));
	return ( ie != "null") ? ie.substring(5, ie.indexOf(";"))*1 : 0;
}
function equipmentIsGood(){
	if(window.screen.availWidth < 800){
		alert("Установите разрешение 800х600 или выше");
		return false;
	}
	if( msieVersion() >= 5.5 ) {
		isXMLmodulInstaled = false
		document.scripts.sIE5.text = 'try{var tempObj = new ActiveXObject("Msxml2.DOMDocument"); isXMLmodulInstaled = true} catch(e){}'
		if(! isXMLmodulInstaled ){
			alert("Установите модуль XML 3.0");
			return false;
		}
	} else {
		alert("Установите IE 5.5 или выше");
		return false;
	}
	setCookie ("BPortalCookieTest1", "done");
	if(getCookie ("BPortalCookieTest1") != "done"){
		alert("Разрешите использование Cookies");
		return false;
	}
	return true;
}
function getBrowserPreference(){
	var i = 0, arrNames = new Array();
	if(window.screen.availWidth >= 800) arrNames[i++] = "is800"
	setCookie ("BPortalCookieTest", "done");
	if(getCookie ("BPortalCookieTest") == "done") arrNames[i++] = "isCookie"
	if( msieVersion() >= 5.5 ) {
		arrNames[i++] = "isIE5"
		isXMLmodulInstaled = false
		document.scripts.sIE5.text = 'try{var tempObj = new ActiveXObject("Msxml2.DOMDocument"); isXMLmodulInstaled = true} catch(e){}'
		if( isXMLmodulInstaled ) arrNames[i++] = "XMLmodul"
	}
	return arrNames
}						 
function setIEBackground( url ){
	if(msieVersion() > 5){
		var dbs = document.body.style;
		dbs.backgroundImage="url("+url+")";		
		dbs.backgroundRepeat="no-repeat";
		dbs.backgroundRepeat="no-repeat";
		dbs.backgroundAttachment="fixed";
	}
}
function setBrowserPreference( path ){
	var path = !!(path) ? path : "";
	var arrNames = getBrowserPreference();
	for(var i in arrNames) document[arrNames[i]].src=path+"images/kv2.gif";		
	setIEBackground( path+"images/bgBottomRight.gif");
}						 


/***Begin Cookies********************************************************/

function getCookie (name)	 {
	var arg = name + '=';
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)	{
		var j = i + alen;
		if (document.cookie.substring (i, j) == arg)	{
			return getCookieVal (j);
		}
		i = document.cookie.indexOf (" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}
function getCookieVal (offset)	 {
	var endstr = document.cookie.indexOf(";", offset);
	if (endstr == -1)	{	endstr = document.cookie.length;	}
	return unescape (document.cookie.substring (offset, endstr));
}
function setCookie (name, value, expires, path, domain, secure)	{
 		document.cookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") + 
		((domain) ? "; domain=" + domain : "") +
		((path) ? "; path=" + path : "") +
		((secure) ? "; secure" : "");
}
/***End Cookies**********************************************************/