///////javascript upload progress////
var uploading =  new Array();
var colorSwitchThreshold = 50;

/*
 * Update de visuele kant van de progress bar met de waarde in 'percentage'. Als
 * deze waarde groter is dan de waarde in colorSwitchThreshold (standaard 50) dan
 * wordt de klasse .progress-50-percent toegepast op de tekst. Zo kan de kleur
 * wijzigen van wit naar zwart, wat duidelijker is.
 */

/**
 * Initialiseer het upload systeem en zet de upload progress bar op 0.
 */
function checkFieldsSign(){
value = true;
allINP = document.getElementById('naw_form').getElementsByTagName('input');
for(i=0;i<allINP.length; i++){
if(allINP[i].value == 0 && allINP[i].parentNode.parentNode.innerHTML.indexOf('*')!=-1 && allINP[i].type!='hidden' ){
	allINP[i].style.border = '1px solid red';
value = false
}

}
if(value == false){
rollIntopbar('#ff6600',2,'Let op, u bent &eacute;&eacute;n of meer verplichte velden vergeten. Controleer de rood omrande velden en probeer het opnieuw');
}
else{
	removeLeaveEvnt();
}
return value;

//return false;
}

 function binding(val){
 gebi('subdomein').value = val;
 }
 
function TestFileType( fileName, fileTypes ) {
if (!fileName) return;

dots = fileName.split(".")
//get the part AFTER the LAST period.
fileType = "." + dots[dots.length-1];

return (fileTypes.join(".").indexOf(fileType) != -1)
//alert('That file is OK!') :
//alert("Please only upload files that end in types: \n\n" + (fileTypes.join(" .")) + "\n\nPlease select a new file and try again.");
} 
 
function beginUpload(id,e){
	if(!e.target){
	target = window.event.srcElement;
	}
	else{
	target = e.target;	
	}
	//alert(target);
target.style.display = 'none';
target.parentNode.getElementsByTagName('span')[0].style.display = 'none';
if(target.parentNode.getElementsByTagName('img')[0]){
target.parentNode.getElementsByTagName('img')[0].style.display = 'none';	
}
if(target.parentNode.getElementsByTagName('br')[0]){
target.parentNode.getElementsByTagName('br')[0].style.display = 'none';	
target.parentNode.getElementsByTagName('br')[1].style.display = 'none';	
}
gebi('pb_'+id).style.display = 'block';
	uploading[id] = true;
	getUploadProgress(id);

	return true;
}



function completeUpload(id,e){
	if(!e.target){
	target = window.event.srcElement;
	}
	else{
	target = e.target;	
	}
	if ( uploading[id])	{
		uploading[id] = false;
	}

	 if(target.contentWindow.completed){
	 gebi('pb_'+id).style.display = 'block';
	 gebi('pb_'+id).innerHTML = '100%&nbsp;'
	 gebi('pb_'+id).style.width = 100+"%";
	 startCross(id,target.contentWindow.tmpid,target.contentWindow.type,target.contentWindow.newid);
	 }
	 else if(target.contentWindow.error){
gebi("fileform_"+id).innerHTML = '<span>Upload media:&nbsp;&nbsp;</span><input name="upload_bestand_'+id+'" onchange="gebi(\'form_'+id+'\').submit();beginUpload(\''+id+'\',event)" type="file" /><div class="progress-bar" id="pb_'+id+'">50%&nbsp;</div>';		setTimeout("rollIntopbar('#ff0000',3,'"+target.contentWindow.error+"');",5);	 
	 }
	 }
function getUploadProgress(id){

	ajaxGETprogress(id);
	if (uploading[id]){
	setTimeout("getUploadProgress('"+id+"')", 200);
	}
}




function startCross(id,id2,type,newimid){
timer = 0;
for(i=100;i>=0;i--){
setTimeout("gebi('pb_"+id+"').style.opacity = '"+i/100+"'",timer);
if(i == 0){
setTimeout("displayIm('"+id+"','"+id2+"','"+type+"','"+newimid+"')",timer);
}
timer = timer+10;
}
}

function displayIm(id,idim,type,newimid){
if(type != 'flv'){
//alert(idim);
if(idim != 'undefined'){
gebi("fileform_"+id).innerHTML = '<img src=\'/inc/img_prev.php?type=thumb200&id='+idim+'&ul='+id+'&reload='+Math.random()+'\'><br /><br /><span>Wijzig media:&nbsp;&nbsp;</span><input name="upload_bestand_'+id+'" onchange="gebi(\'form_'+id+'\').submit();beginUpload(\''+id+'\',event)" type="file" /><div class="progress-bar" id="pb_'+id+'">50%&nbsp;</div>';
}else{
gebi("fileform_"+id).innerHTML = '<img src=\'/inc/img.php?type=thumb200&id='+newimid+'&reload='+Math.random()+'\'><br /><br /><span>Wijzig media:&nbsp;&nbsp;</span><input name="upload_bestand_'+id+'" onchange="gebi(\'form_'+id+'\').submit();beginUpload(\''+id+'\',event)" type="file" /><div class="progress-bar" id="pb_'+id+'">50%&nbsp;</div>';	
}
}else{
gebi("fileform_"+id).innerHTML = "<strong>De video wordt verwerkt en is en is binnen 5 minuten beschikbaar.</strong>";
}
}

///////////////////////////////
function ajaxGETprogress(id){
var xmlhttp=new XMLHttpRequest();
var upload_id = document.getElementById('UPLOAD_IDENTIFIER_'+id).value;
//Processing
xmlhttp.onreadystatechange=function(){
	 if(xmlhttp.readyState==4){
	 if(xmlhttp.responseText!=''){
	 gebi('pb_'+id).innerHTML = Math.round(parseInt(xmlhttp.responseText))+"%&nbsp;";
	 width  = parseInt(xmlhttp.responseText);
	 if(width<1){
	 width = 1;
	 }
	 gebi('pb_'+id).style.width = width+"%";
	 gebi('pb_'+id).style.display = 'block';
	 }
	 else{
	 }
	 }
}

//Sending
xmlhttp.open("GET",'/inc/leanupload/progress.php?id='+upload_id,true);
xmlhttp.send(null);

}




