SpOnENV_SERVER = 'http://www.spiegel.de';
SpOnENV_FlashvideoPopupParams  = 'width=769,height=489,scrollbars=no,resizable=no,screenX=150,screenY=100';
// SpOnENV_FlashPopupParams  = 'scrollbars=no,screenX=150,screenY=100'; 
SpOnENV_PopTopPopupParams = 'width=500,height=310,resizable,screenX=150,screenY=100,status=no';
// SpOnENV_PdfPopupParams    = 'width=600,height=550,scrollbars=no,screenX=150,screenY=100,resizable';

function spToggleMPC(cid,nr) {
	for (i=1;i<=50;i++) {
		var mytab = document.getElementById('spMPCTab-'+cid+'-'+i);
		if (mytab) {
			if (nr == i) {
				mytab.className = 'spMPCTab spMPCTabAktiv';
				document.getElementById('spMPCContent-'+cid+'-'+i).style.display = 'block';
				spCounterContentainer(cid);
			} else {
				mytab.className = 'spMPCTab';
				document.getElementById('spMPCContent-'+cid+'-'+i).style.display = 'none';
			}
		} else {
			break;
		}
	}
}

function spShowCenterGallery(gid,nr) {
	for (i=1;i<=3;i++) {
		var mypic = document.getElementById('spCenterGalleryPic-'+gid+'-'+i);
		if (mypic) {
			if (nr == i) {
				document.getElementById('spCenterGalleryPic-'+gid+'-'+i).style.display = 'inline';
				document.getElementById('spCenterGalleryCredit-'+gid+'-'+i).style.display = 'block';
				document.getElementById('spCenterGalleryControl-'+gid+'-'+i).src='/static/sys/v9/icons/ic_paginate_'+i+'_aktiv.gif';
				//document.getElementById('spCenterGalleryControl-'+gid+'-'+i).className = 'spCenterGalleryControl spActive';
				spCounterGallery(gid);
			} else {
				document.getElementById('spCenterGalleryPic-'+gid+'-'+i).style.display = 'none';
				document.getElementById('spCenterGalleryCredit-'+gid+'-'+i).style.display = 'none';
				document.getElementById('spCenterGalleryControl-'+gid+'-'+i).src='/static/sys/v9/icons/ic_paginate_'+i+'.gif';
				//document.getElementById('spCenterGalleryControl-'+gid+'-'+i).className = 'spCenterGalleryControl';
			}
		} else {
			break;
		}
	}
}

function spCounterGallery(galleryid) {
	spCounter('/fotostrecke/fotostrecke-' + galleryid + '-count.html');
}
function spCounterFlash(flashid) {
	spCounter('/flash/flash-' + flashid + '-count.html');
}
function spCounterContentainer(contentainerid) {
	spCounter('/count/contentainer/0,,' + contentainerid + ',00.html');
}


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);	
}


// Weiterleitung m.spiegel.de

var spMobileClients=[
"midp",
"240x320",
"blackberry",
"netfront",
"nokia",
"panasonic",
"portalmmm",
"sharp",
"sie-",
"sonyericsson",
"symbian",
"windows ce",
"benq",
"mda",
"mot-",
"opera mini",
"philips",
"pocket pc",
"sagem",
"samsung",
"sda",
"sgh-",
"vodafone",
"xda"
];
function spIsMobileClient(userAgent) {
	try {
		userAgent=userAgent.toLowerCase();
		for (var i=0; i < spMobileClients.length; i++) {
			if (userAgent.indexOf(spMobileClients[i]) != -1) {
				return true;
			}
		}
	}
	catch (e) { // pssst.
	}
	return false;
}
function spIsThisBrowserMobileClient() {
	return spIsMobileClient(navigator.userAgent);
}
function spRedirectIfMobileClient() {
	try {
		if (spIsThisBrowserMobileClient()) {
			if (document.location.href.indexOf('nomobile') != -1) {
				document.cookie='nomobile';
				return;
			}
			if (document.cookie && document.cookie.indexOf('nomobile') != -1) {
				return;
			}
			document.location.href="http://m.spiegel.de?redirect=1";
		}
	}
	catch (e) {
	}
}

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;
}/* Calendar */

