/**
*
* Example of how to use this.
* $(".two-col").mocEqualHeights({"col_classes": ["col-one","col-two"]});
*
* the col_classes array should contain alle the sub elements that should be equal in height
*
*/


(function($) {
	function MocEqualHeights(root,conf) {
		var self = this, $self = $(this);

		var handles = [];
		var tallest = 0;

		for(i=0;i<conf.col_classes.length;i++) {
			//var class =conf.col_classes[i];
			handles[i] = $(conf.col_classes[i],root);
		}
		for(i=0;i<handles.length;i++) {
			var totalHeight = handles[i].height();

			totalHeight += parseInt(handles[i].css("padding-top"), 10) + parseInt(handles[i].css("padding-bottom"), 10);

			if(totalHeight > tallest) {
				tallest = totalHeight;
			}
		}

		if(tallest>0) {
			for(i=0;i<handles.length;i++) {
				var padding =parseInt(handles[i].css("padding-top"), 10) + parseInt(handles[i].css("padding-bottom"), 10);
				handles[i].height(tallest-padding);
			}
		}
		/**/
	}

	//Register as jQuery plugin

	$.fn.mocEqualHeights = function(conf) {
		var el;
		this.each(function() {
			el = new MocEqualHeights($(this),conf);
		});

		return el;

	}

})(jQuery);


jQuery(function() {
	jQuery(".news-selected-item h3 a").append("_");
	Cufon.replace(".news-selected-item h3");
	Cufon.replace(".bottom-disclaimer");
	Cufon.replace(".cufon");
	if(jQuery("#wrapper").length > 0){
	    jQuery("#wrapper").mocEqualHeights({"col_classes": ["#menu","#maincontent"]});
	}
	jQuery(".news-list-date").each(function() {
		var subheaderContainer = $(this).siblings("p.bodytext");
		if(subheaderContainer) {
			subheaderContainer.prepend(this);
		}
	});
	jQuery('#getCheckedReports').click(function(e) {
		e.preventDefault();
		var checked = new Array(),
			ids = ''; 
		jQuery("input:checkbox[name=pdf-report]:checked").each(function() {
    		checked.push(jQuery(this).val());
		});
		if (checked.length) {
			ids = checked.toString();
			window.location = '/'+jQuery(this).attr('href')+'&tx_nvproductions_pi3[ids]='+ids;
		} else {
			alert('No productions chosen.');
		}
	});
	jQuery('#checknone').click(function(e){
		jQuery("input:checkbox[name=pdf-report]").attr('checked','');
		e.preventDefault();
	});
	jQuery('#checkall').click(function(e){
		jQuery("input:checkbox[name=pdf-report]").attr('checked','checked');
		e.preventDefault();
	});

});