function shownew(ul){
if(ul=='ul1'){
gebi("fileform_ul1").innerHTML = '<img src="inc/img_eigenaar.php?type=thumb_1&reload='+Math.random()+'" alt="header_custom" /><br /><br /><span style="margin-bottom:2px; display:inline-block;">Wijzig afbeelding:&nbsp;&nbsp;</span><input name="upload_bestand_ul1" onchange="gebi(\'form_ul1\').submit();removeLeaveEvnt();" type="file" />';	

}else{
gebi("fileform_ul2").innerHTML = '<img src="inc/img_eigenaar.php?type=thumb_2&reload='+Math.random()+'" alt="header_custom" /><br /><br /><span style="margin-bottom:2px; display:inline-block;">Wijzig afbeelding:&nbsp;&nbsp;</span><input name="upload_bestand_ul2" onchange="gebi(\'form_ul2\').submit();removeLeaveEvnt();" type="file" />';	

}
}

function shownew_i(){
gebi("fileform_ul1").innerHTML = '<img src="inc/img_header.php?type=header_400&reload='+Math.random()+'" alt="header_custom" /><br /><br /><span>Wijzig media:&nbsp;&nbsp;</span><input name="upload_bestand_ul1" onchange="gebi(\'form_ul1\').submit();" type="file" />';


}






///////////////////////////////
function ajaxGET(url,div,execute){
var xmlhttp=new XMLHttpRequest();

//Processing
xmlhttp.onreadystatechange=function(){
	if(xmlhttp.readyState<4){
		/*Loading*/
	}else if(xmlhttp.readyState==4){
		if(div){document.getElementById(div).innerHTML = xmlhttp.responseText;}
   	if(execute){eval(execute)}
   }
}

//Sending
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}




 var win=null;
function printIt(printThis){
    win = window.open();
    self.focus();
    win.document.open();
    win.document.write('<'+'html'+'><'+'head'+'><'+'style'+'>');
    win.document.write('body, td { font-family: Verdana; font-size: 10pt;}');
    win.document.write('<'+'/'+'style'+'><'+'/'+'head'+'><'+'body'+'>');
    win.document.write(printThis);
    win.document.write('<'+'/'+'body'+'><'+'/'+'html'+'>');
    win.document.close();
    win.print();
    win.close();
}
 
function remove_row(row){
rowId = document.getElementById(row);
rowId.parentNode.removeChild(rowId);
} 
//////
function add_opleiding_row(){
document.getElementById('opleiding_new_td').innerHTML = "<img class=\"delete\" src=\"img/remove.png\" alt=\"remove\" width=\"15\" title=\"Acedemie verwijderen\" onclick=\"remove_row('opleiding_row_"+opleiding_i+"')\" height=\"15\"/>";
document.getElementById('opleiding_new_td').id = "";

opleiding_i++;
row = document.getElementById('add_opleiding_row');
html = "<td><input type=\"text\" class=\"text\" name=\"opleiding["+opleiding_i+"][naam]\" /></td>";
html += "<td><select style=\"width:60px;\"  name=\"opleiding["+opleiding_i+"][datum_van]\" />"+year2option+"</select></td>";
html += "<td><select style=\"width:60px;\"  name=\"opleiding["+opleiding_i+"][datum_tot]\" />"+year2option+"</select></td>";
html += "<td><input style=\"width:100px\" type=\"text\" class=\"text\" name=\"opleiding["+opleiding_i+"][plaats]\" /></td>";
html += "<td><input type=\"text\" class=\"text\" name=\"opleiding["+opleiding_i+"][specialisatie]\" /></td>";
html += "<td>";
html += "<select style=\"width:60px;\" name=\"opleiding["+opleiding_i+"][diploma]\" />";
html += "<option value=\"1\">Ja</option>";
html += "<option value=\"0\">Nee</option>";
html += "</select>";
html += "</td>";
html += "<td id=\"opleiding_new_td\"><img class=\"delete\" src=\"img/plus.gif\" alt=\"plus\" title=\"Nieuwe rij toeveogen\" width=\"15\" height=\"15\" onclick=\"add_opleiding_row();\" /></td>";
row.innerHTML = html;
row.style.visibility = "visible";
row.id = "opleiding_row_"+opleiding_i;

table = document.getElementById('kunstac');
newRow = table.insertRow((table.rows.length-1));
newRow.id = "add_opleiding_row";
newRow.style.visibility = "hidden";
newRow.innerHTML =  "<td colspan=\"7\"></td>";

}
/////////////////
function add_opdracht_row(){
document.getElementById('opdracht_new_td').innerHTML = "<img class=\"delete\" src=\"img/remove.png\" alt=\"remove\" width=\"15\" title=\"Opdracht verwijderen\" onclick=\"remove_row('opdracht_row_"+opdracht_i+"')\" height=\"15\"/>";
document.getElementById('opdracht_new_td').id = "";

opdracht_i++;
row = document.getElementById('add_opdracht_row');


html = "<td><input type=\"text\" class=\"text\" name=\"opdracht["+opdracht_i+"][titel]\" /></td>";
html += "<td><input style=\"width:380px;\" type=\"text\" class=\"text\" name=\"opdracht["+opdracht_i+"][omschrijving]\" /></td>";
html += "<td><select style=\"width:60px;\"  name=\"opdracht["+opdracht_i+"][jaar]\" />"+year2option+"</select></td>";
html += "<td id=\"opdracht_new_td\"><img  class=\"delete\" src=\"img/plus.gif\" alt=\"plus\" width=\"15\" onclick=\"add_opdracht_row()\" title=\"Opdracht toevoegen\" height=\"15\"/></td>";

row.innerHTML = html;
row.style.visibility = "visible";
row.id = "opdracht_row_"+opdracht_i;

table = document.getElementById('opdracht');
newRow = table.insertRow((table.rows.length-1));
newRow.id = "add_opdracht_row";
newRow.style.visibility = "hidden";
newRow.innerHTML =  "<td colspan=\"4\"></td>";

}

