
var currentTitleRow
var currentTitleId;
var currentEpisodeNo;
var currentFilmfile;
var currentTitle;
var currentFilmWidth;
var currentFilmHeight;
var logocontent2;

var filmfile;
var theWidth;
var theHeight;
var autoplay;
var showcontrols;
var loop;
var volume;

function fyllVariabler(filmfile2,theWidth2,theHeight2,autoplay2,showcontrols2,loop2,volume2) {
	filmfile = filmfile2;
	theWidth = theWidth2;
	theHeight = theHeight2;
	autoplay = autoplay2;
	showcontrols = showcontrols2;
	loop = loop2;
	volume = volume2;
}

function showLayout(topic,addToBasket,intro) {
	//alert('addToBasket=' + addToBasket);
	//alert(topic);
	//alert('epi=' + currentEpisodes);
	if (topic == 'Filmarkiv') {
		getCookieAutostart();
		//Hämta kakinfo om rad och id
		var cookieData = document.cookie;
		var startTitleRow = cookieData.indexOf('currentTitleRowSequence=') + 24;
		if (startTitleRow != '23') {
			var endTitleRow = cookieData.indexOf(';',startTitleRow);
			currentTitleRow = cookieData.substring(startTitleRow,endTitleRow);
			currentTitleId = parseInt(document.getElementById(currentTitleRow).getElementsByTagName('div')[0].innerHTML);
			showSequenceInfo(currentTitleRow,currentTitleId, addToBasket);
		}
	} else if (topic == 'Programarkiv') {
		getCookieAutostart();
		//Hämta kakinfo om rad och id
		var cookieData = document.cookie;
		var startTitleRow = cookieData.indexOf('currentTitleRowProgram=') + 23;
		if (startTitleRow != '22') {
			var endTitleRow = cookieData.indexOf(';',startTitleRow);
			currentTitleRow = cookieData.substring(startTitleRow,endTitleRow);
			currentTitleId = parseInt(document.getElementById(currentTitleRow).getElementsByTagName('div')[0].innerHTML);
			var theEpisodes = document.getElementById(currentTitleRow).getElementsByTagName('div')[6].innerHTML;
		}
		//Hämta kakinfo om episod-nr
		var startEpisodeNo = cookieData.indexOf('currentEpisodeNo=') + 17;
		if (startEpisodeNo != '16') {
			var endEpisodeNo = cookieData.indexOf(';',startEpisodeNo);
			currentEpisodeNo = cookieData.substring(startEpisodeNo,endEpisodeNo);
		}
		if (!isNaN(currentEpisodeNo)) {
			showProgramInfo(currentTitleRow,theEpisodes,currentTitleId,currentEpisodeNo, addToBasket);
		} else {
			showProgramInfo(currentTitleRow,theEpisodes,currentTitleId, addToBasket);
		}
	} else if (topic == 'Start') {
		if (intro == 'true') {
			logocontent2 = document.getElementById('logoarea').innerHTML;
			var logocontent = '<div id="bmbtot">' + "\n" + '<div id="bmblogo1">' + "\n" + '<img id="bmblogo1B" src="bmbLogo1.png" width="390" height="158" />' + "\n" + '</div>' + "\n" + '<div id="bmblogo2">' + "\n" + '<img id="bmblogo2B" src="bmbLogo2.png" width="390" height="158" />' + "\n" + '</div>' + "\n" + '<img id="bmbmaskB" src="bmbmask.png" width="390" height="700" />' + "\n" + '</div>';
			document.getElementById('logoarea').innerHTML = logocontent;
			go();
		} else {
			document.getElementById('logoarea').style.top = '0px';
		}
	}
	cashTopicImages();
	document.getElementById('navigation').style.visibility = 'visible';
	/*document.getElementById('footer').style.visibility = 'visible';*/
	document.getElementById('pagecontent').style.visibility = 'visible';
	//document.getElementById('topic1').style.visibility = 'visible';
	//document.getElementById('topic2').style.visibility = 'visible';
	//document.getElementById('topic3').style.visibility = 'visible';
	//document.getElementById('topic4').style.visibility = 'visible';
	//document.getElementById('topic5').style.visibility = 'visible';
	//document.getElementById('topic6').style.visibility = 'visible';
	//document.getElementById('cloud').style.visibility = 'hidden';
	
}
//-----------
function cashTopicImages() {
	var bild1 = new Image();
	var bild2 = new Image();
	var bild3 = new Image();
	var bild4 = new Image();
	var bild5 = new Image();
	var bild6 = new Image();
	var bild7 = new Image();
	var bild8 = new Image();
	var bild9 = new Image();
	var bild10 = new Image();
	
	var bild11 = new Image();
	var bild12 = new Image();
	var bild13 = new Image();
	var bild14 = new Image();
	var bild15 = new Image();
	var bild16 = new Image();
	var bild17 = new Image();
	var bild18 = new Image();
	var bild19 = new Image();
	var bild20 = new Image();
	
	var bild21 = new Image();
	var bild22 = new Image();
	var bild23 = new Image();
	var bild24 = new Image();
	var bild25 = new Image();
	var bild26 = new Image();
	var bild27 = new Image();
	var bild28 = new Image();
	var bild29 = new Image();
	var bild30 = new Image();
	
	var bild31 = new Image();
	var bild32 = new Image();
	var bild33 = new Image();
	var bild34 = new Image();
	var bild35 = new Image();
	var bild36 = new Image();
	var bild37 = new Image();
	var bild38 = new Image();
	var bild39 = new Image();
	var bild40 = new Image();
	
	var bild41 = new Image();
	var bild42 = new Image();
	var bild43 = new Image();
	var bild44 = new Image();
	var bild45 = new Image();
	var bild46 = new Image();
	var bild47 = new Image();
	var bild48 = new Image();
	var bild49 = new Image();
	var bild50 = new Image();
	
	var bild51 = new Image();
	var bild52 = new Image();
	var bild53 = new Image();
	var bild54 = new Image();
	var bild55 = new Image();
	var bild56 = new Image();
	var bild57 = new Image();
	var bild58 = new Image();
	var bild59 = new Image();
	var bild60 = new Image();
	
	var bild61 = new Image();
	var bild62 = new Image();
	var bild63 = new Image();
	var bild64 = new Image();
	var bild65 = new Image();
	var bild66 = new Image();
	var bild67 = new Image();
	var bild68 = new Image();
	var bild69 = new Image();
	var bild70 = new Image();
	
	var bild71 = new Image();
	var bild72 = new Image();
	var bild73 = new Image();
	var bild74 = new Image();
	var bild75 = new Image();
	
	
	bild1.src = "start1.jpg";
	bild2.src = "start2.jpg";
	bild3.src = "start3.jpg";
	bild4.src = "start4.jpg";
	bild5.src = "start5.jpg";
	bild6.src = "start6.jpg";
	bild7.src = "start7.jpg";
	bild8.src = "start8.jpg";
	bild9.src = "start9.jpg";
	bild10.src = "start10.jpg";
	
	bild11.src = "bmbm1.jpg";
	bild12.src = "bmbm2.jpg";
	bild13.src = "bmbm3.jpg";
	bild14.src = "bmbm4.jpg";
	bild15.src = "bmbm5.jpg";
	bild16.src = "bmbm6.jpg";
	bild17.src = "bmbm7.jpg";
	bild18.src = "bmbm8.jpg";
	bild19.src = "bmbm9.jpg";
	bild20.src = "bmbm10.jpg";
	
	bild21.src = "bmba1.jpg";
	bild22.src = "bmba2.jpg";
	bild23.src = "bmba3.jpg";
	bild24.src = "bmba4.jpg";
	bild25.src = "bmba5.jpg";
	bild26.src = "bmba6.jpg";
	bild27.src = "bmba7.jpg";
	bild28.src = "bmba8.jpg";
	bild29.src = "bmba9.jpg";
	bild30.src = "bmba10.jpg";
	
	bild31.src = "film1.jpg";
	bild32.src = "film2.jpg";
	bild33.src = "film3.jpg";
	bild34.src = "film4.jpg";
	bild35.src = "film5.jpg";
	bild36.src = "film6.jpg";
	bild37.src = "film7.jpg";
	bild38.src = "film8.jpg";
	bild39.src = "film9.jpg";
	bild40.src = "film10.jpg";
	
	bild41.src = "prog1.jpg";
	bild42.src = "prog2.jpg";
	bild43.src = "prog3.jpg";
	bild44.src = "prog4.jpg";
	bild45.src = "prog5.jpg";
	bild46.src = "prog6.jpg";
	bild47.src = "prog7.jpg";
	bild48.src = "prog8.jpg";
	bild49.src = "prog9.jpg";
	bild50.src = "prog10.jpg";
	
	bild51.src = "kont1.jpg";
	bild52.src = "kont2.jpg";
	bild53.src = "kont3.jpg";
	bild54.src = "kont4.jpg";
	bild55.src = "kont5.jpg";
	bild56.src = "kont6.jpg";
	bild57.src = "kont7.jpg";
	bild58.src = "kont8.jpg";
	bild59.src = "kont9.jpg";
	bild60.src = "kont10.jpg";
	
	bild61.src = "nyhet1.jpg";
	bild62.src = "nyhet2.jpg";
	bild63.src = "nyhet3.jpg";
	bild64.src = "nyhet4.jpg";
	bild65.src = "nyhet5.jpg";
	bild66.src = "nyhet6.jpg";
	bild67.src = "nyhet7.jpg";
	bild68.src = "nyhet8.jpg";
	bild69.src = "nyhet9.jpg";
	bild70.src = "nyhet10.jpg";

	bild71.src = "bmbmask.png";
	bild72.src = "bmbLogo1.png";
	bild73.src = "bmbLogo2.png";
	bild74.src = "BMB-logo-big.png";
	bild75.src = "BMB-logo-largetrans.png";
}
//-----------
var topicNr;