var spCalendar = function(initDate, startDate, endDate, contentainer) {
	this.initDate=initDate;
	if (contentainer != null)
		this.contentainerObject=document.getElementById(contentainer);
	this.months=new Array("Januar", "Februar", "M&auml;rz", "April", "Mai", "Juni", "Juli","August", "September", "Oktober", "November", "Dezember");
	this.weekDays=new Array("Mo", "Di", "Mi", "Do", "Fr", "Sa", "So");	
	this.year=null;
	this.month=null;
	this.day=null;
	this.date=null;
	this.startDate=startDate;
	this.endDate=endDate;
}

spCalendar.prototype = {

	init: function() {
		if (this.isDateValid(this.initDate)) {
			year=this.initDate.substring(0,4);
			month=this.initDate.substring(4,6);
			day=this.initDate.substring(6,8);
			this.date=new Date(year, month - 1, day);
		}
		else {
			this.date=new Date();
		}
	},

	isDateValid: function(date) {
		return (date != null && date != "" && !isNaN(date) &&	date.length == 8);
	},
	
	prepare: function() {
		if (this.date != null) {
			this.year=this.date.getFullYear();
			this.month=this.date.getMonth()+1;
			this.day=this.date.getDate();
		}
	}, 
	
	draw: function() {
		if (this.contentainerObject != null) {

			this.prepare();
			
			// Start Day of Calendar 
			var tmpDate=this.date;
			tmpDate.setDate(1);
			
			var firstDayOfMonth = tmpDate.getDay();
			if (firstDayOfMonth > 0)
				firstDayOfMonth--;
			else
				firstDayOfMonth=6;

			var daysInMonth = 31;
			if (this.month == 4 || this.month == 6 || this.month == 9 || this.month == 11)
				--daysInMonth;
			if (this.month == 2) {
				daysInMonth = daysInMonth - 3;
				if (this.year % 4 == 0)
					daysInMonth++;
				if (this.year % 100 == 0)
					daysInMonth--;
				if (this.year % 400 == 0)
					daysInMonth++;
			}

			var table="";
			table+="<div id=\"spCalenderHead\"><p>DAS SEITE-2-ARCHIV</p>";

			table+="<table cellpadding=\"0\" cellspacing=\"0\">";
			table+="<tr>";
			if (this.hasPrevMonth())
				table+="<td width=\"40\"><a href=\"javascript:void(0)\" id=\"spBtnBack\"><img src=\"/static/sys/v8/icons/pfeil-links-aktiv.jpg\" /></a></td>";
			else 
				table+="<td width=\"40\"><img src=\"/static/sys/v8/icons/pfeil-links-inaktiv.jpg\" /></td>";

			table+="<td width=\"202\">" + this.months[this.month-1] + " " + this.year + "</td>";
			if (this.hasNextMonth())
				table+="<td width=\"40\"><a href=\"javascript:void(0)\" id=\"spBtnNext\"><img src=\"/static/sys/v8/icons/pfeil-rechts-aktiv.jpg\" /></a></td>";
			else
				table+="<td width=\"40\"><img src=\"/static/sys/v8/icons/pfeil-rechts-inaktiv.jpg\" /></td>";

			table+="</tr>";
			table+="</table></div>";

			table+="<table cellpadding=\"0\" cellspacing=\"0\" id=\"spCalender\">";
			table+="<tr>";
			for (var i = 0; i <= 6; i++) {
				table+="<td><span>";
				table+=this.weekDays[i];
				table+="</span></td>";
			}
			table+="</tr>";
			
			var dayCount=1;
			//Rows
			for (var i = 0; i <= 5; i++) {
				if (dayCount <= daysInMonth) {
					table+="<tr>";
					// Columns
					for (var j = 0; j <= 6; j++) {
						if ((i == 0) && (j < firstDayOfMonth)) {
							table+="<td>&nbsp;</td>";
						}
						else {
							if (dayCount > daysInMonth) {
								table+="<td>&nbsp;</td>";
							}
							else {
								var dateString=this.year+""+(this.month < 10 ? "0"+this.month:this.month)+""+(dayCount<10?"0"+dayCount:dayCount);
	
								var drawLink=false;
								var today=false;
								if (dateString == this.initDate)
									today=true;
	
								if (dateString != this.initDate) {
									if (this.isDateValid(this.startDate) && this.isDateValid(this.endDate)) {
										if (parseInt(dateString) >= parseInt(this.startDate) && 
												parseInt(dateString) <= parseInt(this.endDate))
											drawLink=true;
										//alert(dateString + ">" + this.startDate +"\n" + dateString + "<" + this.endDate);
									}
									else if (this.isDateValid(this.startDate)) {
										if (parseInt(dateString) >= parseInt(this.startDate)) {
											drawLink=true;
										} 
									}
									else if (this.isDateValid(this.endDate)) {
										if (parseInt(dateString) < parseInt(this.endDate)) {
											drawLink=true;
										} 
									}
								}
	
								if (today)
									table+="<td class=\"spActive\">" + dayCount + "</td>";
								else if (this.endDate == dateString)
									table+="<td><a href=\"/home/seite2/index.html\">" + dayCount + "</a></td>";
								else if (drawLink)
									table+="<td><a href=\"/home/seite2/archiv-"+dateString+".html\">" + dayCount + "</a></td>";
								else
									table+="<td>" + dayCount + "</td>";
								dayCount++;
							 }
						}
					}
					table+="</tr>";
				}
			}
			table+="</table>";

			this.contentainerObject.innerHTML=table;

			var object=this;

			var btnNext=document.getElementById("spBtnNext");
			if (btnNext != null) {
				btnNext.onclick=function() {
					object.incMonth();
				}
			}
			var btnBack=document.getElementById("spBtnBack");
			if (btnBack != null) {
				btnBack.onclick=function() {
					object.decMonth();
				}
			}
		}
	},

	incMonth: function() {
		this.date.setMonth(this.date.getMonth()+1);
		this.draw();
	},
	
	decMonth: function() {
		this.date.setMonth(this.date.getMonth()-1);
		this.draw();
	},

	hasPrevMonth: function() {
		if (this.isDateValid(this.startDate)) {
			var sd=this.startDate.substring(0,6);
			var m=this.date.getMonth()+1;
			m=m < 10 ? "0"+m:m;
			var nd=this.date.getFullYear()+""+m;
			return (parseInt(sd) < parseInt(nd))
		}
		return true;
	},

	hasNextMonth: function() {
		if (this.isDateValid(this.endDate)) {
			var sd=this.endDate.substring(0,6);
			var m=this.date.getMonth()+1;
			m=m < 10 ? "0"+m:m;
			var nd=this.date.getFullYear()+""+m;
			return (parseInt(sd) > parseInt(nd))
		}
		return true;
	},

	getNextDayLink: function() {
		if (this.isDateValid(this.initDate) && this.isDateValid(this.endDate)) {
			if (this.initDate < this.endDate) {
				var tmp=new Date(this.date);
				tmp.setDate(tmp.getDate()+1);
				var m=tmp.getMonth()+1;
				var d=tmp.getDate();			
				return tmp.getFullYear()+""+(m<10?"0"+m:m)+""+(d<10?"0"+d:d);
			}
		}
		return "";
		
	},
	
	getLastDayLink:function() {
		if (this.isDateValid(this.initDate) && this.isDateValid(this.startDate)) {
			if (this.initDate > this.startDate) {
				var tmp=new Date(this.date);
				tmp.setDate(tmp.getDate()-1)
				var m=tmp.getMonth()+1;
				var d=tmp.getDate();
				return tmp.getFullYear()+""+(m<10?"0"+m:m)+""+(d<10?"0"+d:d);
			}
		}
		return "";
	
	}
}
/* /Calendar */
function spOpenVideoPopupPlayer(videoid){
	var hashParams="";
	try {
		var params=spGetHashParams();
		var oasVideoBelegung=params["oas.videobelegung"];
		if (oasVideoBelegung != null)
			hashParams="#oas.videobelegung=" + oasVideoBelegung;
	}
	catch(e) {
	}
	window.open('http://www.spiegel.de/video/video-'+videoid+'.html' + hashParams, 'SPONflashvideo', SpOnENV_FlashvideoPopupParams).focus();
}

