function doMove() {
	for (i=0; i<divcount; i++) {
		if (cont==1 && parseInt(mydiv[i].style.left) < -44) {
			nextpos = parseInt(mydiv[(i+divcount-1)%divcount].style.left);
			mydiv[i].style.left = (nextpos+78)+'px';
			changeimage(i);
		} else if (cont==-1 && parseInt(mydiv[i].style.left) > 968) {
			nextpos = parseInt(mydiv[(i+divcount+1)%divcount].style.left);
			mydiv[i].style.left = (nextpos-76)+'px';
			changeimage(i);
		} else {
			mydiv[i].style.left = (parseInt(mydiv[i].style.left)-(cont*(speed==1 ? 3 : 1)))+'px';
		}
	}
}


function cMove() {
	if (cont!=0) {
		if (conttimer > 0) {
			clearTimeout(conttimer);
		}
		conttimer = setTimeout("cMove()",speed);
		doMove();
	}
}


function setcont(towhat) {
	cont = towhat;
	if (conttimer > 0) {
		clearTimeout(conttimer);
	}
	conttimer = setTimeout('cMove()', 20);
}


function setspeed(towhat) {
	speed = towhat;
}


function changeimage(i) {
	var divobject = mydiv[i];
	mymap[i] = (mymap[i] + divcount) % imgcount;
	divobject.innerHTML = '<table width=77 height=77 border=0 cellpadding=0 cellspacing=0><tr><td align="center" valign="middle"><img src="' + solutions[mymap[i]][1] + '"></td></tr></table>';
}


function init() {
	var startleft = 37;
	var divwidth = 78;
	for (i=0; i<divcount; i++) {
		mydiv[i] = document.getElementById('a'+i);
		mydiv[i].style.left = (startleft + (i*divwidth))+'px';
		mymap[i] = i;
	}
	setcont(1);
}


function thumbclick(divid) {
	ajaxpage('/solutions/view_content.php?id='+solutions[mymap[divid]][0], 'content');
}


function thumbpopup(divid) {
	CenteredPopup('/solutions/view.php?id='+solutions[mymap[divid]][0], 975, 750);
}


function CenteredPopup(url, width, height) {
	var left = Math.floor(screen.availWidth/2 - width/2);
	var top = Math.floor(screen.availHeight/2 - height/2);
	var w = window.open(url, 'IONApopup', 'width='+width+',height='+height+',left='+left+',top='+top+',toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes');
	w.focus();
	return false;
}


function SwitchPages(from, to) {
	var o = MM_findObj('page'+from);
	o.className = 'pageoff';
	o = MM_findObj('page'+to);
	o.className = 'pageto';
}


function MM_findObj(n, d) { //v4.0
	var p,i,x;
	if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) 
	x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++)
	x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
	x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById)
	x=document.getElementById(n); return x;
}

