var clientInfo = navigator.userAgent.toLowerCase();
var isIE = ( clientInfo.indexOf("msie") != -1 );
var isWin = ( (clientInfo.indexOf("win")!=-1) || (clientInfo.indexOf("16bit") != -1) );
var bbcodeEditorSiteUrl = '';
/*function createBBtag(openerTag,closerTag,areaId){
	if(isIE && isWin){
		createBBtag_IE(openerTag,closerTag,areaId);
	} else {
		createBBtag_nav(openerTag,closerTag,areaId);
	}
	return;
}
function createBBtag_IE(openerTag,closerTag,areaId){
	var txtArea = document.getElementById(areaId);
	var aSelection = document.selection.createRange().text;
	var range = txtArea.createTextRange();

	if(aSelection){
		document.selection.createRange().text = openerTag + aSelection + closerTag;
		txtArea.focus();
		range.move('textedit');
		range.select();
	} else {
		var oldStringLength = range.text.length + openerTag.length;
		txtArea.value += openerTag + closerTag;
		txtArea.focus();
		range.move('character',oldStringLength);
		range.collapse(false);
		range.select();
	}
	editorBbcodePreview(areaId.replace('_id',''),bbcodeEditorSiteUrl);
	return;
}
function createBBtag_nav(openerTag,closerTag,areaId){
	var txtArea = document.getElementById( areaId );
	if(txtArea.selectionEnd && (txtArea.selectionEnd-txtArea.selectionStart > 0)){
		var preString = (txtArea.value).substring(0,txtArea.selectionStart);
		var newString = openerTag + (txtArea.value).substring(txtArea.selectionStart,txtArea.selectionEnd) + closerTag;
		var postString = (txtArea.value).substring(txtArea.selectionEnd);
		txtArea.value = preString + newString + postString;
		txtArea.focus();
	} else {
		var offset = txtArea.selectionStart;
		var preString = (txtArea.value).substring(0,offset);
		var newString = openerTag + closerTag;
		var postString = (txtArea.value).substring(offset);
		txtArea.value = preString + newString + postString;
		txtArea.selectionStart = offset + openerTag.length;
		txtArea.selectionEnd = offset + openerTag.length;
		txtArea.focus();
	}
	editorBbcodePreview(areaId.replace('_id',''),bbcodeEditorSiteUrl);
	return;
}*/
function createBBtag(tag1,tag2,obj){
    var startPos = 'none';
    var    endPos = 'none';
    textarea = document.getElementById(obj);
    if(document.selection){
        //Code for IE
        textarea.focus();
        var sel = document.selection.createRange();
        var range_all = document.body.createTextRange();
        range_all.moveToElementText(textarea);
        for(var sel_start = 0; range_all.compareEndPoints('StartToStart', sel) < 0; sel_start ++){
            range_all.moveStart('character', 1);
        }
        for(var sel_end = textarea.innerHTML.length; range_all.compareEndPoints('EndToEnd', sel) > 0; sel_end --){
            range_all.moveEnd('character', -1);
        }
        startPos = sel_start+tag1.length;
        endPos = startPos+sel.text.split('\n').join('').length;
        //
        sel.text = tag1 + sel.text + tag2;
    } else {
        // Code for Mozilla Firefox
        var len = textarea.value.length;
        var start = textarea.selectionStart;
        var end = textarea.selectionEnd;
        var scrollTop = textarea.scrollTop;
        var scrollLeft = textarea.scrollLeft;
        var sel = textarea.value.substring(start, end);
        var rep = tag1 + sel + tag2;
        textarea.value =  textarea.value.substring(0,start) + rep + textarea.value.substring(end,len);
        textarea.scrollTop = scrollTop;
        textarea.scrollLeft = scrollLeft;
        //
        var startLen = textarea.value.substring(0,start) + tag1;
        var endLen = textarea.value.substring(0,start) + tag1 + sel;
        startPos = startLen.length;
        endPos = endLen.length;
    }
    if(startPos != 'none' && endPos != 'none'){
        editorPos(textarea,startPos,endPos);
    }
    editorBbcodePreview(obj.replace('_id',''),bbcodeEditorSiteUrl);
}
function editorPos(inputEl, selStart, selEnd){
    if(inputEl.setSelectionRange){
        inputEl.focus();
        inputEl.setSelectionRange(selStart, selEnd);
    } else if(inputEl.createTextRange){
        var range = inputEl.createTextRange();
        range.collapse(true);
        range.moveEnd('character', selEnd);
        range.moveStart('character', selStart);
        range.select();
    }
}
//-->
function BBC2HTML(S){
	if (S.indexOf('[') < 0) return S;
	
	function X(p, f) {return new RegExp(p, f)}
	function D(s) {return rD.exec(s)}
	function R(s) {return s.replace(rB, P)}
	function A(s, p) {for (var i in p) s = s.replace(X(i, 'g'), p[i]); return s;}
	
	function P($0, $1, $2, $3) {
		if ($3 && $3.indexOf('[') > -1) $3 = R($3);
		switch ($1) {
			case 'url':case 'anchor':case 'email':case 'url2': return '<a '+ L[$1] + ($2||$3) +'">'+ $3 +'</a>';
			case 'img': var d = D($2); return '<img src="'+ $3 +'"'+ (d ? ' width="'+ d[1] +'" height="'+ d[2] +'"' : '') +' alt="'+ (d ? '' : $2) +'" />';
			//425, 344
			case 'YOUTUBE':case 'youtube': var d = D($2)||[0, 400, 300]; return '<object width="'+ d[1] +'" height="'+ d[2] +'" wmode="opaque"><param name="movie" value="http://www.youtube.com/v/'+$3+'&hl=nl&fs=1&color1=0x3a3a3a&color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed wmode="opaque" src="http://www.youtube.com/v/'+$3+'&hl=nl&fs=1&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+ d[1] +'" height="'+ d[2] +'"></embed></object>';
			//649, 487
			case 'VIMEO':case 'vimeo': var d = D($2)||[0, 400, 300]; return  '<object width="'+ d[1] +'" height="'+ d[2] +'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+$3+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff2934&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id='+$3+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff2934&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+ d[1] +'" height="'+ d[2] +'"></embed></object>';
			
			case 'flash': var d = D($2)||[0, 425, 366]; return '<object type="application/x-shockwave-flash" data="'+ Y[$1] + $3 +'" width="'+ d[1] +'" height="'+ d[2] +'"><param name="movie" value="'+ Y[$1] + $3 +'" /></object>';
			case 'float': return '<span style="float: '+ $2 +'">'+ $3 +'</span>';
			case 'left':case 'right':case 'center':case 'justify': return '<div style="text-align: '+ $1 +'">'+ $3 +'</div>';
			case 'google':case 'wikipedia': return '<a href="'+ G[$1] + $3 +'">'+ $3 +'</a>';
			case 'b':case 'i':case 'u':case 's':case 'sup':case 'sub':case 'h1':case 'h2':case 'h3':case 'h4':case 'h5':case 'h6':case 'table':case 'tr':case 'th':case 'td': return '<'+ $1 +'>'+ $3 +'</'+ $1 +'>';
			case 'row': case 'r':case 'header':case 'head':case 'h':case 'col':case 'c': return '<'+ T[$1] +'>'+ $3 +'</'+ T[$1] +'>';
			case 'acronym':case 'abbr': return '<'+ $1 +' title="'+ $2 +'">'+ $3 +'</'+ $1 +'>';
			case 'div': return '<div style="'+ $2 +'">'+ $3 +'</div>';
		}
		return '['+ $1 + ($2 ? '='+ $2 : '') +']'+ $3 +'[/'+ $1 +']';
	}
	
	var rB = X('\\[([a-zA-Z][a-zA-Z0-9]*)(?:=([^\\]]+))?]((?:.|[\r\n])*?)\\[/\\1]', 'g'), rD = X('^(\\d+)x(\\d+)$');
	var L = {url: 'href="', 'anchor': 'name="', email: 'href="mailto: ', url2: 'target="_blank" href="'};
	var G = {google: 'http://www.google.com/search?q=', wikipedia: 'http://www.wikipedia.org/wiki/'};
	var Y = {flash: ''};
	var T = {row: 'tr', r: 'tr', header: 'th', head: 'th', h: 'th', col: 'td', c: 'td'};
	var C = {notag: [{'\\[': '[', ']': ']'}, '', ''], code: [{'<': '&lt;'}, '<code><pre>', '</pre></code>']};
	C.php = [C.code[0], C.code[1]+ '&lt;?php ', '?>'+ C.code[2]];
	var F = {font: 'font-family:$1', size: 'font-size:$1px', color: 'color:$1', bgcolor: 'background-color:$1', border: 'border:$1', margin: 'margin:$1'};
	var U = {c: 'circle', d: 'disc', s: 'square', '1': 'decimal', a: 'lower-alpha', A: 'upper-alpha', i: 'lower-roman', I: 'upper-roman'};
	var I = {}, B = {};
	
	for (var i in C) I['\\[('+ i +')]((?:.|[\r\n])*?)\\[/\\1]'] = function($0, $1, $2) {return C[$1][1] + A($2, C[$1][0]) + C[$1][2]};
	for (var i in F) {B['\\['+ i +'=([^\\]]+)]'] = '<span style="'+ F[i] +'">'; B['\\[/'+ i +']'] = '</span>';}
	B['\\[list]'] = '<ul>'; B['\\[list=(\\w)]'] = function($0, $1) {return '<ul style="list-style-type: '+ (U[$1]||'disc') +'">'}; B['\\[/list]'] = '</ul>'; B['\\[\\*]'] = '<li>';
	B['\\[quote(?:=([^\\]]+))?]'] = function($0, $1) {return '<div class="bb-quote">'+ ($1 ? $1 +' wrote' : 'Quote') +':<blockquote>'}; B['\\[/quote]'] = '</blockquote></div>';
	B['\\[(hr|br)]'] = '<$1 />'; B['\\[sp]'] = '&nbsp;';
	return R(A(A(S, I), B));
}

