if ( typeof $ !== 'undefined' ) {
	$(function() {
		
		/* Init datepicker */
		var dates = $('#from, #to').datepicker({
			defaultDate: "+1w",
			changeMonth: true,
			dateFormat: 'dd-mm-yy',
			option: "dayNamesMin",
			numberOfMonths: 2,
			onSelect: function(selectedDate) {
				var option = this.id == "from" ? "minDate" : "maxDate";
				var instance = $(this).data("datepicker");
				var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
				dates.not(this).datepicker("option", option, date);
			}
		});
		
	});
}

function expandNavMenu() {
	d = document.getElementById("menuWrapper");
	d.style.height = "400px";
	d.style.width = "830px";
	changeVar(0);
}

function collapseMenu() {
	d = document.getElementById("menuWrapper");
	d.style.height = "90px";
	d.style.width = "690px";
}

window.onerror=fnErrorTrap;
function fnErrorTrap(msg,url,line) {
    return true;
}

function collapseDelayMenu() {
	d = document.getElementById("menuWrapper");
	d.style.height = "90px";
	d.style.width = "690px";
	changeVar(1);

}

function fillEcard(text,ontvanger,verstuurder){
	document.getElementById('eCardInfo').innerHTML = "<pre class=\"eCardText\">Beste "+ontvanger+",<br><br>"+text+"<br><br>groet,<br>"+verstuurder+"</pre>";	

}

function setEcard(upload_id){
	document.getElementById('eCardInfo').style.display = 'block';
	document.getElementById('upload_id').value = upload_id;
}

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function changeVar(str){	
	/* if(window.Menu) {
		window.document["Menu"].SetVariable("collapse", str); 
		alert(1);
	} */
	if(document.Menu) {
		document.Menu.SetVariable("collapse", str);	
	}
}
