jQuery(function() { 
  
	jQuery('.component_window').bind('click', showComponentFramePopup); 
    $('.dates').datepicker();
    
});

function checkAll(cls, action){

	jQuery('.'+cls).each(function(){
		jQuery(this).attr('checked', action);
	});
	 
}



function submit(task, form){
	
	jQuery('#task').val(task);
	jQuery('#'+form).trigger('submit');
	
	
}

function showComponentFramePopup(){

	data = eval("(" + jQuery(this).attr("rel") + ")");
	
	showModalWindowFrame( jQuery(this).attr("href") , jQuery(this).attr("title") , data.size.x , data.size.y );
	return false;
	
}

function showModalWindowFrame(url, wtitle, width, height){

	jQuery("#ajax_iframe").attr("src",url);  
	showModalWindow( "#popupbox_iframe", wtitle , width, height);

}



function closeModalWindowFrame(){
	
	
	jQuery("#popupbox_iframe").dialog("destroy"); 
	
}

function showModalWindow(el, wtitle, width, height){
	jQuery("#popupbox_iframe").dialog("destroy"); 
	 
	jQuery("#sizes").css('display', 'none'); 
  
  
  	
	jQuery(el).dialog({ 
	bgiframe: true,
	dialogClass: 'flora',	
    modal: true, 
    beforeclose: function(event, ui) { jQuery("#sizes").val('');jQuery("#sizes").css('display', 'block'); },
    title: wtitle,
    height:height, 
    width:width 
	});
	 
}