function BBC2HTML_klein(S){
	if (S.indexOf('[') < 0) return S;
	
	function X(p, f) {return new RegExp(p, f)}
	function D(s) {return rD.exec(s)}
	function R(s) {return s.replace(rB, P)}
	function A(s, p) {for (var i in p) s = s.replace(X(i, 'g'), p[i]); return s;}
	
	function P($0, $1, $2, $3) {
		if ($3 && $3.indexOf('[') > -1) $3 = R($3);
		switch ($1) {
			case 'img': var d = D($2); return '<img src="::SITEURL::plaatje.php?plaatje='+ $3 +'&width=355&height=700 />';
			case 'YOUTUBE':case 'youtube': return '<object width="355" height="287" wmode="opaque"><param name="movie" value="http://www.youtube.com/v/'+$3+'&hl=nl&fs=1&color1=0x3a3a3a&color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed wmode="opaque" src="http://www.youtube.com/v/'+$3+'&hl=nl&fs=1&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="355" height="287"></embed></object>';
			case 'VIMEO':case 'vimeo': return  '<object width="355" height="267"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+$3+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff2934&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id='+$3+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff2934&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="355" height="267"></embed></object>';
			case 'b':case 'i':case 'u':case 's': return '<'+ $1 +'>'+ $3 +'</'+ $1 +'>';
		}
		return '['+ $1 + ($2 ? '='+ $2 : '') +']'+ $3 +'[/'+ $1 +']';
	}
	
	var rB = X('\\[([a-z][a-z0-9]*)(?:=([^\\]]+))?]((?:.|[\r\n])*?)\\[/\\1]', 'g'), rD = X('^(\\d+)x(\\d+)$');
	var L = {url: 'href="', 'anchor': 'name="', email: 'href="mailto: ', url2: 'target="_blank" href="'};
	var G = {google: 'http://www.google.com/search?q=', wikipedia: 'http://www.wikipedia.org/wiki/'};
	var Y = {youtube: 'http://www.youtube.com/v/', flash: ''};
	var T = {row: 'tr', r: 'tr', header: 'th', head: 'th', h: 'th', col: 'td', c: 'td'};
	var C = {notag: [{'\\[': '[', ']': ']'}, '', ''], code: [{'<': '&lt;'}, '<code><pre>', '</pre></code>']};
	C.php = [C.code[0], C.code[1]+ '&lt;?php ', '?>'+ C.code[2]];
	var F = {font: 'font-family:$1', size: 'font-size:$1px', color: 'color:$1', bgcolor: 'background-color:$1', border: 'border:$1', margin: 'margin:$1'};
	var U = {c: 'circle', d: 'disc', s: 'square', '1': 'decimal', a: 'lower-alpha', A: 'upper-alpha', i: 'lower-roman', I: 'upper-roman'};
	var I = {}, B = {};
	
	for (var i in C) I['\\[('+ i +')]((?:.|[\r\n])*?)\\[/\\1]'] = function($0, $1, $2) {return C[$1][1] + A($2, C[$1][0]) + C[$1][2]};
	for (var i in F) {B['\\['+ i +'=([^\\]]+)]'] = '<span style="'+ F[i] +'">'; B['\\[/'+ i +']'] = '</span>';}
	B['\\[list]'] = '<ul>'; B['\\[list=(\\w)]'] = function($0, $1) {return '<ul style="list-style-type: '+ (U[$1]||'disc') +'">'}; B['\\[/list]'] = '</ul>'; B['\\[\\*]'] = '<li>';
	B['\\[quote(?:=([^\\]]+))?]'] = function($0, $1) {return '<div class="bb-quote">'+ ($1 ? $1 +' wrote' : 'Quote') +':<blockquote>'}; B['\\[/quote]'] = '</blockquote></div>';
	B['\\[(hr|br)]'] = '<$1 />'; B['\\[sp]'] = '&nbsp;';
	
	return R(A(A(S, I), B));
}

