function SetDimCSS()
{
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' )
	{
		myWidth = window.innerWidth; myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) )
	{
		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	}
	if(navigator.userAgent.toLowerCase().indexOf( 'safari' ) != -1 && myHeight==0)
	{
		myWidth=window.outerWidth;
		myHeight=window.outerHeight-100;
	}
	if(myWidth+myHeight>0)
	{
		var w0=(myWidth-800)/2;
		var h0=(myHeight-515)/2;
		var w1=parseInt(w0);
		var h1=parseInt(h0);
		if(w1>0 && h1>0)
		{
			var sw1=w1+500;
			var sh1=h1+70;
			var w2=w1+25;
			var h2=h1+490;
			var w3=w2+500;
			var w4=w2+540;
			var h3=h1+115;
			var style="<style type='text/css'>div.menubalk1 {top:"+h1+"px;left:"+w1+"px;}div.slogan {top:"+sh1+"px;left:"+sw1+"px;}div.menubalk2 {top:"+h2+"px;left:"+w2+"px;}div.menubalk2alt {top:"+h2+"px;left:"+w2+"px;}div.copyright {top:"+h2+"px;left:"+w4+"px;}div.content {top:"+h3+"px;left:"+w2+"px;}div.contentalt {top:"+h3+"px;left:"+w2+"px;}div.foto {top:"+h3+"px;left:"+w3+"px;}</style>";
			document.write(style);
		}
	}
}
function Form_Validator(theForm)
{
	if (theForm.naam.value == "")
	{
		alert("Typ uw naam ...");
		theForm.naam.focus();
		return (false);
	}
	if (theForm.datum.value == "")
	{
		alert("Typ uw reisdatum...");
		theForm.datum.focus();
		return (false);
	}
	try{var oEditor = FCKeditorAPI.GetInstance('tekst');}catch (e){}
	if(oEditor)
	{
		if ( oEditor.GetXHTML( false ).length == 0 )
		{
			alert("Typ een bericht ...");
			return (false);
		}
	}

}
function LoadEditor()
{
	var oFCKeditor = new FCKeditor( 'tekst' ) ;
	var sBasePath = '/fckeditor/'
	oFCKeditor.BasePath	= sBasePath ;
	oFCKeditor.Config['CustomConfigurationsPath'] = "/beheer/myfckeditor/fckconfig.js" ;
	oFCKeditor.ToolbarSet = 'GB' ;
	oFCKeditor.Config['SkinPath'] = sBasePath + 'editor/skins/default/' ;
	oFCKeditor.Config["AutoDetectLanguage"] = false ;
	oFCKeditor.Config["DefaultLanguage"] = 'nl' ;
	oFCKeditor.Config['LinkBrowserURL'] = "/beheer/myfckeditor/mcpuk/browser.html?Connector=/beheer/myfckeditor/mcpuk/connectors/php/connector.php&ServerPath=/";
	oFCKeditor.Config['ImageBrowserURL'] = "/beheer/myfckeditor/mcpuk/browser.html?Connector=/beheer/myfckeditor/mcpuk/connectors/php/connector.php&Type=Image&ServerPath=/";
	oFCKeditor.Config['FlashBrowserURL'] = "/beheer/myfckeditor/mcpuk/browser.html?Connector=/beheer/myfckeditor/mcpuk/connectors/php/connector.php&Type=Flash&ServerPath=/";
	oFCKeditor.Height = 220 ; // 400 pixels
	oFCKeditor.Width = 600 ;
	oFCKeditor.ReplaceTextarea() ;
}

function MaakDatum() 
{
	var months = new makeArray('januari','februari','maart','april','mei','juni','juli','augustus','september','oktober','november','december');
	var date = new Date();
	var day  = date.getDate();
	var month = date.getMonth() + 1;
	var yy = date.getYear();
	var year = (yy < 1000) ? yy + 1900 : yy;
	document.forms.invoer.elements.datum.value=day + " " + months[month] + " " + year;
	document.forms.invoer.naam.focus();
	return;
}

function makeArray()
{
	for (i = 0; i<makeArray.arguments.length; i++)
	this[i + 1] = makeArray.arguments[i];
}

function KiesTaal()
{
	location.href="?lang=" + document.getElementById('taalkeuze').value;
}

function KleurMenunaam(menuid)
{
	aA = document.getElementsByTagName("a");
	for (var i=0;i<aA.length ;i++ )
	{
		aA[i].style.color='';
	}
	try
	{
		document.getElementById(menuid).style.color='yellow';
	}
	catch (err)
	{
	}
}


String.prototype.trim = function() 
{return( this.replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') );}

function emailSplit(email,required)
{
	if (email=="")
	{
		if (required==1)
		{
			alert("U moet een email adres invullen");
			return false;
		}
		else
		{
		return true;
		}
	}
	var aEmail="";
	aEmail = email.split(";");
	if (aEmail.length>1)
	{
		alert(email + ": Meerdere e-mail adressen moeten gescheiden worden door een ',' komma.");
		return false;
	}
	aEmail="";
	aEmail = email.split(",");
	var j=0;
	for (j=0;j<(aEmail.length) ; j++)
	{
		if (emailCheck(aEmail[j].trim())==false)
		{
			return false;
		}
	}
	return true;
}

function emailCheck(emailStr)
{
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null)
{
	alert(emailStr + ": Email adres is niet correct (controleer @ and .)");
	return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++)
{
	if (user.charCodeAt(i)>127)
	{
		alert(emailStr + ": De naam (voor het @-teken) bevat ongeldige karakters.");
		return false;
	}
}
for (i=0; i<domain.length; i++)
{
	if (domain.charCodeAt(i)>127)
	{
		alert(emailStr + ": Het domein (achter de @-teken) bevat ongeldige karakters.");
		return false;
	}
}

if (user.match(userPat)==null) 
{
	alert(emailStr + ": De naam is ongeldig.");
	return false;
}

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null)
{
	for (var i=1;i<=4;i++)
	{
		if (IPArray[i]>255)
		{
			alert(emailStr + ": Het IP-adres is ongeldig.");
			return false;
		}
	}
	return true;
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++)
{
	if (domArr[i].search(atomPat)==-1)
	{
		alert(emailStr + ": de domeinnaam is ongeldig.");
		return false;
	}
}

if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1)
{
	alert(emailStr + ": Het adres moet eindigen met een bekend topdomeincode (zoals b.v. com, org, net) of een twee letterige landcode.");
	return false;
}

