/**
 * @author Vlad Yakovlev (scorpix@design.ru)
 * @copyright Art.Lebedev Studio (http://www.artlebedev.ru)
 * @version 0.1 (20.02.2009)
 * @ requires jQuery
 *
 * @adds by Denis Khripkov (denisx@design.ru)
 */

var onTimerDelay = 3000;
//var onTimerFlag = true;
var aPopupBlocks = [];
var fMoveIEBorder = true;
var rollCanWork = true;
var bIEResizeInWork = false;
var bFooterHelper = false;

var nIEResizeTimer = 350;
var oIEResizeInWorkTime = {
	nOldData: 0,
	nNewData: 0
};

function openPopup(eLink, html) {
	var newWin = window.open('about:blank', eLink.target, 'width=820,height=600,status=yes');
	var bFlag = true;
	if (newWin) {
		newWin.document.open();
		newWin.document.write('<html><head><title>' + eLink.target + '<\/title><\/head><\/title><body style="margin: 0; padding: 0 0 0 20px;" bgcolor="#F7F7F7"><iframe src="' + eLink.href + '" style="width: 800px; height: 600px;" frameborder="0"/><\/body><\/html>');
		newWin.document.close();
		bFlag = false;
	}
	return bFlag;
}

//ie6
var ieFixPngImagePath = '/f/1/global/i/0.gif';
if (undefined === common) {
	var common = {};
}

common.Measurer = (function() {
	var funcs = {};
	var interval = 500;
	var genId =  1;
	var curHeight;
	var el;
	var isInit = false;
	var isDocReady = false;
	$(function() {
		isDocReady = true;
		isInit && initBlock();
	});

	function initBlock() {
		el = $("#measurer");
		curHeight = el.height();
		setInterval(function() {
			checkScale();
		}, interval);
		$(window).resize(callFuncs);
	}

	function checkScale() {
		var newHeight = el.height();

		if (newHeight != curHeight) {
			curHeight = newHeight;
			callFuncs();
		}
	}

	function callFuncs() {
		for (var func in funcs) {
			funcs[func]();
		}
	}

	return {
		setFunc: function(name, func) {
			if (!$.isFunction(name) && !$.isFunction(func)) {
				funcs[name] && (delete funcs[name]);

				return;
			}

			isInit = true;
			isDocReady && initBlock();

			if ($.isFunction(name)) {
				funcs[genId.toString()] = name;
				genId++;
			} else {
				funcs[name] = func;
			}
		}
	};
})();


/**
 * а­аМб�аЛаИб�б�аЕб� аПаОаВаЕаДаЕаНаИаЕ input type="search" аКаАаК аВ аЁаАб�аАб�аИ.
 */
$.browser.safari || $(function() {
	$('input[placeholder]').each(function () {
		makePlaceholder(this);
	});

	/**
	 * а­аМб�аЛаИб�б�аЕб� аПаОаВаЕаДаЕаНаИаЕ input type="search" аКаАаК аВ аЁаАб�аАб�аИ.
	 *
	 * @ param {Element} elem а�аОаЛаЕ аВаВаОаДаА
	 * @ param {String} [class_empty] а�аЛаАб�б� аДаЛб� аПб�б�б�аОаГаО аПаОаЛб� аВаВаОаДаА
	 */
	function makePlaceholder(elem, classEmptyP) {
		var classEmpty = classEmptyP;
//		var elem = elemP;
		var t = 'empty';
		if ('string' === typeof classEmpty){ t = classEmpty }
		classEmpty = t;
//		('string' === typeof classEmpty) ? classEmpty : 'empty';

		$(elem).focus(function () {
			if (this.value === $(this).attr('placeholder')) {
				this.value = '';
			}

			$(this).removeClass(classEmpty);
		});

		$(elem).blur(function () {
			if (!this.value.length) {
				this.value = $(this).attr('placeholder');
				$(this).addClass(classEmpty);
			}
		});

		elem.value.length || $(elem).blur();

		var oSubmit = $(elem).parent('form').find('input:submit');
		oSubmit.bind('click keypress',function(){
//			console.log( $(elem).hasClass('empty'), $(elem).attr('placeholder'), $(elem).val() );
			if ( ($(elem).hasClass('empty') && $(elem).attr('placeholder') === $(elem).val()) ){
				$(elem).val('');
			}
		});
	}
});

jQuery.extend(Number.prototype, {

	/* а�аОаЗаВб�аАб�аАаЕб� аКб�аАб�аИаВаО аОб�аОб�аМаЛаЕаНаНаОаЕ б�аИб�аЛаО: 1234567.0981 => 1 234 567,10 */
	nice: function (iRoundBase) {
		var re = /^(-)?(\d+)([\.,](\d+))?$/;
		var iNum = Number(this);
		var sNum = String(iNum);
		var aMatches;
		var sDecPart = '';
		var sMinusSign = '&minus;';
		var sTSeparator = '&nbsp;';

		aMatches = sNum.match(re);
		if ( aMatches ) {

			var sSign = '';
			if ( aMatches[1] ){ sSign = sMinusSign }
//			var sSign = aMatches[1] ? sMinusSign : '';

			var sIntPart = aMatches[2];

			var iDecPart = 0;
			if ( aMatches[4] ){ iDecPart = Number('0.' + aMatches[4]); }
//			var iDecPart = aMatches[4] ? Number('0.' + aMatches[4]) : 0;

			if (iDecPart) {
				var n = 2;
				if ( iRoundBase ){ n = iRoundBase; }
				var iRF = Math.pow(10, n); // iRoundBase ? iRoundBase : 2
				iDecPart = Math.round(iDecPart * iRF);
				if (iRF.toString().length - 1 > iDecPart.toString().length && iDecPart !== 0){
					for (var k = 0; k < (iRF.toString().length - 1) - iDecPart.toString().length; k++){
						iDecPart = "0" + iDecPart;
					}
				}
				sDecPart = '';
				if ( iDecPart ){ sDecPart = ',' + iDecPart; }
//				sDecPart = iDecPart ? ',' + iDecPart : '';
			}

			if (Number(sIntPart) < 10000) {
				return sSign + sIntPart + sDecPart;
			}
			else {
				var sNewNum = '';
				var i;
				for (i = 1; i * 3 < sIntPart.length; i++) {
					sNewNum = sTSeparator + sIntPart.substring(sIntPart.length - i * 3, sIntPart.length - (i - 1) * 3) + sNewNum;
				}
				return sSign + sIntPart.substr(0, 3 - i * 3 + sIntPart.length) + sNewNum + sDecPart;
			}
		}else { // аНаАаМ б�б�аО-б�аО аНаЕ б�аО аПаОаДб�б�аНб�аЛаИ
			return sNum;
		}
	}

});