function editorBbcodePreview(txtId,sitrUrl){
	if(document.getElementById(txtId+'_id')){
		var html = BBC2HTML(document.getElementById(txtId+'_id').value);
		html = html.split('\n').join('<br>');
		html = html.split('::SITEURL::').join(sitrUrl);
		document.getElementById(txtId+'_voorbeeld').innerHTML = html;
	} else if(document.getElementById(txtId+'_voorbeeld_klein')){
		editorBbcodePreviewKlein(txtId,sitrUrl)
	}
}
function editorBbcodePreviewKlein(editor,sitrUrl){
	var html = BBC2HTML_klein(document.getElementById(editor).value);
		html = html.split('\n').join('<br>');
		html = html.split('::SITEURL::').join(sitrUrl);
		document.getElementById(editor+'_voorbeeld_klein').innerHTML = html;	
}

function editorBbcodePopup(editor,popup,include,vars){
	editorBbcodePopupHideAll(editor,popup);
	var div = 'popup_'+editor+popup;
	if(document.getElementById(div).style.display == ''){
		document.getElementById(div).style.display = 'none';
		document.getElementById(div).innerHTML = '';
	} else {
		document.getElementById(div).style.display = '';
		ajaxpack.getAjaxRequest('editor/bbcode_get_content.php', 'page=insert_div&div_id='+div+'&include='+include+vars, get_content, 'txt');
	}
}
function editorBbcodePopupHideAll(editor,cur){
	var arr = new Array('_front_color','_back_color','_link','_list');	
	for(i=0; i<arr.length; i++){
		if(arr[i] != cur){
			var div = 'popup_'+editor+arr[i];
			document.getElementById(div).style.display = 'none';
			document.getElementById(div).innerHTML = '';
		}
	}
}

