 
function funLoad(fun) {
		if (typeof(fun)=='object') {
			mainimg_ref = document.getElementById("mainimg");
			mainimg_ref.src=fun.img;
			mainimg_ref.alt=fun.tit;
			mainimg_ref.title=fun.tit;
			
			funtitle_ref = document.getElementById("funTitle");
			funtitle_ref.innerHTML=fun.tit;
			funtitle_ref.title=fun.tit;
			desc = fun.desc.length>97 ? fun.desc.substr(0,100) + ' ...' : fun.desc;			
			
			document.getElementById("funDescription").innerHTML=desc;
			document.getElementById("funDate").innerHTML=fun.dat.substr(5,11);
			
			
			ref = document.getElementById('funContInner');
			
			ref = ref.getElementsByTagName("a"); 
			
			for (i=0;i<ref.length;i++) {
				ref[i].href=fun.link;
			}
	} else {
		ord = funPos>0 ? "har nått sista" : "är på första";
		funPos>0 ? funPos-- : funPos++;

		alert("Du "+ord+" filmen. Besök RoligaKlipp.se för mera filmer!");

	}
}




function roligaklipp(t) {
	function ie_workaround_up() {
		funLoad(funArr[++funPos]);
	}	

	function ie_workaround_down() {
		funLoad(funArr[--funPos]);
	}	

	function change_icon_to_hand() {
		this.style.cursor = 'pointer';
	}

	function change_icon_to_normal() {
		this.style.cursor = '';
	}
	
funPos = 0;
//alert('wtadsf');
//alert(document.getElementById('roligaklipp').getAttribute('id'));


roligaklipp = t.document.getElementById('roligaklipp');



t2 = document.createElement('div');
t2.setAttribute('id', 'funCont');

t3 = document.createElement('a');
t3.setAttribute('href', 'http://www.roligaklipp.se/');
t3.setAttribute('target','_blank');
t4 = document.createElement('img');
t4.setAttribute('id','logo');
t4.setAttribute('src','http://www.roligaklipp.se/webmaster/img/logo_button_152x38.gif');
t4.setAttribute('alt','RoligaKlipp.se');

t4.setAttribute('title','RoligaKlipp.se');
t3.appendChild(t4); // img i a
t2.appendChild(t3); // a i div cont

t5 = document.createElement('div');
t5.setAttribute('id','funContInner');

t6 = document.createElement('h4');
t7 = document.createElement('a');
t7.setAttribute('href','http://www.roligaklipp.se/');
t7.setAttribute('target','_blank');
t7.setAttribute('name','funLink');
t7.name = 'funLink';
t7.setAttribute('id','funTitle');
t6.appendChild( t7 ); // a i h4
t5.appendChild( t6 ); // h4 i div

t8 = document.createElement('p');
t9 = document.createElement('a');
t9.setAttribute('target','_blank');
t9.setAttribute('href','http://www.roligaklipp.se/');
t9.setAttribute('name','funLink');

t9b = document.createElement('img');
t9b.setAttribute('id','mainimg');
t9b.setAttribute('src','http://www.roligaklipp.se/webmaster/img/thumb43d2896f80f9300000007.jpg');
t9b.setAttribute('alt','');
t9.appendChild( t9b ); // img i a 
t8.appendChild( t9 ); // a i p
t5.appendChild ( t8 ); // p i div

t10 = document.createElement('p');
t10.setAttribute('id','funDate');
t5.appendChild ( t10 ); // p i divb

t11 = document.createElement('p');
t11.setAttribute('id','funDescription');
t5.appendChild ( t11 ); // p i div
t2.appendChild ( t5 ); // innerdiv i div

t12 = document.createElement('div');
t12.setAttribute('id','nav');

t12b = document.createElement('div');
t12b.setAttribute('id','nav-left');
t13 = document.createElement('img');
t13.setAttribute('alt','Föregående klipp');
t13.setAttribute('title','Föregående klipp');
t13.setAttribute('src','http://www.roligaklipp.se/webmaster/img/Al.gif');
t13.setAttribute('onclick','funLoad(funArr[--funPos]);');
t13.onclick =ie_workaround_down;
t13.onmouseover=change_icon_to_hand;
t13.onmouseout=change_icon_to_normal;

t12b.appendChild ( t13 ); // img i div

t14 = document.createElement('div');
t14.setAttribute('id','nav-right');
t15 = document.createElement('img');
t15.setAttribute('alt','Nästa klipp');
t15.setAttribute('title','Nästa klipp');
t15.setAttribute('src','http://www.roligaklipp.se/webmaster/img/Ar.gif');
t15.setAttribute('onclick','funLoad(funArr[++funPos]);');
t15.onclick =ie_workaround_up;
t15.onmouseover=change_icon_to_hand;
t15.onmouseout=change_icon_to_normal;

t14.appendChild ( t15 ); // img i div

t12.appendChild ( t12b ); // div i div
t12.appendChild ( t14 ); // div i div
t2.appendChild ( t12 ); // div i div

roligaklipp.appendChild(t2);  // div i dokument

//t16 = document.createElement('script');
//alert(javascriptcode);
//t16.appendChild( document.createTextNode(javascriptcode));
//roligaklipp.appendChild(t16); // script i dokument

funLoad(funArr[funPos]);
}