
	var unorderedArray = new Array;
	var unorderedArray1 = new Array;
	var arCls = new Array;
	var frmNm = document.frmPost;
	var dom = (document.getElementById)? true:false
	if (dom) {
		doc = "document.getElementById(\"";
		sty = "\").style";
		wrp = "\")";
		htm = "\").innerHTML";
	}

	function createAjaxObj(){
		var httprequest=false
		if (window.XMLHttpRequest){ // if Mozilla, Safari etc
			httprequest=new XMLHttpRequest()
			if (httprequest.overrideMimeType)
			httprequest.overrideMimeType('text/xml')
		}
		else if (window.ActiveXObject){ // if IE
			try {
				httprequest=new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch (e){
				try{
				httprequest=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e){}
			}
		}

		return httprequest
	}

	function rss_ticker(RSS_id, cachetime, divId, divClass, delay, optionalswitch){
		this.RSS_id=RSS_id //Array key indicating which RSS feed to display
		this.cachetime=cachetime //Time to cache feed, in minutes. 0=no cache.
		this.tickerid=divId //ID of ticker div to display information
		this.delay=delay //Delay between msg change, in miliseconds.
		this.logicswitch=(typeof optionalswitch!="undefined")? optionalswitch : -1
		this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over ticker (and pause it if it is)
		this.pointer=0
		this.ajaxobj=createAjaxObj()
		document.write('<div id="'+divId+'" class="'+divClass+'">Initializing ticker...</div>')
		this.getAjaxcontent()
	}

	rss_ticker.prototype.getAjaxcontent=function(){
		if (this.ajaxobj){
			var instanceOfTicker=this
			var parameters="id="+encodeURIComponent(this.RSS_id)+"&cachetime="+this.cachetime+"&bustcache="+new Date().getTime()
			this.ajaxobj.onreadystatechange=function(){instanceOfTicker.initialize()}
			this.ajaxobj.open('GET', "external/rssfetch.php?"+parameters, true)
			this.ajaxobj.send(null)
		}
	}

	rss_ticker.prototype.initialize=function(){ 
		if (this.ajaxobj.readyState == 4){ //if request of file completed
			if (this.ajaxobj.status==200){ //if request was successful
				sData = this.ajaxobj.responseText;
				if (sData=="Error") {}
				else{
					fnMakeJSArray();
					popArray(unorderedArray);
					sText = inner3();
					document.getElementById(this.tickerid).innerHTML = sText 
				}
				return
				//}
				var instanceOfTicker=this
				this.feeditems=xmldata.getElementsByTagName("item")
				//Cycle through RSS XML object and store each peice of the item element as an attribute of the element	 
				for (var i=0; i<this.feeditems.length; i++){
					this.feeditems[i].setAttribute("ctitle", this.feeditems[i].getElementsByTagName("title")[0].firstChild.nodeValue)
					this.feeditems[i].setAttribute("clink", this.feeditems[i].getElementsByTagName("link")[0].firstChild.nodeValue)
					this.feeditems[i].setAttribute("cdescription", this.feeditems[i].getElementsByTagName("description")[0].firstChild.nodeValue)
				}
				document.getElementById(this.tickerid).onmouseover=function(){instanceOfTicker.mouseoverBol=1}
				document.getElementById(this.tickerid).onmouseout=function(){instanceOfTicker.mouseoverBol=0}
				this.rotatemsg()
			}
		}
	}

	rss_ticker.prototype.rotatemsg=function(){
		var instanceOfTicker=this
		if (this.mouseoverBol==1) //if mouse is currently over ticker, do nothing (pause it)
			setTimeout(function(){instanceOfTicker.rotatemsg()}, 100)
		else{
			var tickerDiv=document.getElementById(this.tickerid)
			var tickercontent='<a href="'+this.feeditems[this.pointer].getAttribute("clink")+'">'+this.feeditems[this.pointer].getAttribute("ctitle")+'</a>'
			if (this.logicswitch=="showdescription")
				tickercontent+="<br />"+this.feeditems[this.pointer].getAttribute("cdescription")
			tickerDiv.innerHTML=tickercontent
			this.pointer=(this.pointer<this.feeditems.length-1)? this.pointer+1 : 0
			setTimeout(function(){instanceOfTicker.rotatemsg()}, this.delay) //update container every second
		}
	}

	function fnMakeJSArray(){
		var arrMainRec;// = new Array();
		var arrSubRec;// = new Array();
		arrMainRec = sData.split("#|");
		var vb2jsi,vb2jsj;
		if(typeof (aRc) =='object' ) {
			aRc.length = arrMainRec.length;
			unorderedArray.length = arrMainRec.length;
			unorderedArray1.length = arrMainRec.length;		
		}else{		
		}	
		aRc = new Array(2);
		for (vb2jsi=0; vb2jsi < 2; vb2jsi++) {
			aRc[vb2jsi] = new Array(arrMainRec.length)
			for (vb2jsj=0; vb2jsj < arrMainRec.length; vb2jsj++) aRc[vb2jsi][vb2jsj] = " "
		}
		var i; 
		i = 0;
		for(i = 0;i < arrMainRec.length; i++) {
			dr = arrMainRec[i];			
			arrSubRec = dr.split("#~");
			var j;
			j =0;
			for(j=0; j < arrSubRec.length; j++)
			{			
				aRc[j][i]= arrSubRec[j];				
			}
		}
	}
		
	function popArray(theArray) {
		for (var j=0;j<aRc[0].length;j++) {
			theArray[j] = [aRc[0][j],aRc[1][j]];		
		}		
	}

	function inner3() { //Used to create table of record 
		var string = new Array();
		string.push(' ');
		for (var i=0;i<unorderedArray.length;i++) {
			if (i==0) {			
				continue;		
			}
			else {
				var strVal = unescape(unorderedArray[i][1]);
				string.push('<li><a href="http://www.estatemedia.no/DE/FullArticle.aspx?aid='+ unorderedArray[i][0] +'" target="_new">'+strVal+'</a></li>');
			}
		}
		var writestring = string.join('');
		return  "<ul class='bLst'>" + writestring + "</ul>" + "<div class=\"hS2\"><i></i></div><div class=\"\"><a href=\"http://www.dagenseiendom.no/dagenseiendom/userframe.aspx\" target=\"_new\">Flere nyheter</a></div>";
	}