function editorBbcodeKleurView(editor,kleur){
	document.getElementById(editor+'_ColorPreview').style.backgroundColor = '#'+kleur;
	document.getElementById(editor+'_view_kleur_code').value = kleur;
}
function editorBbcodeKleurSet(editor,kleur){
	document.getElementById(editor+'_gekozen_kleur').style.backgroundColor = '#'+kleur;
	document.getElementById(editor+'_gekozen_code').value = kleur;
}
function editorBbcodeList(editor,soort,total){
	if(soort != ''){
		soort = '='+soort;
	}
	var html = '[list'+soort+']\n';
	for(i=0; i<total; i++){
		var veld = document.getElementById(editor+'_insert_list_'+i);
		if(veld && veld.value != ''){
			html += '  [*]'+veld.value+'\n';
		}
	}
	html += '[/list]';
	createBBtag(html,'',editor+'_id');
	//
	editorBbcodePopupHideAll(editor,'');
}
function editorBbcodeBotPopup(editor,include,vars){
	var div = 'popup_bottom_'+editor;
	if(include == 'hide'){
		document.getElementById(div).style.display = 'none';
		document.getElementById(div).innerHTML = '';
	} else {
		document.getElementById(div).style.display = '';
		ajaxpack.getAjaxRequest('editor/bbcode_get_content.php', 'page=insert_div&div_id='+div+'&include='+include+vars, get_content, 'txt');
	}
}

