function moveToTinyMce(num){
	var transitDiv = 	document.getElementById('transitDiv'+num);
	tinyMCE.execInstanceCommand('mce_editor_'+num,'mceSetContent','false', transitDiv.innerHTML);
	return false;
}
function makePopup(url,w,h){
		newwindow = window.open(url,"fotopop","height="+h+",width="+w+",scrollbars=1"+",resizable=1");
		
		if (!newwindow.opener) newwindow.opener = self;

	if (window.focus) {newwindow.focus()}
	return false
}
function showEdit(edit_div_id,edit_field)
{
    
	var aDiv = document.getElementById(edit_div_id);
    var div_style = GetLayerStyle(edit_div_id);
    var leftpos = 0;
    var toppos  = 0;

   //  GET THE POSITION, THIS IS A COOL WAY TO GET THE POSITION:
    aTag = document.getElementById(edit_field);
    do {
      aTag     = aTag.offsetParent;
      leftpos += aTag.offsetLeft;
      toppos  += aTag.offsetTop;      
    } while (aTag.tagName != 'BODY');

    toppos += 24;
    div_style.left = leftpos+'px';
    div_style.top = toppos+'px';
    div_style.display = 'inline';
 
}
function toggle_Div(id){
			div_obj = document.getElementById('hidden_result_'+id);
			img_obj = document.getElementById('toggle_img_'+id);
            if(div_obj.style.display == 'block'){
                div_obj.style.display = 'none';
                img_obj.src = "img/expand.gif";
             }else{
                div_obj.style.display = 'block';
                img_obj.src = "img/collapse.gif";
             }
		
}
var timer = null;
var ms = 500;
function delay(function_string){
	if ( timer != null )
	    clearTimeout(timer);
	timer = setTimeout(function_string, ms);
}

function upload_foto(){

    document.foto_form.submit();
  
}

function redir(mid){
	document.location = '?mid='+mid;
}
function fillContent(editorsArray){
	//console.log(editorsArray.length);
	for (i in editorsArray)
	{
		if(!isNaN(i)){
			var content = tinyMCE.getContent('mce_editor_'+i);
			$(editorsArray[i]).value = content;
		}	
	}
	
}
function sendListToAjax(container){
	var params = Sortable.serialize(container.id);
	xajax_saveList(params);
}

function confirmDel(confirmString,sTableName, sPrimaryKey, iId)
{		
	var confirmB = confirm(confirmString);
		if(confirmB){	
			xajax_confirmedDel(sTableName, sPrimaryKey, iId);
		}else{		
			return;
		} 
		
}
function customHighlight(id,startcolorString){
	new Effect.Highlight(id,{startcolor: startcolorString})
}

function jsUpload(uploadField,fieldId)
{
    upload_field.form.submit();
	alert('dasd');
    $(fieldId).value = "Bestand wordt geupload";
    upload_field.disabled = true;
    return true;
}

var W3CDOM = (document.createElement && document.getElementsByTagName);

function initFileUploads() {
	if (!W3CDOM) return;
	var fakeFileUpload = document.createElement('div');
	fakeFileUpload.className = 'fakefile';
	var newinput = document.createElement('input');
	newinput.className = 'textinputUpload';
	fakeFileUpload.appendChild(newinput);
	var image = document.createElement('img');
	image.src='../tpl/admin/img/upload.jpg';
	fakeFileUpload.appendChild(image);
	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if (x[i].type != 'file') continue;
		if (x[i].parentNode.className != 'fileinputs') continue;
		x[i].className = 'file';
		var clone = fakeFileUpload.cloneNode(true);
		x[i].parentNode.appendChild(clone);
		x[i].relatedElement = clone.getElementsByTagName('input')[0];
		x[i].onchange = x[i].onmouseout = function () {
			this.relatedElement.value = this.value;
		}
	}
}