common.checkCanvas = function() {
	if (undefined !== window.HTMLCanvasElement){
		return true;
	}

	// а� IE аДаЛб� VML аНаАаДаО аДаОаБаАаВаИб�б� б�б�аЕаМб� аИ б�б�аИаЛаИ.
	if (!document.namespaces['v']) {
		document.namespaces.add('v', 'urn:schemas-microsoft-com:vml');

		var ss = document.createStyleSheet();

		ss.cssText = 'v\\:* {behavior:url(#default#VML);display:block;}';
	}

	return false;
};

common.isCanvas = common.checkCanvas();

if ($.browser.msie) {
	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {}

	function fixIePng(element) {
		if (!(/MSIE (5\.5|6).+Win/.test(navigator.userAgent))) {
			return;
		}

		var src;

		if ('IMG' == element.tagName || ('INPUT' == element.tagName && 'image' == element.type)) {
			if (/\.png$/.test(element.src)) {
				src = element.src;
				element.src = ieFixPngImagePath;
			}
		} else {
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);

			if (src) {
				src = src[1];
				element.runtimeStyle.backgroundImage = 'none';
			}
		}

		var reScaleMode = /iesizing\-(\w+)/;
		var m = reScaleMode.exec(element.className);

		if (src) {
			var scaleMode = 'crop';
//					(m) ? m[1] : 'crop';
			if ( m ){ scaleMode = m[1]; }
			element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='" + scaleMode + "')";
		}
	}
}


function showJsBlocks(){
	$('.js_enable').css("visibility","visible");
}

function unColorizeTable(obj){
	$('tr', obj).each(function(){
		$(this).removeClass('stripe');
	});
}
function colorizeResizeTable(){
	var measurer = $("#measurer").height()*38;
	if ($.browser.msie) {
			measurer = $("#measurer").height()*34;
			$('.text_data').prev(".caption").width($("#measurer").height()*34);
	}

	var tableWidth = $('.text_data');

	tableWidth.each(
		function(){
			var bNeedClass = true;
			var oTrLine = $('tr:has("td")', $(this));
			oTrLine.each(function(){
				var oTr = $(this);
				if ( oTr.hasClass('hidden') === false ){
					//oTr.find('td:first').css({'border-left':'1px solid magenta'});
					if ( bNeedClass ) {
						oTr.addClass("stripe");
					}
					//oTr.find('td:first').css({'border-left':'0px solid magenta'});
					var oTrNext = oTr.next();
					//oTrNext.find('td:first').css({'border-left':'1px solid green'});
					if ( !oTrNext.find('td').hasClass('comment') ){
						bNeedClass = !bNeedClass;
					}
					//oTrNext.find('td:first').css({'border-left':'0px solid green'});
				}
				});

			if(!$(this).hasClass('wide')){
				if ($(this).width() > measurer){
					$(this).width(measurer);
				}
			}
		}
	);
}

function selectorToggle(){
	$('.selector').hover(
		function(){
			$(this).addClass('hovered');
		},
		function(){
			$(this).removeClass('hovered');
		}
	);
	$('.selector').click(
		function(e){
			e.stopPropagation();
			$('.selector_block').show();
		}
	);
	$(document).click(
		function(){
			$('.selector_block').hide();
		}
	);
}

function brightLinks(){

	if($("html").hasClass("no_contrast")){
		var arr = $("#main_navigation li.selected, .left_column .navigation li .marked");

		if(arr.length !== 0){
			var obj = $(arr[arr.length-1]);
			if(obj[0].nodeName === "B" || obj[0].nodeName === "A"){
				obj = $(arr[arr.length-1]).find(".w");
			}
			var tmp;
			if((obj[0].nodeName === "LI")){
				tmp = $(obj[0]);
			}
			else{
				var s = obj.text().split(/\u0020/);
				var outputStr = '';
				for (var k = 0; k < s.length; k++){
					outputStr += "<span class='w'>" + s[k] + "<\/span> ";
				}
				obj.replaceWith(outputStr);

				tmp = $(arr[arr.length-1]).find(".w");
				obj = $(arr[arr.length-1]).find(".w");
			}

			var startColor = tmp.css("background-color");





			var endColor;
			if(startColor == 'rgb(0, 122, 194)' || startColor == '#007ac2'){
				endColor = "#99ccff";
			}
			else{
				endColor = "#ccff66";
			}

			jTweener.addTween(
				obj,
				{
					backgroundColor: endColor,
					time: 0.5,
					delay: 0.5,
					transition: 'easeNone'
				}
			);
			jTweener.addTween(
				obj,
				{
					backgroundColor: startColor,
					time: 0.5,
					delay: 1,
					transition: 'easeNone'
				}
			);
			/*obj.animate(
				{
					backgroundColor: endColor
				}, 500,
				function(){
					obj.animate(
						{
							backgroundColor: startColor
						}, 500);
				}
			);*/
		}
	}
}

function allsitesChooser( param ){


	var sites = param.sites;
	var closer = param.closer;
	var all = param.all;
	var sub = param.sub;
	var allList = param.allList;
	var subList = param.subList;

	if($(document).height() < 900){
		if ( subList !== null ){
			subList.height("40em");
		}
	}

	if (all !==null){
	all.click(
		function(){
			var obj = $(this);
			if(obj.hasClass("pseudo_link")){
				all.removeClass("pseudo_link").addClass("selected");
				sub.removeClass("selected").addClass("pseudo_link");
				allList.removeClass("hidden");
				subList.addClass("hidden");
			}
//			console.log(100);
		}
	);}

	if (sub !==null){
	sub.click(
		function(){
			if($(this).hasClass("pseudo_link")){
				sub.removeClass("pseudo_link").addClass("selected");
				all.removeClass("selected").addClass("pseudo_link");
				subList.removeClass("hidden");
				allList.addClass("hidden");
			}
//			console.log(101);
		}
	);}

	closer.hover(
		function(){
			closer.addClass("active");
		},
		function(){
			closer.removeClass("active");
		}
	);

	closer.click(
		function(){
			sites.addClass("hidden");
//			console.log(102);
		}
	);
}