var spOasAllowPanoPlayerAds = 1;
function spPanoPlayerPlay (videoid, category) {

	try {
		var params=spGetHashParams();
		var oasVideoBelegung=params["oas.videobelegung"];
		if (oasVideoBelegung != null)
			category = oasVideoBelegung;
	}
	catch (e) {};
	
	
	var PlayerFlashVars = {
		brand: 				"sponCenterPlayer",
		disableHQ : 		"true",
		allowAds:			spOasAllowPanoPlayerAds,
		category:			category,
		fitVideoToStage : 	"true",
		videoid: 			videoid
	};
	var PlayerParams = {
		allowScriptAccess: "always",
		allowFullScreen: "true"
	};

	swfobject.embedSWF("/static/flash/flashvideo/videoplayer-pan-4-002.swf", "spPanoPlayerPane" + videoid , "522", "320", "10.0.0", "", PlayerFlashVars, PlayerParams);

	document.getElementById('spPanoPlayerPicCredit' + videoid).style.display = 'none';
	document.getElementById('spPanoPlayerVideoCredit' + videoid).style.display = 'block';
	return false;
}


// wird die TimeSeen-Funktion mit dem neuen Player noch verwendet /noch ausgewertet? prüfen!

var spOasTimeseenUrl = '';
var spOasCurrentTimeseen = -1;
function spOasSetCurrentTimeseen(seconds) {
	spOasCurrentTimeseen = seconds;
}
function spOasSetTimeseenUrl(url) {
	spOasTimeseenUrl = url;
}
function spOasTimeseenOnunload() {
	if (spOasCurrentTimeseen >= 0 && spOasCurrentTimeseen < 999)
	{
		if (spOasTimeseenUrl)
		{
			TimeseenPic = new Image();
			TimeseenPic.src = spOasTimeseenUrl.replace("\[sekunden.gif\]", spOasCurrentTimeseen + ".gif");
		}
	}
}

