var win=false;
var ProgressBar={
	show:function(){
		if(win){
			this._oldCont.html=win.getContent().innerHTML;
			win.getContent().select("input").each(function(inp){ProgressBar._oldCont.childsEl.push({id:inp.id,value:inp.value,checked:inp.checked})});
		    win.setHTMLContent(this._htmlCont);
			this._dialog=false;
			return;
		}
		Dialog.info(this._htmlCont, {effectOptions:{duration:0.2},className:"alphacube",width:230, height:90, showProgress: false});
		this._dialog=true; 
	},
	_dialog:false,
	hide:function(){
		if(this._dialog){
			Dialog.closeInfo();
			return;
		}
		win.setHTMLContent(this._oldCont.html);
		this._oldCont.childsEl.each(function(inp){
			if(!$(inp.id)){
				return;
			}
			$(inp.id).value=inp.value;
			$(inp.id).checked=inp.checked;
        });
		this._oldCont={html:"",childsEl:[]};
	},
	_htmlCont:'<div class="message">Пожалуйста, подождите</div><div class="spinner"></div>',
	_oldCont:{html:"",childsEl:[]}
};
function rate(el,info,url){Effect.Fade(el,{duration:0.4,queue: {position: 'end', scope: 'ratesend'}});new Ajax.Request(url+"/"+info.rating,{method:"get",onComplete:function(r){if(r.headerJSON.raiting){new Starbox(el,r.headerJSON.raiting,{locked:true});}Effect.Appear(el,{duration:0.6,queue: {position: 'end', scope: 'ratesend'}});}});};
document.observe("dom:loaded", function() {
    if($("lform")){
    el=$("lform").getInputs();
    if(el[0].value.empty()){
        $("login_label").update("login");
    }
    if(el[1].value.empty()){
        $("password_label").update("пароль");
    }
    el[0].observe("focus",function(){
        if(!$("login_label")) return;
        $("login_label").setStyle({top:"-9999px"});
        
    });
    el[0].observe("blur",function(){
        if(!$("login_label")) return;
        if(this.value.empty()){
            $("login_label").update("login");
            $("login_label").setStyle({top:""});
        }
    });
    el[1].observe("focus",function(){
        if(!$("password_label")) return;
        $("password_label").setStyle({top:"-9999px"});
    });
    el[1].observe("blur",function(){
        if(!$("password_label")) return;
        if(this.value.empty()){
            $("password_label").update("пароль");
            $("password_label").setStyle({top:""});
        }
    });
    }
});

function openGCWindow(url,title,sizeW,sizeH,no_ajax){
	if(!title){
		title="";
	}
    win=new Window({
        className:"alphacube",
        zIndex:100,
        resizable:false,
        title:title,
        effectOptions:{duration:0.1},
        destroyOnClose:true
    });
    if(no_ajax){
        win.setHTMLContent('<div class="message">Пожалуйста подождите</div><div class="spinner"></div>');
        win.setURL(url);
        win.setSize(sizeW,sizeH);
        win.showCenter(true);
        return;
    }
    win.setAjaxContent(
        url,
        {asynchronous:true, evalScripts:true,
            onCreate: function() {
                win.setHTMLContent('<div class="message">Пожалуйста подождите</div><div class="spinner"></div>');
                win.setSize(300,130);
                win.showCenter(true);
            },
            onComplete:function(){
                windowScroll = WindowUtilities.getWindowScroll(win.options.parent);
                pageSize = WindowUtilities.getPageSize(win.options.parent);
                mTop = ((pageSize.windowHeight - (sizeH + win.heightN + win.heightS))/2)+windowScroll.top;
                mLeft = ((pageSize.windowWidth - (sizeW + win.widthW + win.widthE))/2)+windowScroll.left;
                win.setSize(sizeW,sizeH,true,mTop,mLeft);
            }
        }
    );
}