function editorBbcodeLinkSoortSelect(editor_name,folder,width,this_val){
	var types = Array('page','foto','file');
	for(i=0; i<types.length; i++){
		if(document.getElementById(editor_name+'_link_soort_img_'+types[i])){
			if(types[i] == this_val){
				document.getElementById(editor_name+'_link_soort_img_'+types[i]).style.borderColor = '#000000';
				ajaxpack.getAjaxRequest(folder+'bbcode_get_content.php', 'field='+editor_name+'_link_soort_content&include=bbcode_'+types[i]+'_link.php&page_width='+width+'&editor_name='+editor_name+'&folder='+folder, get_splitter, 'txt');
			} else {
				document.getElementById(editor_name+'_link_soort_img_'+types[i]).style.borderColor = '#c5dbe8';
			}
		}
	}
}

function bbcode_insert_img(foto,editor_name){
	
	foto = '::SITEURL::'+foto.replace('../','');
	
	var width = Math.round(document.getElementById(editor_name+'_insert_img_width').value);
	var height = Math.round(document.getElementById(editor_name+'_insert_img_height').value);
	
	
	var hspace = document.getElementById(editor_name+'_insert_img_hspace').value;
	var vspace = document.getElementById(editor_name+'_insert_img_vspace').value;
	
	var border = document.getElementById(editor_name+'_insert_img_border').value;
	var bordercolor = document.getElementById(editor_name+'_insert_img_bordercolor').value
	var alt = document.getElementById(editor_name+'_insert_img_alt').value;
	
	var align = document.getElementById(editor_name+'_insert_img_align').value;
	
	var a_type = document.getElementById(editor_name+'_insert_img_link_val').value;
	var a_site = document.getElementById(editor_name+'_insert_img_website').value;
	var a_targ = document.getElementById(editor_name+'_insert_img_target_val').value;
	if(a_targ == '_blank'){
		var a_srt = '2';
	} else {
		var a_srt = '';
	}
	  
	
	var html = '';
	var img = '';
	var div1 = '';
	var div2 = '';
	var useDiv = false;
	//
	div1 += '[div=';
	if(border != "" && border > 0){
		div1 += ' border:'+border+'px solid '+bordercolor+'; ';
		useDiv = true;
	}
	if(hspace != "" && hspace > 0){
		div1 += ' margin-left:'+hspace+'px; margin-right:'+hspace+'px; ';
		useDiv = true;
	}
	if(vspace != "" && vspace > 0){
		div1 += ' margin-bottom:'+vspace+'px; margin-top:'+vspace+'px; ';
		useDiv = true;
	}
	if(align != ""){
		div1 += ' float:'+align+'; ';
		useDiv = true;
	}
	div1 += ' width:'+width+'px;';
	div1 += ']';
	//
	img += '[img='+width+'x'+height+']'+foto+'[/img]';
	//
	div2 += '[/div]';
	
	if(useDiv){
		html += div1+img+div2;
	} else {
		html += img;
	}
	
	if(a_type == 'website'){
		html = '[url'+a_srt+'='+a_site+']'+html+'[/url'+a_srt+']';
	} else if(a_type == 'foto'){
		html = '[url'+a_srt+'='+foto+']'+html+'[/url'+a_srt+']';
	}
	
	
	/*if(alt != ""){
		html += ' alt="'+alt+'" title="'+alt+'"';
	}*/
	
	createBBtag(html,'',editor_name+'_id');
}
function editorBbcodeChangeSettings(method,value,editor_name){
	if(method == 'align'){
		document.getElementById(editor_name+'_insert_foto_voorbeeld').align = value;
	} else if(method == 'hspace'){
		document.getElementById(editor_name+'_insert_foto_voorbeeld').hspace = value;
	} else if(method == 'vspace'){
		document.getElementById(editor_name+'_insert_foto_voorbeeld').vspace = value;
	} else if(method == 'border'){
		document.getElementById(editor_name+'_insert_foto_voorbeeld').style.border = value+'px solid '+document.getElementById(editor_name+'_insert_img_bordercolor').value;
	} else if(method == 'borderColor'){
		document.getElementById(editor_name+'_insert_foto_voorbeeld').style.borderColor = value;
	} else if(method == 'alt'){
		document.getElementById(editor_name+'_insert_foto_voorbeeld').alt = value;
		document.getElementById(editor_name+'_insert_foto_voorbeeld').title = value;
	}
}
function editorBbcodeInsertImgChangeDim(van_waar,waar_val,begin_width,begin_height,editor_name){
	if(van_waar == editor_name+'_insert_img_width'){
		document.getElementById(editor_name+'_insert_img_height').value = (begin_height/(begin_width/waar_val));
	} else {
		document.getElementById(editor_name+'_insert_img_width').value = (begin_width/(begin_height/waar_val));
	}
	//voorbeeld change
	document.getElementById(editor_name+'_insert_foto_voorbeeld').style.width = document.getElementById(editor_name+'_insert_img_width').value+'px';
	document.getElementById(editor_name+'_insert_foto_voorbeeld').style.height = document.getElementById(editor_name+'_insert_img_height').value+'px';
}