/////////////////
function add_price_row(){
document.getElementById('price_new_td').innerHTML = "<img class=\"delete\" src=\"img/remove.png\" alt=\"remove\" width=\"15\" title=\"price verwijderen\" onclick=\"remove_row('price_row_"+price_i+"')\" height=\"15\"/>";
document.getElementById('price_new_td').id = "";

price_i++;
row = document.getElementById('add_price_row');


html = "<td><input style=\"width:516px;\"  type=\"text\" class=\"text\" name=\"price["+price_i+"][titel]\" /></td>";
html += "<td><select style=\"width:59px;\"  name=\"price["+price_i+"][jaar]\" />"+year2option+"</select></td>";
html += "<td id=\"price_new_td\"><img  class=\"delete\" src=\"img/plus.gif\" alt=\"plus\" width=\"15\" onclick=\"add_price_row()\" title=\"price toevoegen\" height=\"15\"/></td>";

row.innerHTML = html;
row.style.visibility = "visible";
row.id = "price_row_"+price_i;

table = document.getElementById('price');
newRow = table.insertRow((table.rows.length-1));
newRow.id = "add_price_row";
newRow.style.visibility = "hidden";
newRow.innerHTML =  "<td colspan=\"3\"></td>";

}

/////////////////

function add_subs_row(){

document.getElementById('subs_new_td').innerHTML = "<img class=\"delete\" src=\"img/remove.png\" alt=\"remove\" width=\"15\" title=\"Subsidie verwijderen\" onclick=\"remove_row('subs_row_"+subs_i+"')\" height=\"15\"/>";
document.getElementById('subs_new_td').id = "";
 
subs_i++;
row = document.getElementById('add_subs_row');


html = "<td><input style=\"width:300px;\" type=\"text\" class=\"text\" name=\"subs["+subs_i+"][titel]\" /></td>";
html += "<td><input style=\"width:201px;\" type=\"text\" class=\"text\" name=\"subs["+subs_i+"][instelling]\" /></td>";
html += "<td><select style=\"width:60px;\"  name=\"subs["+subs_i+"][jaar]\" />"+year2option+"</select></td>";
html += "<td id=\"subs_new_td\"><img  class=\"delete\" src=\"img/plus.gif\" alt=\"plus\" width=\"15\" onclick=\"add_subs_row()\" title=\"Subsidie toevoegen\" height=\"15\"/></td>";

row.innerHTML = html;
row.style.visibility = "visible";
row.id = "subs_row_"+subs_i;

table = document.getElementById('subs');
newRow = table.insertRow((table.rows.length-1));
newRow.id = "add_subs_row";
newRow.style.visibility = "hidden";
newRow.innerHTML =  "<td colspan=\"4\"></td>";

}

/////////////////

function add_publicatie_row(){

document.getElementById('publicatie_new_td').innerHTML = "<img class=\"delete\" src=\"img/remove.png\" alt=\"remove\" width=\"15\" title=\"publicatieidie verwijderen\" onclick=\"remove_row('publicatie_row_"+publicatie_i+"')\" height=\"15\"/>";
document.getElementById('publicatie_new_td').id = "";
 
publicatie_i++;
row = document.getElementById('add_publicatie_row');


html = "<td><input style=\"width:300px;\" type=\"text\" class=\"text\" name=\"publicatie["+publicatie_i+"][titel]\" /></td>";
html += "<td><input style=\"width:201px;\" type=\"text\" class=\"text\" name=\"publicatie["+publicatie_i+"][gepubliceerd_in]\" /></td>";
html += "<td><select style=\"width:60px;\"  name=\"publicatie["+publicatie_i+"][jaar]\" />"+year2option+"</select></td>";
html += "<td id=\"publicatie_new_td\"><img  class=\"delete\" src=\"img/plus.gif\" alt=\"plus\" width=\"15\" onclick=\"add_publicatie_row()\" title=\"publicatieidie toevoegen\" height=\"15\"/></td>";

row.innerHTML = html;
row.style.visibility = "visible";
row.id = "publicatie_row_"+publicatie_i;

table = document.getElementById('publ');
newRow = table.insertRow((table.rows.length));
newRow.id = "add_publicatie_row";
newRow.style.visibility = "hidden";
newRow.innerHTML =  "<td colspan=\"4\"></td>";

}

///////

  
function makeeditable(id){
object_editor = document.getElementById(id);
object_editor_document = object_editor.contentWindow.document;
object_editor.contentWindow.document.designMode = 'on';
object_editor.contentWindow.focus();
if(object_editor.contentWindow.addEventListener){
object_editor.contentWindow.addEventListener("click", checkState, false);
object_editor.contentWindow.addEventListener("keydown", checkState, false);
object_editor.contentWindow.addEventListener("paste", pasteIntercept, false);
}else{
object_editor.contentWindow.attachEvent("onclick", checkState);
object_editor.contentWindow.attachEvent("onkeydown", checkState);
object_editor.contentWindow.attachEvent("onpaste", pasteIntercept);	
}
}

function createPopup(HTML, width, height){
popup = document.createElement('div');
overlay = document.createElement('div');
overlay.id = 'editoverlay';
popup.id = 'editpopup';
document.body.appendChild(overlay);
document.body.appendChild(popup);
popup.innerHTML = HTML;
popup.style.width = width+"px";
popup.style.height = height+"px";
}

function removePopup(){
document.body.removeChild(document.getElementById('editoverlay'));
document.body.removeChild(document.getElementById('editpopup'));
object_editor.contentWindow.focus();
}

function insertText(text){
text = text.replace(/</g, "&lt;");
text = text.replace(/>/g, "&gt;");
text = text.replace(/\n/g, "<br />");
object_editor.contentWindow.focus();
object_editor.contentWindow.document.execCommand("insertHTML",false,text);
}

function keepRat(input1,input2,org1,org2,changer){
	org1 = parseInt(org1);
	org2 = parseInt(org2);
	input1 = document.getElementById(input1);
	input2 = document.getElementById(input2);
	target = document.getElementById(changer);
	new1 = parseInt(input1.value);
	new2 = parseInt(input2.value);
	if(input1 == target){
	rat = new1/org1;
	newvalue = org2*rat;
	if(!isNaN(newvalue)){
	input2.value = Math.round(newvalue);
	}
	else{
	input2.value = '';
	}
	}
	if(input2 == target){
	rat = new2/org2;
	newvalue = org1*rat;
	if(!isNaN(newvalue)){
	input1.value = Math.round(newvalue);
	}
	else{
	input1.value = '';
	}
	}	
}


