if (!self.olshownews) {
var olshownews = {
get: function() {
//get a random number
var news = 0;
var i = 10;
while (--i > 0)
{
news = Math.floor(olshownews.totalItem*Math.random());
if(news != olshownews.currentItem) break;
}
olshownews.currentItem = news;

if(!olshownews.cachearray[olshownews.currentItem]){
url = olshownews.livesite + '/modules/mod_olshownews/ol_shownews/ol-shownewsloader.php?curnews=' + olshownews.currentItem + '&loadajax=1&total=' + olshownews.totalItem;
new Ajax(url,{method:'get',onComplete:olshownews.update}).request();
}else{
olshownews.update(null);
}
return false;
},

update: function(request) {
if (request)
{
olshownews.cachearray[olshownews.currentItem] = request;
}else{
request = olshownews.cachearray[olshownews.currentItem];
}
olshownews.responce = request.split(olshownews.splitter);
//olshownews.currentItem = olshownews.responce[1];
olshownews.objs[1].innerHTML = olshownews.responce[0];
olshownews.e.animation();
olshownews.timer = setTimeout(olshownews.get, olshownews.delaytime*1000);
return false;
},

init: function (){
olshownews.cachearray = new Array(olshownews.totalItem);
olshownews.timer = setTimeout(olshownews.get, olshownews.delaytime*1000);

olshownews.objs = new Array();
olshownews.objs[0] = document.getElementById("ol-scroll_1");
olshownews.objs[1] = document.getElementById("ol-scroll_2");
if (!olshownews.objs[0] || !olshownews.objs[1])
{
return;
}
switch(olshownews.animation){
case 'scroll_right':
olshownews.e = new scroll_right(olshownews.objs);
break;
case 'scroll_up':
olshownews.e = new scroll_up(olshownews.objs);
break;
case 'scroll_down':
olshownews.e = new scroll_down(olshownews.objs);
break;
case 'effect_fade':
olshownews.e = new effect_fade(olshownews.objs);
break;
case 'effect_replace':
olshownews.e = new effect_replace(olshownews.objs);
break;
case 'scroll_left':
default:
olshownews.e = new scroll_left(olshownews.objs);
break;

}
},

swap: function() {
term = olshownews.objs[0];
olshownews.objs[0] = olshownews.objs[1];
olshownews.objs[1] = term;
}

}
olAddEvent(window,'load', olshownews.init);
}

scroll_base = new Class ({
animation:function () {
x = new Fx.Elements(olshownews.objs, { wait: false, duration: olshownews.interval, onComplete:olshownews.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(olshownews.objs, { wait: false, duration: olshownews.interval, onComplete:olshownews.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 () {
olshownews.swap();
this.elements[0].style.display="block";
this.elements[1].style.display="none";
return false;
}
})