
window.onresize = function () {
    setReqLeft();
}
function init(id, s, inter, center)
{
    mvOb = document.getElementById(id);
    
    // alert(1);
    	step = s;
	moveFlag = false;
	vector = 0;
    sI = window.setInterval('move();', inter);

    mvObWidth = parseInt(document.getElementById('mv_img').offsetWidth);
    // alert(document.getElementById('fon').offsetWidth);
    // bWidth = screen.availWidth;
    bWidth = parseInt(document.getElementById('fon').offsetWidth);
    // alert(bWidth);

    maxLeft = 0;
    minLeft = -(mvObWidth - bWidth) + 5;


    // center

    if (center) {
	
    	reqC = Math.round(mvObWidth / 2) - Math.round(bWidth / 2);
    	// alert(reqC);
        mvOb.style.left = -reqC;
    } else {
    	mvOb.style.left = 0;
    }
    mvOb.style.visibility = 'visible';


}

function setReqLeft()
{
	var curValue = parseInt(mvOb.style.left);
	var nextValue = curValue + 0;

	bWidth = parseInt(document.getElementById('fon').offsetWidth);
	maxLeft = 0;
	minLeft = -(mvObWidth - bWidth) + 5;

	if (nextValue >= maxLeft) {
	    mvOb.style.left = maxLeft;
	} else if (nextValue <= minLeft) {
	    mvOb.style.left = minLeft;
	} else {
		mvOb.style.left = nextValue;
	}
}

// Move
function move()
{
    if (moveFlag) {
        var curValue = parseInt(mvOb.style.left);
        var nextValue = curValue + vector;

	    bWidth = parseInt(document.getElementById('fon').offsetWidth);
	    maxLeft = 0;
	    minLeft = -(mvObWidth - bWidth) + 5;


        if (nextValue >= maxLeft) {
            mvOb.style.left = maxLeft;
        } else if (nextValue <= minLeft) {
            mvOb.style.left = minLeft;
        } else {
        	mvOb.style.left = nextValue;
        }

    }
}

function startMove(v)
{
	vector = step * parseInt(v);
	moveFlag = true;
}

function stopMove()
{
	// alert(moveFlag);
	moveFlag = false;
	// alert(moveFlag);
}

function moveRight()
{
	startMove(1);
}

function moveLeft()
{
	startMove(-1);
}





function showTip(id)
{
    var tip = document.getElementById(id);

    eval('window.clearTimeout(window.' + id + ')');

    if (tip.style.display != 'block') {
        tip.style.display = 'block';
        tip.onmouseover = function() {
            showTip(id);
        }
        tip.onmouseout = function() {
            hideTip(id);
        }
    }
}


function hideTip(id)
{    eval('window.' + id + ' = window.setTimeout(function(){document.getElementById(id).style.display = \'none\';}, 1000)');
}



jQuery(document).ready(
    function() {

        $("a.with_tooltip").easyTooltip(
            {
                xOffset: 15
            }
        );

    }
);












