var position = 0;

function showBg(sPath, sId)
{
	oTd = document.getElementById(sId);
	if(oTd)
	{
		//alert(oTd.style.backgroundImage);
		oTd.style.backgroundImage = 'url("'+sPath+'")';
	}
}

inpDropText = function(input, text) {
	if (input.value == text) input.value = '';
}
	
function showImage(sSrc)
{
	oImg = document.getElementById('locationImage');
	if(oImg)
	{
		oImg.src = sSrc;
	}
}


function preview()
{
	oDiv = document.getElementById('sliderContainer');
	if(oDiv)
	{
//		alert(position);
		if(-(intval(oDiv.style.left)-40-646) <= intval(oDiv.style.width))
		{
			if(position >= 0 && position <=1)
			{count = 606}else{count = 566}
			step = -20;
			window.setTimeout('changePosition('+intval(oDiv.style.left)+', '+(intval(oDiv.style.left)-count)+','+step+', '+10+')', 10);
//				tmp = intval(oDiv.style.left)-1;
//				oDiv.style.left = tmp+'px';
			position--;
		}
	}
}

function next()
{
	oDiv = document.getElementById('sliderContainer');
	if(oDiv)
	{
//		alert(position);
		if(intval(oDiv.style.left) < 0)
		{
			if(position <=0 && position >=-1)
			{count = 606}else{count=566}
			window.setTimeout('changePosition('+intval(oDiv.style.left)+', '+(intval(oDiv.style.left)+count)+','+20+', '+10+')', 10);
//				tmp = intval(oDiv.style.left)+1;
//				oDiv.style.left = tmp+'px';
			position++;
		}
	}
}

function changePosition(start, finish, step, time)
{
//	alert('start='+start+'; finish='+finish+'; step='+step);
	obj = document.getElementById('sliderContainer');

	oPrev = document.getElementById('previewButton');
	if(oPrev){oPrev.style.display = 'none';}

	
	oNext = document.getElementById('nextButton');
	if(oNext){oNext.style.display = 'none';}
	
	
//	alert('start='+start+'; finish='+finish+'; step='+step+'; left='+intval(obj.style.left));
	if(obj)
	{
		if(step > 0)
		{
			if(intval(obj.style.left)+step <= finish)
			{
				obj.style.left = intval(obj.style.left)+step+'px';
				window.setTimeout('changePosition('+start+','+finish+','+step+','+time+')',time);
				
			}else{
				obj.style.left = finish+'px';
				if(intval(obj.style.left) <= 0)
				{
					if(oNext){oNext.style.display = 'block';}
				}
				if(oPrev){oPrev.style.display = 'block';}
				clearInterval();
			}
		}else{
				
			if(intval(obj.style.left)+step >= finish)
			{
				
				obj.style.left = intval(obj.style.left)+step+'px';
				window.setTimeout('changePosition('+start+','+finish+','+step+','+time+')',time);
			}else{
				obj.style.left = finish+'px';
				if(oNext){oNext.style.display = 'block';}
				
				if(intval(obj.style.left)-646 >= (-intval(obj.style.width)) )
				{
					if(oPrev){oPrev.style.display = 'block';}
				}
				clearInterval();
			}
		}
		
	}
}

function intval (mixed_var, base) {
    var tmp;
 
    var type = typeof(mixed_var);
     if (type === 'boolean') {
        return +mixed_var;
    } else if (type === 'string') {
        tmp = parseInt(mixed_var, base || 10);
        return (isNaN(tmp) || !isFinite(tmp)) ? 0 : tmp;    } else if (type === 'number' && isFinite(mixed_var)) {
        return mixed_var | 0;
    } else {
        return 0;
    }
}