function insertPic(mode,fileurl,filename,filetype,node){
if(mode=='setedit'){
sel = object_editor.contentWindow.getSelection();
nodeObj = sel.anchorNode.childNodes[sel.anchorOffset];
nodeObj.width = document.getElementById('width').value;
nodeObj.height = 	document.getElementById('height').value;
nodeObj.hspace = document.getElementById('hspace').value;
nodeObj.align = document.getElementById('align').value;
removePopup()
}
else if(mode=='edit'){
showOverlay();
showPopup("<div align=\"center\" style='padding:5px;'><table width=100% cellspacing=8 cellpadding=0><tr><td><b>Breedte</b></td><td><input onchange=\"keepRat('width','height',window.org1,window.org2);\" id='width' name=\"width\" type=\"text\" size=\"2\" maxlength=\"4\"></td><td><b>Hoogte</b></td><td><input onchange=\"keepRat('width','height',window.org1,window.org2);\" id='height' name=\"height\" type=\"text\" size=\"2\" maxlength=\"4\"></td></tr><tr><td style='font-size:10px;' align=center colspan=4><table border=\"0\" cellspacing=\"2\" cellpadding=\"0\"><tr><td><INPUT TYPE=\"checkbox\" id=\"aspect\" name=\"aspect\" value=\"aspect\" checked=\"checked\"></td><td style='font-size:10px;'>&nbsp;Verhoudingen behouden</td></tr></table></td></tr></table><br><table width=100% border=0 cellspacing=8 cellpadding=0><tr><td colspan=2><b>Ruimte om afbeelding</b></td><td align=right><input value='2' name=\"hspace\" id=\"hspace\" type=\"text\" size=\"2\" maxlength=\"3\"></td></tr><tr><td><b>Uitlijning</b></td><td colspan=2><select style='font-size:12px;' id='align'><option value='top'>Boven</option><option value='bottom'>Benen</option><option value='middle'>Midden</option><option value='left'>Links</option><option value='right'>Rechts</option></select></td></tr></table><br><input onmouseover=\"this.className = 'ed-Xcoolsubmit'\" onmouseout=\"this.className = 'ed-coolsubmit'\"  type=\"submit\" style=\"margin-top:-10px;\" class=\"ed-coolsubmit\" onclick=\"insertPic('setedit')\" value=\"OK!\" id='editPIC'></div>",260,250,"Afbeelding bewerken");

window.org1 = node.width;
window.org2 = node.height;
document.getElementById('height').value = node.height;
document.getElementById('width').value = node.width;
document.getElementById('hspace').value = node.hspace;
document.getElementById('align').value = node.align;
setTimeout("document.getElementById('width').focus()",1);

}
else if(mode=='submit'){
if(document.getElementById('resmeth').value == 'PHP'){
  var xmlHttp = new XMLHttpRequest();
  xmlHttp.onreadystatechange=function(){
   if(xmlHttp.readyState==4){
   if(xmlHttp.responseText == "resized"){
	object_editor_document.execCommand('insertHTML',false,"<img src='"+window.img_filepath+"' height='"+document.getElementById('height').value+"' width='"+document.getElementById('width').value+"' hspace = '"+document.getElementById('hspace').value+"' align='"+document.getElementById('align').value+"'>");  
	removePopup();
	}else{
	alert("Something went wrong while resizing:\n"+xmlHttp.responseText);
	}
    }
   }
  xmlHttp.open("GET","inc/resize.php?img_height="+document.getElementById('height').value+"&img_width="+document.getElementById('width').value+"&img_filepath="+window.img_filepath+"&img_abs_path="+window.img_abs_path+"",true);
  xmlHttp.send(null);	
}else{
object_editor_document.execCommand('insertHTML',false,"<img src='"+window.img_filepath+"' height='"+document.getElementById('height').value+"' width='"+document.getElementById('width').value+"' hspace = '"+document.getElementById('hspace').value+"' align='"+document.getElementById('align').value+"'>");
removePopup();
}
}
else{
createPopup("<div class='closebtn'><img onclick='removePopup();' src='img/closelight.png' onmouseover=\"this.src ='img/closedark.png'\" onmouseout=\"this.src ='img/closelight.png'\" title='Popup sluiten' /></div><h1>Afbeedling invoegen</h1><form style=\"margin:10px;\" id='Picform' enctype=\"multipart/form-data\" action=\"inc/upload.php?img=true\" method='post' target=\"Ipic\"><input size=58 name=\"uploadfile\" onChange=\"document.getElementById('noimselect').style.display = 'none'; document.getElementById('imgloader').style.display = 'inline'; document.getElementById('Picform').submit();\" type=\"file\"></form><table cellspacing='10' cellpadding='0'><tr><td id=\"dimen\" valign='top'><div class=\"fieldtitle\">- Afmetingen -</div><table border=\"0\" cellspacing=\"9\" cellpadding=\"0\"><tr><td><b>Breedte</b></td><td><input onkeyup=\"keepRat('width','height',window.org1,window.org2,'width');\" id='width' disabled name=\"width\" type=\"text\" size=\"2\" maxlength=\"4\"></td><td><b>Hoogte</b></td><td><input onkeyup=\"keepRat('width','height',window.org1,window.org2,'height');\" id='height' name=\"height\" type=\"text\" size=\"2\" disabled maxlength=\"4\"></td></tr><tr><td><strong>Manier</strong></td><td colspan=\"3\"><select style='font-size:12px;font-family:Verdana, Geneva, sans-serif;' name='resmeth' id='resmeth'><option value='PHP'>Bestand verkleinen</option><option value='HTML'>Kleiner weergeven</option></select></td></tr><tr><td colspan=\"4\" align=\"center\"><table border=\"0\" cellspacing=\"2\" cellpadding=\"0\"><tr><td><INPUT TYPE=\"checkbox\" id=\"aspect\" NAME=\"aspect\" VALUE=\"aspect\" CHECKED></td><td style='font-size:10px;'>&nbsp;Verhoudingen behouden</td></tr></table></tr></table></td><td valign='top'  id=\"dimen\"><div class=\"fieldtitle\">- Opties -</div><table width=\"100%\" border=\"0\" cellspacing=\"9\" cellpadding=\"0\"><tr><td colspan=\"2\"><strong>Ruimte om afbeelding</strong></td><td align=\"right\"><input value='2' name=\"hspace\" id=\"hspace\" type=\"text\" size=\"2\" maxlength=\"3\"></td></tr></table><table style=\"margin-top:-9px;\" width=\"100%\" border=\"0\" cellspacing=\"9\" cellpadding=\"0\"><tr><td><strong>Uitlijning</strong></td><td align=\"right\"><select style='font-size:12px;' id='align'><option value='top'>Boven</option><option value='bottom'>Benen</option><option value='middle'>Midden</option><option value='left'>Links</option><option value='right'>Rechts</option></select></td></tr></table></td></tr></table><div id=\"example\"><div style=\"margin-bottom:-17px;\" class=\"fieldtitle\">- Voorbeeld -</div><table style=\"width:100%; height:100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td valign=\"middle\" align=\"center\"><iframe name='Ipic' style='display:none;'></iframe><strong><img  src='img/ajax-loader.gif' id='imgloader'><span id='imprev'></span><span id='noimselect'>U heeft nog geen afbeelding geselecteerd</span></strong></td></tr></table></div><div align=center><input onmouseover=\"this.className = 'ed-Xcoolsubmit'\" onmouseout=\"this.className = 'ed-coolsubmit'\"  type=\"submit\" class=\"ed-coolsubmit\"  disabled  onclick=\"insertPic('submit',window.fileurl,window.filename,window.filetype)\" value=\"Invoegen!\" id='addPIC'></div>",505,450);
}
}