function showTopics() {
	topicNr = 1;		
	moveId = setInterval('showTopicsGo()',100);
}
//-----------
function showTopicsGo() {
	if (topicNr < 7) {
	var topic = 'topic' + topicNr;	document.getElementById(topic).style.visibility = 'visible';
	topicNr = topicNr + 1;
	} else {
		clearInterval(moveId);
		document.getElementById('cloud').style.visibility = 'hidden';
		document.getElementById('footer').style.visibility = 'visible';
		document.getElementById('pagecontent').style.visibility = 'visible';
	}
}

//-----------
function markTopic(nr,filebase) {
	var theObject = "i" + nr;
	var theContent = filebase + "_p.png";
	document.getElementById(theObject).src = theContent;
}

function unmarkTopic(nr,filebase) {
	var theObject = "i" + nr;
	var theContent = filebase + "_um.png";
	document.getElementById(theObject).src = theContent;
}

function markFilm(theRow) {
	//theRow.style.backgroundColor = '#b3c7f5';
}

function unmarkFilm(theRow) {
	
	//if (theRow.style.color != 'rgb(34, 38, 77)') {
		//theRow.style.backgroundColor = 'transparent';
	//}
	
}
var earlierRow;

function showSequenceInfo(theRow,theTitleId, addToBasket, theWidth, theHeight) {
	currentTitleId = theTitleId;//for the Add to the basket function
	/*Justera bredden på beskrivningsboxen efter filmbredden*/
	document.getElementById('filmdescription').style.width = 760 - theWidth;
	document.cookie = "currentTitleRowSequence=" + theRow;
	if (document.getElementById(earlierRow) != undefined) {
		document.getElementById(earlierRow).style.color = '#363636';
		document.getElementById(earlierRow).style.backgroundColor = 'transparent';
	}
	document.getElementById(theRow).style.color = '#22264d';
	document.getElementById(theRow).style.backgroundColor = '#b3c7f5';
	document.getElementById('filmdescription').innerHTML = document.getElementById(theRow).getElementsByTagName('div')[4].innerHTML;
	var filmfile = 'bmb_nedladdning/S-' + document.getElementById(theRow).getElementsByTagName('div')[5].innerHTML + '_Demo.mov';
	currentFilmfile = filmfile;
	if(filmfile != '' && filmfile != undefined) {
		//document.movie1.SetControllerVisible(true);
		//alert('(visar kontroller): ' + filmcode);
		//document.movie1.SetURL(filmcode);
		if (document.getElementById('autostart').checked && !addToBasket) {
			//alert('autostart');
			//temp = setTimeout('playMovie()',1100);
			getFilm(filmfile,theWidth,theHeight,true,true,false,'100');
		} else {
			getFilm(filmfile,theWidth,theHeight,false,true,false,'100');
		}
	} else {
		//alert('No: ' + filmfile);
		//document.movie1.SetControllerVisible(false);
		//document.movie1.SetURL('filmplaceholder.jpg');
		var filmfile = 'filmplaceholder.jpg';
		getFilm(filmfile,theWidth,theHeight,false,false,false,'100');
	}
	currentFilmWidth = theWidth;
	currentFilmHeight = theHeight;
	earlierRow = theRow;
	document.getElementById('add').disabled = false;
	document.getElementById('download').disabled = false;
}

var currentEpisodes;

function showProgramInfo(theRow,theEpisodes,theTitleId,episodeNo,addToBasket,theWidth,theHeight) {
	//alert('addToBasket2=' + addToBasket);
	currentTitleId = theTitleId;//for the Add to the basket function
	currentEpisodes = theEpisodes;
	currentFilmWidth = theWidth;
	currentFilmHeight = theHeight;
	if(theEpisodes == '') {
		document.getElementById('addAll').disabled = true;
	} else {
		document.getElementById('addAll').disabled = false;
	}
	//Justera bredden på beskrivningsboxen efter filmbredden filmWidth används bara här
	if (theWidth < 361) {
		filmWidth= '361';
	} else {
		filmWidth= theWidth;
	}
	document.getElementById('programdetailstext').style.width = 760 - filmWidth;
	document.cookie = "currentTitleRowProgram=" + theRow;
	if (document.getElementById(earlierRow) != undefined) {
		document.getElementById(earlierRow).style.color = '#363636';
		document.getElementById(earlierRow).style.backgroundColor = 'transparent';
	}
	document.getElementById(theRow).style.color = '#22264d';
	document.getElementById(theRow).style.backgroundColor = '#b3c7f5';
	document.getElementById('programdescription').innerHTML = document.getElementById(theRow).getElementsByTagName('div')[4].innerHTML;
		earlierRow = theRow;
	//get the info for the first episode
	var id = parseInt(document.getElementById(theRow).getElementsByTagName('div')[0].innerHTML);
	//correct the joker's in the string
	//"g" replace all occurances of the search string
	var theRegExp = /\+/g;
	var newText = '\"';
	theEpisodesCorrected = theEpisodes.replace(theRegExp,newText);
	var theRegExp = /#/g;
	var newText = '\'';
	theEpisodesCorrected = theEpisodesCorrected.replace(theRegExp,newText);
	var theRegExp = /&lt;/g;
	var newText = '<';
	theEpisodesCorrected = theEpisodesCorrected.replace(theRegExp,newText);
	var theRegExp = /&gt;/g;
	var newText = '>';
	theEpisodesCorrected = theEpisodesCorrected.replace(theRegExp,newText);
	//place the corrected string in the episode menu
	var basename = document.getElementById(theRow).getElementsByTagName('div')[5].innerHTML;
	theEpisodeTagg = '<b>Välj avsnitt: </b><select id="episodemenu" name="episode" size="1" onchange="showEpisodes(this.options[this.selectedIndex].value,\'' + addToBasket + '\',\'' + theWidth + '\',\'' + theHeight + '\',\'' + basename + '\')">' + "\n" +
	theEpisodesCorrected + "\n" +
	'</select>';
	document.getElementById('episode').innerHTML = theEpisodeTagg;
	var episodesExist=theEpisodesCorrected;
	
	if (episodesExist != '') {
		//it exists episodes
		//alert('programmet har avsnitt');
		document.getElementById('episode').style.display = 'block';
		if (isNaN(episodeNo)) {
			//episodeNo is a number
			//alert('avsnittsparameter medföljer: ' + episodeNo);
showEpisodes(document.getElementById('episodemenu').options[episodeNo-1].value, addToBasket,theWidth,theHeight,basename);
			document.getElementById('episodemenu').options[episodeNo-1].selected = true;
		} else {
			//episodeNo is not a number
			//alert('avsnittsparameter medföljer EJ');
			showEpisodes(document.getElementById('episodemenu').options[0].value, addToBasket,theWidth,theHeight,basename);
		}
		document.getElementById('programdescription').style.height =  '128px';
	} else {
		//it exists no episodes
		//alert('programmet har EJ avsnitt');
		document.getElementById('episodedescription').innerHTML = '';
		document.getElementById('programdescription').style.height =  '277px';
		document.getElementById('episode').style.display = 'none';
		//alert('basename: ' + basename);	
		if (basename != '') {
			//alert('inga episoder');
			//document.movie1.SetControllerVisible(true);
			//document.movie1.SetURL(filmfile);
			var filmfile = 'bmb_nedladdning/P-' + basename + '_Demo.mov';
			if (document.getElementById('autostart').checked && !addToBasket) {
				getFilm(filmfile,theWidth,theHeight,true,true,false,'100');
			} else {
				getFilm(filmfile,theWidth,theHeight,false,true,false,'100');
			}
		} else {
			//alert('inget program');
			//document.movie1.SetControllerVisible(false);
			//document.movie1.SetURL('filmplaceholder.jpg');
			var filmfile = 'filmplaceholder.jpg';
			getFilm(filmfile,theWidth,theHeight,false,false,false,'100');
		}
		currentFilmfile = filmfile;
		currentTitle = document.getElementById(theRow).getElementsByTagName('div')[3].innerHTML;
	}
	document.getElementById('programdescription').scrollTop = '0';
	document.getElementById('add').disabled = false;
	document.getElementById('addAll').disabled = false;
	document.getElementById('download').disabled = false;
}

