// JavaScript Document

jQuery(document).ready(function() {
	var dToday = new Date();
	var sToday = makeLength2(dToday.getDate()) + "/" + makeLength2(dToday.getMonth() + 1) + "/" + dToday.getFullYear();
	jQuery('#uiv_van').DatePicker({
		date: sToday,
		format: 'd/m/Y',
		onBeforeShow: function() {
			if(jQuery('#uiv_van').val().length > 0) {
				jQuery('#uiv_van').DatePickerSetDate(jQuery('#uiv_van').val(), true);
				jQuery('#uiv_van').val('');
			}
		},
		onChange: function(formatted, dates) {
			jQuery('#uiv_van').val(formatted);
			jQuery('#uiv_van').DatePickerHide();
		}
	});
	jQuery('#uiv_tot').DatePicker({
		date: sToday,
		format: 'd/m/Y',
		onBeforeShow: function() {
			if(jQuery('#uiv_tot').val().length > 0) {
				jQuery('#uiv_tot').DatePickerSetDate(jQuery('#uiv_tot').val(), true);
				jQuery('#uiv_tot').val('');
			}
		},
		onChange: function(formatted, dates) {
			jQuery('#uiv_tot').val(formatted);
			jQuery('#uiv_tot').DatePickerHide();
		}
	});
	//jQuery('#uiv_van').DatePickerShow();
});

jQuery(document).ready(function() {
	jQuery("div.clickme").click(function(){
		location.href = jQuery('a', this).attr('href');
	});
	jQuery("div.clickme").mouseover(function(){
		jQuery('h2 a', this).css('text-decoration', 'underline');
		jQuery('h3', this).css('text-decoration', 'underline');
		jQuery('h4', this).css('text-decoration', 'underline');
		jQuery('p', this).css('text-decoration', 'underline');
		jQuery('p a', this).css('text-decoration', 'underline');
		jQuery('h5', this).css('text-decoration', 'underline');
	});
	jQuery("div.clickme").mouseout(function(){
		jQuery('h2 a', this).css('text-decoration', 'none');
		jQuery('h3', this).css('text-decoration', 'none');
		jQuery('h4', this).css('text-decoration', 'none');
		jQuery('p', this).css('text-decoration', 'none');
		jQuery('p a', this).css('text-decoration', 'none');
		jQuery('h5', this).css('text-decoration', 'none');
	});
});

jQuery(document).ready(function() {
	jQuery("form.contact input, form.contact textarea").focus(function(){
		if(jQuery(this).val().toString() == jQuery(this).attr('default').toString()) jQuery(this).val('');
	});
	jQuery("form.contact input, form.contact textarea").blur(function(){
		if(jQuery(this).val() == "") jQuery(this).val(jQuery(this).attr('default'));
	});
});

function checkSearch(oForm) {
	if(oForm.uiv_keyword.value.length == 0 && oForm.uiv_rubr.value == "0" && oForm.uiv_regio.value == "0" && (oForm.uiv_van.value.length == 0 || oForm.uiv_tot.value.length == 0)) {
		//alert('Gelieve ten minste 1 zoekveld te gebruiken.');
		//return false;
	}
	if((oForm.uiv_van.value.length > 0 && oForm.uiv_tot.value.length == 0) || (oForm.uiv_van.value.length == 0 && oForm.uiv_tot.value.length > 0)) {
		alert('Bij het zoeken op datum moet zowel een begin- als einddatum aangeduid worden.');
		return false;
	}
	return true;
}

function checkContact(oForm) {
	return true;
}

function makeLength2(s) {
	if(s.toString().length == 1) return "0" + s.toString();
	return s;
}