function editorBbcodeAddVideoLink(editor_name){
	var tag = editorBbcodeGetVideoTypLink(editor_name);
	var messDiv = document.getElementById(editor_name+'_v_link_mess');
	if(tag == 'empty'){
		messDiv.innerHTML = 'Je hebt geen code ingevuld';
		messDiv.style.display = '';
	} else if(tag == 'wrong_code'){
		messDiv.innerHTML = 'onjuiste code';
		messDiv.style.display = '';
	} else if(tag == 'not_found'){
		messDiv.innerHTML = 'Je kan alleen een youtube of vimeo linkjes invullen';
		messDiv.style.display = '';
	} else {
		document.getElementById(editor_name+'_v_link').value = '';
		createBBtag(tag,'',editor_name);
		messDiv.style.display = 'none';
	}
}
function editorBbcodeGetVideoTypLink(editor_name){
	var vidCode = document.getElementById(editor_name+'_v_link').value;
	var found = false;
	if(vidCode != vidCode.replace('youtube','')){
		if(vidCode != vidCode.replace('http://www.youtube.com/v/','')){
			var ytArr1 = vidCode.split('http://www.youtube.com/v/');
			var ytArr2 = ytArr1[1].split('&');
			vidCode = ytArr2[0];
		}
		vidCode = vidCode.replace('http://www.youtube.com/v/','');
		vidCode = vidCode.replace('http://www.youtube.com/watch?v=','');
		var ytArr = vidCode.split('&');
		vidCode = ytArr[0];
		vidCode = '[youtube]'+vidCode+'[/youtube]';
		found = true;
	} else if(vidCode != vidCode.replace('vimeo','')){
		if(vidCode != vidCode.replace('http://vimeo.com/moogaloop.swf?clip_id=','')){
			var ytArr1 = vidCode.split('http://vimeo.com/moogaloop.swf?clip_id=');
			var ytArr2 = ytArr1[1].split('&');
			vidCode = ytArr2[0];
		}
		vidCode = vidCode.replace('http://vimeo.com/moogaloop.swf?clip_id=','');
		vidCode = vidCode.replace('http://vimeo.com/','');
		vidCode = vidCode.replace('http://www.vimeo.com/','');
		var vmArr = vidCode.split('&');
		vidCode = vmArr[0];
		vidCode = '[vimeo]'+vidCode+'[/vimeo]';
		found = true;
	}
	//
	if(vidCode == ''){
		return 'empty';
	} else if(!found){
		return 'not_found';
	} else if(vidCode != vidCode.replace('www','') || vidCode != vidCode.replace('http','')){
		return 'wrong_code';
	} else {
		return vidCode;
	}
}

function editorBbcodeAddImageLink(editor_name){
	var img = document.getElementById(editor_name+'_i_link').value;
	var messDiv = document.getElementById(editor_name+'_i_link_mess');
	if(img == ''){
		messDiv.innerHTML = 'Je hebt geen foto link ingevuld';
		messDiv.style.display = '';
	} else if(img == img.replace('http','')){
		messDiv.innerHTML = 'Je hebt een onjuiste foto link ingevuld';
		messDiv.style.display = '';
	} else {
		document.getElementById(editor_name+'_i_link').value = '';
		createBBtag('[img]'+img+'[/img]\n','',editor_name);
		messDiv.innerHTML = '';
		messDiv.style.display = 'none';
	}
}