///////algemeen///////

	// bookmark script
	function CreateBookmarkLink(dn,ai,rc,wl) {
		url = dn;
		title = "Online films kijken!";   
		
		if (ai!="") {
			url=url+"?ai="+ai;
			if (rc!="") {
				url=url+"&refcode="+rc;
			}
			if (wl!="") {
				title = "Online films kijken!";   	
				url=url+"&version="+wl;
			}
		}
	
		if (window.sidebar) { 	// Mozilla Firefox Bookmark	
			window.sidebar.addPanel(title, url,"");	
		}
		else if( window.external ) { // IE Favorite		
			window.external.AddFavorite(url,title)
		}	
	} 
	
	// show the word 'code' in password field
	function codeword() {
		if(document.getElementById('password-field').value!==''){document.getElementById('password-field').style.backgroundImage='';}
		if(document.getElementById('email').value==''){document.getElementById('email').value='e-mailadres';}
	
	}

	// whitelabel loginpopup script
	function openLoginPop() {
		document.getElementById('loginpop').style.display = 'block';
		document.getElementById('loginpoptxt').style.display = 'block';
	}
	
	function closeLoginPop() {
		document.getElementById('loginpop').style.display = 'none'; 
		document.getElementById('loginpoptxt').style.display = 'none'; 
	}
	
	// wis de standaard tekst in invoervelden
	function clearDefault(el) {
	  if (el.defaultValue==el.value) el.value = ""
	}
	
	//open popups
	function popups(pwidth, pheight, url, scrollbars) {
		var left = (window.screen.width/2 - pwidth/2);
		var top = (screen.height/2 - pheight/2);
		newwindow=window.open(''+url+'','','width='+pwidth+',height='+pheight+',left='+left+',top='+top+',scrollbars='+scrollbars+',dependent=yes,alwaysRaised=1');
	}

	//html popup read vars
	function gup( name ){  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  var regexS = "[\\?&]"+name+"=([^&#]*)";  var regex = new RegExp( regexS );  var results = regex.exec( window.location.href );  if( results == null )    return "";  else    return results[1];}
	
	// date script bottom website 
	maanden = new Array('januari','februari','maart','april','mei','juni','juli','augustus','september','oktober','november','december');
	function maakDatum(datum) {
		var d= datum.getDate();
		var m = maanden [datum.getMonth()];
		var j = datum.getFullYear();
		var datumstring = d + " " +  m + " " + j;
		return datumstring;
	}
	
	// show active channel in topmenu
	function myCurrent(wat, subject) {
		if (wat == "films" || wat == "filmsnachtclub"){
			if (document.getElementById('btnthuisbios')) {
				if(wat == "filmsnachtclub"){
					document.getElementById('btnnachtclub').style.backgroundImage="url('/images/tmnachtclubomo.gif')";
					}
				else{
					document.getElementById('btnthuisbios').style.backgroundImage="url('/images/tmthuisbiosomo.gif')";
					}
			} 
			if (document.getElementById('smbtnthuisbios')) {
				document.getElementById('smbtnthuisbios').style.backgroundImage="url('/images/smthuisbiosomo.gif')";
			} 
			else if (document.getElementById('smbtnthuisbios18')) {
				document.getElementById('smbtnthuisbios18').style.backgroundImage="url('/images/smthuisbios18omo.gif')";
			}
		}
		if (wat == "trailers"){
			if (document.getElementById('btnthuisbios')) {
				document.getElementById('btnthuisbios').style.backgroundImage="url('/images/tmthuisbiosomo.gif')";
			} 
			if (document.getElementById('smbtntrailers')) {
				document.getElementById('smbtntrailers').style.backgroundImage="url('/images/smtrailersomo.gif')";
			} 
		}
		if (wat == "nachtclub"){
			if (document.getElementById('btnnachtclub')) {
				document.getElementById('btnnachtclub').style.backgroundImage="url('/images/tmnachtclubomo.gif')";
			} 
		}
		if (wat == "klantenservice"){ 
			if (subject == "faq") {
				document.getElementById('faq').style.display="block";
			}
			if (subject == "pctv" || subject == "mce" || subject == "pczapper" || subject == "doehetzelf" || subject == "draadloos") {
				document.getElementById('pctv').style.display="block";
			}
			if (subject == "mijngegevens" || subject == "dezemaand" || subject == "facturen" || subject == "persoonsgegevens" || subject == "abonnementen") {
				document.getElementById('mijngegevens').style.display="block";
			}
		}
		
	}
	
	//detect browser
	var detect = navigator.userAgent.toLowerCase();  
	var OS,browser,version,total,thestring;    
	
	if (checkIt('konqueror'))  {   
		browser = "Konqueror";   
		OS = "Linux";  
	}  
	else if (checkIt('safari')) 
		browser = "Safari";  
	else if (checkIt('omniweb')) 
		browser = "OmniWeb";  
	else if (checkIt('opera')) 
		browser = "Opera";  
	else if (checkIt('webtv')) 
		browser = "WebTV";  
	else if (checkIt('icab')) 
		browser = "iCab";  
	else if (checkIt('msie')) 
		browser = "Internet Explorer";  
	else if (!checkIt('compatible'))  {   
		browser = "Netscape Navigator";   
		version = detect.charAt(8);  
	}  
	else browser = "An unknown browser";    
	
	if (!version) version = detect.charAt(place + thestring.length);    if (!OS)  {   if (checkIt('linux')) OS = "Linux";   else if (checkIt('x11')) OS = "Unix";   else if (checkIt('mac')) OS = "Mac";   else if (checkIt('win')) OS = "Windows";   else OS = "an unknown operating system";  }    function checkIt(string)  {   place = detect.indexOf(string) + 1;   thestring = string;   return place;  }  
	
	// start focus on formfield
	function startFocus(element) {
		if (document.getElementById(element)){
			document.getElementById(element).focus()
		}
	}
	
	// general check if numbers are present in form field
	function checkForNumbers(naampje) {
		var nummer = 0;
		for (i=0;i<naampje.length;i++) {
			if (!isNaN(naampje.charAt(i)) && naampje.charAt(i)!=" ") {
				nummer = 1;
			}
		}
		return nummer;
	}

	// creating cookies for favorites
	function createCookie(name,value,days) {
		var x = readCookie(name)
		if (x) {
			x = x+","+value;
			arr_value = x.split(",");
			arr_value = unique(arr_value);
			for (var i = 0; i < arr_value.length; i++) {
				if(i == 0){
				value = arr_value[i];
				}
				else{
				value = value+","+arr_value[i];
				}
			} 
		}
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
		if (days !== -1){
			if (name == 'favorites'){
				alert("Deze film is toegevoegd aan je favorieten!");
				}
			else if (name == 'favoritetrailers'){
				alert("Deze trailer is toegevoegd aan je favorieten!");
				}
			else if (name == 'favoritewebcams'){
				alert("Dit model is toegevoegd aan je favorieten!");
				}
			else if (name == 'blockedwebcams'){
				alert("Dit model wordt niet meer getoond!");
				location.reload(true);
				}
			else {
				}
		}
	}
	
	function changeCookie(name,value,days) {
		var x = readCookie(name)
		if (x) {
			arr_value = x.split(",");
			arr_value = unique(arr_value);
			deleteitem = value;
			$a = 0;
			for (var i = 0; i < arr_value.length; i++) {
					if (arr_value[i] == deleteitem){
						//verwijder
					}
					else{
							if($a == 0){
							value = arr_value[i];
							}
							else{
							value = value+","+arr_value[i];
							}
							$a++;
					}
			} 
		}
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
		if (arr_value.length == 1) {
			eraseCookie(name);
		}
		location.reload(true);
	}
	
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	
	function eraseCookie(name) {
		createCookie(name,"",-1);
	}

	// part of cookie script
	function unique(a) {
		tmp = new Array(0);
		for(i=0;i<a.length;i++){
			if(!contains(tmp, a[i])){
				tmp.length+=1;
				tmp[tmp.length-1]=a[i];
			}
		}
		return tmp;
	}

	// part of cookie script
	function contains(a, e) {
		for(j=0;j<a.length;j++)if(a[j]==e)return true;
		return false;
	}

	// show png images in IE6 or lower
	function replaceImgpng(img, id){
		if (browser == "Internet Explorer"){ 
		which= img;
		if (id){ which = img + id;}
		document.getElementById(which).src = "/images/blank.gif"; 
		document.getElementById(which).style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/" + img + ".png', sizingMethod='image')"; 
		}
	}

	// less pretty, but needed for some starratings, because no unique ID is present
	function replaceImg(url,target,img,imgblank,title,align,valign){
		if(url){
			document.write('<a href="'+url+'" target="'+target+'">');
		}
			if (browser == "Internet Explorer"){   
				document.write("<img src=\"/images/"+imgblank+"\" alt=\""+title+"\" title=\""+title+"\" border=\"0\" align=\""+align+"\" valign=\""+valign+"\" style=\"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/"+img+"', sizingMethod='image');\" >");  
			}  
			else {   
				document.write('<img src="/images/'+img+'" alt="'+title+'" title="'+title+'" border="0" align="'+align+'" valign="'+valign+'" />');  
			}  
		if(url){
			document.write('</a>');
		}
	
	
	}

	// for replacing arrows written by php scripting for whitelabel images
	function replaceImgAI(img){
		if (browser == "Internet Explorer"){ 
			document.getElementById(img).src = "/images/blank.gif"; 
			document.getElementById(img).style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/" + img + ".png', sizingMethod='image')"; 
		}
		else{
			document.getElementById(img).src = "/images/" + img + ".png"; 
		}
	}
	
	// show MSN presence
	function showpresence(presence)
	{
	  if(presence.statusText == 'Online'){
		if(document.getElementById("msnchat")){
			document.getElementById("msnchat").style.display = "inline";
		}
		if(document.getElementById("msnchattop")) {
			document.getElementById("msnchattop").style.display = "inline";
		}
	  }
	}