function format(cue,id){
if(cue=="TXT"){
createPopup("<div class='closebtn'><img onclick='removePopup();' src='img/closelight.png' onmouseover=\"this.src ='img/closedark.png'\" onmouseout=\"this.src ='img/closelight.png'\" title='Popup sluiten' /></div><h1>Tekst invoegen</h1><textarea id='insertArea'></textarea><br /><button onclick=\" insertText(document.getElementById('insertArea').value);removePopup(); \">Invoegen!</button>");
setTimeout("document.getElementById('insertArea').focus()",1);
}
else if(cue=="IMG"){

insertPic();

}else if(cue=="P" || cue=="H1" || cue=="H2" || cue=="H3" || cue=="H4" || cue=="H5" || cue=="H6"){
object_editor.contentWindow.focus();
object_editor.contentWindow.document.execCommand("formatBlock",false,"<"+cue+">");
checkState();
//alert('wtf')
}else{
object_editor.contentWindow.document.execCommand(cue,false,null);}
object_editor.contentWindow.focus();
checkState();
}

function checkState(){
if(object_editor.contentWindow.document.queryCommandState('Bold')){
document.getElementById('boldInd').className = 'active';
}
else{
document.getElementById('boldInd').className = '';
}

if(object_editor.contentWindow.document.queryCommandState('Underline')){
document.getElementById('underlineInd').className = 'active';
}
else{
document.getElementById('underlineInd').className = '';
}

if(object_editor.contentWindow.document.queryCommandState('Italic')){
document.getElementById('italicInd').className = 'active';
}
else{
document.getElementById('italicInd').className = '';
}
}

function pasteIntercept(e){
alert('Het is niet mogelijk direct te plakken; om te plakken kiest u Invoegen > Tekst')
e.preventDefault();
}

function expandMenu(id,id2){
if(document.getElementById(id).style.display == 'block'){
document.getElementById(id).style.display = 'none';
}
else{
document.getElementById(id).style.display = 'block';
document.getElementById(id).style.left = document.getElementById(id2).offsetLeft+1+"px";
if(parseInt(document.getElementById(id).offsetWidth) < parseInt(document.getElementById(id2).offsetWidth)){
document.getElementById(id).style.width = (parseInt(document.getElementById(id2).offsetWidth))+"px";
}
}
}

function showTB(id,e){
	if(!e.target){
	target = window.event.srcElement;
	}
	else{
	target = e.target;	
	}	
TB = document.getElementById(id);
if(TB.style.display == 'none'){
TB.style.display = 'table';
target.innerHTML = 'Sluiten'
}
else{
TB.style.display = 'none';
target.innerHTML = 'Openen'
}
}

function rollIntopbar(color,rollouttime,value){
document.getElementById('error').innerHTML = value;
if(!color){
color = '#FF0000';
}
document.getElementById('error').style.backgroundColor = color;
if(rollouttime){
hoesnel3 = 10 //in milliseconden
div3 = document.getElementById('shadow');
div4 = document.getElementById('error');
timer3 = rollouttime*1000;
i5 = 0;
for (i4=25;i4>=-10;i4--) 
{
setTimeout("div4.style.top = '"+i5+"px'",timer3);
setTimeout("div3.style.top = '"+i4+"px'",timer3);
timer3 = timer3+hoesnel3;
i5--;
}	
}
hoesnel2 = 10 //in milliseconden
div3 = document.getElementById('shadow');
div4 = document.getElementById('error');
timer2 = 0;
i3 = -25;
for (i2=0;i2<=25;i2++) 
{
setTimeout("div4.style.top = '"+i3+"px'",timer2);
setTimeout("div3.style.top = '"+i2+"px'",timer2);
timer2 = timer2+hoesnel2;
i3++;
}
}

function switchTab(parentID,newID,tabsContID){
	allelem = document.getElementById(parentID).getElementsByTagName('table');
	for(i=0;i<allelem.length;i++){
		allelem[i].style.display = 'none';
	}
	document.getElementById(newID).style.display = 'table';
	
	alltabs = document.getElementById(tabsContID).getElementsByTagName('a');
	for(i=0;i<alltabs.length;i++){
		alltabs[i].className = 'tab';
	}
}

///////

