
var aLoaded=false;

function confirm_this() {
	return confirm('Weet u het zeker?');
}

var noedit = true;

function show(obj) {
	noedit=true;
	document.getElementById('item_'+obj+'_show').style.display='block';
	document.getElementById('item_'+obj+'_edit').style.display='none';
	for (i=1;i<=10;i++) {
		document.getElementById('but_'+i+'_edit').disabled=false;
		document.getElementById('item_'+i+'_move').style.display='block';
	}
}
function edit(obj) {
	if (noedit) {
		noedit=false;
		document.getElementById('item_'+obj+'_edit').style.display='block';
		document.getElementById('item_'+obj+'_show').style.display='none';
		check_size('txt_'+obj,'cnt_'+obj);
		for (i=1;i<=10;i++) {
			document.getElementById('but_'+i+'_edit').disabled=true;
			document.getElementById('item_'+i+'_move').style.display='none';
		}
	}
}

function cancel(obj) {
	document.getElementById('txt_'+obj).value = document.getElementById('orig_'+obj).value;
	show(obj);
}

function check_size(fld,box) {
	var size = 1000;
	//eval ("if (document.getElementById('"+fld+"').value.length > "+size+") document.getElementById('"+fld+"').value = document.getElementById('"+fld+"').value.substring(0, "+size+");");
	eval ("document.getElementById('"+box+"').value = ("+size+" - document.getElementById('"+fld+"').value.length);");
	
	if (document.getElementById(fld).value.length > size) {
		document.getElementById(box).style.color='FF0000';
	} else {
		document.getElementById(box).style.color='000000';
	}
}

function check_edit() {
	return noedit;
}

function popup(commercial_id,scene_id) {
	obj = window.open('','popup','width=700,height=525');
	obj.document.write("<html>");
	obj.document.write("<head><style>body {margin:0}</style><title>Foto "+scene_id+"</title></head>");
	obj.document.write("<body><img src='commercials/commercial_"+commercial_id+"/foto_"+scene_id+".jpg' width='700' height='525' onclick='window.close()' style='cursor: pointer' title='Klik hier om de foto te sluiten' /></body>");
	obj.document.write("</html>");
	obj.window.focus();
}

function popupOlc(commercial_id,scene_id) {
	obj = window.open('','popup','width=700,height=525');
	obj.document.write("<html>");
	obj.document.write("<head><style>body {margin:0}</style><title>Foto "+scene_id+"</title></head>");
	obj.document.write("<body><img src='../commercials/commercial_"+commercial_id+"/foto_"+scene_id+".jpg' width='700' height='525' onclick='window.close()' style='cursor: pointer' title='Klik hier om de foto te sluiten' /></body>");
	obj.document.write("</html>");
	obj.window.focus();
}

function find_words(str) {
	return str.match(/\b(gouden)\b/gim);
}

function check_sterkepunten() {
	
	if ( (res = find_words(document.getElementById('kernpunt_1').value)) ||
		 (res = find_words(document.getElementById('kernpunt_2').value)) ||
		 (res = find_words(document.getElementById('kernpunt_3').value)) ||
		 (res = find_words(document.getElementById('kernpunt_4').value)) ||
		 (res = find_words(document.getElementById('kernpunt_5').value)) ) {
		if (res.length > 1) {
			alert('De volgende woorden zijn niet toegestaan: '+res);
		} else {
			alert('Het volgende woord is niet toegestaan: '+res);
		}
		return false;
	}
}

function check_text(obj) {
	if (res = find_words(document.getElementById('txt_'+obj).value)) {
		if (res.length > 1) {
			alert('De volgende woorden zijn niet toegestaan: '+res);
		} else {
			alert('Het volgende woord is niet toegestaan: '+res);
		}
		document.getElementById('txt_'+obj).focus();
		return false;
	}
}

function klantnummer_check() {
	if(isNaN(document.getElementById("klantnummer").value)) {
		alert("Een klantnummer kan alleen uit cijfers bestaan");
		document.getElementById("klantnummer").focus();
		return false
	}
	return true;
}

function login_check() {
	if(document.getElementById("emailadres").value=="") {
		alert("Vergeet niet een e-mailadres in te vullen!");
		document.getElementById("emailadres").focus();
		return false
	}
	var regx  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (! regx.test(document.getElementById("emailadres").value) ) {
	  alert("Het ingevulde e-mailadres is ongeldig, probeer het nog eens!");
	  document.getElementById("emailadres").focus();
		  return (false); 	  
   }
	if(document.getElementById("wachtwoord").value=="") {
		alert("Vergeet niet een wachtwoord in te vullen!");
		document.getElementById("wachtwoord").focus();
		return false
	}
}

function stap1_check() {
	if(document.getElementById("bedrijf").value=="") {
		alert("Vergeet niet een bedrijf/instelling in te vullen!");
		document.getElementById("bedrijf").focus();
		return false
	}
	if(document.getElementById("straat").value=="") {
		alert("Vergeet niet een straat in te vullen!");
		document.getElementById("straat").focus();
		return false
	}
	if(document.getElementById("huisnummer").value=="") {
		alert("Vergeet niet een huisnummer adres in te vullen!");
		document.getElementById("huisnummer").focus();
		return false
	}
	if(document.getElementById("postcode").value=="") {
		alert("Vergeet niet een postcode in te vullen!");
		document.getElementById("postcode").focus();
		return false
	}
	if(document.getElementById("plaats").value=="") {
		alert("Vergeet niet een plaats in te vullen!");
		document.getElementById("plaats").focus();
		return false
	}
	if(document.getElementById("emailadres").value=="") {
		alert("Vergeet niet een e-mailadres in te vullen!");
		document.getElementById("emailadres").focus();
		return false
	}
	var regx  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (! regx.test(document.getElementById("emailadres").value) ) {
		alert("Het ingevulde e-mailadres is ongeldig, probeer het nog eens!");
		document.getElementById("emailadres").focus();
		return false; 	  
	}
}

function klant_scene_check(sceneId) {
	if ( document.getElementById("txt_"+sceneId).value.length < 10 ) {
		return confirm("Wanneer u weinig tekst opgeeft zal de foto kort worden weergegeven. Weet u zeker dat uw wilt opslaan?");
	}
}

function olc_scene_check(sceneId) {
	return true;
	// Voor nu nog geen validatie
}


function stap6_check() {
	if(document.getElementById("afgekeurd").checked==true && document.getElementById("reden").value=="") {
		alert("U dient een reden op te geven!");
		document.getElementById("reden").focus();
		return false
	}
	return true;
}

function LoadSwf(SwfUrl,bgcolor,width,height,objectid) {
        document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" id="'+objectid+'" width="'+width+'" height="'+height+'">');
        document.write('<param name="allowScriptAccess" value="always" />');
        document.write('<param name="movie" value="'+SwfUrl+'" />');
        document.write('<param name="quality" value="best" />');
        document.write('<param name="bgcolor" value="'+bgcolor+'" />');
        document.write('<embed src="'+SwfUrl+'" quality="best" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'" name="'+objectid+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
        document.write('</object>');
}	

