function $(node) {
	return document.getElementById(node);
}
function fixDecorWidth() {
	$('header').style.width = '950px';
	if ($('left_decor')) {
		$('left_decor').style.width = '513px';
	}
	if ($('right_decor')) {
		$('right_decor').style.left = '500px';
	}
	$('menu').style.width = '600px';
}
function unFixDecorWidth() {
	$('header').style.width = '100%';
	if ($('left_decor')) { 
		$('left_decor').style.width = '50%';
	}
	if ($('right_decor')) {
		$('right_decor').style.right = '0';
		$('right_decor').style.left = '';
	}
	$('menu').style.width = '60%';
}
function loadHolder() {
	if (document.body.clientWidth < 1020) {
		fixDecorWidth();
	}
	
}
function resizeHolder() {
	if (document.body.clientWidth < 1020) {
		fixDecorWidth();
	} else {
		unFixDecorWidth();
	}
}

var mouseX;
var mouseY;

function loadWindow() {
	loadHolder();
	if ($('adv_blocks')) {
		$('adv_blocks').style.border = '1px solid #272F33';
		setTimeout("$('adv_blocks').style.border = 'none';", 50);
	}
	var target_image = document.getElementById('right_img');
	//if (target_image) {
		//alert("123123");
		//flashinstalled = 0;
		insertFlashOrPng(
			{width : '273', height : '96', id : 'logo_img', src : '/images/logo.swf', 'bgcolor' : '#FFFFFF'},
			'logo_link',
			'/images/logo.png'
		);
		try {
			insertFlashOrPngRight(
				{width : '687', height : '488', id : 'right_image', src : page_right_swf, 'bgcolor' : '#FFFFFF'}, //object params and atts
				'right_img_container',
				page_right_image
			);
		} catch (e) {}
		// PNGFix для IE после добавления картинок
		if (flashinstalled != 2) {
			try {pngFix();} catch (e) {}
		}
	//}
	var dataBottom = $('data').offsetTop + $('data').clientHeight;
	var winHeight = document.body.clientHeight; // window.innerHeight
	var diff = dataBottom - winHeight + 100;
	var footer = $('footer');
	if (diff > 0) {
		footer.style.top = dataBottom + 30 + 'px';
	} else {
		footer.style.top = winHeight - 100  + 'px';
	}
	footer.style.left = '0px';
	window.status = 'Done';
	
	var body = document.getElementsByTagName('body').item(0);
	body.onmousemove = getCoords;
}

function getCoords(e) {
	e = e || event;
	if (!e) e = window.event;
	if (e.pageX || e.pageY) {
		mouseX = e.pageX;
		mouseY = e.pageY;
	} else if (e.clientX || e.clientY) {
		mouseX = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
		mouseY = e.clientY + (document.documentElement.scrollTop  || document.body.scrollTop) - document.documentElement.clientTop;
	}
}

function tryToSetFlash() {
	if ($('right_img_container') && $('footer')) {
		loadWindow();
		//pngFix();
	} else {
		setTimeout('tryToSetFlash()', 500);
	}
}
var flashSleep = flashSleep || 200;
setTimeout('tryToSetFlash()', flashSleep);
window.onload = loadWindow;
window.onresize = resizeHolder;

