$(function() {	
	$.extend($.ui.dialog.prototype.options, {
		closeOnEscape: true,
		width: 960,
		height: 600,
		close: function(event, ui) {
			$('#dialog-content').html('');
		}
	});
	$( "#flashMessage" ).dialog({ resizable: false, title: 'Status', width: 500, height: 240 });
	
	
	if ($("#flashMessage").hasClass('success')){
		$("#flashMessage").parent('div.ui-dialog.ui-widget').addClass('success-message');
		$("#flashMessage").prepend('<span class="flash-icon"></span>');
		$("#flashMessage").prepend('<div class="clear"></div>');
	}else if($("#flashMessage").hasClass('error')){
		$("#flashMessage").parent('div.ui-dialog.ui-widget').addClass('error-message');
		$("#flashMessage").prepend('<span class="flash-icon"></span>');
		$("#flashMessage").prepend('<div class="clear"></div>');
	}
		
	//Set the timeOut for the flash message timeOut_{lengh} in nano seconds length = 0 if you want it to not timeout
	$('#flashMessage').filter(function(){ 
        var classes = $(this).attr("className").split(" "); 
        var timeOutLength = 5000; 
        
        for (var i = 0; i < classes.length; i++){
                if ( classes[i].substr(0,7) == "timeOut" ){ 
                	var substr = classes[i].split('_');
                	timeOutLength = substr[1];
                	break;
                }
        }
        if(timeOutLength != '0'){
        	setTimeout(function() {
    			$('#flashMessage').remove();
    		}, timeOutLength);
        }
	}); 
});
