SpOnENV_FlashvideoPopupParams  = 'width=769,height=489,scrollbars=no,resizable=no,screenX=150,screenY=100';
SpOnENV_PopTopPopupParams = 'width=500,height=310,resizable,screenX=150,screenY=100,status=no';

function goURL(frmlrname){
	adresse = document.forms[frmlrname].to.options[document.forms[frmlrname].to.selectedIndex].value;
	if(adresse=="") adresse = "javascript:void(0)";
	if(adresse.substr(0,1) == '/') adresse = SpOnENV_SERVER + adresse;
	window.location = adresse;
}


function spCounter(url) {
	if (typeof(spon_vdz_countframe) != 'undefined') spon_vdz_countframe.location.href = SpOnENV_SERVER + url;
}

function spFramebuster() {
	if (top!=self) {
		top.location.href=self.location.href;
	}
}

function SPONgetCookie (name)
{
	function SPONgetCookieVal (offset)
	{
		var endstr = document.cookie.indexOf (";", offset);
		if (endstr == -1)
			endstr = document.cookie.length;
		return unescape(document.cookie.substring(offset, endstr));
	}
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return SPONgetCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function spGetHashParams() {
	var loc=(document.location+"");
	var pos=loc.indexOf("#");
	if (pos == -1)
		return [];
	var hashQs=loc.substring(pos+1, loc.length);
	return spSplitParams(hashQs);
}
function spSplitParams(params) {
	var result=[];
	var pairs=params.split("&");
	for (var i=0; i < pairs.length; i++) {
		var kv=pairs[i].split("=");
		if (kv.length == 2)
			result[kv[0]]=kv[1];
	}
	return result;
}
function spShowOASPos(pos) {
	var color='red';
	if (typeof OAS_listpos != 'undefined' && typeof OAS_allposlist != 'undefined') {
		var searchpos = new RegExp('(^|,)'+pos+'(,|$)');
		if (searchpos.exec(OAS_listpos)) {
			color='lightgreen';
		} else if (searchpos.exec(OAS_allposlist)) {
			color='yellow';
		}
	}
	document.write('<div style="display:inline; border:1px solid black; background-color:'+color+'; text-decoration:blink;  margin:1px; padding:1px; font-size:12px; font-family: Arial; font-weight:bold">Ad: ' + pos + '</div>');
}


function spOpenLargePicture(page, width, height) {
	spon_popup(page,width+20,height+25,false,false);	
}




function spSetCookie(name, value, daystoexpire, path, domain, secure) {

	var expires = new Date();
	expires.setTime(expires.getTime() + (daystoexpire * 86400000));

	document.cookie= name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
} 

// HP-Channelboxen
function spHPTeaserInit(allchannels) {
	spHPTeaserLen = {};
	var cookie = SPONgetCookie('spHPTeaser');
	if (cookie != null) {
		var channel = cookie.split(' ');

		for (var i in channel) {
			spHPTeaserLen[channel[i]] = 1;
		}
	}
	var allchannelslist = allchannels.split(' ');
	for (var c in allchannelslist) {
		spHPTeaserToggle(allchannelslist[c],(typeof(spHPTeaserLen[allchannelslist[c]]) == 'undefined' ? 'less' : 'more'),0);
	}
	return false;
}

function spHPTeaserToggle(channelname, what, save) {
	if (typeof(spHPTeaserLen) == 'undefined') {
		spHPTeaserLen = {};
	}
	if (what == 'more') {
		spHPTeaserLen[channelname] = '1';
		document.getElementById('spRTmore_'+channelname).style.display = 'block';
		document.getElementById('spRTless_'+channelname).style.display = 'none';
	} else if (what == 'less'){
		if (typeof(spHPTeaserLen[channelname]) != 'undefined') {
			delete spHPTeaserLen[channelname];
		}
		document.getElementById('spRTmore_'+channelname).style.display = 'none';
		document.getElementById('spRTless_'+channelname).style.display = 'block';
	} else {
		return false;
	}
	
	if (save == 1) {
		var cookie = '';
		for (var c in spHPTeaserLen) {
			cookie = cookie + (cookie.length > 0 ? ' ' : '') + c
		}
		spSetCookie('spHPTeaser',cookie,365);
	}
	return false;
}

function spSetObjectHeight(id,newSize) {
    document.getElementById(id).height = newSize;
}
function spSetObjectSize(id,newWidth,newHeight) {
    document.getElementById(id).height = newHeight;
    document.getElementById(id).width  = newWidth;
}


var spSearchCookie="spSearchCookie";

function spSearchVerifyCookie() {
	var url = document.location + ""
	queryParams = spGetQueryStringParameter(url);
	var offset = queryParams["offset"];
	if (!offset) {
		spSetCookie(spSearchCookie, Array(), null, "/", null, null);
	}
}

function spSearchStoreUrl() {

	var url = document.location + ""
	queryParams = spGetQueryStringParameter(url);
	var pageNumber = queryParams["pageNumber"];
	if (pageNumber && pageNumber != 1)
		url = url.replace("pageNumber=" + pageNumber, "pageNumber=1");

	var offset = queryParams["offset"];
	if (!offset)
		offset=0;

	var cookie=spSearchGetCookie(spSearchCookie);
	
	if (cookie.length <= offset) {
		cookie.push(url);
		spSearchSetCookie(spSearchCookie, cookie, null, "/", null, null);
	}
}

function spSearchGoBack() {
	
	var cookie=spSearchGetCookie(spSearchCookie);
	if (cookie.length > 0) {

		var url = document.location + ""
		queryParams = spGetQueryStringParameter(url);
		var offset = queryParams["offset"];
		if (offset && cookie.length >= offset) {

			backurl=cookie[offset-1];
			document.location.href=backurl;
		}
	}
}

function spSearchDrawBackLink() {
	var cookie=spSearchGetCookie(spSearchCookie);
	if (cookie.length > 0) {
		
	    document.write('<div class="spItemNumber">');
	    document.write('<a href="javascript:spSearchGoBack()" style="font-size:1.4em">');
	    document.write('&#x25C4;');
	    document.write('</a>');
	    document.write('</div>');

	}

}

function spGetQueryStringParameter(queryString) {
	pairs = Array();
	queryString = queryString.substring(queryString.indexOf("?") + 1,
			queryString.length);
	qs = queryString.split("&");
	for (i = 0; i < qs.length; i++) {
		pair = qs[i].split("=");
		if (pair[1])
			pairs[pair[0]] = pair[1];
	}
	return pairs;
}

function spSearchSetCookie(name, cookie, expires, path, domain, secure) {
	if (cookie)
		cookievalue=cookie.join(";");
	else 
		cookievalue=null;
	spSearchSetCookieString(name, cookievalue, expires, path, domain, secure);
}

function spSearchSetCookieString(name, value, expires, path, domain, secure) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime(today.getTime());

	/*
	 if the expires variable is set, make the correct
	 expires time, the current script below will set
	 it for x number of days, to make it for hours,
	 delete * 24, for minutes, delete * 60 * 24
	 */
	if (expires) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date(today.getTime() + (expires));

	document.cookie = name + "=" + escape(value)
			+ ((expires) ? ";expires=" + expires_date.toGMTString() : "")
			+ ((path) ? ";path=" + path : "")
			+ ((domain) ? ";domain=" + domain : "")
			+ ((secure) ? ";secure" : "");
}