function setCookie(cookieName, cookieContent, cookieExpireTime){
	if(cookieExpireTime>0){
		var expDate=new Date();
		expDate.setTime(expDate.getTime()+cookieExpireTime*1000*60*60);
		var expires=expDate.toGMTString();
		document.cookie=cookieName+"="+escape(cookieContent)+"; path="+escape('/')+"; expires="+expires
	}else{
		document.cookie=cookieName+"="+escape(cookieContent)+"; path="+escape('/')+"";
	}
}

function setCookieCopy( cookieName, cookieContent, cookiepath, cookieExpireTime ){
	var cookiepathL = cookiepath;
	if ( cookiepath === '' ){ cookiepathL = escape('/'); }
	var s = cookieName + "=" + escape(cookieContent) + "; path=" + escape(cookiepathL) + "";
	if( cookieExpireTime > 0 ){
		var expDate = new Date();
		expDate.setTime(expDate.getTime() + cookieExpireTime*1000*60*60);
		s += "; expires=" + expDate.toGMTString();
	}
	document.cookie = s;
}

function contrastSwitcher(){
	var contrastButton = $(".site_version p");

	contrastButton.click(
		function(){
			if ($("html").hasClass("contrast")){
				setCookieCopy("contrast", "false", '/', 9000);
//				console.log(2);
				$("html").removeClass("contrast").addClass("no_contrast");
				makeUrlContrast(false);

				  
//				if ( $.browser.msie ){
//					$('#outer').css({'position':'absolute'});
//					$('#outer').css({'position':'relative'});
//
//				}
			}
			else{ //setTimeout("deleteCss()", 1000);

			/*function deleteCss() {
				alert('sd');
			}*/
				setCookieCopy("contrast", "true", '/', 9000);
//				console.log(3);
				$("html").removeClass("no_contrast").addClass("contrast");
//				var addStr = '?';
//				if ( document.location.search.length  ){ addStr = '&'; }

				makeUrlContrast(true);


			}
//			contrastButton.html( contrastButton.html() + '<div class="hidden">.. <\/div>' );
			resizeIEThings();;
			return false;
		}
	);
}

$(function(){
	colorizeResizeTable();
	selectorToggle();
	brightLinks();
	showJsBlocks();

	var param = {
		sites : $("#sites_list"),
		closer : $("#sites_list .closer"),
		all : $("#sites_list .allsitesall"),
		sub : $("#sites_list .allsitessub"),
		allList : $("#sites_list .allsites_list"),
		subList : $("#sites_list .subs_sites_list")
	};
	allsitesChooser( param );

	contrastSwitcher();

});


var ie = {browser: false, v6:false, v7:false, v8:false};
if ( $.browser.msie ){
	ie.browser = true;
	if ( $.browser.version < 7 ){
		ie.v6 = true;
	}
	if ( $.browser.version >= 7 && $.browser.version < 8 ){
		ie.v7 = true;
	}
	if ( $.browser.version >= 8 && $.browser.version < 9 ){
		ie.v8 = true;
	}
//		alert($.browser.version + ' ' + ie.v7);
}

/**
	 * Возвращает значение CSS-свойства <code>name</code> элемента <code>elem</code>
	 * @author John Resig (http://ejohn.org)
	 * @param {Element} elem Элемент, у которого нужно получить значение CSS-свойства
	 * @param {String} name Название CSS-свойства
	 * @return {String}
	 */
	function getStyle(elem, name) {
		// If the property exists in style[], then it's been set
		// recently (and is current)
		if (elem.style[name]) {
			return elem.style[name];
		}

		//Otherwise, try to use IE's method
		else if ($.browser.msie) {
			return elem.currentStyle[name];
		}
		// Or the W3C's method, if it exists
		else if (document.defaultView && document.defaultView.getComputedStyle) {
			//It uses the traditional 'text-align' style of rule writing,
			//instead of textAlign
			name = name.replace(/([A-Z])/g, "-$1").toLowerCase();
			// Get the style object and get the value of the property (if it exists)
			var s = document.defaultView.getComputedStyle(elem, "");
			return s && s.getPropertyValue(name);
		}
		//Otherwise, we're using some other browser
		else {
			return null;
		}
	}

