var rotate;
var timer;

function startRotate()	{ timer = setTimeout("nextPhoto();",3000); }

function stopRotate() { clearTimeout(timer); }

function nextPhoto() {
	stopRotate();
	if(curPhoto + 1 <= total) {
		curPhoto = curPhoto + 1;
	}
	else{ curPhoto = 1; }
	selectPage();
	if(rotate == true && curPhoto != total) {startRotate();}
	else{
		if(rotate == true && curPhoto == total) toggleRotate(this);
	}
}

function prevPhoto() {
	stopRotate();
	if(curPhoto != 1 && curPhoto >= 2) {
		curPhoto = curPhoto - 1 < 0 ? 1 : (curPhoto-1)
	}
	else { curPhoto = total; }
	selectPage();
	if(rotate == true) { startRotate();}
}


function galleryHover(obj) {
    obj.style.filter = obj.style.filter? "":"alpha(opacity=50)";
    obj.style.opacity = obj.style.opacity? "":".50";
    obj.onmouseout = function() { galleryHover(this); };
}

function divFillCol(uri, fillField){
	var xmlhttp = fillField;
	xmlhttp = xmlHtmlStart();
	xmlhttp.open('GET', uri, true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			var content = xmlhttp.responseText;
			if(content){
				document.getElementById(fillField).innerHTML = content;
			}
		}
	}
	xmlhttp.send(null);
}

function switchRow(obj) {
 	var rows=obj.parentNode.parentNode.getElementsByTagName('tr');

	for(var i=0; i<rows.length; i++) {
		if(obj!=rows[i]) {
			rows[i].className='item';
		} else {
			rows[i].className='selected';
		}
	}
}