function getFilm(filmfile,theWidth,theHeight,autoplay,showcontrols,loop,volume) {
	alert(theWidth + ',' + theHeight);
	if (usersip == '81.216.159.1481'){
		var filmcode = 'Bo, du är tillfälligt avstängd från filmvisning!';
	} else {
		var filmcode = '<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"' + "\n" + 'CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab"' + "\n" + 'HEIGHT="' + theHeight + 'px"' + "\n" + 'WIDTH="' + theWidth + 'px"' + "\n" + 'id="movie1">' + "\n" + '<PARAM NAME="src" VALUE="' + filmfile + '" >' + "\n" + '<PARAM NAME="controller" VALUE="' + showcontrols + '" >' + "\n" + '<PARAM NAME="autoplay" VALUE="' + autoplay + '" >' + "\n" + '<PARAM NAME="hspace" VALUE="0px" >' + "\n" + '<PARAM NAME="vspace" VALUE="0px" >' + "\n" + '<PARAM NAME="loop" VALUE="' + loop + '" >' + "\n" + '<PARAM NAME="scale" VALUE="Aspect" >' + "\n" + '<PARAM NAME="volume" VALUE="' + volume + '" >' + "\n" + '<PARAM NAME="kioskmode" VALUE="true" >' + "\n" + '<PARAM NAME="showlogo" VALUE="false" >' + "\n\n" + '<EMBED SRC="' + filmfile + '" HEIGHT="' + theHeight + 'px" WIDTH="' + theWidth + 'px" AUTOSTART=' + autoplay + ' CONTROLLER=' + showcontrols + ' HSPACE="0px" VSPACE="0px" LOOP="' + loop + '" SCALE="Aspect" KIOSKMODE="true" VOLUME="' + volume + '" SHOWLOGO="false" TYPE="video/quicktime" PLUGINSPAGE="http://www.apple.com/quicktime/download/" EnableJavaScript="true" NAME="movie1" />' + "\n\n" + '</OBJECT>';
	}
	document.getElementById('filmarchivemovie').innerHTML=filmcode;
}

function getTrailerfilm() {
	if (usersip == '81.216.159.1481'){
		var filmcode = 'Bo, du är tillfälligt avstängd från filmvisning!';
	} else {
		var filmcode = '<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"' + "\n" + 'CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab"' + "\n" + 'HEIGHT="' + theHeight + 'px"' + "\n" + 'WIDTH="' + theWidth + 'px"' + "\n" + 'id="movie1">' + "\n" + '<PARAM NAME="src" VALUE="' + filmfile + '" >' + "\n" + '<PARAM NAME="controller" VALUE="' + showcontrols + '" >' + "\n" + '<PARAM NAME="autoplay" VALUE="' + autoplay + '" >' + "\n" + '<PARAM NAME="hspace" VALUE="0px" >' + "\n" + '<PARAM NAME="vspace" VALUE="0px" >' + "\n" + '<PARAM NAME="loop" VALUE="' + loop + '" >' + "\n" + '<PARAM NAME="scale" VALUE="Aspect" >' + "\n" + '<PARAM NAME="volume" VALUE="' + volume + '" >' + "\n" + '<PARAM NAME="kioskmode" VALUE="true" >' + "\n" + '<PARAM NAME="showlogo" VALUE="false" >' + "\n\n" + '<EMBED SRC="' + filmfile + '" HEIGHT="' + theHeight + 'px" WIDTH="' + theWidth + 'px" AUTOSTART=' + autoplay + ' CONTROLLER=' + showcontrols + ' HSPACE="0px" VSPACE="0px" LOOP="' + loop + '" SCALE="Aspect" KIOSKMODE="true" VOLUME="' + volume + '" SHOWLOGO="false" TYPE="video/quicktime" PLUGINSPAGE="http://www.apple.com/quicktime/download/" EnableJavaScript="true" NAME="movie1" />' + "\n\n" + '</OBJECT>';
	}
	document.getElementById('filmtrailer').innerHTML=filmcode;
}

function playMovie() {
	document.movie1.Play();
}

function showEpisodes(episodeData, addToBasket, theWidth, theHeight,basename) {
	//alert('showEpisodes körs');
	//alert(episodeData);
	var arrayAsText = "new Array(" + episodeData + ")";
	var episodeDataArray = eval(arrayAsText);
	var theRegExp = /xx/g;
	var newText = ' ';
	document.getElementById('episodedescription').innerHTML = decodeURIComponent(episodeDataArray[0].replace(theRegExp,newText));
	var filmfile = 'bmb_nedladdning/' + episodeDataArray[1];
	currentEpisodeNo = episodeDataArray[2];
	document.cookie = "currentEpisodeNo=" + currentEpisodeNo;
	//alert('filmfile: ' + filmfile);
	if(filmfile != '') {
		//document.movie1.SetControllerVisible(true);
		//document.movie1.SetURL(filmfile);
		//if (document.getElementById('autostart').checked && !addToBasket) {
			//temp = setTimeout('playMovie()',1100);
		//}
		if (document.getElementById('autostart').checked && !addToBasket) {
			getFilm(filmfile,theWidth,theHeight,true,true,false,'100');
		} else {
			getFilm(filmfile,theWidth,theHeight,false,true,false,'100');
		}
		currentTitle = basename + ' - avsnitt ' + currentEpisodeNo;
	} else {
		//document.movie1.SetControllerVisible(false);
		//document.movie1.SetURL('filmplaceholder.jpg');
		var filmfile = 'filmplaceholder.jpg';
		getFilm(filmfile,theWidth,theHeight,false,false,false,'100');
		currentTitle = '';
	}
	currentFilmfile = filmfile;
	document.getElementById('episodedescription').scrollTop = '0';
}
//------------
function  activatePayMethod(type) {
	if (type == 'online download') {
		/*KORTBETALNING NEDLADDNING*/
		document.getElementById('cardtype').style.visibility = 'visible';
		document.getElementById('cardnumber').style.visibility = 'visible';
		document.getElementById('expiredate').style.visibility = 'visible';
		document.getElementById('cardowner').style.visibility = 'visible';
		document.getElementById('aPaymethod').innerHTML = '*';
		document.getElementById('aCardtype').innerHTML = '*';
		document.getElementById('aCardnumber').innerHTML = '*';
		document.getElementById('aSecuritycode').innerHTML = '*';
		document.getElementById('aExpiredate').innerHTML = '*';
		document.getElementById('aCardowner').innerHTML = '*';
		document.getElementById('aFirstname').innerHTML = '*';
		document.getElementById('aLastname').innerHTML = '*';
		document.getElementById('aCompany').innerHTML = '&emsp;';
		document.getElementById('aAddress').innerHTML = '&emsp;';
		document.getElementById('aZipcode').innerHTML = '&emsp;';
		document.getElementById('aCity').innerHTML = '&emsp;';
		document.getElementById('aEmail').innerHTML = '&emsp;';
		document.getElementById('aTelephone').innerHTML = '*';
	} else if (type == 'online post') {
		/*KORTBETALNING POSTGÅNG*/
		document.getElementById('cardtype').style.visibility = 'visible';
		document.getElementById('cardnumber').style.visibility = 'visible';
		document.getElementById('expiredate').style.visibility = 'visible';
		document.getElementById('cardowner').style.visibility = 'visible';
		document.getElementById('aPaymethod').innerHTML = '*';
		document.getElementById('aCardtype').innerHTML = '*';
		document.getElementById('aCardnumber').innerHTML = '*';
		document.getElementById('aSecuritycode').innerHTML = '*';
		document.getElementById('aExpiredate').innerHTML = '*';
		document.getElementById('aCardowner').innerHTML = '*';
		document.getElementById('aFirstname').innerHTML = '*';
		document.getElementById('aLastname').innerHTML = '*';
		document.getElementById('aCompany').innerHTML = '&emsp;';
		document.getElementById('aAddress').innerHTML = '*';
		document.getElementById('aZipcode').innerHTML = '*';
		document.getElementById('aCity').innerHTML = '*';
		document.getElementById('aEmail').innerHTML = '&emsp;';
		document.getElementById('aTelephone').innerHTML = '*';

	} else {
		
		/*POSTFÖRSKOTT*/
		document.getElementById('cardtype').style.visibility = 'hidden';
		document.getElementById('cardnumber').style.visibility = 'hidden';
		document.getElementById('expiredate').style.visibility = 'hidden';
		document.getElementById('cardowner').style.visibility = 'hidden';
		document.getElementById('aPaymethod').innerHTML = '*';
		document.getElementById('aCardtype').innerHTML = '&emsp;';
		document.getElementById('aCardnumber').innerHTML = '&emsp;';
		document.getElementById('aSecuritycode').innerHTML = '&emsp;';
		document.getElementById('aExpiredate').innerHTML = '&emsp;';
		document.getElementById('aCardowner').innerHTML = '&emsp;';
		document.getElementById('aFirstname').innerHTML = '*';
		document.getElementById('aLastname').innerHTML = '*';
		document.getElementById('aCompany').innerHTML = '&emsp;';
		document.getElementById('aAddress').innerHTML = '*';
		document.getElementById('aZipcode').innerHTML = '*';
		document.getElementById('aCity').innerHTML = '*';
		document.getElementById('aEmail').innerHTML = '&emsp;';
		document.getElementById('aTelephone').innerHTML = '&emsp;';
	}
}
//------------

