// plans have been made to write a wordpress plugin for error detection
// for now this will have to do, as IE throws errors on javascript related to flash
// see: http://bugs.adobe.com/jira/browse/SDK-14380
var err = function(msg, url, linenumber) {
	return true;
}

window.onerror = err;

jQuery(document).ready( function() {
	// wie pagina
	if(jQuery("#ff_big_f").length > 0) {
		jQuery("#ff_big_f").cycle(
			{ fx: 'fade', speed:  3500 }
		);
	}

	// sharethis is trying to make its properties inaccessible
	jQuery("span[id^='sharethis_']").css('float', 'right').css('margin', '10px 0px');

	// are we on result-page?
	var _clients = jQuery('.klantresult');
	if (_clients.length > 0) {
		// height and top of div "content"
		var _contentHeight = jQuery("#content").height();
		var _contentTop    = jQuery("#content").position();
		var _contentTop    = _contentTop.top;
		// console.log('height and top of div with id="content" are ' + _contentHeight+ ' and ' + _contentTop);
		// for client descriptions on 'resultaat' page
		_clients.each( function() {
			// where is this client element?
			var _pos = jQuery(this).position();
			// so the top relative to the containing div is _pos.top - _contentTop
			var _clientTop = _pos.top - _contentTop;
			var _firstp = jQuery(this).children('p:first');
			// adjust position of first paragraph to keep it inside #content
			// if it would collapse outside of the containing div
			if ((_clientTop + _firstp.height() + 10) > _contentHeight) {
				_firstp.css('margin-top', '-172px');
			} else {
				_firstp.css('margin-top', '2px');
			}
			jQuery(this).hover(
				function() {
					jQuery(this).children('p').show();
				},
				function() {
					jQuery(this).children('p').hide();
				}
			);
		});
	}
});