function changeValue(target,property,value,window){
windowID = document.getElementById(window);
if(target == 'menua'){
	sheet = windowID.contentWindow.document.styleSheets[1];
	if(sheet.cssRules){
		theRules = sheet.cssRules;}
	else{
		theRules = sheet.rules	
	}
	theRules[theRules.length-3].style.color = '#'+value;
}
else if(target == 'menuaover'){
	sheet = window.contentWindow.document.styleSheets[1];
	if(sheet.cssRules){
		theRules = sheet.cssRules;}
	else{
		theRules = sheet.rules	
	}
	theRules[theRules.length-1].style.color = '#'+value;
	theRules[theRules.length-2].style.color = '#'+value;
}
else{
	targetOBJ = windowID.contentWindow.document.getElementById(target);
	if(property == 'backgroundColor'){
		if(target == 'menu'){
			sheet = windowID .contentWindow.document.styleSheets[1];
			if(sheet.cssRules){
				theRules = sheet.cssRules;}
			else{
				theRules = sheet.rules	
			}
			theRules[theRules.length-1].style.backgroundColor = '#'+value;
		}
		targetOBJ.style.backgroundColor = "#"+value;
	}
if(property == 'color'){
	targetOBJ.style.color = "#"+value;
	}
}
}

function gebi(id){
return document.getElementById(id);
}

function gebtn(tag){
return document.getElementsByTagName(tag);
}

/*
function saveStyles(){
bodybgval = '#'+gebi('bodybg').value;
menubgval = '#'+gebi('menubg').value;
contentbgval = '#'+gebi('contentbg').value;
tekstCval = '#'+gebi('tekstC').value;
naamCval = '#'+gebi('naamC').value;
footerCval = '#'+gebi('footerC').value;
menuCval = '#'+gebi('menuC').value;
menuACval = '#'+gebi('menuAC').value;
}
*/

function setLeaveEvnt(){
allObj = gebtn('*');
for(i=0; i<allObj.length;i++){
	if(allObj[i].addEventListener){
allObj[i].addEventListener('change',alertonleave,false);
	}else{
		allObj[i].attachEvent('onchange',alertonleave);
	}
}
}

function alertonleave(){
window.onbeforeunload = function(){return 'Alle niet opgeslagen gegevens zullen verloren gaan.'}
}


function crybeforeleave(){
window.onbeforeunload = function(){return 'Uw aanmelding is nog niet voltooid weet u zeker dat u wilt stoppen?'}
allform = document.getElementsByTagName('input');
for(i=0;i<allform.length;i++){
	allform[i].onsubmit = function(){
		alert('test');
		window.onbeforeunload = function(){};
	}
}
}


function removeLeaveEvnt(){
window.onbeforeunload = function(){};
}


///

function addGroep(){
name = prompt('Vul hier de naam van de nieuwe groep in');
if(name){
window.location.href = '?page=kunstwerken&action=addgroep&titel='+name
}else{
alert("U heeft geen naam opgegeven!");
}
}

function showOrHide(id,type){
if(!type){type = 'block';}
if(gebi(id).style.display == 'none'){
gebi(id).style.display = type;
return true;
}
else{
gebi(id).style.display = 'none';
return false;
}
}

function autotranslate(){
if(gebi('content[en][titel]]').value == ''){
google.language.translate(document.getElementById('content[nl][titel]]').value, 'nl', 'en',function(result){document.getElementById('content[en][titel]]').value = result.translation;});
}
if(gebi('content[en][omschrijving]]').value == ''){
google.language.translate(document.getElementById('content[nl][omschrijving]]').value, 'nl', 'en',function(result){document.getElementById('content[en][omschrijving]]').value = result.translation;});
}
if(gebi('content[en][materiaal]]').value == ''){
google.language.translate(document.getElementById('content[nl][materiaal]]').value, 'nl', 'en',function(result){document.getElementById('content[en][materiaal]]').value = result.translation;});
}
if(gebi('content[en][sokkel_materiaal]]').value == ''){
google.language.translate(document.getElementById('content[nl][sokkel_materiaal]]').value, 'nl', 'en',function(result){document.getElementById('content[en][sokkel_materiaal]]').value = result.translation;});
}

if(gebi('content[de][titel]]').value == ''){
google.language.translate(document.getElementById('content[nl][titel]]').value, 'nl', 'de',function(result){document.getElementById('content[de][titel]]').value = result.translation;});
}
if(gebi('content[de][omschrijving]]').value == ''){
google.language.translate(document.getElementById('content[nl][omschrijving]]').value, 'nl', 'de',function(result){document.getElementById('content[de][omschrijving]]').value = result.translation;});
}
if(gebi('content[de][materiaal]]').value == ''){
google.language.translate(document.getElementById('content[nl][materiaal]]').value, 'nl', 'de',function(result){document.getElementById('content[de][materiaal]]').value = result.translation;});
}
if(gebi('content[de][sokkel_materiaal]]').value == ''){
google.language.translate(document.getElementById('content[nl][sokkel_materiaal]]').value, 'nl', 'de',function(result){document.getElementById('content[de][sokkel_materiaal]]').value = result.translation;});
}

if(gebi('content[fr][titel]]').value == ''){
google.language.translate(document.getElementById('content[nl][titel]]').value, 'nl', 'fr',function(result){document.getElementById('content[fr][titel]]').value = result.translation;});
}
if(gebi('content[fr][omschrijving]]').value == ''){
google.language.translate(document.getElementById('content[nl][omschrijving]]').value, 'nl', 'fr',function(result){document.getElementById('content[fr][omschrijving]]').value = result.translation;});
}
if(gebi('content[fr][materiaal]]').value == ''){
google.language.translate(document.getElementById('content[nl][materiaal]]').value, 'nl', 'fr',function(result){document.getElementById('content[fr][materiaal]]').value = result.translation;});
}
if(gebi('content[fr][sokkel_materiaal]]').value == ''){
google.language.translate(document.getElementById('content[nl][sokkel_materiaal]]').value, 'nl', 'fr',function(result){document.getElementById('content[fr][sokkel_materiaal]]').value = result.translation;});
}

if(gebi('content[es][titel]]').value == ''){
google.language.translate(document.getElementById('content[nl][titel]]').value, 'nl', 'es',function(result){document.getElementById('content[es][titel]]').value = result.translation;});
}
if(gebi('content[es][omschrijving]]').value == ''){
google.language.translate(document.getElementById('content[nl][omschrijving]]').value, 'nl', 'es',function(result){document.getElementById('content[es][omschrijving]]').value = result.translation;});
}
if(gebi('content[es][materiaal]]').value == ''){
google.language.translate(document.getElementById('content[nl][materiaal]]').value, 'nl', 'es',function(result){document.getElementById('content[es][materiaal]]').value = result.translation;});
}
if(gebi('content[es][sokkel_materiaal]]').value == ''){
google.language.translate(document.getElementById('content[nl][sokkel_materiaal]]').value, 'nl', 'es',function(result){document.getElementById('content[es][sokkel_materiaal]]').value = result.translation;});
}

if(gebi('content[it][titel]]').value == ''){
google.language.translate(document.getElementById('content[nl][titel]]').value, 'nl', 'it',function(result){document.getElementById('content[it][titel]]').value = result.translation;});
}
if(gebi('content[it][omschrijving]]').value == ''){
google.language.translate(document.getElementById('content[nl][omschrijving]]').value, 'nl', 'it',function(result){document.getElementById('content[it][omschrijving]]').value = result.translation;});
}
if(gebi('content[it][materiaal]]').value == ''){
google.language.translate(document.getElementById('content[nl][materiaal]]').value, 'nl', 'it',function(result){document.getElementById('content[it][materiaal]]').value = result.translation;});
}
if(gebi('content[it][sokkel_materiaal]]').value == ''){
google.language.translate(document.getElementById('content[nl][sokkel_materiaal]]').value, 'nl', 'it',function(result){document.getElementById('content[it][sokkel_materiaal]]').value = result.translation;});
}

if(gebi('content[pt][titel]]').value == ''){
google.language.translate(document.getElementById('content[nl][titel]]').value, 'nl', 'pt',function(result){document.getElementById('content[pt][titel]]').value = result.translation;});
}
if(gebi('content[pt][omschrijving]]').value == ''){
google.language.translate(document.getElementById('content[nl][omschrijving]]').value, 'nl', 'pt',function(result){document.getElementById('content[pt][omschrijving]]').value = result.translation;});
}
if(gebi('content[pt][materiaal]]').value == ''){
google.language.translate(document.getElementById('content[nl][materiaal]]').value, 'nl', 'pt',function(result){document.getElementById('content[pt][materiaal]]').value = result.translation;});
}
if(gebi('content[pt][sokkel_materiaal]]').value == ''){
google.language.translate(document.getElementById('content[nl][sokkel_materiaal]]').value, 'nl', 'pt',function(result){document.getElementById('content[pt][sokkel_materiaal]]').value = result.translation;});
}

if(checkartfields())
{
	isReady();
}

}

