function showContour(sCountourPrefix) {
	if (sCountourPrefix && sCountourPrefix != '') {
		var eContour = document.getElementById(sCountourPrefix + '-contour');
		if (eContour) eContour.style.visibility = 'visible';
	}
	bMouseOverRegion = true;
	return true;
}

function hideContour(sCountourPrefix) {
	if (sCountourPrefix && sCountourPrefix != '') {
		var eContour = document.getElementById(sCountourPrefix + '-contour');
		if (eContour) eContour.style.visibility = 'hidden';
	}
	bMouseOverRegion = false;
	return true;
}

function showImage(eImg) {
	if (eImg) eImg.style.visibility = 'visible';
}

var iImagesToGo = 14;
var iImagesCnt = 0;
function fadeInImageById(sImgId, bCntImage) {
	if (bCntImage) iImagesCnt++;
	if (iImagesCnt >= iImagesToGo) {
		var eMate = document.getElementById('mate');
		if (eMate) eMate.style.display = 'none';
	}
//	setOpacityById(sImgId, 10);
	var eImg = document.getElementById(sImgId);
	if (eImg) eImg.style.visibility = 'visible';
}

function setOpacityById(sElemId, iOpacity) {
	var eElement = document.getElementById(sElemId);
	if (eElement) {
		if (iOpacity < 11) eElement.style.visibility = 'visible';
		if (document.all && !window.opera) {
			eElement.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + iOpacity + ')'
		} else {
			eElement.style.opacity = iOpacity / 100;
		}
		if (iOpacity < 100) {
			iOpacity += iOpacity
			setTimeout('setOpacityById("' + sElemId + '", "' + iOpacity + '")', 300);
		}
	}
}

var bMouseOverRegion = false;
var eView = null;
var eFrame = null;
var eActions = null;
var iFrameWidth = 1544;
var iMaxLeftPos = 0;
var iWinWidth = 0;
var iMoveRegion = 100;
var iMoveStep = 30;
var iMoveSpeed = 100;
var iCurrPos = 0;
var iMoveTO = 0;

function getWindowWidth() {
	if (window.innerWidth) iWinWidth = window.innerWidth;
	else if (document.body && document.body.clientWidth) iWinWidth = document.body.clientWidth;
	
	var iReducer = (iWinWidth < 800)? 800 : iWinWidth;
	iMaxLeftPos = iFrameWidth - iReducer;
}

function resizeWindow() {
	getWindowWidth();
	stopMovement();
	moveFrame();
}

var sMovement = null;
function moveFrame() {
	var bContinue = false;
	var bMove = false;
	if (sMovement == 'left') {
		if (iCurrPos > 0) {
			bMove = true;
			if (iCurrPos > iMoveStep) {
				iCurrPos -= iMoveStep;
				bContinue = true;
			} else iCurrPos = 0;
		}
	} else if (sMovement == 'right') {
		if (iCurrPos < iMaxLeftPos) {
			bMove = true;
			if (iCurrPos + iMoveStep < iMaxLeftPos) {
				iCurrPos += iMoveStep;
				bContinue = true;
			} else iCurrPos = iMaxLeftPos;
		}
	} else {
		if (iCurrPos > iMaxLeftPos) {
			iCurrPos = (iMaxLeftPos < 0)? 0 : iMaxLeftPos;
			bMove = true;
		}
	}
	if (bMove) {
		if (eFrame) eFrame.style.left = (iCurrPos * -1) + 'px';
		if (eActions) eActions.style.left = (iCurrPos * -1) + 'px';
	}
	if (bContinue) {
		iMoveTO = setTimeout('moveFrame()', iMoveSpeed);
	} else {
		iMoveTO = 0;
	}
//	dalert('curpos: ' + iCurrPos + '; maxpos: ' + iMaxLeftPos + '; mov: ' + sMovement);
}

function mouseMovement(evt) {
	if (eView) {
		var eEvt = (evt)? evt : window.event;
		var iMouseX = eEvt.clientX;
		if (iMouseX < iMoveRegion) {
			// move left
			sMovement = 'left';
			if (!iMoveTO) moveFrame();
		} else if (iMouseX > iWinWidth - iMoveRegion) {
			// move right
			sMovement = 'right';
			if (!iMoveTO) moveFrame();
		} else {
			if (iMoveTO) {
				clearTimeout(iMoveTO);
				iMoveTO = 0;
			}
			sMovement = null;
		}
	}
}

function stopMovement() {
	if (iMoveTO) clearTimeout(iMoveTO);
	sMovement = null;
	iMoveTO = 0;
}

function initView() {
	eView = document.getElementById('view');
	eFrame = document.getElementById('frame');
	eActions = document.getElementById('actions');
	if (eView) {
		getWindowWidth();
		eView.onmousemove = mouseMovement;
		window.onmouseout = stopMovement;
		document.onmouseout = stopMovement;
	}
}

//	window.onload = initView;
window.onresize = resizeWindow;
