var KinUP = new Object;
KinUP = {
	DisplayNone: new Object,
	setTitleAttribOnClickDisplayUL: new Object,
	Counter: new Object,
	NewFoto: new Object,
	AddMouseListenerOverOut: new Object,
	PositionAbsolute: new Object,
	AddAttributeColorToInput: new Object,
	SetSelected: new Object,
	UserBrowser: new Object,
	GetBrowserName: new Object,
	Flash: new Object,
	CreateFlash: new Object,
	VBScriptForIE: new Object,
	FixBeerjaHeight: new Object,
	SetWidthForBeerjaHelpNavy: new Object
}

window.onresize = function(){
	if(document.getElementById('rk')){
		KinUP.OperaFixBodyBG.init();
	}
}
window.onload = function(){
	var c = 'black';
	if(document.getElementById('rk')){
		KinUP.OperaFixBodyBG.init(); //защищаюсь от бага Оперы, в разделе RK
	}
	try{//устанавливаю цвет текста с поле поиска, при перемещении туда фокуса, что б в разных разделах, при вводе текста в поиске, цвет текста был разный цвет. По умолчанию цвет в поле поиска 'black'
		if(document.getElementById('marrakesh')) c = '#292929';
		if(document.getElementById('beerja')) c = '#fff';
		if(document.getElementById('fitness')) c = '#aeccfe';
		if(document.getElementById('rk')) c ='#669933';
		var searchInput = document.getElementById('searchInput');
			searchInput.onfocus = function(){
				this.value = '';
				this.style.color = c;
			}
	}catch(error){
		;
	}
}

KinUP.OperaFixBodyBG = {
    init: function(){ //защита от бага Оперы, в разделе Развлекательный Комплекс
	var opera = KinUP.UserBrowser.opera();
		if(opera){
			var	bodyWidth = document.getElementById('rk').clientWidth;
			var	allWidth = document.getElementById('all').clientWidth;
			if(bodyWidth > 990){
					if(bodyWidth%2 !=0){
						document.getElementById('all').style.left = '0px';
					}else{
						document.getElementById('all').style.left = '-1px';
					}
				}
			}
	}
}
KinUP.VBScriptForIE = {
	VBScriptForFlash: function (){
		document.writeln('<script language="VBScript" type="text/vbscript">');
		document.writeln('<!-- // Visual basic helper required to detect Flash Player ActiveX control version information');
		document.writeln('Function VBGetSwfVer(i)');
		document.writeln('on error resume next');
		document.writeln('Dim swControl, swVersion, functionReturnVal');
		document.writeln('swVersion = 0');
		document.writeln('functionReturnVal = false');

		document.writeln('set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash."+CStr(i))');
		document.writeln('if (IsObject(swControl)) then');
		document.writeln('		functionReturnVal = true');
		document.writeln('end if');
		document.writeln('VBGetSwfVer = functionReturnVal');
		document.writeln('End Function');
		document.writeln('// -->');
		document.writeln('</script>')
	},
	init: function(){
		this.VBScriptForFlash();
	}
}
KinUP.VBScriptForIE.init();
KinUP.UserBrowser = {//определение браузера
		ie: function(){
			if ((navigator.appName.substring (0,3)=='Mic') && !((new Date().getYear().toString()).substring (0,1)=='1')){//определяю год; ie выдаст в формате гггг, а мозилла 1гг
					return true;
			}else{
				return false;
			}
		},
		mozilla: function(){
			if(navigator.appName.substring (0,3)=='Net'){
				return true;
			}else{
				return false;
			}
		},
		opera: function(){
			if((navigator.appName.substring (0,5)=='Opera') || ((navigator.appName.substring (0,3)=='Mic') && (new Date().getYear().toString()).substring (0,1)=='1'))//определяю год; ie выдаст в формате гггг, а мозилла 1гг
			{
				return true;
			}else{
				return false;
			}
		}
	}