function markCardtype(myself,type) {
	if (type == 'Mastercard') {
		document.getElementsByName('cardtype')[0].checked = true;
		myself.style.borderColor = '22264d';
		myself.nextSibling.style.borderColor = 'white';
	} else {
		document.getElementsByName('cardtype')[1].checked = true;
		myself.style.borderColor = '22264d';
		myself.previousSibling.style.borderColor = 'white';
	}
}
//-------------
function markCardtypeImage(type) {
	if (type == 'Mastercard') {
		document.getElementById('cardtype').getElementsByTagName('img')[0].style.borderColor = '#22264d';
		document.getElementById('cardtype').getElementsByTagName('img')[1].style.borderColor = 'white';
	} else {
		document.getElementById('cardtype').getElementsByTagName('img')[1].style.borderColor = '#22264d';
		document.getElementById('cardtype').getElementsByTagName('img')[0].style.borderColor = 'white';
	}
}
//-------------
function sortTitles(senderPage, topic, sortcolumn) {
 window.location.href= senderPage + "?topic=" + topic + "&sortcolumn=" + sortcolumn;
}
//---------------
function addToBasket(currentTitleId, senderPage, currentEpisodeNo, searchstring, searchtype, searchfield, category, topic, sortcolumn) {
	var antalVaror = document.getElementById(earlierRow).getElementsByTagName('div')[6].innerHTML;
	if (senderPage == 'bmb_filmarkiv.php' && antalVaror > 0) {
		alert('Du kan bara beställa ett exemplar av en sekvens!');
	} else {
		window.location.href="bmb_adderavara.php?titleId=" + currentTitleId + "&senderPage=" + senderPage + "&episodeNo=" + currentEpisodeNo + "&searchstring=" + searchstring + "&searchtype=" + searchtype + "&searchfield=" + searchfield + "&category=" + category + "&topic=" + topic + "&sortcolumn=" + sortcolumn;
	}
}

//-----------
function downloadDemo(typ) {
	var filenameShort = document.getElementById(earlierRow).getElementsByTagName('div')[3].innerHTML;
	var legalFilenameShort = getFilebase(filenameShort);
	if (typ == 'program') {
		if (currentEpisodeNo == undefined) {
			var filenameLong = "bmb_nedladdning/P-" + legalFilenameShort + "_NDemo.mov.zip";
		} else {
			var filenameLong = "bmb_nedladdning/P-" + legalFilenameShort + "-avsnitt_" + currentEpisodeNo + "_NDemo.mov.zip";
		}
	} else {
		var filenameLong = "bmb_nedladdning/S-" + legalFilenameShort + "_NDemo.mov.zip";
	}
	var newWind = window.open("bmb_nedladdningdemo.php?filename=" + filenameLong + "&title=" + filenameShort,"subwindow","width=300,height=150,resizable=no,menubar=no,location=no,minimizable=no,modal=yes,top=100,left=400,status=no,toolbar=no,chrome=no,alwaysRaised=yes,titlebar=no");
	setTimeout("closeWindow(newWind)",10);
}

function closeWindow(newWind) {
	newWind.close();
}
//----------
function makeDownload(theRow, username, orderProductId, theTitle) {
	if (theRow.style.color == 'rgb(163, 177, 219)') {
		alert('Titeln är redan nedladdad och kan inte laddas ned fler gånger. Om det uppstod något fel vid nedladdningen, kontakta BMB Mediaproduktion AB.');
	} else {
		theRow.style.color = '#a3b1db';
		var theURL = 'skript/bmb_laddanedfil.php?username=' + username + '&orderproductid=' + orderProductId + '&title=' + theTitle;
		window.location.href= theURL;
	}
}
//-----------
	
function getFilebase(name) {
	var nameLegal = encodeURIComponent(name);
	var searchChar = /.20/g;
	nameLegal = nameLegal.replace(searchChar,"_");
	searchChar = /\%/g;
	nameLegal = nameLegal.replace(searchChar,".");
	/*var legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-.";
	var nameLegal = '';
	var currentChar;
	for (i=0; i < name.length; i++) {
		currentChar = name.substr(i,1);
		if (currentChar == ' ') {
			nameLegal = nameLegal + '_';
		} else {
			if (legalChars.indexOf(currentChar)!= -1) {
				nameLegal = nameLegal + currentChar;
			}
		}
	}*/
	return nameLegal;
}

//-----------
function markTitle(theRow) {
	//theRow.style.backgroundColor = '#b3c7f5';
}
//-----------
function unmarkTitle(theRow) {
	
	//if (theRow.style.color != 'rgb(34, 38, 77)') {
		//theRow.style.backgroundColor = 'transparent';
	//}
	
}
//-------------
var currentTitleType,currentAmount