// Reminder für alten Popup-Player

function spOasSetReminder(html){
	if (html == null || html == 'null') {
		html = "";
	}
	document.getElementById('spOasReminder').innerHTML = html;
}
/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();function spFlashDetect(reqMajorVer, reqMinorVer, reqRevision) {
	return true;
}
function spFlashDetectInit() {
	return true;
}
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 RandomImg (Pfad,aBilder,Ext){
	if (typeof(Ext)=='undefined')Ext = "";
	if (Pfad =="img"){
		Pfad = SpOnENV_SERVER_IMG + "/img/0,1020,";
		if(Ext!="") Ext = ",00" + Ext;
	} else {
		Pfad = SpOnENV_SERVER_IMG + "/static/img/" + Pfad;
	}
	return Pfad + aBilder[Math.round(Math.random()*(aBilder.length-1))] + Ext;
}
function spon_popup(seite,breite,hoehe,scroll,rsize) {
	sbars = (scroll==1)? "yes" : "no";
	rsize = (rsize==1)? "yes" : "no";
	if(seite.substr(0,1) == '/') seite = SpOnENV_SERVER + seite;
	var win_name = breite+hoehe;
	var win_attr = "menubar=no,location=no,directories=no,toolbar=no,screenX=0,screenY=0";
	win_attr += ",width=" + breite + ",height=" + hoehe + ",scrollbars=" + sbars + ",resizable=" + rsize;
	sponWin = open(seite,win_name,win_attr);
	sponWin.focus();
}
function bilderladen(pfad,bildIds,ext) {
	if(document.images) {
		if(pfad.indexOf("img")==1) {
			pfad = pfad + '0,1020,';
			ext = ',00' + ext;
		}
		if(pfad.substr(0,1) == '/') pfad = SpOnENV_SERVER_IMG + pfad;
		var bilder = new Array();
		for(i=0;i < bildIds.length;i++) {
			bilder[i] = pfad + bildIds[i] + ext;
		}
		chgImg = new Array();
		for(i=0;i < bilder.length;i++) {
			chgImg[i] = new Image();
			chgImg[i].src = bilder[i];
		}
	}
}
function bildtausch(imgname,imgnr) {
	if(document.images) {
		if(imgnr < (chgImg.length)) imgname.src = chgImg[imgnr].src;
	}
}
/**
 * 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;
	}
}



/**
 * 
 * @return
 */
