//margin funct
jQuery.setMargins = function(obj,height,imgHeight,width,imgWidth,dialogWidth){
	var marginHeight = (  height-imgHeight-25) / 2;
	var marginWidth = (width -(imgWidth + dialogWidth)) / 2 ;
	
if(marginHeight > 0){ 
        $(obj)
			.css("margin-top",marginHeight+"px");}
else{ 			
$(obj)
			.css("margin-top",-8+"px");}

if(marginWidth > 0){ 			
$(obj)
			.css("margin-right",marginWidth+"px");}
	else{ 			
$(obj)
			.css("margin-right",-8+"px");}
};	
//END margin funct

//load img funct
    $(jQuery.loadImg =function (mImg,mTitle) {
		 $("#loader img").remove();
		$("#loader p").remove();
		$('#loader').addClass('loading');
        var img = new Image();
        $(img).load(function () {
            //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
            $(this).hide();
            $('#loader').removeClass('loading').append(this,'<p></p>');
			$('#loader p').append(mTitle);
            $(this).fadeIn(2000);

//Height
setM = $.setMargins(this,$(window).height(),$(this).height(),$(window).width(),$(this).width(),$(".ui-dialog").width());
//END Heights
        }).error(function () {
            // notify the user that the image could not be loaded      
}).attr('src', mImg);
    });
//END load img funct