KinUP.GetBrowserName = {//определение названия браузера
	browser: KinUP.UserBrowser,
	make: function(){
		if(this.browser.ie()) {
			return 'internet exlorer';
		}else{
			if(this.browser.mozilla()) {
				return 'mozilla';
			} else{
				if(this.browser.opera()) {
						return 'opera';
				}else{
						return 'unknow browser';
				}
			}
		}
	},
	get: function(){
			return this.make();
	}
}
KinUP.Counter = {//создан для создания уникального значения или имени, при каждой инициализации, возвращает всегда значение большее на 1
	counter: 0,
	setCounter: function(){
		this.counter++;
	},
	init: function(){
		this.setCounter();
		return this.counter;
	}
}
KinUP.DisplayNone = {
	init: function(obj){
		try{
			document.getElementById(obj).style.display = 'none';
		}catch(error){
			;
		}
	}
}
KinUP.AddCSSStyleCursor = {//устанавливаю стиль курсора для элемента.
	documentElement: '',
	getElement: function(obj){
		try{
			this.documentElement = document.getElementById(obj);
			return documentElement;
		}catch(error){
			;
		}
	},
	init: function(obj, cursor_type){
		this.getElement(obj);
		try{
			this.documentElement.style.cursor = cursor_type;
		}catch(error){
			return false;
		}
	}
}
KinUP.AddMouseListenerOverOut = {
	documentObject: '',
	setObjectListenerMouseover: function(){
	    var ie = KinUP.UserBrowser.ie();
		var mozilla = KinUP.UserBrowser.mozilla();
		var TOP_POSITION = 27; //положение меню, отступ с верху, объявил фактически как константу
		var set_menu_position = TOP_POSITION;//положение меню, отступ с верху, объявил  как переменную, которая берет значение константы TOP_POSITION и изменяет его, в зависимости от браузера пользователя

		this.documentObject.onmouseover = function(){
			try{
				var beerja_status = false;
				if(document.getElementById('beerja')) beerja_status = true;
					KinUP.PositionAbsolute.init('subNavigation', set_menu_position, 0);
					if(beerja_status==false) document.getElementById('h1').style.backgroundPosition = '0 -175px';
						if(beerja_status){
							document.getElementById('subNavigationLeftConner').style.backgroundPosition = '0 -34px';
							document.getElementById('subNavigationRightConner').style.display = 'block';
						}

					/*это действие - защита от IE 6, для Марракеша, поскольку  IE6 не корректно высчитывает положение закругленных нижних углов*/
						if(ie && ('4.0 (compatible; MSIE 6'==navigator.appVersion.toString().substring (0,23))){
							try{
								if(document.getElementById('marrakesh')){
									document.getElementById('subNavigationRightConner').style.display = 'none';
									document.getElementById('subNavigationLeftConner').style.display = 'none';
								}
							}catch(error){
								;
							}
						}
						//это действие - защита от mozilla, т.к. в мозилла в "марракеше" делает отступ на 1 пиксель меньше.
						if(mozilla){
							if(document.getElementById('marrakesh')){
								KinUP.PositionAbsolute.init('subNavigation', ++set_menu_position, 0);
								set_menu_position = TOP_POSITION;
							}
						}
			}catch(error){
				;
			}
		}
		this.documentObject.onmouseout = function(){
		var beerja_status = false;
		if(document.getElementById('beerja')) beerja_status = true;
						if(beerja_status){
							document.getElementById('subNavigationLeftConner').style.backgroundPosition = '0 0';
							document.getElementById('subNavigationRightConner').style.display = 'none';
						}
				try{
					KinUP.PositionAbsolute.init('subNavigation', 0, -10000);
					if(beerja_status!=true) document.getElementById('h1').style.backgroundPosition = '0 2px';

				}catch(error){
					;
				}
			}
	},
	init: function(obj){
		try{
			this.documentObject = document.getElementById(obj);
			this.setObjectListenerMouseover();
		}catch(error){
			;
		}
	}
}
KinUP.PositionAbsolute = {//установка положения элементу
	init: function(obj, top, left){
		try{
			document.getElementById(obj).style.position = 'absolute';
			document.getElementById(obj).style.top = top + 'px';
			document.getElementById(obj).style.left = left + 'px';
		}catch(error){
			;
		}
	}
}

KinUP.NewFoto = {//создание нового окна с картинкой
	init: function(url, width, height){
	var winName = 'window';//задаю имя окна
		winName += KinUP.Counter.init();//делаю окну уникальное имя, что б каждый раз создавалось новое окно, а не происходила ситуация, когда инфа грузится в одно окно
		myWin= open("", winName, "width=" + width + ",height=" + height +",status=no,toolbar=no,menubar=no,directories=no,location=no,resizable=no, left=300, top=200");
			myWin.document.open();
			myWin.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n<html><head>\n<meta http-equiv="content-type" content="text/html; charset=windows-1251">\n<title>Фотография</title>\n<style type="text/css">img{position:absolute;top:0;left:0;}</style>\n</head><body>\n');
			myWin.document.write('<img src="' + url +'" alt=""\n title="закрыть окно" onclick="javascript:window.close();"\n style="cursor:pointer">');
			myWin.document.write("\n</body></html>");
			myWin.document.close();
	}
}