var spHpTopicBoxState=false;
function spHpTopicBoxToggle(spElementName) {
	
	if (!spHpTopicBoxState) {
		spHpTopicBoxSetDisplay(spElementName, true);
		spStartMouseEvent();
	}
	else
		spHpTopicBoxSetDisplay(spElementName, false);
}
/**
 * 
 * @param spDisplay
 * @return
 */
var spHpTopicBoxCurrentElement=null;
function spHpTopicBoxSetDisplay(spElementName, spDisplay) {
	
	spHpTopicBoxElement = document.getElementById("spSubjectBox_"+spElementName).style;
	spHpTopicBoxElement.display = (spDisplay ? "block" : "none");
	spHpTopicBoxState=spDisplay;
	spHpTopicBoxCurrentElement=spElementName
}


/**
 * Simple in_array function
 * @param haystack (Array)
 * @param needle (Object)
 * @return
 */
function spInArray(haystack, needle) {
	for (var i in haystack) {
		if (haystack[i] == needle)
			return true;
	}
	return false;
}
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;
	}
}

function spMainNaviInit() {
	if (document.all && document.getElementById) {
		var spNavContainer = document.getElementById("spChannel");
		var spNavis = spNavContainer.getElementsByTagName('ul');
		for (var i in spNavis) {
			var ul = spNavis[i];
//			wenn 2. Ebene, ...
			if (ul.nodeName == 'UL') {
				var spNavItems = spNavContainer.getElementsByTagName('li');
				for (var j in spNavItems) {
					var li = spNavItems[j];
//					...dann 3. Ebene einblenden, falls vorhanden
					if (li.nodeName == 'LI') {
						li.onmouseover = function() {
//							lazy initialization
							if (! this.spSubNav) {
								var spSubNavTmp = this.getElementsByTagName('ul')[0];
								if (spSubNavTmp && spSubNavTmp.nodeName == 'UL' && spSubNavTmp.className == 'spNaviLevel2')
									this.spSubNav = spSubNavTmp;
							}
							if (this.spSubNav) {
								this.spSubNav.style.display = "block";
							}
						}
						li.onmouseout = function() {
//							lazy initialization
							if (! this.spSubNav) {
								var spSubNavTmp = this.getElementsByTagName('ul')[0];
								if (spSubNavTmp && spSubNavTmp.nodeName == 'UL' && spSubNavTmp.className == 'spNaviLevel2')
									this.spSubNav = spSubNavTmp;
							}
							if (this.spSubNav)
								this.spSubNav.style.display = "none";
						}
					}
				}
			}
		}
	}
}

function spAutoDbChangeModellMultiInstanz(formularname)
{
	var spHerstellerIndex = document.forms[formularname].hersteller.selectedIndex;
	var spHersteller = document.forms[formularname].hersteller.options[spHerstellerIndex].text;
	
	if(spHerstellerIndex > 0)
	{
		document.forms[formularname].typ.length = spHerstellerModelle[spHersteller].length + 1;			
		document.forms[formularname].typ.options[0].text = "beliebig";
		
		document.forms[formularname].typ.style.color = "#000000";
		document.forms[formularname].typ.style.background = "#ffffff";
		
		for (var i = 1; i < spHerstellerModelle[spHersteller].length + 1; i++) {
			document.forms[formularname].typ.options[i].text = spHerstellerModelle[spHersteller][i-1];
		}
		
		document.forms[formularname].typ.selectedIndex = 0;
		
	} else {
		document.forms[formularname].typ.length = 1;
		document.forms[formularname].typ.options[0].text = "beliebig";
		
		document.forms[formularname].typ.style.color = "#666666";
		document.forms[formularname].typ.style.background = "#f9f9f9";
	}
}

function spAutoDbShowResultMultiInstanz(formularname) {
	document.forms[formularname].submit();
}