$(document).ready(function(){

	/************************************************************/
	// сборник классов
	var c = {
		h:'hidden',
		r:'roll',
		one:'one',
		two:'two',
		rD:'rollDown',
		rDE:'rollDownEnd',
		m:'major'

//		// may9.js
//		hp:'hidePart',
//		up:'up',
//		down:'down',
//		bT:'rollDown',
//		bTE:'rollDownEnd',
//		vml:'png-vml'
	};
/************************************************************/

	// боян

	if ( rollCanWork ){
	// прячем ненужные элементы в бояне
	var objA = $('.'+c.rD);
	objA.each(function(){
		var obj = $(this).nextUntil('.'+c.rDE);
		obj.each(function(){
			if ( !$(this).hasClass(c.m) ){
				this.storedHeight = $(this).height();
				this.storedMarginTop = (isNaN(parseInt(getStyle(this, 'marginTop'), 10))) ? 0 : parseInt(getStyle(this, 'marginTop'), 10);
				this.storedMarginBottom = (isNaN(parseInt(getStyle(this, 'marginBottom'), 10))) ? 0 : parseInt(getStyle(this, 'marginBottom'), 10);
				this.storedPaddingTop = (isNaN(parseInt(getStyle(this, 'paddingTop'), 10))) ? 0 : parseInt(getStyle(this, 'paddingTop'), 10);
				this.storedPaddingBottom = (isNaN(parseInt(getStyle(this, 'paddingBottom'), 10))) ? 0 : parseInt(getStyle(this, 'paddingBottom'), 10);
				$(this).hide().css({
					height : 0,
					marginTop: 0,
					marginBottom: 0,
					paddingTop:0,
					paddingBottom:0
				});
			}
		});
		$(':not(.'+c.m+')',obj).each(function(){
			this.storedHeight = $(this).height();
				this.storedMarginTop = (isNaN(parseInt(getStyle(this, 'marginTop'), 10))) ? 0 : parseInt(getStyle(this, 'marginTop'), 10);
				this.storedMarginBottom = (isNaN(parseInt(getStyle(this, 'marginBottom'), 10))) ? 0 : parseInt(getStyle(this, 'marginBottom'), 10);
				this.storedPaddingTop = (isNaN(parseInt(getStyle(this, 'paddingTop'), 10))) ? 0 : parseInt(getStyle(this, 'paddingTop'), 10);
				this.storedPaddingBottom = (isNaN(parseInt(getStyle(this, 'paddingBottom'), 10))) ? 0 : parseInt(getStyle(this, 'paddingBottom'), 10);
				$(this).hide().css({
					height : 0,
					marginTop: 0,
					marginBottom: 0,
					paddingTop:0,
					paddingBottom:0
				});
		});
	});

	// события бояна
	$('.'+c.r).bind('click',function(){
		$('.'+c.one+',.'+c.two,$(this)).each(function(){
			$(this).toggleClass(c.h);
		});
		var obj = $(this).nextUntil('.'+c.rD);
		if ( obj.length  ){
//			console.log(1, obj);
			obj = $(obj[obj.length-1]); 
//			console.log(2, obj);
		}else{
			obj = $(this);
		}
		obj = obj.next();
//		console.log(3, obj);
		obj = obj.nextUntil('.'+c.rDE);
//		console.log(3,  '.'+c.rDE);

		function actionRoll(child){
//			var child = $(this);
			if ( !child.hasClass(c.m) ){
				if ( ie.v6 ){
					if ( child.css('display') === 'none' ){
						child.show();
					}else{
						child.hide();
					}
					resizeIEThings();
				}else{
					if ( child.is(':visible') ) {
						child.animate({
										height: 0,
						 				marginTop: 0,
										marginBottom: 0,
										paddingTop:0,
										paddingBottom:0
									},
									{
										duration: 'slow',
										complete: function () {
											child.hide();
											resizeIEThings();
									}
						});
					} else {
						child.show().animate({
						 						height : child[0].storedHeight,
						 						marginTop : child[0].storedMarginTop,
						 						marginBottom : child[0].storedMarginBottom,
						 						paddingTop : child[0].storedPaddingTop,
						 						paddingBottom : child[0].storedPaddingBottom
						 					},
						 					{
						 						duration: 'slow',
						 						complete: function () {
													resizeIEThings();
											}
						});
					}

//					child.slideToggle('slow',
//						function(){
//						resizeIEThings();
//					});
				}
			}
			return false;
		}

		obj.each(function(){
			var obj = $(this);
			actionRoll(obj);
			$('*',obj).each(function(){
				actionRoll($(this));
			});
		});
	});
}
/************************************************************/

	$('div.language a').click(function(){
		if ( $(this).attr('href').search(rContrast) > -1 ){
			setCookie('contrast', 'false', 0);
//			console.log(1);
		}
		return $(this);
	});

	$('div.allsites').each(function( i ){
		param = {
			sites : $(this).find('>div>div[id]'),
			closer : $(this).find('>div>div[id]>div.closer'),
			all : null,
			sub : null,
			allList : null,
			subList : null
		};

		if ( i > 0 ){
			allsitesChooser( param );
		}
	});

// объединяем ховер фотки с подписью и наоборот
//	 ховер на картинку
	function makeLinkHoverTakeObj( o ){
		var obj = o;
		if ( obj.next().hasClass('description') ) {
			obj = obj.next();
		}
		obj = obj.next();
		// noindex в ie не парситься как контейнер
		if ( $.browser.msie ){
			obj = obj.next();
		}else{
			obj = obj.find('div');
		}
		return obj;
	}


	$('div.media a:has("img")').mouseover(function(){
		makeLinkHover( $(this) );
	});
	$('div.media a:has("img")').focus(function(){
		makeLinkHover( $(this) );
	});
	function makeLinkHover( o ){
		var obj = o;
		obj = makeLinkHoverTakeObj( obj );
		obj.find('a').addClass('pic_sourse_active');
	}


	$('div.media a:has("img")').mouseout(function(){
		makeLinkUnhover( $(this) );
	});
	$('div.media a:has("img")').blur(function(){
		makeLinkUnhover( $(this) );
	});
	function makeLinkUnhover( o ){
		var obj = o;
		obj = makeLinkHoverTakeObj( obj );
		obj.find('a').removeClass('pic_sourse_active');
	}



	// ховер на ссылку
	function makePicHoverTakeObj( o ){
		var obj = o;
		// noindex в ie не парситься как контейнер
		if ( $.browser.msie ){
			obj = obj.parent().prev().prev();
		}else{
			obj = obj.parent().parent().prev();
		}
		if ( obj.hasClass('description') ) {
			obj = obj.prev();
		}
		return obj;
	}


	$('div.media .pic_source a').mouseover(function(){
		makePicHover( $(this) );
	});
	$('div.media .pic_source a').focus(function(){
		makePicHover( $(this) );
	});
	function makePicHover( o ){
		var obj = o;
		obj = makePicHoverTakeObj( obj );
		obj.addClass('pic_sourse_active');
	}


	$('div.media .pic_source a').mouseout(function(){
		makePicUnhover( $(this) );
	});
	$('div.media .pic_source a').blur(function(){
		makePicUnhover( $(this) );
	});
	function makePicUnhover( o ){
		var obj = o;
		obj = makePicHoverTakeObj( obj );
		obj.removeClass('pic_sourse_active');
	}



	$('div.media a:has("img")').click(function(){
		$(this).blur();
	});
//	$('div.media a:has("img")').focus(function(){
//		$(this).blur();
//	});

		/* баннер ver5 */

//		var iBgWidth = $('span.uniform-bg span span span').width();
//		var iBgHeight = $('span.uniform-bg span span span').height();
////		$('span.uniform-bg span').css({'width':iBgWidth+'px'});
//		$('span.uniform-bg span span').css({'width':iBgHeight+'px'});


	if(getCookie("contrast") === 'true'){
		document.documentElement.className += ' contrast';
		makeUrlContrast(true);
	}else{
		var str = document.location.search;
		if ( str.search(rContrast) > -1 ){
			document.documentElement.className += ' contrast';
			makeUrlContrast(true);
			setCookieCopy("contrast", "true", '/', 9000);
//			console.log(4);
		}else{
			document.documentElement.className += ' no_contrast';
		}
	}

	resizeIEThings();
	onTimer();

});