var readyTimer = null;
function isReady()
{
	if(gebi('content[pt][materiaal]]').value != '')
	{
		clearTimeout(readyTimer);
		removeLeaveEvnt(); 
		gebi('art_info').submit();
	} else {
		readyTimer = setTimeout("isReady()",500);
	}
}

function checkartfields(){
/*Verplicht:
- Titel
- Materiaal
- Groep
- Categorie (graag standaard op 'maak een keuze')
- Thema (graag standaard op 'maak een keuze')
- Techniek (graag standaard op 'maak een keuze')
- Prijs (graag nog een Û ervoor)
- Type lijst (graag standaard op 'maak een keuze')
- breedte (de tweede)
- Gewicht
- Beschikbaarheid
- Opties*/
//alert(gebi('content[nl][omschrijving]]').value);
if(gebi('content[nl][titel]]').value != '' && gebi('content[nl][materiaal]]').value != '' && gebi('categorie').value != 'Maak een keuze' && gebi('thema').value != 'Maak een keuze' && gebi('techniek').options[gebi('techniek').selectedIndex].innerHTML != 'Maak een keuze' && gebi('prijs').value != '' && gebi('prijs').value != 0 && gebi('type_lijst').options[gebi('type_lijst').selectedIndex].innerHTML != 'Maak een keuze' && gebi('breedte').value != '' && gebi('breedte').value != 0 && gebi('diepte').value != '' && gebi('diepte').value != 0 && gebi('hoogte').value != '' && gebi('hoogte').value != 0 && gebi('gewicht_kg').value != '' && gebi('gewicht_kg').value != 0 && gebi('status_id').value != '' && gebi('fileform_ul1').getElementsByTagName('img')[0] && (gebi('type_lijst').options[gebi('type_lijst').selectedIndex].value == 8 || 

(gebi('hoogte_incl_lijst').value != '' && gebi('hoogte_incl_lijst').value != 0 && gebi('breedte_incl_lijst').value != '' && gebi('breedte_incl_lijst').value != 0)

)){

return true

}
else{
if(gebi('content[nl][titel]]').value == ''){
gebi('content[nl][titel]]').style.borderColor = 'Red'; 
}
if(gebi('content[nl][materiaal]]').value == ''){
gebi('content[nl][materiaal]]').style.borderColor = 'Red'; 
}
if(gebi('categorie').options[gebi('categorie').selectedIndex].value == ""){
gebi('categorie').style.border= '1px solid red';  
}
if(gebi('thema').options[gebi('thema').selectedIndex].value == ""){
gebi('thema').style.border= '1px solid red'; 
}
if(gebi('techniek').options[gebi('techniek').selectedIndex].value == ""){
gebi('techniek').style.border= '1px solid red';  
}
if(gebi('prijs').value == '' || gebi('prijs').value == 0){
gebi('prijs').style.borderColor = 'Red'; 
}
if(gebi('type_lijst').options[gebi('type_lijst').selectedIndex].value == ""){
gebi('type_lijst').style.border= '1px solid red';  
}

if(gebi('type_lijst').options[gebi('type_lijst').selectedIndex].value != 8){
if(gebi('hoogte_incl_lijst').value == '' || gebi('hoogte_incl_lijst').value == 0){
gebi('hoogte_incl_lijst').style.borderColor = 'Red'; 
}
if(gebi('breedte_incl_lijst').value == '' || gebi('breedte_incl_lijst').value == 0){
gebi('breedte_incl_lijst').style.borderColor = 'Red'; 
}
}

if(gebi('breedte').value == '' || gebi('breedte').value == 0){
gebi('breedte').style.borderColor = 'Red'; 
}
if(gebi('hoogte').value == '' || gebi('hoogte').value == 0){
gebi('hoogte').style.borderColor = 'Red'; 
}
if(gebi('diepte').value == '' || gebi('diepte').value == 0){
gebi('diepte').style.borderColor = 'Red'; 
}
if(gebi('gewicht_kg').value == '' || gebi('gewicht_kg').value == 0){
gebi('gewicht_kg').style.borderColor = 'Red'; 
}
if(gebi('status_id').value == ''){
gebi('status_id').style.borderColor = 'Red'; 
}
if(!gebi('fileform_ul1').getElementsByTagName('img')[0]){
gebi('fileform_ul1').parentNode.getElementsByTagName('div')[0].style.border= '1px solid red';  
}
setTimeout("rollIntopbar('#ff6600',3,'Let op, u bent &eacute;&eacute;n of meer verplichte velden vergeten. Controleer de rood omrande velden en probeer het opnieuw');",5);
return false;
}
}