///////enkel klantenservice///////

	// mce + pczapper screenshots
	function imagepopups(myWidth, myHeight, photo) {
		var ns = navigator.appName.indexOf('Netscape')!=-1 && !ie && !opera;
		var dirname = "images";
		var newWin = 0;
		var left = (window.screen.width/2 - myWidth/2);
		var top = (screen.height/2 - myHeight/2);
		//browsercheck
		//if (ns){myHeight+=0;}
		newWin ++;
		addBar = 'no';
		if (myHeight > screen.availheight - 24){ 
			myHeight = screen.availheight - 24; 
			addBar = 'yes'; myWidth +=16;
		}
		if (myWidth > screen.availwidth){ 
			myWidth = screen.availwidth; 
			addBar = 'yes';
		}
		myFeatures=('width='+myWidth+',height='+myHeight+',left='+left+',top='+top+',scrollbars='+addBar+',dependent=yes,alwaysRaised=1');
		myWin=open('',newWin,myFeatures);
		myWin.document.open();
		myWin.document.write('<html><head><title>Mejane.com</title>');
		myWin.document.write('<META HTTP-EQUIV="imagetoolbar" CONTENT="no">');
		myWin.document.write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>');
		myWin.document.write('<body style="padding:0px; margin:0px;">');
		myWin.document.write('<a href="javascript:window.close();" style="cursor:pointer;"><img src="'+dirname+'/'+photo+'" border="0" width="'+myWidth+'" height="'+myHeight+'" alt="Klik om te sluiten" title="Klik om te sluiten"></a></body></html>');
		myWin.document.close();
	}
	
	// check on toegangscodevergeten page
	function checkPincodeForm() {
	
		doorgaan = true;
		var str=document.submitform.emailadres.value;
		var filter=/^.+@.+\..{2,3}$/;
	
		if (document.submitform.emailadres.value == '') {
			doorgaan = false;
			var foutmelding = "Er is geen e-mailadres ingevuld";
			document.submitform.emailadres.focus();
		} else if (!filter.test(str)) {
			doorgaan = false;
			var foutmelding = "Er is geen geldig e-mailadres ingevoerd.";
			document.submitform.emailadres.value = '';
			document.submitform.emailadres.focus();
		}
	
		if (doorgaan == true) {
			return true;
		}else {
			alert(foutmelding);
			return false;
		}	
	}
	
	
	// resize iframe nieuwsbrief
	function resizeMe(obj){
		docHeight = nieuwsbrief.document.body.scrollHeight ;
		obj.style.height = docHeight + 10 + 'px' ;
	}