function onTimer(){
//	console.log(1);

	var f;
//		$('#outer').bind('change resize',function(){
//			resizeIEThings();
//		});

	f = mediaDescriptionWidth();

	if ( !f ){
//		onTimerFlag = f;
		setTimeout('onTimer()', onTimerDelay);
	}
}

	function mediaDescriptionWidth(){
//	if ( $.browser.msie && $.browser.version < 7 ){
		var bFlag = true; // все элементры нормально отработали
	$('.text_block .media .description').each(function(){
		var obj = $(this);
		console.log(-1, $(this).css('width'));
		if ( !obj.parent().parent().hasClass('text_note') ){
			obj = obj.prev();
			if ( obj.find('img').length == 1 ){
				obj = obj.find('img');
			}
			var width = obj.width();
			if ( width === 0 ){
				width = obj.attr('width');
				console.log(0, $(this).css('width'));
			}
			if ( width > 0 ){
				$(this).css({'width':width,'max-width':width});
				console.log(1, $(this).css('width'));
			}else{
				console.log(2, $(this).css('width'));
				if ( $(this).css('width') === 'auto' ){
					bFlag = false;
				}
			}
		}
	});
////	}
		return bFlag;
	}


function setWidthSlider(){
	var cont = $("#date_navigation");
	var listWidth = 0;
	$('#date_list_ul img').each(function(){
		listWidth += 93; // width photo
	});
	listWidth += 133; // large size of first photo
	if ( cont.width() > listWidth ){
		$("#date_navigation").css('cssText','width: ' + listWidth + 'px !important');
	}
	picSlider.init();
}

function getCookie(cookieName){
	var ourCookie = document.cookie;
	if (!ourCookie || ourCookie === ''){ return ''; }
	ourCookie = ourCookie.split(';');
	var i = 0;
	var cookie;
	while( ourCookie.length > i ){
		cookie = ourCookie[i].split('=')[0];
		if( cookie.charAt(0) === ' ' ){
			cookie = cookie.substring(1);
		}
		if(cookie == cookieName){
			return unescape(ourCookie[i].split('=')[1]);
		}
		i++;
	}
	return '';
}
var rContrast = /(\&|\?)contrast=true/i;
function makeUrlContrast(f){
	var objLang = $('div.language a');
	var objLangLink = objLang.attr('href');
	if ( f ){
		objLangLink += '?contrast=true';
	}else{
		objLangLink = objLangLink.replace(rContrast,'');
	}
	objLang.attr({ 'href' : objLangLink });
}

	function resizeIEThings(){
		if ( $.browser.msie && !bIEResizeInWork && oIEResizeInWorkTime.nOldData + nIEResizeTimer < oIEResizeInWorkTime.nNewData ){
			bIEResizeInWork = true;
			var nFooterHelperMove = 100;

			if ( fMoveIEBorder ){
				var objR = $( '#background_right' ).not($( '.informatorium #background_right' ));
				var objRB = $( '.background_bottom .background_bottom_right' ).not($( '.informatorium .background_bottom .background_bottom_right' ));
				var objB = $( '.background_bottom' ).not($( '.informatorium .background_bottom' ));
				resizeIERightBorder();
				moveIEBottom();
			}else{
				moveIEBottomOuter();
			}

			$('#quotes').bind('change resize load', function(){
				if ( fMoveIEBorder ){
					resizeIERightBorder( this );
					moveIEBottom();
				}else{
					moveIEBottomOuter();
				}
			});

			$( window ).bind( 'change resize click load', function(){
				if ( fMoveIEBorder ){ resizeIERightBorder( this ); moveIEBottom(); }else{
					moveIEBottomOuter();
				}
			});

		function resizeIERightBorder( ){
			objR.each(function(){
				$(this).css({
					'left' : ( objB.width() ) + 'px',
					'margin-left' : - objR.width()
				});
			});
			objRB.each(function(){
				$(this).css({
					'left' : ( objB.width() ) + 'px',
					'margin-left' : - objRB.width()
				});
			});
			return false;
		}
		function moveIEBottom(){
			var foo = $('#footer');
//			aler(1 + ' ' + bFooterHelper);
			if ( !bFooterHelper && oAlert.documentReady ){
//				aler('1--' + ' ' + bFooterHelper);
				foo.css({ 'margin-top': 0 });
				foo.wrap( "<div id='footer_helper'><\/div>"  );
				bFooterHelper = true;
			}

//			var doc = $(document);
			var docH = $('div.background').height() - nFooterHelperMove;
			var docW = $('div.background').width();
			var fh = $('#footer_helper');
			fh.css({
				'top': docH + 'px'
			});
			fh.css({
//				'width': doc.width() + 'px'
				'width': docW + 'px'
			});
//			setTimeout(function(){
			if ( oAlert.documentReady ){
				var t = 0;
				t = $(document).height() - $('#outer').height();
//				aler( $('#outer').height() + ' ' + $(document).height() + ' ' + $('#page').height() +  ' ' + t);
				if (  t <= 0 || t > 70 ){
					t = 0;
				}
				$('#outer').css( {'padding-bottom': t + 'px'} );

//			},200);
			}
			return false;
		}
		function moveIEBottomOuter(){
			var foo = $('#footer');
//			aler(2 + ' ' + bFooterHelper);
			if ( !bFooterHelper && oAlert.documentReady){
//				aler('2--' + ' ' + bFooterHelper);
				foo.css({ 'margin-top': 0 });
				foo.wrap( "<div id='footer_helper'><\/div>"  );
				bFooterHelper = true;
			}

//			var doc = $(document);
			var docH = $('#outer').height() - nFooterHelperMove;
			var docW = $('#outer').width();
			var fh = $('#footer_helper');
			fh.css({
				'top': docH + 'px'
			});
			fh.css({
//				'width': doc.width() + 'px'
				'width': docW + 'px'
			});
			return false;
		}

//		$('#outer').bind('change resize',function(){
//			resizeIEThings();
//		});


	}
		bIEResizeInWork = false;
	}




