// fix the min-height of the first content block (if multiple) to make sure that it is
// tall enough to support the left column.
$(function(){
	if($('div.wrapper div.left').length>0){
		var minheight=0;
		var kids=$('div.wrapper div.left').children();
		for(var i=0; i< kids.length;i++){
			minheight += $(kids[i]).outerHeight(true);
		}
		var content_blocks=$('div.wrapper div.right div.content_block');
		for(var i=1; i<content_blocks.length; i++){
			minheight -= $(content_blocks[i]).outerHeight(true);
		}
		if($('div#slider_content').length>0){
			minheight -= $('div#slider_content').outerHeight();
		}
		if(content_blocks.length>0){
			$(content_blocks[0]).css('min-height',minheight+'px');
			if($(content_blocks[0]).height()<minheight){
				//we're probably in ie6, and the height will be interpreted
				//as min-height.
				$(content_blocks[0]).css('height',minheight+'px');
			}
		}
	}
});

//code for region dialog
$(function() {
	$('#open_change_region').click(function () {
		$('div.region').hide();
		$('div.change_region').show();
		return false;
	});
	$('#field_region').change(function(){
		$('body').append('<div class="screen_mask">&nbsp;</div>');
		$('div.screen_mask').height($(document).height()).css('opacity',0.50).show();
		$('#change_region').submit();
	});
/*	$('#change_region_popup').dialog({
		bgiframe: true,
		autoOpen: false,
		height: 300,
		modal: true,
		buttons: {
			Cancel: function()
			{
				$(this).dialog('close');
			}
		}
	});

	
	$('#open_change_region').click(function () {
		//$('#change_region_popup').jqpopup_open(this.id);
		$('#change_region_popup').dialog('open');
	});
	
	$('#field_region').change(function(){
		$('#change_region').submit();
	});
*/
});
