var dieee = Array('a','b','c','d');
dieee['a'] = dieee['b'] = dieee['c'] = dieee['d'] = '';

function slide(what,who,id,price1,price2,price3){
	var box_2Pos = $('box_'+what+'_2').offsetLeft;
	var box_3Pos = $('box_'+what+'_3').offsetLeft;
	//alert(box_2Pos+' : '+box_3Pos+' : '+who);
	if(~~box_2Pos == 163 && ~~box_3Pos == 318 && who == 'two')
		start_one(what,id,price1,price2,price3);
	else if(~~box_2Pos == 330 && ~~box_3Pos == 163 && who == 'one')
		start_two(what,id,price1,price2,price3);
}

function start_one(what,id,price1,price2,price3){
	if(dieee[what] == '')
		dieee[what] = setInterval('rusz_one("'+what+'","'+id+'","'+price1+'","'+price2+'","'+price3+'")', 30);
}

function start_two(what,id,price1,price2,price3){
	if(dieee[what] == '')
		dieee[what] = setInterval('rusz_two("'+what+'","'+id+'","'+price1+'","'+price2+'","'+price3+'")', 30);
}

function stop(what){
	clearInterval(dieee[what]);
	dieee[what] = '';
}

function rusz_one(what,id,price1,price2,price3){
	var box_2MovePos = $('box_'+what+'_2').offsetLeft;
	var box_3MovePos = $('box_'+what+'_3').offsetLeft;


	if( ~~box_3MovePos > 163 ){
		$('mainPageSlidesBorderLeft_'+what).style.display = 'none';
		$('mainPageSlidesBorder_'+what).style.display = 'none';
		$('box_'+what+'_2').style.left = (~~(box_2MovePos)+5) + 'px';
		$('box_'+what+'_3').style.left = (~~(box_3MovePos)-5) + 'px';
		if(~~box_2MovePos == 238){
			$('prices_'+what).innerHTML = '<strong>Price from <span class="ap-price">'+price1+' PLN</span></strong><br />'+price2+'&euro; or &#126;'+price3+'&pound; &frasl; night';
			$('link_'+what+'_1').href = '/details.html?prpId='+id;
			$('link_'+what+'_2').href = '/details.html?prpId='+id;
			$('box_'+what+'_2').style.left = (~~(box_2MovePos)+17) + 'px';
		}
	}
	else {
		stop(what);
		$('mainPageSlidesBorderLeft_'+what).style.left = 167 + 'px';
		$('mainPageSlidesBorder_'+what).style.left = 167 + 'px';
		$('mainPageSlidesBorderLeft_'+what).style.display = 'block';
		$('mainPageSlidesBorder_'+what).style.display = 'block';
	}
}

function rusz_two(what,id,price1,price2,price3){
	var box_2MovePos = $('box_'+what+'_2').offsetLeft;
	var box_3MovePos = $('box_'+what+'_3').offsetLeft;

	if( ~~box_2MovePos > 163 ){
		$('mainPageSlidesBorderLeft_'+what).style.display = 'none';
		$('mainPageSlidesBorder_'+what).style.display = 'none';
		$('box_'+what+'_2').style.left = (~~(box_2MovePos)-5) + 'px';
		$('box_'+what+'_3').style.left = (~~(box_3MovePos)+5) + 'px';
		if(~~box_2MovePos == 250){
			$('prices_'+what).innerHTML = '<strong>Price from <span class="ap-price">'+price1+' PLN</span></strong><br />'+price2+'&euro; or &#126;'+price3+'&pound; &frasl; night';
			$('link_'+what+'_1').href = '/details.html?prpId='+id;
			$('link_'+what+'_2').href = '/details.html?prpId='+id;
			$('box_'+what+'_2').style.left = (~~(box_2MovePos)-17) + 'px';
		}
	}
	else {
		stop(what);
		$('mainPageSlidesBorderLeft_'+what).style.left = 0 + 'px';
		$('mainPageSlidesBorder_'+what).style.left = 0 + 'px';
		$('mainPageSlidesBorderLeft_'+what).style.display = 'block';
		$('mainPageSlidesBorder_'+what).style.display = 'block';
	}
}