function disableEnterKey(e)
{
     var key;
     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox
     if(key == 13)
          return false;
     else
          return true;
}

function setStyleSheet(achtergrond,menubalk,tekstachtergrond,tekstkleur,naam,footer,menulinks,menulinks_actief,header,hd,window){
window = document.getElementById(window);
sheet = window.contentWindow.document.styleSheets[1];
if(sheet.cssRules){
theRules = sheet.cssRules;}
else{
theRules = sheet.rules	
}
theRules[theRules.length-3].style.color = '#'+menulinks;
gebi('menuC').color.fromString(menulinks);
theRules[theRules.length-1].style.color = '#'+menulinks_actief;
theRules[theRules.length-2].style.color = '#'+menulinks_actief;
gebi('menuAC').color.fromString(menulinks_actief);
theRules[theRules.length-1].style.backgroundColor = '#'+menubalk;
window.contentWindow.document.body.style.backgroundColor = '#'+achtergrond;
gebi('bodybg').color.fromString(achtergrond);
window.contentWindow.document.getElementById('menu').style.backgroundColor = '#'+menubalk;
gebi('menubg').color.fromString(menubalk);
window.contentWindow.document.getElementById('bottomcorners').style.backgroundColor = '#'+tekstachtergrond;
gebi('contentbg').color.fromString(tekstachtergrond);
window.contentWindow.document.getElementById('content').style.backgroundColor = '#'+tekstachtergrond;
window.contentWindow.document.getElementById('content').style.color = '#'+tekstkleur;
gebi('tekstC').color.fromString(tekstkleur);
window.contentWindow.document.getElementById('name').style.color = '#'+naam;
gebi('naamC').color.fromString(naam);
window.contentWindow.document.getElementById('footer').style.color = '#'+footer;
gebi('footerC').color.fromString(footer);
window.contentWindow.document.getElementById('header').style.backgroundImage = 'url('+header+')';
gebi('default_header').value = hd;
}

function setMeActive(parent,tag,e){
	if(!e.target){
	target = window.event.srcElement;
	}
	else{
	target = e.target;	
	}	
allen = gebi(parent).getElementsByTagName(tag);
for(i=0; i<allen.length; i++){
if(allen[i].className == 'active'){
allen[i].className = 'smpl';
allen[i].onmouseover = function(){this.className = 'Xsmpl'};
allen[i].onmouseout = function(){this.className = 'smpl'};
}
}
target.className = 'active';
target.onmouseover = function(){};
target.onmouseout = function(){};
}

function checkNAW(){
if(gebi('email').value != '' && gebi('naam').value != '' && gebi('achternaam').value != '' && gebi('sexe').value != '' && gebi('straatnr').value != '' && gebi('postcode').value != '' && gebi('plaats').value != '' && gebi('telefoon').value != ''){
return true;
}
else{
rollIntopbar('#ff6600',2,'Let op, u bent &eacute;&eacute;n of meer verplichte velden vergeten. Controleer de rood omrande velden en probeer het opnieuw');
if(gebi('email').value == ''){
gebi('email').style.borderColor = 'red';	
}
if(gebi('naam').value == ''){
gebi('naam').style.borderColor = 'red';	
}
if(gebi('achternaam').value == ''){
gebi('achternaam').style.borderColor = 'red';	
}
if(gebi('sexe').value == ''){
gebi('sexe').style.borderColor = 'red';	
}
if(gebi('straatnr').value == ''){
gebi('straatnr').style.borderColor = 'red';	
}
if(gebi('postcode').value == ''){
gebi('postcode').style.borderColor = 'red';	
}
if(gebi('plaats').value == ''){
gebi('plaats').style.borderColor = 'red';	
}
if(gebi('telefoon').value == ''){
gebi('telefoon').style.borderColor = 'red';	
}
return false;	
}
}

function checkBET(){
if(gebi('bank_rekeningnummer').value != '' && gebi('bank_tennamevan').value != '' && gebi('bank_plaats').value != '' && gebi('bank_iban').value != ''){
return true;
}
else{
rollIntopbar('#ff6600',2,'Let op, u bent &eacute;&eacute;n of meer verplichte velden vergeten. Controleer de rood omrande velden en probeer het opnieuw');
if(gebi('bank_rekeningnummer').value == ''){
gebi('bank_rekeningnummer').style.borderColor = 'red';	
}
if(gebi('bank_tennamevan').value == ''){
gebi('bank_tennamevan').style.borderColor = 'red';	
}
if(gebi('bank_plaats').value == ''){
gebi('bank_plaats').style.borderColor = 'red';	
}
if(gebi('bank_iban').value == ''){
gebi('bank_iban').style.borderColor = 'red';	
}
if(gebi('min_uitbetaling').value == ''){
gebi('min_uitebetaling').style.borderColor = 'red';	
}
return false;	
}	
}


function checkBELAS(){
if(gebi('btwnr_tr').style.display != 'none'&& gebi('btwnr').value == ''){
	rollIntopbar('#ff6600',2,'Let op, u bent &eacute;&eacute;n of meer verplichte velden vergeten. Controleer de rood omrande velden en probeer het opnieuw');
	gebi('btwnr').style.borderColor = 'red';	
	return false;
}
else{
	return true;
}
}