//<p>универсальная переключалка: function в уже общем файле. количество разделов любое. при отсутствии js показываются все разделы.</p>
//
//<div class="change">
//	<p>
//		<span class="active"><span class="item1">item1</span></span> и
//		<span class="pseudo_link"><span class="item2">item2</span></span> и
//		<span class="pseudo_link"><span class="item3">item3</span></span>
//	</p>
//</div>
//
//<div class="toChange item1">
//  <p>item1</p>
//</div>
//<div class="toChange second item2">
//  <p>item2</p>
//</div>
//<div class="toChange second item3">
//  <p>item3</p>
//</div>
$(document).ready(function(){

	var changePath = 'div.change span.pseudo_link, div.change span.active';
//	console.log($.browser.version);
	if ( $.browser.msie && $.browser.version < 7 ){
//		console.log($.browser.version);
		$('.js div.toChange.second').hide();
	}

	$(changePath).click(function(){

		function action(objLink,show){
			var strA = 'active';
			var strB = 'pseudo_link';
			var el = $('span', $(objLink)).attr('class');
			el = $('div.toChange.' + el );
//			console.log( $(objLink) );
//			console.log( el );

			if ( show ){
				$(objLink).addClass(strA);
				$(objLink).removeClass(strB);
//				console.log( $('div.toChange.' + el ) );
				el.show();
			}else{
				$(objLink).removeClass(strA);
				$(objLink).addClass(strB);
//				console.log( $('div.toChange.' + el ) );
				el.hide();
			}
		}

		$(changePath).each(function(){
//			console.log( 1, this );
			action(this,false);
		});

		action(this,true);
//		console.log(105);
	});

});


/* готовим данные для ugallery */

//$(function() {
//
//	var aImg = [];
//	$('.images_list a.img_link').each(function(i){
//		var obj = $(this);
//		var img = $('img', $(this));
//		aImg[i] = {
//			id: i,
//			preview: { src: img.attr('src'), width: img.attr('width'), height: img.attr('height') },
//			image: { src: obj.attr('href'), width: 100, height: 100 },
//			href: './photo.htm',
//			description: $('span.pic_description', obj)
//		};
//	});

//	console.log( aImg );
//	gallery('.gallery_previews', '.gallery_content .pictures', 1, aImg);

//});

//ie alert :)
var oAlert = {
	nCount: 1,
	sQueue: '',
	bInWork: false,
	bTextarea: false,
	obj: null,
	br: '\r\n',
	documentReady: false
};
function aler(s){
	if ( oAlert.bInWork || !oAlert.bTextarea ){
		// создали очередь
		oAlert.sQueue += 'oAlert.nCount_x=' + oAlert.nCount + s + oAlert.br;
	}else{
		oAlert.bInWork = true;
		
		if ( $.browser.mozilla ){
			if ( oAlert.sQueue.length > 0 ){
				console.log('oAlert.sQueue =', oAlert.sQueue);
				oAlert.sQueue = '';
			}
			console.log(s);
		}else{

			var t = oAlert.obj.text() + oAlert.br;
			if ( oAlert.nCount % 30 === 0 ){
//				t = '';
			}
			//		if ( alerCount === 1 ){ alert('!'); }
			// если очень не пустая - вывод и очистка
			if ( oAlert.sQueue.length > 0 ){
//				$('h1').html(t + 'oAlert.nCount=' + oAlert.nCount + ' ' + oAlert.sQueue);
				oAlert.obj.text( 'oAlert.nCount=' + oAlert.nCount + ' ' + oAlert.sQueue + oAlert.br );
				oAlert.sQueue = '';
			}
//			$('h1').html(t + 'oAlert.nCount=' + oAlert.nCount + ' ' + s); // $('h1').html() +
			oAlert.obj.text( t + 'oAlert.nCount=' + oAlert.nCount + ' ' + s );
			oAlert.nCount++;
		}
		oAlert.bInWork = false;
	}
}

$(document).ready(function(){
	oAlert.documentReady = true;
//	for debug
//	if ( !oAlert.bTextarea ){
//		$('h1').after('<textarea id="alertID" style="height: 10em; width: 30em;"><\/textarea>');
//		oAlert.bTextarea = true;
//		oAlert.obj = $('#alertID');
//	}
});

//эмуляция css правил span.date+h3 итп. ie6
$(document).ready(function(){
	if ( $.browser.msie && $.browser.version < 7 ){
	var list = [
		{
			css:{
				'margin-top':'0'
//				,'border':'1px solid red'
			},
			tags: [
				'.text_block span.date+h3',
				'.text_block span.date+h4',
				'.text_block p.date+h2',
				'text_block p.date+h3',
				'text_block p.date+h4',
				'.text_block p.date+p.date',
				'.text_block div.date-text+h3'
			]
		},
		{	//второй, отдельный набор правил
			css:{
				'padding-top':'0'
			},
			tags: [
				'.text_block span.date+h3'
			]
		}
	];
	for (var i=0, n=list.length; i<n; i++){
		for (var j=0,m=list[i].tags.length; j<m; j++){
			$(list[i].tags[j]).each(function(){
				for (var k in list[i].css){
					$(this).css(k,list[i].css[k]);
				}
			});
		}
	}
	}
});

$(document).ready(function(){
	if ($('#important_news .picture').length ) {
		if ($.browser.safari || $.browser.chrome ){
			$('#important_news .picture').css({
				'max-width':'1300px'
			});
		}
	}
});