KinUP.NewWindow = {//создание нового окна и загрузка в него содержимого html документа
	init: function(url, name, x, y) {
	//полученное имя окна делаю уникальным, что б каждый раз создавалось новое окно, а не происходила ситуация, когда инфа грузится в одно окно
	/*name += KinUP.Counter.init();*/
	    var proWindow = window.open(url,name,"left=0, top=0, menubar=no, toolbar=no, location=no, directories=no, statusbar=0, scrollbars=0, resizable=0,  width=" + x + ", height=" + y);
	}
}
/*
	@author - Юнком
	@title - отображение фото в новом окне
	@description - создается новое окно, куда грузится фото
*/
/*
function openWin(images, w, h) {
  myWin= open("", "PhotoAlbumWindow", "width="+w +",height="+h +",status=no,toolbar=no,menubar=no,directories=no,location=no,resizable=no");
  myWin.document.open();
  myWin.document.write("<html><head><title>Фотоальбом</title></head>");
  myWin.document.write("<body leftmargin=0 topmargin=0 marginheight=0 marginwidth=0>");
  myWin.document.write("<a href=\"javascript:window.close()\"><img src="+images+" width="+w+" height="+h+" border=\"0\" title=\"Закрыть окно\" alt=\"Закрыть окно\"></a>");
  myWin.document.write("</body></html>");
  myWin.document.close();
}*/
KinUP.Flash = {
	text: '',
	alternativeText: '',
	flashVersion: 8,
	setText: function(text){
		this.text = text;
	},
	setAlternativeText: function(alternativeText){
		this.alternativeText = alternativeText;
	},
	setFlashVersion: function(flashVersion){
		this.flashVersion = flashVersion;
	},
	getText: function(){
		return this.text;
	},
	getAlternativeText: function(){
		return this.alternativeText;
	},
	getFlashVersion: function(){
		return this.flashVersion;
	},
	make: function(){
		var ie = KinUP.UserBrowser.ie();
		var flash;
		var versionString;
		var versionCount = 0;
				if(ie){
					if(VBGetSwfVer(this.flashVersion)){
						document.writeln(this.text);
					}else{
						for(var i = 25; i > 0; i--){
							versionStr = VBGetSwfVer(i);
							if(versionStr) {
								break;
							}
							versionCount++;
						}
						if(versionCount == 25){
							document.writeln(this.text);
						}else{
							document.writeln(this.alternativeText);
						}
					}
				}
				else{
					if(navigator.plugins["Shockwave Flash"]){
						flash = navigator.plugins["Shockwave Flash"];
							if((flash.description.toString().substring (16,17) == this.flashVersion) || (flash.description.toString().substring (16,17) > this.flashVersion)){
								document.writeln(this.text);
								}
							else{
								document.writeln(this.alternativeText);
							}
					}else{
						document.writeln(this.alternativeText);
					}
				}
		},
	init: function(){
		this.make();
	}
}
KinUP.CreateFlash = {
	init: function(object_url, object_width, object_height, alternative_img){
		var text, altenative_text;
				text =	'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+object_width+'" height="'+object_height+'" />';
				text += '<param name="allowScriptAccess" value="sameDomain" />';
				text += '<param name="movie" value="' + object_url + '" />';
				text += '<param name="quality" value="high" />';
				text += '<param name="scale" value="noborder" />';
				text += '<param name="salign" value="b" />';
				//text += '<param name="bgcolor" value="#0099FF" />';
				text += '<embed src="' + object_url + '" quality="high" scale="noborder" salign="b" width="' +object_width+'" height="'+object_height+'" name="Project-1280" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
				text += '</object>';

				altenative_text += '<img src="'+alternative_img+'" style="width:'+object_width+';height:"'+object_height+';" alt="" />';
		KinUP.Flash.setAlternativeText(altenative_text);
		KinUP.Flash.setText(text);
		KinUP.Flash.init();
	}
}
KinUP.FixBeerjaHeight = {
	init: function(){
		try{
			var centerLeft = document.getElementById('centerLeft').offsetHeight;
			var mainText = document.getElementById('mainText').offsetHeight;
			if(mainText<centerLeft) {
				document.getElementById('mainText').style.display = 'block';
				document.getElementById('mainText').style.paddingBottom  = centerLeft-mainText-140  + 'px';
			}
		}catch(error){
			return false;
		}
	}
}
KinUP.SetWidthForBeerjaHelpNavy = {
	init: function(){
	var opera = KinUP.UserBrowser.opera();
	var ie = KinUP.UserBrowser.ie();
	var block_additional_width = 18;
	var h1 = document.getElementById('h1').offsetWidth;
	if(ie && ('4.0 (compatible; MSIE 6'==navigator.appVersion.toString().substring (0,23))) {
		block_additional_width = block_additional_width + 2;
	}
	try{
		var docTitle = document.getElementById('docTitle').offsetWidth;
				document.getElementById('subNavigation').style.width = h1 + 18 + 'px';
				if(opera) document.getElementById('subNavigationRightConner').style.left = h1 - 27 + 'px';

	}catch(error){
			return false;
	}
	}
}


/* spamstop */
function smail (login, sc)
{
 eml = login +  "@" + "kinup.ru";
 return eml;
}

function smylo (login, sc)
{
document.write (smail(login, sc));
}

function nasmylo (login, sc, sub)
{
eml = "mailto:" + smail(login, sc);
if (sub != "") eml += "?subject=" + sub;
window.location.href = eml;
}