function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
	
	function cycleImages(pos)
	{
		var cur_id = document.getElementById('mainimgid');

		cur_id = parseInt(cur_id.value);

		switch(pos)
		{
			case 'next' : var newnum = cur_id + 1; break;
			case 'prev' : var newnum = cur_id - 1; break;
		}
		
		var mainlink = document.getElementById('imagemain');
		var photoarray = photoGroups[newnum];

		if(typeof(photoarray) == 'object')
		{
			var linkurl = imageLocation+'/'+imageURL+'/'+photoarray[2][2];
			var thumburl = imageLocation+'/'+imageURL+'/'+photoarray[1][2];
			
			mainlink.setAttribute('href',linkurl);
			document.getElementById('bigimage').setAttribute('src',linkurl);
			
			var linkimg = mainlink.getElementsByTagName('img')[0];
			
			linkimg.setAttribute('src',thumburl);
			
			document.getElementById('mainimgid').value = newnum;
			
			var oldzooms = getElementsByClass('MagicZoomBigImageCont');
			
			if(oldzooms.length > 0)
			{
				var oldpar = oldzooms[0].parentNode;
				oldpar.removeChild(oldpar.childNodes[1]);
				oldpar.removeChild(oldpar.childNodes[2]);
			}
			
			//MagicZoomBigImageCont
			MagicZoom_stopZooms();
			MagicZoom_findZooms();
		}
	}