function showTitleInfo(theRow, theTitleId, theEpisodeNo, theTitleType, theAmount) {
	currentTitleId = theTitleId;//for the Delete from the basket function
	currentEpisodeNo = theEpisodeNo;//for the Delete from the basket function
	currentTitleType = theTitleType;//for the Delete from the basket function
	currentAmount = theAmount;//for the ChangeBasket function
	if (earlierRow != undefined) {
		earlierRow.style.color = '#363636';
		earlierRow.style.backgroundColor = 'transparent';
	}
	theRow.style.color = '#22264d';
	theRow.style.backgroundColor = '#b3c7f5';
	earlierRow = theRow;
	document.getElementById('titleId').value = theTitleId;
	document.getElementById('episodeNo').value = theEpisodeNo;
	document.getElementById('titleType').value = theTitleType;
	document.getElementById('editAmount').value = theAmount;
	document.getElementById('cleartitle').disabled = false;
	document.getElementById('editAmount').disabled = false;
	document.getElementById('spara').disabled = false;
}
//--------------
function deleteFromBasket(currentTitleId,currentEpisodeNo,currentTitleType) {
		window.location.href="bmb_subtraheravara.php?titleId=" + currentTitleId + "&episodeNo=" + currentEpisodeNo + "&titleType=" + currentTitleType; 
}
//--------------
function checkCardnumberValue(evt) {
	theChar = String.fromCharCode(evt.which);
	if (!isNaN(theChar)) {
		return true;
	} else {
		alert('Kortnummer består enbart av siffror!');
		return false;
	}
}
//--------------
function checkSecuritynumberValue(evt, theValue) {
	theChar = String.fromCharCode(evt.which);
	theValueString = theValue.value;
	if (!isNaN(theChar)) {
		if (theValueString.length < 3) {
			return true;
		} else {
			alert('Säkerhetsnummer består av högst 3 siffror!');
			return false;
		}
	} else {
		alert('Säkerhetsnummer består enbart av siffror!');
		return false;
	}
}
//-------------
function checkRecords() {
	//Återställer färg på rubriker
	document.getElementById('paymethod').getElementsByTagName('label')[0].style.color = '#363636';
	document.getElementById('cardtype').getElementsByTagName('label')[0].style.color = '#363636';
	document.getElementById('cardnumber').getElementsByTagName('label')[1].style.color = '#363636';
	document.getElementById('expiredate').getElementsByTagName('label')[0].style.color = '#363636';
	document.getElementById('cardowner').getElementsByTagName('label')[0].style.color = '#363636';
	document.getElementById('basketpaymentcolumn3').getElementsByTagName('label')[7].style.color = '#363636';
	document.getElementById('basketpaymentcolumn3').getElementsByTagName('label')[3].style.color = '#363636';
	document.getElementById('basketpaymentcolumn3').getElementsByTagName('label')[4].style.color = '#363636';
	document.getElementById('basketpaymentcolumn3').getElementsByTagName('label')[5].style.color = '#363636';
	document.getElementById('basketpaymentcolumn3').getElementsByTagName('label')[0].style.color = '#363636';
	document.getElementById('basketpaymentcolumn3').getElementsByTagName('label')[1].style.color = '#363636';
	
	if (document.forms[0].paymethod[0].checked == false && document.forms[0].paymethod[1].checked == false) {
		alert('Du måste välja ett betalningssätt!');
		document.getElementById('paymethod').getElementsByTagName('label')[0].style.color = 'red';
		return false;	
	}
	
	if (document.forms[0].paymethod[0].checked == true) {
		var paymethod = document.forms[0].paymethod[0].value
	} else {
		var paymethod = document.forms[0].paymethod[1].value
	}
	//alert(paymethod);
	if (paymethod == 'kortbetalning') {
		
		if (document.forms[0].cardtype[0].checked == false && document.forms[0].cardtype[1].checked == false) {
			alert('Du måste välja en korttyp!');
			document.getElementById('cardtype').getElementsByTagName('label')[0].style.color = 'red';
			return false;	
		}
	
		if (document.forms[0].cardnumber.value == '') {
			alert('Du måste ange kortnumret!');
			document.getElementById('cardnumber').getElementsByTagName('label')[0].style.color = 'red';
			return false;	
		}
	
		if (document.forms[0].securitycode.value == '') {
			alert('Du måste ange säkerhetskoden!');
			document.getElementById('cardnumber').getElementsByTagName('label')[1].style.color = 'red';
			return false;	
		}
		
		if (document.forms[0].securitycode.value.length < 3) {
			alert('Säkerhetskoden skall bestå av 3 siffror!');
			document.getElementById('cardnumber').getElementsByTagName('label')[1].style.color = 'red';
			return false;	
		}
	
		var expiredate = false;
		//Hoppar över det tomma menyvärdet
		for (var i=1;i < 5; i++) {
			if (document.forms[0].expireyear.options[i].selected == true) {
				expiredate = true;
			}
		}
		if (expiredate == false) {
			alert('Du måste ange kortets utgångsår!');
			document.getElementById('expiredate').getElementsByTagName('label')[0].style.color = 'red';
			return false;	
		}
	
		var expiredate = false;
		//Hoppar över det tomma menyvärdet
		for (var i=1;i < 13; i++) {
			if (document.forms[0].expiremonth.options[i].selected == true) {
				expiredate = true;
			}
		}
		if (expiredate == false) {
			alert('Du måste ange kortets utgångsmånad!');
			document.getElementById('expiredate').getElementsByTagName('label')[0].style.color = 'red';
			return false;	
		}
	
		if (document.forms[0].cardowner.value == '') {
			alert('Du måste ange namnet på kortets ägare!');
			document.getElementById('cardowner').getElementsByTagName('label')[0].style.color = 'red';
			return false;	
		}
		
		if (document.forms[0].telephone.value == '') {
			alert('Du måste ange ett telefonnummer!');
			document.getElementById('basketpaymentcolumn3').getElementsByTagName('label')[7].style.color = 'red';
			return false;	
		}

	
	} else {
		//alert('post');
		if (document.forms[0].address.value == '') {
			alert('Du måste ange en adress!');
			document.getElementById('basketpaymentcolumn3').getElementsByTagName('label')[3].style.color = 'red';
			return false;		
		}

		if (document.forms[0].zipcode.value == '') {
			alert('Du måste ange ett postnummer!');
			document.getElementById('basketpaymentcolumn3').getElementsByTagName('label')[4].style.color = 'red';
			return false;		
		}

		if (document.forms[0].city.value == '') {
			alert('Du måste ange en postadress!');
			document.getElementById('basketpaymentcolumn3').getElementsByTagName('label')[5].style.color = 'red';
			return false;		
		}
	
	}
	
	//alert('övrigt');
	if (document.forms[0].firstname.value == '') {
		alert('Du måste ange ett förnamn!');
		document.getElementById('basketpaymentcolumn3').getElementsByTagName('label')[0].style.color = 'red';
		return false;		
	}
	
	if (document.forms[0].lastname.value == '') {
		alert('Du måste ange ett efternamn!');	
		document.getElementById('basketpaymentcolumn3').getElementsByTagName('label')[1].style.color = 'red';
		return false;	
	}
	return true;
}
//------------

var currentAutostart;

function getCookieAutostart() {
	//Hämta autostart från kaka
	var cookieData = document.cookie;
	var startAutostart = cookieData.indexOf('autostart=') + 10;
	if (startAutostart != '9') {
		var endAutostart = cookieData.indexOf(';',startAutostart);
		currentAutostart = cookieData.substring(startAutostart,endAutostart);
		//sätter explicit då "false" into blir false
		if (currentAutostart == 'false') {
			//alert('false ' + currentAutostart);
			document.getElementsByName('autostart')[0].checked = false;
		} else {
			//alert('true ' + currentAutostart);
			document.getElementsByName('autostart')[0].checked = true;
		}	
	}
}
//------------

function setCookieAutostart() {
	//Spara autostart i kaka
		if (document.getElementsByName('autostart')[0].checked == true) {
		currentAutostart = true;
		document.cookie = "autostart=true";
	} else {
		currentAutostart = false;
		document.cookie = "autostart=false";
	}
}
//----------
function changeLoudness(movieName) {
	if (movieName ==  undefined) {
		movieName = '1';
	}
	var totalMovieName = 'movie' + movieName;
	var longfile = document.getElementById(movieName).src;
	var startChar = longfile.indexOf('speaker_off.jpg');
	var shortfile = longfile.substr(startChar,longfile.length)
	if (shortfile == "speaker_off.jpg") {
		document.getElementById(movieName).src = "speaker_on.jpg";
		document.getElementsByName(totalMovieName)[0].SetVolume(50);
		
	} else {
		document.getElementById(movieName).src = "speaker_off.jpg";
		document.getElementsByName(totalMovieName)[0].SetVolume(0);
	}
}
//-----------
function checkUsername(username) {
	if (username != '') {
		return true;
	} else {
		alert('Du måste logga in för att kunna se dina titlar.');
		return false;
	}
}
//-----------
function checkAmountvalue() {
	var antalVaror = document.getElementById('editAmount').value;
	var typ = document.getElementById('titleType').value;
	if (isNaN(antalVaror) || antalVaror == '') {
		alert('Antalet måste vara ett nummer!');
		return false;
	} else if (typ == 'film' && antalVaror > 1) {
		alert('Du kan bara beställa ett exemplar av en sekvens!');
		return false;
	} else {
		return true;
	}
}
//----------
function biggerPictF(pictfile,aspect,descriptionF) {
	//alert(descriptionF);
	var theWidth = Math.round(aspect * 200);
	if (pictfile != '') {
		var theTag = '<img src="' + pictfile + '" width=' + theWidth + ' height=200 /><div style="font-size: 11px;width: ' + theWidth + 'px">' + decodeURIComponent(descriptionF) + '</div>';
		//alert(theTag);
		document.getElementById('refpictFilm').innerHTML = theTag;
			document.getElementById('refpictFilm').style.visibility = 'visible';
	} else {
		document.getElementById('refpictFilm').innerHTML = '';
			document.getElementById('refpictFilm').style.visibility = 'hidden';
	}
}

