/*
 * 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.controls['navigator']=(function()
{var _pane,_bCn,_bEn;var _$home,_$user,_$login,_$reg,_$upload,_$download,_$about,_$support,_$help,_$logout;var _$timer;var _transCn=function()
{COOKIE2('lang','zh-cn');LANG.translate();WIN.trigger(E['app-lang-update'],['zh-cn']);_update();};var _transEn=function()
{COOKIE2('lang','en');LANG.translate();WIN.trigger(E['app-lang-update'],['en']);_update();};var _init=function()
{_pane=$('#pager > #header');if(_pane.length)
{_bCn=_pane.children('.logo').find('em:eq(0)').click(_transCn);_bEn=_pane.children('.logo').find('em:eq(1)').click(_transEn);var p=_pane.find('.navi > ul');_$home=p.children('#nav_home');_$user=p.children('#nav_user').click(_onQueryProfile);_$login=p.children('#nav_login').click(_onQuerySignin);_$reg=p.children('#nav_register').click(_onQueryRegister);_$upload=p.children('#nav_upload').click(_onQueryUpload);_$download=p.children('#nav_download');_$about=p.children('#nav_about');_$support=p.children('#nav_support');_$help=p.children('#nav_help');_$logout=p.children('#nav_logout');_$timer=_pane.find('.navi > span');setInterval(_ontimer,1000);_update();_$logout.bind('click',_logout);}}
var _onQueryProfile=function()
{var l='customer.aspx';if(LANGID()!='zh-cn')
{l='en/customer.aspx';}
window.open(l);return false;};var _onQuerySignin=function()
{app.controls.signin();};var _onQueryRegister=function()
{app.controls.register();};var _onQueryUpload=function()
{var l='upload.aspx';if(LANGID()!='zh-cn')
{l='en/upload.aspx';}
UI_FRMBOX.show({'size':[738,374],'url':l});return false;};var _logout=function()
{app.user.logout();};var _update=function()
{if(app.user.load())
{_$home.show();_$user.children('a').empty().append(USER.data('username')+('<label>{0}</label>'.toString(WORD('profile'))));_$user.show();_$login.hide();_$reg.hide();_$upload.show();_$logout.show();}
else
{_$home.show();_$user.hide();_$login.show();_$reg.show();_$upload.show();_$logout.hide();}
var l=LANG.getLanguageId();if(l==='en')
{_$user.children('a').attr('href','en/customer.aspx');_$upload.children('a').attr('href','en/upload.aspx');_$download.children('a').attr('href','en-download.htm');_$about.children('a').attr('href','en-aboutus.htm');_$support.children('a').attr('href','en-support.htm');_$help.children('a').attr('href','en-help.htm');}
else
{_$user.children('a').attr('href','customer.aspx');_$upload.children('a').attr('href','upload.aspx');_$download.children('a').attr('href','download.htm');_$about.children('a').attr('href','aboutus.htm');_$support.children('a').attr('href','support.htm');_$help.children('a').attr('href','help.htm');}};var _ontimer=function()
{_$timer.text(Date.formatBorn(WORD('timer'),12));};_init();return{update:function()
{_update();return this;},upload:function()
{_onQueryUpload();}}})();$.extend(window,{NAVI:app.controls['navigator']});});
