var isIE = /*@cc_on!@*/false;
var isIE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
var isIE7 = false /*@cc_on || @_jscript_version >= 5.7 @*/;

var slideshow = false;

function confirm_link(message, link)
{
	var r=confirm(message);
	if(!link) { return (r) ? true : false }
	if (r==true) document.location.href=link;
}

function go_link(link, _blank)
{
	if(_blank === true)
	{
		var newWindow = window.open(link, 'newWindow');
		newWindow.focus();
		return;
	}
	document.location.href=link;
}

function init_loginform()
{
	if(document.loginform)
	{
		var user = document.loginform.user;
		var pass = document.loginform.pass;
		var val2 = 'gebruikersnaam';
		var val3 = 'wachtwoord';
		var color_inactive = '#91989B'; //grijs
		var color_active = '#000000'; //zwart
		
		user.setStyle('color', color_inactive); //init
		pass.setStyle('color', color_inactive); //init
		user.value = val2;
		pass.value = val3;
		
		if(isIE || isIE6 || isIE7)
		{	
			user.attachEvent('onblur', function(){
					if(user.value=='') {
						user.setStyle('color', color_inactive);
						user.value=val2;
					}
				});
			user.attachEvent('onfocus', function(){
					if(user.value==val2) user.value='';
					user.setStyle('color', color_active);
				});
			pass.attachEvent('onblur', function(){
					if(pass.value=='') {
						pass.setStyle('color', color_inactive);
						pass.value=val3;
					}
				});
			pass.attachEvent('onfocus', function(){
					if(pass.value==val3) pass.value='';
					pass.setStyle('color', color_active);
				});
		}
		else //ff
		{
			user.addEvent('blur', function(event){
					if(user.value=='') {
						user.setStyle('color', color_inactive);
						user.value=val2;
					}
				});
			user.addEvent('focus', function(event){
					if(user.value==val2) user.value='';
					user.setStyle('color', color_active);
				});
			pass.addEvent('blur', function(event){
					if(pass.value=='') {
						pass.setStyle('color', color_inactive);
						pass.value=val3;
					}
				});
			pass.addEvent('focus', function(event){
					if(pass.value==val3) pass.value='';
					pass.setStyle('color', color_active);
				});
		}
		
		user.addEvent('keydown', function(event){
			if(event.key == 'enter') { pass.focus(); }
		});
		pass.addEvent('keydown', function(event){
			if(event.key == 'enter') { document.loginform.submit(); }
		});
	}
}

function init_tbfield(tbclass, tbdefault)
{
	var color_inactive = '#91989B'; //grijs
	var color_active = '#000000'; //zwart
	
	$$('.'+tbclass).each(function(item){
		if(isIE || isIE6 || isIE7)
		{
			item.attachEvent('onblur', function(){
					if(item.value=='') {
						item.setStyle('color', color_inactive);
						item.value=tbdefault;
					}
				});
			item.attachEvent('onfocus', function(){
					if(item.value==tbdefault) item.value='';
					item.setStyle('color', item);
				});
		}
		else //ff
		{
			item.addEvent('blur', function(event){
					if(item.value=='') {
						item.setStyle('color', color_inactive);
						item.value=tbdefault;
					}
				});
			item.addEvent('focus', function(event){
					if(item.value==tbdefault) item.value='';
					item.setStyle('color', color_active);
				});
		}
		
		item.addEvent('keydown', function(event){
			if(event.key == 'enter') { return false; }
		});
		
		
		if(item.value == '') //init
		{
			item.value = tbdefault;
			item.setStyle('color', color_inactive);
		}
	});
}

function init_tinymce()
{
	tinyMCE.init({
		// General options
		//mode : "textareas",
		
		//mode : "exact",
		//elements : "main",
		extended_valid_elements : "iframe[src|width|height|name|align]",
		
		width : "784",
		height : "600",
		mode : "textareas",
		theme : "advanced",
		skin : "o2k7",
		plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,liststyle,loremipsum",

		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,liststyle,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,|,forecolor,backcolor",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : false,

		// Example content CSS (should be your site CSS)
		content_css : "css/tinymce.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js"

		/*
		save_enablewhendirty : false,								//LET OP KOMMAS!!!!
		//save_callback : "save_tinymce"
		save_onsavecallback : "save_tinymce",
		file_browser_callback : "kfm_for_tiny_mce"
		*/

		
		// Replace values for the template plugin
		//template_replace_values : {
		//	username : "Some User",
		//	staffid : "991234"
		//}
	});
}

window.addEvent('domready', function() {
	var isIE = /*@cc_on!@*/false;
	var isIE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
	var isIE7 = false /*@cc_on || @_jscript_version >= 5.7 @*/;
	
	if(slideshow === false)
	{
		SqueezeBox.initialize({
	        size: {x: 'auto', y: 'auto'}
	    });
	}
	SqueezeBox.assign($$('a[rel=lightbox]'));
	
	if($('message')) {
		setTimeout("$('message').highlight('#a8a8a8')", 400);
	}
	
	init_loginform();
	
	initImageZoom();
});