function spSearchGetCookie(check_name) {
	var cookie=spSearchGetCookieString(check_name);
	if (!cookie)
		cookie=Array();
	else 
		cookie=cookie.split(";");

	return cookie
}

function spSearchGetCookieString(check_name) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split(';');
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for (i = 0; i < a_all_cookies.length; i++) {
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split('=');

		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if (cookie_name == check_name) {
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if (a_temp_cookie.length > 1) {
				cookie_value = unescape(a_temp_cookie[1].replace(
						/^\s+|\s+$/g, ''));
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if (!b_cookie_found) {
		return null;
	}
}
 var spTmpImgSetToLoad;
//Muss ausserhalb des spEnhPaginators stehen, da per timeout aufgerufen...
function spLoadDeferImgSet(prefix) {
	for (var i=0; i < spTmpImgSetToLoad.length; i++) {
		var imgElement=document.getElementById(prefix + i);
		if (imgElement != null)
			imgElement.src = spTmpImgSetToLoad[i];
	}
}
var spEnhPaginator = function(paginatorId, imageSets) {
	this.pages=[];
	this.controls=[];
	this.imageSets=imageSets;
	this.completedImageSets=(imageSets != null) ? new Array(imageSets.length) : null;
	this.index=0;
	this.paginatorId=paginatorId;
	this.imageSetToLoad=null;
	this.currentPage=null;
	this.currentControl=null;
	this.initDone=false;
	this.onChangePage=null;
}
spEnhPaginator.prototype = {
		checkInit: function() {
	if (!this.initDone) {
		var container=document.getElementById(this.paginatorId);
		var pagesTmp=container.getElementsByTagName('DIV');
		for (key=0; key < pagesTmp.length; key++) {
			if (pagesTmp[key].className == 'spPaginatorPage') {
				this.pages.push(pagesTmp[key]);
			}
			if (pagesTmp[key].className == 'spPaginatorControl' || pagesTmp[key].className == 'spPaginatorControl spActive') {
				this.controls.push(pagesTmp[key]);
			}
		}
		this.currentPage=this.pages[this.index];
		this.currentControl=this.controls[this.index];
		this.initDone=true;
	}
},
showNext: function(element) {
	this.checkInit();
	var oldIndex = this.index++;
	if (this.index >= this.pages.length)
		this.index = 0;
	if (this.onChangePage != null)
		this.onChangePage(this.pages[oldIndex]);
	this.switchToNewIndex();
},
showPrev: function(element) {
	this.checkInit();
	var oldIndex = this.index--;
	if (this.index < 0)
		this.index = this.pages.length - 1;
	if (this.onChangePage != null)
		this.onChangePage(this.pages[oldIndex]);
	this.switchToNewIndex();
},
showNum: function(element) {
	this.checkInit();
	var oldIndex = this.index;
	this.index = arguments[0];
	if (this.index < 0)
		this.index = this.pages.length - 1;
	if (this.onChangePage != null)
		this.onChangePage(this.pages[oldIndex]);
	this.switchToNewIndex();
},
switchToNewIndex: function(newPage) {
	this.currentPage.style.display='none';
	if (this.currentControl != null)
		this.currentControl.className = 'spPaginatorControl';
	this.currentPage=this.pages[this.index];
	this.currentControl=this.controls[this.index];
	this.currentPage.style.display='block';
	if (this.currentControl != null)
		this.currentControl.className = 'spPaginatorControl spActive';
	this.checkLoadImages();
},
checkLoadImages: function() {
	if (this.imageSets != null) {
		var imageSetIndex=this.index-1;
		if (this.imageSets[imageSetIndex] != null && !this.completedImageSets[imageSetIndex]) {
			spTmpImgSetToLoad=this.imageSets[imageSetIndex];
			window.setTimeout("spLoadDeferImgSet('" + this.paginatorId + imageSetIndex + "')", 20);
			this.completedImageSets[imageSetIndex]=true;
		}
	}
}
}
function spVideoGet(videoId) {
	if (navigator.appName.indexOf("Microsoft") != -1)
		return window[videoId];
	else
		return document[videoId];
}
function spVpPaginatorOnChangePage(element) {
	if (element == null || element.childNodes == null || element.childNodes.length == 0)
		return;
	var node=element.firstChild;
	while (node != null) {
		if (node.nodeName.toUpperCase() == "OBJECT") {
			var v=spVideoGet(node.id);
			if (v != null) {
				try {
					v.stopVideo();
					return;
				}
				catch(e) {
				}
			}
		}
		else if (node.childNodes != null && node.childNodes.length > 0)
			spVpPaginatorOnChangePage(node);
		node=node.nextSibling;
	}
}




/**
 * Event handler function tests where the user clicked
 * and acts	according to this
 */
function spMouseUpEvent(e) {
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;

	if (targ.id == "spTopicBoxToggleLink_" + spHpTopicBoxCurrentElement || targ.id == "spTopicBoxToggleLinkMore_" + spHpTopicBoxCurrentElement) {
		spStopMouseEvent();
		return false;
	}
	if (spHpTopicBoxCurrentElement && targ.id == "spSubjectBox_"+spHpTopicBoxCurrentElement) {
		return false;
	}


	var isHpTopicboxDiv = false;
	while(targ != null) {
		if (spHpTopicBoxCurrentElement && targ.id == "spSubjectBox_"+spHpTopicBoxCurrentElement) {
			isHpTopicboxDiv=true;
			break;
		}
		targ = targ.parentNode;
	}

	if (!isHpTopicboxDiv) {
		spHpTopicBoxToggle(spHpTopicBoxCurrentElement, false);
		spStopMouseEvent();
	}
	return false;
}

/**
 * starts EventHandling
 */
function spStartMouseEvent(){
	if (document.addEventListener) { // DOM Level 2 Event Model
		document.addEventListener("mouseup", spMouseUpEvent, true);
	}
	else if (document.attachEvent) { // IE 5+ Event Model
		document.attachEvent("onmouseup", spMouseUpEvent);
	}
	else { // IE 4 Event Model
		document.onmouseup=spMouseUpEvent;
	}
}
/**
 * stops EventHandling
 * spOldHandler is a hack for EI4 Event Model
 */
var spOldHandler = document.onmouseup;	// Eventhandler for EI 4 StopEvent
function spStopMouseEvent() {
//	Unregister the capturing event handlers.
	if (document.removeEventListener) { // DOM Event Model
		document.removeEventListener("mouseup", spMouseUpEvent, true);
	}
	else if (document.detachEvent) { // IE 5+ Event Model
		document.detachEvent("onmouseup", spMouseUpEvent);
	}
	else { // IE 4 Event Model
		document.onmouseup = spOldHandler;
	}
}

function checkLengthTextbox() {
  str = document.forms["settingsForm"].elements["signatur"].value;
  if (str.length > 250) str = str.substring(0, 250);
  document.forms["settingsForm"].elements["signatur"].value = str;  
}