if (len<2)
{
	alert(emailStr + ": Dit adres mist een hostname.");
	return false;
}

return true;
}

var MyFloater=false;
function ToonFoto(Foto,w,h) 
{
var left = screen.width-(w+20) ;
if (MyFloater) MyFloater.close();
MyFloater=window.open("/toonfoto.php?lang=nl&foto="+Foto,"nakje1","width=850,height=870,left=" + left + ",top=200");
if (MyFloater.opener == null) MyFloater.opener = self;
}

function ToonVerslag(iTekst,iPrint, iClose) 
{
if('undefined' == typeof iPrint) iPrint = 0;
if('undefined' == typeof iClose) iClose = 0;
var left = screen.width-(600+20) ;
if (MyFloater) MyFloater.close();
MyFloater=window.open("/toonverslag.php?iTekst="+iTekst+"&print="+iPrint+"&close="+iClose,"verslag","scrollbars=yes,width=600,height=700,left=" + left + ",top=100");
if (MyFloater.opener == null) MyFloater.opener = self;
}

function printFriendly()
{
	if (document.getElementById != null)
	{
		var html = "<HTML>\n<HEAD>\n";
		html += "<link href='site.css' rel='stylesheet' type='text/css' media='all'>\n";
		html += "\n</HEAD>\n<BODY class='afdruk'>";
		var printFriend = document.getElementById("printThis");
		if (printFriend != null)
		{
			html += printFriend.innerHTML;
		}
		else
		{
			alert("Could not find any thing to print");
			return;
		}
		html += '\n</BODY>\n</HTML>';
		var printWin = window.open("","VerslagAfdrukken");
		printWin.document.open();
		printWin.document.write(html);
		printWin.print();
		printWin.document.close();
	}
	else
	{
		window.print();
	}
}

//Agenda functies
function showAgendaDescription(id)
{
	var mode=document.getElementById(id).style.display;
	if (mode=='none')
	{
		mode='block';
	}
	else
	{
		mode='none';
	}
	document.getElementById(id).style.display=mode;
}

function toonAgenda(cat_id,w,h)
{
	var left = screen.width-(w+20) ;
	if (MyFloater)
	{
		MyFloater.close();
	}
	MyFloater=window.open("/webcalendar116/upcoming-jas.php?cat_id="+cat_id,"nakje1","width="+w+",height="+h+",left=" + left + ",top=200,scrollbars=1");
	if (MyFloater.opener == null)
	{
		MyFloater.opener = self;
	}
}

function ToonAanbod(Tabel,Id, iPrint, iClose, iPDF) 
{
	if (Id == "")
	{
		return false;
	}
if('undefined' == typeof iPrint) iPrint = 0;
if('undefined' == typeof iClose) iClose = 0;
if('undefined' == typeof iPDF) iPDF = 0;
var left = screen.width-(600+20) ;
if (MyFloater) MyFloater.close();
MyFloater=window.open("/toonaanbod.php?tabel="+Tabel+"&id="+Id+"&print="+iPrint+"&close="+iClose+"&pdf="+iPDF,"portfolio","scrollbars=yes,width=600,height=700,left=" + left + ",top=100");
if (MyFloater.opener == null) MyFloater.opener = self;
}

function toonKaart(table,id,w,h)
{
	var left = screen.width-(w+20) ;
	if (MyFloater)
	{
		MyFloater.close();
	}
	MyFloater=window.open("/maps/index6.php?cat_id="+cat_id,"nakje1","width="+w+",height="+h+",left=" + left + ",top=200");
	if (MyFloater.opener == null)
	{
		MyFloater.opener = self;
	}
}
function toonGlyph()
{
	var left = screen.width-200 ;
	naam = document.getElementById('glyph').value;
	if (naam)
	{
		MyFloater=window.open("/toonglyphs.php?naam="+naam,"glyph","width=180,left=" + left+",top=100");
		if (MyFloater.opener == null)
		{
			MyFloater.opener = self;
		}
	}
}


function writeMailto(coded,ssubject,slink,spre,spost)
{
	cipher = "aZbYcXdWeVfUgThSiRjQkPlOmNnMoLpKqJrIsHtGuFvEwDxCyBzA1234567890";
	shift=coded.length;
	link="";
	for (i=0; i<coded.length; i++)
	{
		if (cipher.indexOf(coded.charAt(i))==-1)
		{
			ltr=coded.charAt(i);
			link+=(ltr);
		}
		else
		{
			ltr = (cipher.indexOf(coded.charAt(i))-shift+cipher.length) % cipher.length;
			link+=(cipher.charAt(ltr));
		}
	}
	subject="";
	if (ssubject)
	{
		subject="?subject="+ssubject;
	}
	if (slink=="")
	{
		slink=link;
	}
	document.write(spre+"<a href='mailto:"+link+subject+"'>"+slink+"</a>"+spost);
}

function iLink(link)
{
	lnk = "tekst=" + link ;
	this.location.href="?"+lnk;
}