//$(document).ready(function(){
//	var oParams = {
//		prev: {
//			id: 'prevLink',
//			href: '',
//			bEl: false
//		},
//		next: {
//			id: 'nextLink',
//			href: '',
//			bEl: false
//		},
//		bTextArea: false,
//		browser: {
//			opera: false
//		}
//	};
//	oParams.browser.opera = $.browser.opera;
//	aler( oParams.browser.opera );
//	if ( $('#' + oParams.prev.id).length ){
//		oParams.prev.bEl = true;
//		oParams.prev.href = $('#'+oParams.prev).attr('href');
//	}
//	if ( $('#' + oParams.next.id).length ){
//		oParams.next.bEl = true;
//		oParams.next.href = $('#'+oParams.next).attr('href');
//	}
//	$('textarea').bind('focusin', function(){
//		oParams.bTextArea = true;
//	});
//	$('textarea').bind('focusout', function(){
//		oParams.bTextArea = false;
//	});
//	$(document).bind('keydown', function(e){
//		var key = e.keyCode || e.charCode;
//		var href = '';
//		aler( e.ctrlKey + ' 1 ' + e.shiftKey + ' 2 ' + oParams.browser.opera );
//		if ( e.ctrlKey || (e.ctrlKey && e.shiftKey && oParams.browser.opera) ){
//			if ( key === 36 && !oParams.bTextArea ){ // ctrl + home = уходим на корень
//				href = location.protocol + '//' + location.hostname + '/';
//				if ( href !== location.href ){
//					redirect( href );
//				}
//			}
//			if ( key === 38 ){ // ctrl + ↑ = уходим на уровень выше
//				href = location.href.replace( /(.*\/)[^\/]*\/.*/gi, '$1' );
//				if ( href.search(location.hostname) > -1 ){
//					redirect( href );
//				}
//			}
//			if ( key === 37 && oParams.prev.bEl ){ // ctrl + ← = уходим влево
//				redirect( oParams.prev.href );
//			}
//			if ( key === 39 && oParams.next.bEl ){ // ctrl + → = уходим вправо
//				redirect( oParams.prev.href );
//			}
//		}
//	});
//
//	function redirect(url){
////		так не будет работать кнопка back в браузере
////		location.replace( url );
////		а так будет
//		location.href = url;
//	}
//});


var jCommon = {};

/**
 * Объект для работы с клавиатурными сокращениями.
 *
 * @example
 * jCommon.shortcuts.unbind('next');
 * jCommon.shortcuts.bind('prev', 'http://ya.ru', 0x24, true);
 *
 * @version 1.0
 * @date 2009-08-11
 */
jCommon.shortcuts = (function() {
	var navigationLinks = {
		'start': { keyCode: 0x24, ctrlKey: true, altKey: false },
		'prev':  { keyCode: 0x25, ctrlKey: true, altKey: false },
		'up':    { keyCode: 0x26, ctrlKey: true, altKey: false },
		'next':  { keyCode: 0x27, ctrlKey: true, altKey: false },
		'down':  { keyCode: 0x28, ctrlKey: true, altKey: false }
	};

	$(function() {
		$('link').each(function() {

			var rel = $(this).attr('rel');

			if (navigationLinks[rel]) {
				navigationLinks[rel].href = $(this).attr('href');
			}
		});

		var bInput = false;
		$('input, textarea').bind('focusin', function(){
			bInput = true;
		});
		$('input, textarea').bind('focusout', function(){
			bInput = false;
		});

		$(document).keydown(function(event) {
			var links = navigationLinks;

			for (var rel in links) {
				if (links[rel].keyCode == event.keyCode && links[rel].ctrlKey == event.ctrlKey && links[rel].altKey == event.altKey) {
					if (!bInput) {
						if ('string' == typeof links[rel].href && '' != links[rel].href) {
							document.location = links[rel].href;
						} else if ($.isFunction(links[rel].href)) {
							return links[rel].href(event);
						}
					}
				}
			}
		});
	});

	return {
		/**
		 * Привязывает к шорткату клавиатуры действие.
		 * @param {String} name Тип действия.
		 * @param {String|Function} href Если строка, то осуществлять переход по адресу, если функция, то выполнить функцию (первый параметр — объект Event).
		 * @param {Number} keyCode Код нажатой клавиши.
		 * @param {Boolean} [ctrlKey] Нажат ли <code>Ctrl</code>.
		 * @param {Boolean} [altKey] Нажат ли <code>Alt</code>.
		 */
		bind: function(name, href, keyCode, ctrlKey, altKey) {
			ctrlKey = new Boolean(ctrlKey);
			altKey = new Boolean(altKey);

			navigationLinks[name] = {
				href: href,
				keyCode: keyCode,
				ctrlKey: ctrlKey,
				altKey: altKey
			};
		},

		/**
		 * Удаляет действие для шортката.
		 * @param {String} name Тип действия.
		 */
		unbind: function(name) {
			delete navigationLinks[name];
		},

		/**
		 * Удаляет все шорткаты.
		 */
		unbindAll: function() {
			navigationLinks = {};
		}
	};
})();


/**
 * Расширение jQuery-метода animate позволяющее анимировать background-картинки
 */
(function($) {
	if(!document.defaultView || !document.defaultView.getComputedStyle){ // IE6-IE8
		var oldCurCSS = jQuery.curCSS;
		jQuery.curCSS = function(elem, name, force){
			if(name === 'background-position'){
				name = 'backgroundPosition';
			}
			if(name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[ name ]){
				return oldCurCSS.apply(this, arguments);
			}
			var style = elem.style;
			if ( !force && style && style[ name ] ){
				return style[ name ];
			}
			return oldCurCSS(elem, 'backgroundPositionX', force) +' '+ oldCurCSS(elem, 'backgroundPositionY', force);
		};
	}

	var oldAnim = $.fn.animate;
	$.fn.animate = function(prop){
		if('background-position' in prop){
			prop.backgroundPosition = prop['background-position'];
			delete prop['background-position'];
		}
		if('backgroundPosition' in prop){
			prop.backgroundPosition = '('+ prop.backgroundPosition;
		}
		return oldAnim.apply(this, arguments);
	};

	function toArray(strg){
		strg = strg.replace(/left|top/g,'0px');
		strg = strg.replace(/right|bottom/g,'100%');
		strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
		var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
		return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
	}

	$.fx.step. backgroundPosition = function(fx) {
		if (!fx.bgPosReady) {
			var start = $.curCSS(fx.elem,'backgroundPosition');

			if(!start){//FF2 no inline-style fallback
				start = '0px 0px';
			}

			start = toArray(start);

			fx.start = [start[0],start[2]];

			var end = toArray(fx.options.curAnim.backgroundPosition);
			fx.end = [end[0],end[2]];

			fx.unit = [end[1],end[3]];
			fx.bgPosReady = true;
		}
		//return;
		var nowPosX = [];
		nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
		nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
		fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

	};
})(jQuery);


function welcomeEnBlock (cont){
	this.halfWidth = 535;
	this.cont = jQuery(cont);
	this.spotCont = $(".spot", this.cont);
	this.regionCont = $(".region_content", this.cont);
	this.currentCities = $(".current .cities", this.regionCont);
	this.spotCont.css({backgroundPosition: "-" + (this.halfWidth) +"px 0px"});
	this.currentCities.css("left", "0px");
	this.showStartAnim();
};


