function adEv(obj,evt,func) {
	var oldhndlr=obj[evt];
	obj[evt]=(typeof obj[evt]!='function')?func:function(ev){oldhndlr(ev);func(ev);};
}
function $() {
    var elems = [];
    for (var i=0; i<arguments.length; i++) {
        var elem = arguments[i];
        if (typeof elem == 'string') elem = document.getElementById(elem);
        if (arguments.length == 1) return elem;
        elems.push(elem);
    }
    return elems;
}
// class, scope, tag
function $c(c,o,t) { 
	o = o || document;
    if (!o.length) { o = [o]; }
    var elements = [];
    for(var i = 0; i<o.length; i++) { 
        e = o[i];
        if(e.getElementsByTagName) {
            o.children = e.getElementsByTagName(t || '*');
            for (var j = 0; j<o.children.length; j++) {
                o.child = o.children[j];
                if(o.child.className&&(new RegExp('\\b'+c+'\\b').test(o.child.className))) { elements.push(o.child); }
            }
        }
    }
    return elements;
}
var swish = {
	oCur : null,
	oNxt : null,
	oInt : null,
	iCur : 1,
	aInfo : null,
	tTM : null,
	init : function()
		{
		var c = swish;
		c.aInfo = $c('swish-info');
		c.oCur = $('swish-a');
		c.oNxt = $('swish-b');
		c.oCur.innerHTML = $('swish-info-1').innerHTML
		var oLeft = $('swish-goleft');
		var oRight = $('swish-goright');
		var oSwish = $('swish');
		oSwish.className = 'jsactive';
		adEv(oLeft,'onclick',function(){c.slideRight()});
		adEv(oRight,'onclick',function(){c.slideLeft()});
		},
	slideLeft : function()
		{
		var c = swish;
		iNxt = (c.iCur >= c.aInfo.length) ? 1 : c.iCur+1;
		c.iCur = iNxt;
		c.tTM = setTimeout(function() {c.pan(true,Math.PI,iNxt)},20); 
		},
	slideRight : function()
		{
		var c = swish;
		iNxt = (c.iCur > 1) ? c.iCur-1 : c.aInfo.length;
		c.iCur = iNxt;
		c.tTM = setTimeout(function() {c.pan(false,Math.PI,iNxt)},20);
		},
	pan: function(bRight,iRadians,iNxt)
		{
		var c = swish;
		if (c.tTM) {clearTimeout(c.tTM)}
		if (iRadians == Math.PI) // starting pan (setup)
			{
			c.oNxt.innerHTML = $('swish-info-'+iNxt).innerHTML;
			}
		iRadians += Math.PI / 40;
		if (iRadians < (2 * Math.PI)) // pan in progress
			{
			var iX = Math.floor(550 * (1.0 + Math.cos(iRadians)));
			if (bRight) {iX = -iX;}
			c.oCur.style.left = iX;
			c.oNxt.style.left = iX + (bRight ? 1100 : -1100);
			c.tTM = setTimeout(function(){c.pan(bRight,iRadians,iNxt)},20);   
			}
		else // finished pan (clean up)
			{
			c.oInt = c.oCur;
			c.oCur = c.oNxt;
			c.oNxt = c.oInt;
			c.oNxt.innerHTML = '';
			//$('swish-page').innerHTML = 'Page '+iNxt;
			}
		}
	}
adEv(window,'onload',swish.init);
