arpic = new Array();
//arpic['wall'] = new Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24");
//arpic['wall'] = new Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
arpic['wall'] = new Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28");
curpic = new Array();
curpic['wall'] = 1;
var tm;
tm = setInterval( function() {
	changepic_f(1, "wall");
},4000);

function changepic(next, what){
	//$('body').append(tm+' ');
	clearInterval(tm);
	//$('body').append(tm+'; ');
	changepic_f (next, what);
	tm = setInterval( function() {
		changepic_f(1, "wall");
	},4000);	
}
function changepic_f (next, what) {
	$("#"+what).animate({opacity:'0'},300, function() {
		if(next == 1 && curpic[what] == arpic[what].length - 1){
			curpic[what] = 0;
		}
		else if(next == 0 && curpic[what] == 0){
			curpic[what] = arpic[what].length - 1;
		}
		else{
			if(next == 1){
				curpic[what]++;
			}
			if(next == 0){
				curpic[what]--;
			}
		}
		document.getElementById(what).style.background = "url(img/" + what + "/" + arpic[what][curpic[what]] + "_s.jpg) no-repeat center center";
		document.getElementById('a' + what).href =  "pictureviewer.php?pict=" + arpic[what][curpic[what]] + "&what=" + what;
		$("#"+what).animate({opacity:'1'},300);
	});
}