///////enkel movie pages///////

	// menu swaps
	function moviedetailswap(wat) {
		if(wat == 4){ watt = 3; }	else {	watt = wat;	}
		document.getElementById('btnmoviedetail1').src ="/images/btnmoviedetail1"+watt+".gif";
		document.getElementById('btnmoviedetail2').src ="/images/btnmoviedetail2"+watt+".gif";
		document.getElementById('btnmoviedetail3').src ="/images/btnmoviedetail3"+watt+".gif";
		document.getElementById('moviedetail1').style.display = "none";
		document.getElementById('moviedetail2').style.display = "none";
		document.getElementById('moviedetail3').style.display = "none";
		document.getElementById('moviedetail4').style.display = "none";
		document.getElementById('moviedetail'+wat+'').style.display = "block";
	}

	// menu swaps whitelabel
	function moviedetailswapai(wat) {
		if(wat == 4){ watt = 3; }	else {	watt = wat;	}
		document.getElementById('moviedetail1').style.display = "none";
		document.getElementById('moviedetail2').style.display = "none";
		document.getElementById('moviedetail3').style.display = "none";
		document.getElementById('moviedetail4').style.display = "none";
		document.getElementById('moviedetail'+wat+'').style.display = "block";
	}

	// menu swaps playpage
	function playswap(wat) {
			document.getElementById('btnplay1').src ="/images/btnplay1"+wat+".gif";
			document.getElementById('btnplay2').src ="/images/btnplay2"+wat+".gif";
			document.getElementById('play1').style.display = "none";
			document.getElementById('play2').style.display = "none";
			document.getElementById('play'+wat+'').style.display = "block";
	}

	// menu swaps playpage whitelabel
	function playswaaip(wat) {
			document.getElementById('play1').style.display = "none";
			document.getElementById('play2').style.display = "none";
			document.getElementById('play'+wat+'').style.display = "block";
	}

	// validate review
	function validate()
	{
		var form = document.forms.reviewForm;
		var radio = form.rating;
		for (var i=0;i<radio.length;i++)
		{
			if (radio[i].checked)
			var checked = true;
		}
		if(checked == true)
		{
			return true;
		}
		else
		{
			alert('Je dient bij een review tenminste een cijfer te geven.');
			return false;
	
		}
	}
	
	// shows paymethods or PCTV on movie front page
	var whichTxt = Math.round(Math.random()*2) + 1;
	function showTxt(){
		document.getElementById('blokje'+whichTxt).style.display = 'block';
	}
	
	// start screenshot slideshow
	function runSlideShow(){
		if (document.all){
			document.images.PictureBox.style.filter="blendTrans(duration=2)";
			document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
			document.images.PictureBox.filters.blendTrans.Apply();
		}
	
		document.images.PictureBox.src = preLoad[jss].src;
			
		if (document.all) document.images.PictureBox.filters.blendTrans.Play();
		jss = jss + 1;
		if (jss > (Picture.length-1)) jss=0;
		tss = setTimeout('runSlideShow()', SlideShowSpeed);
	}

/////////enkel betaalscherm

	function toTop(){
		if (parent) parent.location.hash = '#';
	}

///////enkel Webcams///////

	// change schreenshot pics
	function changePic(welk){
		document.getElementById("groot").src = welk;
	}
	
	//check nickname webcamchat
	function checkFormChat(){
			doorgaan = "true";
			if (document.nicknameform.nickname.value.length<4) {
				doorgaan = "false";
				foutmelding = "Nickname is minumaal 4 karakters lang.";
			}else if (document.nicknameform.nickname.value.length>12) {
				doorgaan = "false";
				foutmelding = "Nickname is maximaal 12 karakters lang.";
			}else if (checkForNumbers(document.nicknameform.nickname.value)) {
				doorgaan = "false";
				foutmelding = "Nickname mag geen cijfers bevatten.";
			}
				
			if (doorgaan=="true") {
				return true;
			}else {
				alert(foutmelding);
				return false;
			}
	}
	