function smallerPictF() {
	document.getElementById('refpictFilm').innerHTML = '';
	document.getElementById('refpictFilm').style.visibility = 'hidden';
}

function biggerPictP(pictfile,aspect) {
	var theWidth = Math.round(aspect * 200);
	//alert(theWidth);
	if (pictfile != '') {
		var theTag = '<img src="' + pictfile + '" width=' + theWidth + ' height=200 />';
		//alert(theTag);
		document.getElementById('refpictProgram').innerHTML = theTag;
			document.getElementById('refpictProgram').style.visibility = 'visible';
	} else {
		document.getElementById('refpictProgram').innerHTML = '';
			document.getElementById('refpictProgram').style.visibility = 'hidden';
	}
}

function smallerPictP() {
	document.getElementById('refpictProgram').innerHTML = '';
	document.getElementById('refpictProgram').style.visibility = 'hidden';
}

//----------
function test(ordet) {
	//alert(ordet);
}
//----------
function checkUser(evt,topic,nr,filebase) {
	//evt = (evt) ? window.evt : ((event) ? window.event : null);

		if (filebase == 'programarkiv') {
			filebase = 'prog';
		} else {
			filebase = 'film';
		}
		var topicName = 'topic' + nr;
		var theFile = filebase + '1.jpg';
		var theTag = '<img src="' + theFile + '" />';
		document.getElementById(topicName).innerHTML = theTag;
		document.getElementById('dialogtext').innerHTML = 'Menyvalet ' + topic + ' är ej tillgängligt än. Vi öppnar under våren 2012.';
		if (topic=='Filmklipp') {
			document.getElementById('hiddenDialog').style.top = '250px';
		} else {
			document.getElementById('hiddenDialog').style.top = '282px';
		}
		document.getElementById('hiddenDialog').style.visibility = 'visible';
		dialoggrowinit();
		return false;
	
}
//----------
var nyaFonstret,currentFilmtime;

function showLargeFilm() {
	if (currentFilmfile != undefined) {
		var theFile = '../bmb_storfilm.php?filmfile=' + currentFilmfile + '&title=' + currentTitle + '&theWidth=' + currentFilmWidth * 2 + '&theHeight=' + currentFilmHeight * 2;
		var theProperties = 'height=' + eval((currentFilmHeight * 2) + 10) + ',width=' + eval((currentFilmWidth * 2) + 10) + ',toolbar=no,menubar=no,chrome=no,location=no,status=no,personalBar=no';
		document.movie1.Stop();
		currentFilmtime = document.movie1.GetTime();
		nyaFonstret = window.open(theFile,'storfilm',theProperties);
		setTimeout("spelaStorfilm()",1000);
		return true;
	} else {
		alert('Du måste välja en film först!');
		return false;
	}
}
//---------
function spelaStorfilm() {
	nyaFonstret.document.movie1.SetTime(currentFilmtime);
	nyaFonstret.document.movie1.Play();
}
//---------
function checkQT(topic,filmfile,width,height,autoplay,showcontrols,loop,volume) {
	//alert(topic+filmfile+width+height+autoplay+showcontrols+loop+volume);
	//alert(showcontrols);
	if (usersip == '81.216.159.1481') {
		//Bo Landgrens IP
		if (haveqt == false) {
			if (topic == 'Start') {
				document.getElementById('feltext').innerHTML = '<div><p>En insticksmodul till Bos webbläsare  saknas i din dator!</p><p><a href="http://www.apple.com/se/quicktime/download/" title="www.apple.com/se/quicktime/download" target="_blank"><img src="QT-logo_liten.png" style="border-style: none" /><br/>Ladda ned QuickTime-tillägget</a></p></div>';
				if (platform == 'Windows') {
					var filmfileWin = filmfile.substring(0,filmfile.length - 4) + '.wmv';
					var filmcode = '<OBJECT CLASSID="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6" id="player" width="' + width + '" height="' + height + '"><param name="url" value="' + filmfileWin + '"><param name="autostart" value="' + autoplay + '"><param name="showcontrols" value="' + showcontrols + '"><embed type="application/x-mplayer2" id="MediaPlayer" src="' + filmfileWin + '" width="' + width + '" height="' + height + '" autostart="' + autoplay + '" showcontrols="' + showcontrols + '" />';
					document.getElementById('filmtrailer').innerHTML = filmcode;
				}
			}
		} else {
			if (topic == 'Start') {
				
			}
		}

	} else {
		if (haveqt == false) {
			if (topic == 'Start') {
				document.getElementById('feltext').innerHTML = '<div><p>En insticksmodul till Bos webbläsare  saknas i din dator!</p><p><a href="http://www.apple.com/se/quicktime/download/" title="www.apple.com/se/quicktime/download" target="_blank"><img src="QT-logo_liten.png" style="border-style: none" /><br/>Ladda ned QuickTime-tillägget</a></p></div>';
				if (platform == 'Windows') {
					var filmfileWin = filmfile.substring(0,filmfile.length - 4) + '.wmv';
					/*var filmcode = '<OBJECT CLASSID="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6" id="player" width="' + width + '" height="' + height + '"><param name="url" value="' + filmfileWin + '"><param name="autostart" value="' + autoplay + '"><param name="showcontrols" value="' + showcontrols + '"><embed type="application/x-mplayer2" id="MediaPlayer" src="' + filmfileWin + '" width="' + width + '" height="' + height + '" autostart="' + autoplay + '" showcontrols="' + showcontrols + '" />';*/
					var filmfileWin = filmfile.substring(0,filmfile.length - 4) + '.wmv';
					var filmcode = '<object type="video/x-ms-wmv" data="bmb_nedladdning/TRAILER_091002_Trailer.wmv" width="500px" height="345px">' + "\n" + '<param name="src" value="bmb_nedladdning/TRAILER_091002_Trailer.wmv" />' + "\n" + '<param name="autostart" value="true">' + "\n" + '<param name="loop" value="true">' + "\n" + '<param name="showcontrols" value="false">' + "\n" + '</object>';
					document.getElementById('filmtrailer').innerHTML = filmcode;
				}
			}
		} else {
			if (topic == 'Start') {
				
			}
		}
	}
}
//------LOGOTYPANIMATION
var move1Id;
var i;
var move2Id;
var n;
var moveMId;
var m;
var nedIntroId;
var f;

function go() {
	document.getElementById('logoarea').style.top = '0px';
	document.getElementById('bmblogo1B').style.top = '0px';
	i=158;
	n=-158;
	m=-316;
	move1Id = setInterval("move1()",10);
	move2Id = setInterval("move2()",10);
	moveMId = setInterval("moveM()",1);
}

function move1() {
	if (i > 0) {
		i--;
		document.getElementById('bmblogo1B').style.top = i + 'px';
	} else {
		clearInterval(move1Id);
		var introfilmId = setTimeout(visaIntrofilm,1000);
	}
}

function move2() {
	if (n < 0) {
		n++;
		document.getElementById('bmblogo2B').style.top = n + 'px';
	} else {
		clearInterval(move2Id);
	}
}

function moveM() {
	if (m > -900) {
		m=m-3;
		document.getElementById('bmbmaskB').style.top = m + 'px';
	} else {
		clearInterval(moveMId);
	}
}

function visaIntrofilm() {
	f = 100;
	nedIntroId = setInterval("tonaNedIntrofilm()",1);
}

function tonaNedIntrofilm() {
	if (f > 0) {
		f = f - 2;
		document.getElementById('logoarea').style.opacity = (f * 0.01);
	} else {
		clearInterval(nedIntroId);
		document.getElementById('logoarea').style.opacity = 0;
		document.getElementById('logoarea').innerHTML = logocontent2;
		//document.getElementById('logoarea').style.opacity = 1;
		f = 0;
		nedIntroId = setInterval("tonaUppIntrofilm()",1);
	}
}