function spAutoDbToggleViewMultiInstanz(formularname)
{
	if(document.forms[formularname].spSearchExtended.value == "true") {
		document.getElementById("spDivErweiterteSucheCO2"+formularname).style.display = 'none';
		document.getElementById("spDivErweiterteSucheZeitraum"+formularname).style.display = 'none';
		document.getElementById("spEinblendenSucheErweitert"+formularname).style.display = 'block';
		document.getElementById("spEinblendenSucheKompakt"+formularname).style.display = 'none';			
		document.forms[formularname].spSearchExtended.value = "false";
		document.forms[formularname].co2ausstoss.selectedIndex = 0;
		document.forms[formularname].zeitraum.selectedIndex = 0;
	}
	else {
		document.getElementById("spDivErweiterteSucheCO2"+formularname).style.display = 'block';
		document.getElementById("spDivErweiterteSucheZeitraum"+formularname).style.display = 'block';
		document.getElementById("spEinblendenSucheErweitert"+formularname).style.display = 'none';
		document.getElementById("spEinblendenSucheKompakt"+formularname).style.display = 'block';
		document.forms[formularname].spSearchExtended.value = "true";
	}
}



function spAutoDbSetUserParamsMultiInstanz(formularname) {
	
	if(typeof spAutoDbUserSelection_hersteller != 'undefined') {
		for (var i = 1; i < document.forms[formularname].hersteller.options.length; i++) {
			if(document.forms[formularname].hersteller.options[i].text == spAutoDbUserSelection_hersteller) {
				document.forms[formularname].hersteller.selectedIndex = i;
				spAutoDbChangeModellMultiInstanz(formularname);
			}
		}
	}
	
	if(typeof spAutoDbUserSelection_typ != 'undefined') {
		for (var i = 1; i < document.forms[formularname].typ.options.length; i++) {
			if(document.forms[formularname].typ.options[i].text == spAutoDbUserSelection_typ) {
				document.forms[formularname].typ.selectedIndex = i;
			}
		}
	}


	if(typeof spAutoDbUserSelection_karosserie != 'undefined') {
		for (var i = 1; i < document.forms[formularname].karosserie.options.length; i++) {
			if(document.forms[formularname].karosserie.options[i].text == spAutoDbUserSelection_karosserie) {
				document.forms[formularname].karosserie.selectedIndex = i;
			}
		}
	}

	if(typeof spAutoDbUserSelection_suchbegriff != 'undefined') {
		document.forms[formularname].suchbegriff.value = spAutoDbUserSelection_suchbegriff;
	}
		
	if(typeof spAutoDbUserSelection_co2ausstoss != 'undefined') {
		for (var i = 1; i < document.forms[formularname].co2ausstoss.options.length; i++) {
			if(document.forms[formularname].co2ausstoss.options[i].text == spAutoDbUserSelection_co2ausstoss) {
				document.forms[formularname].co2ausstoss.selectedIndex = i;
			}
		}
	}

	if(typeof spAutoDbUserSelection_zeitraum != 'undefined') {
		for (var i = 1; i < document.forms[formularname].zeitraum.options.length; i++) {
			if(document.forms[formularname].zeitraum.options[i].text == spAutoDbUserSelection_zeitraum) {
				document.forms[formularname].zeitraum.selectedIndex = i;
			}
		}
	}
	
	if(typeof spAutoDbUserSelection_extended != 'undefined') {
		document.forms[formularname].spSearchExtended.value = spAutoDbUserSelection_extended;
	}
}


function spAutoDbInitMultiInstanz(formularname) {
	
	spAutoDbChangeModellMultiInstanz(formularname);

	if(document.getElementsByName('spSearchExtended')[0].value == "true") {
		document.getElementById("spDivErweiterteSucheCO2"+formularname).style.display = 'block';
		document.getElementById("spDivErweiterteSucheZeitraum"+formularname).style.display = 'block';
		document.getElementById("spEinblendenSucheErweitert"+formularname).style.display = 'none';
		document.getElementById("spEinblendenSucheKompakt"+formularname).style.display = 'block';
	}
	
	if(typeof spAutoDbUserSelection_hersteller != 'undefined') {
		spAutoDbSetUserParamsMultiInstanz(formularname);
	}
}
function spVgWortCount(token) {
	document.write('<div style="display:none;"><img src="http://spiegel.met.vgwort.de/na/'+token+'" width="1" height="1" alt="" align="right" /></div>');
}
