//window.onload = initFontSize;
var pScrollId = '';
var pCurrMargin = 520;
var pWidthPixel = 3000;
var pScrollTimeOut = 50;
var pWidthArea = 420;
var lId = '';
var lUid = '';


function initScrolling(pScrollDirection,pId, pUid) {
	lId= pId;
	lUid = pUid;
	timerId=setTimeout("loadScrolling()", 100) 
}

function loadScrolling() {
	cElem = document.getElementById(lId);
	if (navigator.appName=='Microsoft Internet Explorer') {
		lText=document.all["cty"+lUid].innerText;
	} else {
		lText=cElem.textContent;
	}
	pWidthPixel = lText.length*7;
	//alert(pWidthPixel);
	if (cElem != null) {
		cElem.style.position='relative';
		cElem.style.top='1px';
		cElem.style.left='0px';
		cElem.style.width='500px';
		cElem.style.borderTop='1px solid red';				
		cElem.style.borderBottom='1px solid red';
		cElem.style.backgroundColor='#FFFFFF';
		cElem.style.marginBottom = '10px';
		cElem.style.marginTop = '10px';
		cElem.style.paddingLeft = '10px';
		cElem.style.paddingTop = '2px'
		cElem.style.overflow = 'hidden';
	}
		
	cElem = document.getElementById('cty'+lUid);
	if (cElem != null) {
		pScrollId = cElem;
		cElem.style.position='relative';
		cElem.style.height='1.4em';
		cElem.style.overflow='hidden';
		cElem.style.width=pWidthPixel+'px';
		timerId=setTimeout("ticker()", pScrollTimeOut) 
	}

}
function ticker() {

if (pScrollId != null) {	
	pCurrMargin = pCurrMargin-2;
	//alert(pScrollId.id);
	if (pCurrMargin < (pWidthPixel*(-2))) {
		pCurrMargin = pWidthArea;
	}
	pScrollId.style.marginLeft = pCurrMargin+'px';
	timerId=setTimeout("ticker()", pScrollTimeOut);
} else {
	alert('noElem');
}
} 

/**
 * Add to Favorites
 */
function addToFavorites(url, title) {
	if (url == '') {
		url = document.location;
	}
	if (title == '') {
		title = document.title;
	}

	if (window.sidebar) {
		// firefox
		window.sidebar.addPanel(title, url, '');
	}
	else if (window.opera && window.print) {
		// opera
		var elem = document.createElement('a');
		elem.setAttribute('href', url);
		elem.setAttribute('title', title);
		elem.setAttribute('rel', 'sidebar');
		elem.click();
	} 
	else if (document.all) {
		// ie
		window.external.AddFavorite(url, title);
	}
	else {
		alert('Ihr Webbrowser unterst�tzt diese Funktion leider nicht.');
	}
}

/**
 * Print Page
 */
function printPage() {
	if (window.print) {
		window.print();
	} else {
		alert('Ihr Webbrowser unterst�tzt diese Funktion leider nicht.');
	}
}

/**
 * Disable external CSS-Stylesheets
 */
function clearCSS() {
	//document.getElementById('css_link').disabled=!document.getElementById('css_link').disabled;
	var css_links = document.getElementsByTagName("link");
	for (i=0; i<css_links.length; i++) {
		if (css_links[i].getAttribute("rel") == "stylesheet") {
			css_links[i].disabled = true;
		}
	}
}

function windowOpen(url, windowname,width,height) {
	newwindow=window.open('',windowname,'height='+height+',width='+width);
	newwindow.close();
	newwindow=window.open(url,windowname,'height='+height+',width='+width);
	newwindow.focus();
	return false;
}

/**
 * Set Cookie
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *            (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *            secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
	document.cookie= name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}

/**
 * Get cookie value
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie, or null if cookie does
 * not exist.
 */
function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else {
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) {
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Delete cookie
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
	if (getCookie(name)) {
		document.cookie = name + "=" + 
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