function tonaUppIntrofilm() {
	if (f < 100) {
		f = f + 2;
		document.getElementById('logoarea').style.opacity = (f * 0.01);
	} else {
		clearInterval(nedIntroId);
		document.getElementById('logoarea').style.opacity = 1;
		getTrailerfilm();
	}
}

var topicColorId1,topicColorId2, topicColorId3, topicColorId4, topicColorId5, topicColorId6, topicColorId8, forceColorId;
var gNr, gOldNr, gStatus, gFilebase;

function topicColor(theTopic,nr,filebase) {
	
			
	if ((gStatus != 'true') && (nr != gNr)) {
		//alert('gStatus=' + gStatus + ' nr=' + nr + ' gNr=' + gNr);
		gFilebase = filebase;
		gNr = nr;
		var topicName = 'topic' + gNr;
		//var theNo = parseInt(document.getElementById(topicName).firstChild.src.substr(-5,1));
		var theNo = parseInt(document.getElementById(topicName).firstChild.src.charAt(document.getElementById(topicName).firstChild.src.length-5));
		//alert('gStatus=' + gStatus + ' gNr=' + gNr + ' nr=' + nr + ' theNo=' + theNo + ' theTopic=' + theTopic);

		//alert('återställ');
		clearInterval(topicColorId1);
		clearInterval(topicColorId2);
		clearInterval(topicColorId3);
		clearInterval(topicColorId4);
		clearInterval(topicColorId5);
		clearInterval(topicColorId6);
		clearInterval(topicColorId8);
		if (parseInt(document.getElementById('topic1').firstChild.src.charAt(document.getElementById('topic1').firstChild.src.length-5)) != 0) {
			document.getElementById('topic1').innerHTML = '<img src="start1.jpg" />';
		}
		if (parseInt(document.getElementById('topic2').firstChild.src.charAt(document.getElementById('topic2').firstChild.src.length-5)) != 0) {
			document.getElementById('topic2').innerHTML = '<img src="bmbm1.jpg" />';
		}
		if (parseInt(document.getElementById('topic3').firstChild.src.charAt(document.getElementById('topic3').firstChild.src.length-5)) != 0) {
			document.getElementById('topic3').innerHTML = '<img src="bmba1.jpg" />';
		}
		if (parseInt(document.getElementById('topic4').firstChild.src.charAt(document.getElementById('topic4').firstChild.src.length-5)) != 0) {
			document.getElementById('topic4').innerHTML = '<img src="film1.jpg" />';
		}
		if (parseInt(document.getElementById('topic5').firstChild.src.charAt(document.getElementById('topic5').firstChild.src.length-5)) != 0) {
			document.getElementById('topic5').innerHTML = '<img src="prog1.jpg" />';
		}
		if (parseInt(document.getElementById('topic6').firstChild.src.charAt(document.getElementById('topic6').firstChild.src.length-5)) != 0) {
			document.getElementById('topic6').innerHTML = '<img src="kont1.jpg" />';
		}
		if (parseInt(document.getElementById('topic8').firstChild.src.charAt(document.getElementById('topic8').firstChild.src.length-5)) != 0) {
			document.getElementById('topic8').innerHTML = '<img src="nyhet1.jpg" />';
		}
		
		gStatus = 'true';
		gOldNr = gNr;
		
		
		//alert(' theTopic=' + theTopic);
		if (theNo != 0) {
			//alert('markera');
			switch (theTopic) {
				case 'Start':
				//alert('kör start');
				//alert('nrNu=' + nr);
					topicColorId1 = setInterval(topicColorize,80,nr,filebase);
				break;
				case 'Om BMB Media':
					topicColorId2 = setInterval(topicColorize,80,nr,filebase);
				break;
				case 'Om BMBs arkiv':
					topicColorId3 = setInterval(topicColorize,80,nr,filebase);
				break;
				case 'Filmklipp':
					topicColorId4 = setInterval(topicColorize,80,nr,filebase);
				break;
				case 'Program':
					topicColorId5 = setInterval(topicColorize,80,nr,filebase);
				break;
				case 'Kontakt':
					topicColorId6 = setInterval(topicColorize,80,nr,filebase);
				break;
				case 'Nyheter':
					topicColorId8 = setInterval(topicColorize,80,nr,filebase);
				break;
			}
		//forceColorId = setTimeout(topicUncolorForce,5000);
		} else {
			gStatus = 'false';
		}
	}
}

function topicColorize(nr,filebase) {
	
	var topicName = 'topic' + gNr;
	var theNo = parseInt(document.getElementById(topicName).firstChild.src.charAt(document.getElementById(topicName).firstChild.src.length-5));
	//alert('theNo=' + theNo);
	theNo++;
	
	var theFile= gFilebase + theNo + '.jpg';
	var theTag = '<img src="' + theFile + '" />';
	var theTagId = 'topic' + gNr;
	document.getElementById(theTagId).innerHTML = theTag;
	if (theNo > 7) {
		switch (gNr) {
			case 1:
				clearInterval(topicColorId1);
			break;
			case 2:
				clearInterval(topicColorId2);
			break;
			case 3:
				clearInterval(topicColorId3);
			break;
			case 4:
				clearInterval(topicColorId4);
			break;
			case 5:
				clearInterval(topicColorId5);
			break;
			case 6:
				clearInterval(topicColorId6);
			break;
			case 8:
				clearInterval(topicColorId8);
			break;
		}
		gStatus = 'false';
	}
}

function topicUncolor(theTopic,nr,filebase) {
	//
	clearInterval(topicColorId1);
		clearInterval(topicColorId2);
		clearInterval(topicColorId3);
		clearInterval(topicColorId4);
		clearInterval(topicColorId5);
		clearInterval(topicColorId6);
		clearInterval(topicColorId8);
		if (parseInt(document.getElementById('topic1').firstChild.src.charAt(document.getElementById('topic1').firstChild.src.length-5)) != 0) {
			document.getElementById('topic1').innerHTML = '<img src="start1.jpg" />';
		}
		if (parseInt(document.getElementById('topic2').firstChild.src.charAt(document.getElementById('topic2').firstChild.src.length-5)) != 0) {
			document.getElementById('topic2').innerHTML = '<img src="bmbm1.jpg" />';
		}
		if (parseInt(document.getElementById('topic3').firstChild.src.charAt(document.getElementById('topic3').firstChild.src.length-5)) != 0) {
			document.getElementById('topic3').innerHTML = '<img src="bmba1.jpg" />';
		}
		if (parseInt(document.getElementById('topic4').firstChild.src.charAt(document.getElementById('topic4').firstChild.src.length-5)) != 0) {
			document.getElementById('topic4').innerHTML = '<img src="film1.jpg" />';
		}
		if (parseInt(document.getElementById('topic5').firstChild.src.charAt(document.getElementById('topic5').firstChild.src.length-5)) != 0) {
			document.getElementById('topic5').innerHTML = '<img src="prog1.jpg" />';
		}
		if (parseInt(document.getElementById('topic6').firstChild.src.charAt(document.getElementById('topic6').firstChild.src.length-5)) != 0) {
			document.getElementById('topic6').innerHTML = '<img src="kont1.jpg" />';
		}
		if (parseInt(document.getElementById('topic8').firstChild.src.charAt(document.getElementById('topic8').firstChild.src.length-5)) != 0) {
			document.getElementById('topic8').innerHTML = '<img src="nyhet1.jpg" />';
		}
		
		gStatus = 'false';
		gNr = 0;


	if ((gStatus == 'false') && (gNr != gOldNr)) {
		/*alert('UT');
		gFilebase = filebase;
		gNr = nr;
		var topicName = 'topic' + gNr;
		var theNo = parseInt(document.getElementById(topicName).firstChild.src.charAt(document.getElementById(topicName).firstChild.src.length-5));
		if (theNo > 7) {
			switch (theTopic) {
				case 'Start':
					clearInterval(topicColorId1);
					topicColorId1 = setInterval(topicUncolorize,80,nr,filebase,false);
				break;
				case 'Om BMB Media':
					clearInterval(topicColorId2);
					topicColorId2 = setInterval(topicUncolorize,80,nr,filebase,false);
				break;
				case 'Om BMBs arkiv':
					clearInterval(topicColorId3);
					topicColorId3 = setInterval(topicUncolorize,80,nr,filebase,false);
				break;
				case 'Filmklipp':
					clearInterval(topicColorId4);
					topicColorId4 = setInterval(topicUncolorize,80,nr,filebase,false);
				break;
				case 'Program':
					clearInterval(topicColorId5);
					topicColorId5 = setInterval(topicUncolorize,80,nr,filebase,false);
				break;
				case 'Kontakt':
					clearInterval(topicColorId6);
					topicColorId6 = setInterval(topicUncolorize,80,nr,filebase,false);
				break;
				case 'Nyheter':
					clearInterval(topicColorId8);
					topicColorId8 = setInterval(topicUncolorize,80,nr,filebase,false);
				break;
			}
		}*/
	}
}

