__storypopups = new Array();
__selectedSortyPopup = -1;
function hideAllStoryPopups(){

	for(var i = 0; i < __storypopups.length; i++){
	//alert(__storypopups);
		__storypopups[i].hide();
	}
}
function hideStoryPopup(idx){
	__storypopups[idx].hide();
}
function showStoryPopup(idx){
	__storypopups[idx].show();
	__storypopups[idx].addClassName('popup_location');
	//__storypopups[idx].style.top='0px';
	//__storypopups[idx].style.left='0px';
}
function setStoryPopup(idx){
	//alert(idx);
	hideAllStoryPopups();
	idx = idx % __storypopups.length;
	if(idx < 0)
		idx = __storypopups.length + idx;

	showStoryPopup(idx);
	__selectedSortyPopup = idx;
}
function nextStoryPopup(){
	setStoryPopup(__selectedSortyPopup + 1);
}
function prevStoryPopup(){
	setStoryPopup(__selectedSortyPopup - 1);
}
Event.observe(window, 'load', function(){
	__storypopups =  __('.StoriesPopup_wrapper');
	hideAllStoryPopups();
});
