/*
 * hipic.web.app
 * Copyright(c) 2010, FeiKan.
 * 
 * This code is licensed under BSD license. Use it as you wish, 
 * but keep this copyright intact.
 */


$(function()
{app.ui.loading=function(elem,cls)
{var _cls;switch(cls)
{case 2:_cls='ui-loading2';break;case 1:default:_cls='ui-loading';break;}
var em=elem.children('.{0}'.toString(_cls));if(!em.length)
{elem.children().hide();em=$('<em class="{0}"></em>'.toString(_cls)).appendTo(elem);}
var setPos=function()
{var x=(elem.width()-em.width())/2;var y=(elem.height()-em.height())/2;em.css({left:x+'px',top:y+'px'});};var onResize=function()
{setPos();};elem.bind('holderresize',onResize);return{show:function()
{setPos();return this;},hide:function()
{em.remove();elem.unbind('holderresize',onResize).children().show();return this;},center:function()
{setPos();return this;}};}
$.extend(window,{UI_LOADING:app.ui.loading});});