function topicUncolorForce() {
	//alert('force');
	
	var topicName = 'topic' + gNr;
	var theNo = parseInt(document.getElementById(topicName).firstChild.src.charAt(document.getElementById(topicName).firstChild.src.length-5));
	//alert(document.getElementById(topicName).innerHTML);
	//alert(theNo + ' ' + gNr);
	//alert(gOldNr + ' ' + theNo);
	if((theNo > 1) && (theNo != 0)) {
		switch (gNr) {
			case 1:
				document.getElementById('topic1').innerHTML = '<img src="start1.jpg" />';
			break;
			case 2:
				document.getElementById('topic2').innerHTML = '<img src="bmbm1.jpg" />';
			break;
			case 3:
				document.getElementById('topic3').innerHTML = '<img src="bmba1.jpg" />';
			break;
			case 4:
				document.getElementById('topic4').innerHTML = '<img src="film1.jpg" />';
			break;
			case 5:
				document.getElementById('topic5').innerHTML = '<img src="prog1.jpg" />';
			break;
			case 6:
				document.getElementById('topic6').innerHTML = '<img src="kont1.jpg" />';
			break;
			case 8:
				document.getElementById('topic8').innerHTML = '<img src="nyhet1.jpg" />';
			break;
		}
		/*switch (gNr) {
				case 1:
					topicColorId1 = setInterval(topicUncolorize,80,nr,filebase,'false');
				break;
				case 2:
					topicColorId2 = setInterval(topicUncolorize,80,nr,filebase,'false');
				break;
				case 3:
					topicColorId3 = setInterval(topicUncolorize,80,nr,filebase,'false');
				break;
				case 4:
					topicColorId4 = setInterval(topicUncolorize,80,nr,filebase,'false');
				break;
				case 5:
					topicColorId5 = setInterval(topicUncolorize,80,nr,filebase,'false');
				break;
				case 6:
					topicColorId6 = setInterval(topicUncolorize,80,nr,filebase,'false');
				break;
				case 8:
					topicColorId8 = setInterval(topicUncolorize,80,nr,filebase,'false');
				break;
		}*/

	}
}

var tempId;

function topicUncolorize(nr,filebase,force) {
	var topicName = 'topic' + gNr;
	var theNo = parseInt(document.getElementById(topicName).firstChild.src.charAt(document.getElementById(topicName).firstChild.src.length-5));
	
	theNo--;
	var theFile= gFilebase + theNo + '.jpg';
	var theTag = '<img src="' + theFile + '" />';
	var theTagId = 'topic' + gNr;
	document.getElementById(theTagId).innerHTML = theTag;
	if (theNo < 2) {
		switch (gNr) {
			case 1:
				clearInterval(topicColorId1);
				document.getElementById('topic1').innerHTML = '<img src="start1.jpg" />';
				//clearTimeOut(tempId);
				//tempId = setTimeout(checkColor,2000);
			break;
			case 2:
				clearInterval(topicColorId2);
				document.getElementById('topic2').innerHTML = '<img src="bmbm1.jpg" />';
				//clearTimeOut(tempId);
				//tempId = setTimeout(checkColor,2000);
			break;
			case 3:
				clearInterval(topicColorId3);
				document.getElementById('topic3').innerHTML = '<img src="bmba1.jpg" />';
				//clearTimeOut(tempId);
				//tempId = setTimeout(checkColor,2000);
			break;
			case 4:
				clearInterval(topicColorId4);
				document.getElementById('topic4').innerHTML = '<img src="film1.jpg" />';
				//clearTimeOut(tempId);
				//tempId = setTimeout(checkColor,2000);
			break;
			case 5:
				clearInterval(topicColorId5);
				document.getElementById('topic5').innerHTML = '<img src="prog1.jpg" />';
				//clearTimeOut(tempId);
				//tempId = setTimeout(checkColor,2000);
			break;
			case 6:
				clearInterval(topicColorId6);
				document.getElementById('topic6').innerHTML = '<img src="kont1.jpg" />';
				//clearTimeOut(tempId);
				//tempId = setTimeout(checkColor,2000);
			break;
			case 8:
				clearInterval(topicColorId8);
				document.getElementById('topic8').innerHTML = '<img src="nyhet1.jpg" />';
				//clearTimeOut(tempId);
				//tempId = setTimeout(checkColor,2000);
			break;
		}
		gStatus = 'false';
		gOldNr = gNr;
		gNr = 0;
	}
}

function checkColor() {
	if (document.getElementById('topic1').firstChild.src != 'start1.jpg') {
		topicColorId1 = setInterval(topicUncolorize,40,'1','start');
	} 
	if (document.getElementById('topic2').firstChild.src != 'bmbm1.jpg') {
		topicColorId2 = setInterval(topicUncolorize,40,'2','bmbm');
	} 
	if (document.getElementById('topic3').firstChild.src != 'bmba1.jpg') {
		topicColorId3 = setInterval(topicUncolorize,40,'3','bmba');
	}
	if (document.getElementById('topic4').firstChild.src != 'film1.jpg') {
		topicColorId4 = setInterval(topicUncolorize,40,'4','film');
	}
	if (document.getElementById('topic5').firstChild.src != 'prog1.jpg') {
		topicColorId5 = setInterval(topicUncolorize,40,'5','prog');
	}
	if (document.getElementById('topic6').firstChild.src != 'kont1.jpg') {
		topicColorId6 = setInterval(topicUncolorize,40,'6','kont');
	}
	if (document.getElementById('topic8').firstChild.src != 'nyhet1.jpg') {
		topicColorId8 = setInterval(topicUncolorize,40,'8','nyhet');
	}
}

function topicDown(nr,filebase) {
	switch (gNr) {
		case 1:
			clearInterval(topicColorId1);
		break;
		case 2:
			clearInterval(topicColorId2);
		break;
		case 3:
			clearInterval(topicColorId3);
		break;
		case 4:
			clearInterval(topicColorId4);
		break;
		case 5:
			clearInterval(topicColorId5);
		break;
		case 6:
			clearInterval(topicColorId6);
		break;
		case 8:
			clearInterval(topicColorId8);
		break;
	}
	var topicName = 'topic' + gNr;
	var theFile = filebase + '9.jpg';
	var theTag = '<img src="' + theFile + '" />';
	document.getElementById(topicName).innerHTML = theTag;
}

function topicUp(theTopic,filebase,event,nr) {
	var theFile = 'bmb_' + filebase + '.php?topic=' + theTopic;
	if (theTopic == 'Filmklipp' || theTopic == 'Program') {
		if (checkUser(event,theTopic,nr,filebase)) {
			location.href = "http://www.bmbmedia.se/" + theFile;
		}
	} else {
		location.href = "http://www.bmbmedia.se/" + theFile;
	}
}

function unmarkTopic() {
	//clearTimeOut(forceColorId);
	forceColorId = setTimeout(topicUncolorForce,2000);
}

function closeDialog() {
	document.getElementById('hiddenDialog').style.visibility='hidden';
}
var dialogTemp,theHeight;

function dialoggrowinit() {
	document.getElementById('hiddenDialog').style.height = '0px';
	theHeight = 0;
	dialogTemp = setInterval(dialoggrow,1);
}

function dialoggrow() {
	theHeight = theHeight + 3;
	if (theHeight < 52) {
		document.getElementById('hiddenDialog').style.height = theHeight + 'px';
	} else {
		clearInterval(dialogTemp);
	}
}

function goHome() {
	if (document.getElementById('hiddenDialog').style.visibility == 'visible') {
		if(document.getElementById('hiddenDialog').style.top == '250px') {
			location.href = "http://www.bmbmedia.se/bmb_filmarkiv.php?topic=Filmklipp" 
		} else {
			location.href = "http://www.bmbmedia.se/bmb_programarkiv.php?topic=Program" 
		}
	}
}
