if (document.getElementById) {
	document.writeln('<script language="Javascript" type="text\/javascript" src="http://www.aposolutions.com/generell/inc/modul/common/scroll_newbrowser.js"><\/script>');
} else if (document.layers) {
	document.writeln('<script language="Javascript" type="text\/javascript" src="http://www.aposolutions.com/generell/inc/modul/common/scroll_oldnn.js"><\/script>');
} else {
	document.writeln('<script language="Javascript" type="text\/javascript" src="http://www.aposolutions.com/generell/inc/modul/common/scroll_default.js"><\/script>');
}

var scroll_css_control_play = '';
var scroll_css_control_stop = '';
var scroll_css_item_play = '';
var scroll_css_item_stop = '';
var scroll_css_item_title = '';
var scroll_css_item_description = '';
var scroll_css_item_links = '';
var scroll_link_title = true;
var scroll_link_description = false;
var scroll_width = 154;
var scroll_height = 55;
var scroll_pause = 6;
var scroll_fps = 96;
var scroll_pixels = 2;
var scroll_shuttle = 1;
var onMouseOver_pause = false;
var scroll_control = new Array();
var scroll_css_cache = new Array();

function scroll_new_control(id) {
	this.id			= id.toString();
	this.width		= scroll_width;
	this.height		= scroll_height;
	this.pause		= Math.round(scroll_pause * 1000);
	this.pause_mo	= onMouseOver_pause;
	this.timeout	= Math.round(1000 / scroll_fps);
	this.px			= scroll_pixels;
	this.shuttle	= scroll_shuttle;
	this.play		= false;
	this.timer		= null;
	this.classPlay	= scroll_css_control_play;
	this.classStop	= scroll_css_control_stop;
}

function scroll_new_item(id, title, description, url, target) {
	this.id				= id.toString();
	this.title			= title;
	this.description	= description;
	this.url			= (url ? url : '');
	this.target			= target;
	this.classPlay		= (scroll_css_item_play ? scroll_find_class(scroll_css_item_play) : null);
	this.classStop		= (scroll_css_item_stop ? scroll_find_class(scroll_css_item_stop) : null);
	this.classTitle		= (scroll_css_item_title ? scroll_find_class(scroll_css_item_title) : null);
	this.classDesc		= (scroll_css_item_description ? scroll_find_class(scroll_css_item_description) : null);
	this.classLink		= (scroll_css_item_links ? scroll_find_class(scroll_css_item_links) : null);
	this.link_title		= scroll_link_title;
	this.link_desc		= scroll_link_description;
}

function scroll_speed(id, speed, increment) {
	scroll_speed_sc(scroll_find(id), speed, increment);
}


function scroll_speed_shuttle(id, shuttle) {
	scroll_speed_sc(scroll_find(id), shuttle, true);
}

function scroll_play_stop(id) {
	var scroller = scroll_find(id);
	scroll_speed_sc(scroller, 1);
	if (scroller.play) {
		scroll_stop_sc(scroller);
	} else {
		scroll_play_sc(scroller);
	}
}

function scroll_play(id) {
	scroll_play_sc(scroll_find(id));
}
function scroll_play_sc(scroller) {
	if (!scroller.play) {
		scroller.play = true;
		scroll_restore_sc(scroller);
	}
}

function scroll_stop(id) {
	scroll_stop_sc(scroll_find(id));
}
function scroll_stop_sc(scroller) {
	if (scroller.play) {
		scroller.play = false;
		scroll_freeze_sc(scroller);
		scroll_pf_stop(scroller);
	}
}

function scroll_freeze(id, pause) {
	if (pause != false) {
		scroll_freeze_sc(scroll_find(id));
	} else {
		scroll_restore_sc(scroll_find(id));
	}
}

function scroll_mo_freeze(id, pause) {
	var scroller = scroll_find(id);
	if (pause != false) {
		if (scroller.freeze) {
			clearTimeout(scroller.freeze);
			scroller.freeze = null;
		}
		scroll_freeze_sc(scroller);
	} else {
		if (!scroller.freeze) {
			scroller.freeze = setTimeout('scroll_freeze(\'' + id + '\', false);', 1);
		}
	}
}

function scroll_freeze_sc(scroller) {
	clearTimeout(scroller.timer);
	scroller.timer = null;
}

function scroll_restore_sc(scroller) {
	if (scroller.play && !scroller.timer) {
		scroll_pf_play(scroller);
	}
}

function scroll_speed_sc(scroller, speed, increment) {
	var shuttle = scroller.shuttle;
	scroller.shuttle = (increment ? scroller.shuttle : 0) + speed;
	if (scroller.shuttle && shuttle * scroller.shuttle <= 0) {
		scroll_pf_direction(scroller);
	}

	if (scroller.play) {
		if (scroller.shuttle) {
			scroll_restore_sc(scroller);
		} else {
			scroll_freeze_sc(scroller);
		}
	}
}

function scroll_add(title, url, target) {
	var scroller = scroll_control[scroll_control.length - 1];
	if (scroller.first) {
		var i = 1;
		var item = scroller.first;
		while (item.next) {
			item = item.next;
			i++;
		}
		item.next = new scroll_new_item(scroller.id + '-' + i, title, url, target);
		item.next.prev = item;
	} else {
		scroller.first = new scroll_new_item(scroller.id + '-0', title, url, target);
	}
}

function scroll_item_html(i) {
	var html = '';
	if (i.title) {
		html += '<strong' + scroll_css_html(i.classTitle) + '>' + (i.link_title && i.url ? scroll_item_link_html(i, i.title) : i.title) + '<\/strong><br \/>';
	}

	scroll_clear_node(i);

	return html;
}


function scroll_item_link_html(i, text) {
	return '<a href="' + i.url + (i.target ? '" target="' + i.target : '') + '"' + scroll_css_html(i.classLink) + '>' + text + '<\/a>';
}

function scroll_css_html(css) {
	return (css ? ' class="' + scroll_css_cache[css] + '"' : '');
}

function scroll_clear_node(i) {
	i.title			= null;
	i.description	= null;
	i.url			= null;
	i.target		= null;
	i.classTitle	= null;
	i.classDesc		= null;
	i.classLink		= null;
	i.link_title	= null;
	i.link_desc		= null;
}

function scroll_find(id) {
	var i = 0;
	while (i < scroll_control.length) {
		if (scroll_control[i].id == id) {
			return scroll_control[i];
		}
		i++;
	}
	return scroll_control[0];
}

function scroll_find_class(name) {
	var i = 0;
	while (i < scroll_css_cache.length) {
		if (scroll_css_cache[i] == name) {
			return i;
		}
		i++;
	}
	scroll_css_cache[i] = name;
	return i;
}

function scroll_create(id) {
	scroll_control[scroll_control.length] = new scroll_new_control(id);
}

function scroll_done() {
	var scroller = scroll_control[scroll_control.length - 1];
	var i = scroller.first;
	while (i.next) {
		i = i.next;
	}
	i.next = scroller.first;
	scroller.first.prev = i;
	scroll_write_html(scroller);
}

