if (!self.atshownews) {
var atshownews = {
get: function() {
//get a random number
var news = 0;
var i = 10;
while (--i > 0)
{
news = Math.floor(atshownews.totalItem*Math.random());
if(news != atshownews.currentItem) break;
}
atshownews.currentItem = news;

if(!atshownews.cachearray[atshownews.currentItem]){
url = atshownews.livesite + '/modules/mod_atshownews/at_shownews/at-shownewsloader.php?curnews=' + atshownews.currentItem + '&loadajax=1&total=' + atshownews.totalItem;
new Ajax(url,{method:'get',onComplete:atshownews.update}).request();
}else{
atshownews.update(null);
}
return false;
},

update: function(request) {
if (request)
{
atshownews.cachearray[atshownews.currentItem] = request;
}else{
request = atshownews.cachearray[atshownews.currentItem];
}
atshownews.responce = request.split(atshownews.splitter);
//atshownews.currentItem = atshownews.responce[1];
atshownews.objs[1].innerHTML = atshownews.responce[0];
atshownews.e.animation();
atshownews.timer = setTimeout(atshownews.get, atshownews.delaytime*1000);
return false;
},

init: function (){
atshownews.cachearray = new Array(atshownews.totalItem);
atshownews.timer = setTimeout(atshownews.get, atshownews.delaytime*1000);

atshownews.objs = new Array();
atshownews.objs[0] = document.getElementById("at-scroll_1");
atshownews.objs[1] = document.getElementById("at-scroll_2");
if (!atshownews.objs[0] || !atshownews.objs[1])
{
return;
}
switch(atshownews.animation){
case 'scroll_right':
atshownews.e = new scroll_right(atshownews.objs);
break;
case 'scroll_up':
atshownews.e = new scroll_up(atshownews.objs);
break;
case 'scroll_down':
atshownews.e = new scroll_down(atshownews.objs);
break;
case 'effect_fade':
atshownews.e = new effect_fade(atshownews.objs);
break;
case 'effect_replace':
atshownews.e = new effect_replace(atshownews.objs);
break;
case 'scroll_left':
default:
atshownews.e = new scroll_left(atshownews.objs);
break;

}
},

swap: function() {
term = atshownews.objs[0];
atshownews.objs[0] = atshownews.objs[1];
atshownews.objs[1] = term;
}

}
atAddEvent(window,'load', atshownews.init);
}

scroll_base = new Class ({
animation:function () {
x = new Fx.Elements(atshownews.objs, { wait: false, duration: atshownews.interval, onComplete:atshownews.swap});
x.start(this.ef);
return false;
}
})
scroll_up = scroll_base.extend({
initialize: function(objs) {
this.elements = objs;
this.elements[0].style.top=0;
this.elements[1].style.top='100%';
this.elements[0].style.display="block";
this.elements[1].style.display="block";
this.W = this.elements[0].offsetHeight;
this.elements[0].style.height = this.W + "px";
this.elements[1].style.height = this.W + "px";

this.ef = {};
this.ef[0] = { 'top': [ 0 , -this.W] };
this.ef[1] = { 'top': [ this.W, 0] };

return false;
}

});

scroll_down = scroll_base.extend ({
initialize: function(objs) {
this.elements = objs;
this.elements[0].style.top=0;
this.elements[1].style.top='100%';
this.elements[0].style.display="block";
this.elements[1].style.display="block";
this.W = this.elements[0].offsetHeight;
this.elements[0].style.height = this.W + "px";
this.elements[1].style.height = this.W + "px";

this.ef = {};
this.ef[0] = { 'top': [ 0, this.W] };
this.ef[1] = { 'top': [ -this.W, 0] };

return false;
}
});

scroll_left = scroll_base.extend ({
initialize: function(objs) {
this.elements = objs;
this.elements[0].style.left=0;
this.elements[1].style.left='100%';
this.elements[0].style.display="block";
this.elements[1].style.display="block";
this.W = this.elements[0].offsetWidth;
this.elements[0].style.width = this.W + "px";
this.elements[1].style.width = this.W + "px";

this.ef = {};
this.ef[0] = { 'left': [ 0 , -this.W] };
this.ef[1] = { 'left': [ this.W, 0] };

return false;
}
});

scroll_right = scroll_base.extend ({
initialize: function(objs) {
this.elements = objs;
this.elements[0].style.left=0;
this.elements[1].style.left='100%';
this.elements[0].style.display="block";
this.elements[1].style.display="block";
this.W = this.elements[0].offsetWidth;
this.elements[0].style.width = this.W + "px";
this.elements[1].style.width = this.W + "px";

this.ef = {};
this.ef[0] = { 'left': [ 0 , this.W] };
this.ef[1] = { 'left': [ -this.W, 0] };

return false;
}
});

effect_fade = new Class ({
initialize: function(objs) {
this.elements = objs;
this.elements[0].style.display="block";
this.elements[1].style.display="block";
new Fx.Style(this.elements[1], 'opacity').set(0);
return false;
},

animation:function () {
x = new Fx.Elements(atshownews.objs, { wait: false, duration: atshownews.interval, onComplete:atshownews.swap, transition: Fx.Transitions.Expo.easeOut});
ef = {};
ef[0] = { 'opacity': [ 1, 0] };
ef[1] = { 'opacity': [ 0, 1] };
x.start(ef);
return false;
}
})

effect_replace = new Class ({
initialize: function(objs) {
this.elements = objs;
this.elements[0].style.display="block";
this.elements[1].style.display="none";
return false;
},

animation:function () {
atshownews.swap();
this.elements[0].style.display="block";
this.elements[1].style.display="none";
return false;
}
})