welcomeEnBlock.prototype = {
	/**
	 * Задаем размер контейнера
	**/
	showStartAnim : function(){
		var that = this;
		that.animateFullRight(that.animateFullLeft, that.attachSpotEvents);
		$(".links .pseudo_link", that.cont).click(function(){
			$(".cont", that.regionCont).removeClass("current").filter("#" + $(this).attr("id") + "_cont").addClass("current");
			if(!$(this).hasClass("active")){
				$(".region_content", that.cont).slideDown("slow",function(){
					$(that.cont).removeClass("hide");
				});
				$(".links .pseudo_link", that.cont).removeClass("active").filter(this).addClass("active");
			} else {
				$(".region_content", that.cont).slideUp("slow");
				$(document).unbind('mousemove.welcome_cities');
				$(that.cont).addClass("hide");
				$(".links .pseudo_link", that.cont).removeClass("active");
			}
			that.currentCities = $(".current .cities", that.regionCont);
			that.attachCityEvents();
		});
	},

	animateFullLeft : function(callback, callback_param){
		var that = this;
		$(that.spotCont).animate(
			{backgroundPosition: "-" + (that.halfWidth) + "px 0"},
			{
				duration:1500,
				easing: 'linear',
				complete: function() {
					if(callback)
						callback.call(that, callback_param);
				}
			}
		);
	},

	animateFullRight : function(callback, callback_param){
		var that = this;
		$(that.spotCont).animate(
			{backgroundPosition: (that.spotCont.width() - that.halfWidth ) + "px 0"},
			{
				duration: 1500,
				easing: 'linear',
				complete: function() {
					if(callback)
						callback.call(that, callback_param);
				}
			}
		);
	},

	attachSpotEvents : function(){
		var that = this;
		$(document).bind('mousemove.welcome', function(e){
//			$(that.spotCont).stop().animate(
//				{backgroundPosition: (e.pageX - that.halfWidth ) + "px 0"},
//				{
//					duration: 50,
//					easing: 'linear'
//				}
//			);
			$(that.spotCont).css({backgroundPosition: (e.pageX - that.halfWidth ) +"px 0px"});
		});
	},

   attachCityEvents : function(){
		var that = this;
		$(document).unbind('mousemove.welcome_cities');
		$(document).bind('mousemove.welcome_cities', function(e){
			//console.log(that.cont.width()+", ",e.pageX+", ",that.currentCities.width()+", ",  "-" + Math.round(((e.pageX * that.currentCities.width()) / that.cont.width()) - e.pageX));
			if(that.currentCities.width() > 0){ //ie hack
				$(that.currentCities).css("left", "-" + Math.round(((e.pageX * that.currentCities.width()) / that.cont.width()) - e.pageX) + "px");
			}
		});
	}
};


$(document).ready(function(){

	var myWelcomeEnBlock = new welcomeEnBlock(".welcome_cont");

	$('#text_pic_switcher li span.img').each(function(){
		var width = $(this).width() + 15;
//		console.log( width );
		$(this).next().css({'margin-left':width+'px'});
	});

	if($(".analyst_comment_cont .short").length > 0){
		$(".analyst_comment_cont .js-hide").css("display", "none").removeClass("js-hide");
		if(window.location.hash){
			$(window.location.hash + "_comment")
				.prev(".short").hide().end().show();
			resizeIEThings();
			$("html").animate({
				scrollTop: $(window.location.hash + "_comment").offset().top - 20 + 'px'
			}, 'slow');
		} else {
			$(".analyst_comment_cont .short:first")
				.hide()
				.next(".analyst_comment")
				.bind( 'resize', function(){
					resizeIEThings();
				})
				.slideDown(2500, function() {
					resizeIEThings();
			});
		}
	}
	
	$(".analyst_comment_cont .short .comment .pseudo_link").click(function(){
		$(this)
			.closest(".short")
			.hide()
			.siblings(".short")
			.show()
			.end()
			.next(".analyst_comment")
			.show()
			.siblings(".analyst_comment")
			.hide();

		resizeIEThings();
		$("html").animate({
			scrollTop: $(this).closest(".short").next(".analyst_comment").offset().top - 20 + 'px'
		}, 'slow');

	});

	$(".analyst_comment_cont .analyst_comment .content .comment .pseudo_link").click(function(){
		$(this)
			.closest(".analyst_comment").stop(false, true).hide().prev(".short").show();
		resizeIEThings();
	});

	// home page en welcome block

});

var tempCount = 0;
var tempCountMax = 20;
var curHeight = 0;
var curHeightNew = 0;

//var outerHeight = 0;
//var outerHeightNew = 0;


function ieResizeTimer(){
	tempCount++;
	var el = $("#measurer");
	curHeightNew = el.height();
//	var elOuter = $("#outer");
//	outerHeightNew = elOuter.height();
//	if ( oAlert.documentReady && outerHeightNew !== outerHeight ){
//		outerHeight = outerHeightNew;
//		$('#outer').css( {'height': outerHeightNew + 'px'} );
//	}
	if ( curHeightNew !== curHeight ){
		curHeight = curHeightNew;
//		aler( $('#outer').height() + ' ' + $('#measurer').height() + ' ' + curHeight + ' ' + curHeightNew );
//		$('#outer').css({ 'height': $('#outer').height() + 'px' });
		var t = new Date();
		var tnum = t.getFullYear().toString() + check(t.getMonth()) + check(t.getDate()) + check(t.getHours()) + check(t.getMinutes()) + check(t.getSeconds()) + check(t.getMilliseconds(),3);
		if (	oIEResizeInWorkTime.oldData === 0 ) {
			oIEResizeInWorkTime.nOldData = tnum - nIEResizeTimer - 1;
		}
		oIEResizeInWorkTime.nNewData = tnum;
	//	aler( tnum );
		if ( !bIEResizeInWork && oIEResizeInWorkTime.nOldData + nIEResizeTimer <= oIEResizeInWorkTime.nNewData ){
			resizeIEThings();
		}
	//	if ( tempCount < tempCountMax ){
	//	}
	}
	setTimeout('ieResizeTimer();', nIEResizeTimer);
}
//if ( ie.browser ){
	ieResizeTimer();
//}

function check(i,f) {
	var level = f;
	if ( isNaN(f) ){
		level = 2;
	}
	var n = i.toString();
	while (n.length < level ){
		n = '0' + n;
	}
	return n;
}