function _(element) 
{
    if (arguments.length > 1) 
    {
        for (var i = 0, elements = [], length = arguments.length; i < length; i++)
          elements.push($(arguments[i]));
        return elements;
    }
    else
        return document.getElementById(element);
}


//init the server list
function areaChanged(value, type) 
{
	oAreaId = _('area_id_'+type);
	oServerId = _('server_id_'+type);

    var area = serverList[0];
    for (var i=0; i<serverList.length; i++) 
    {
        if (serverList[i].id == value) 
		{
        	area = serverList[i];
        	break;
        }
    }
            
    if (area) 
    {
        oServerId.options.length = 0;
        for (var i=0; i<area.sub.length; i++) 
        {
        	oServerId.options.add(new Option(area.sub[i].name, area.sub[i].id));
        	if ('1' == area.sub[i].id) 
        		oServerId.options[i].selected = true;
        }
    }
}
//初始化服务器列表
function initServerList(id)
{
	try
	{
		oAreaId = _('area_id_'+id);
		oServerId = _('server_id_'+id);
		oAreaId.options.length = 0;
	        
		for (var i=0; i<serverList.length; i++) 
		{
			oAreaId.options.add(new Option(serverList[i].name,serverList[i].id));
			if ('1' == serverList[i].id) 
				oAreaId.options[i].selected = true;
		}
		
		areaChanged(1, id);		
	}
	catch(e){}	
}
function changeCode()
{
	_('_code').src='upload_photo.php?do=code&'+Math.random();
}
$(function()
		   {
			   initServerList(0);
		   }
)
function login()
{
	var account = $('#account').val();
	var password = $('#password').val();
	var vcode = $('#vcode').val();
	if(account=='' || account==null)
	{
		alert('Account Id');
		_('account').focus();
		return;
	}
	if(password=='' || password==null)
	{
		alert('Password');
		_('password').focus();
		return;
	}
	if(vcode=='' || vcode==null)
	{
		alert('Verify Code');
		_('vcode').focus();
		return;
	}
	var param = 
		{
			account:account,
			area_id:_('area_id_0').value,
			server_id:_('server_id_0').value,
			password:password,
			vcode:vcode,
			uppic:_('uppic').src,
			pic_over_1:_('pic_over_1').src,
			pic_over_2:_('pic_over_2').src
		}
	$.post
	(
	 	'upload_photo.php?do=login',
		param,
		function(data)
		{
			eval("var data="+data+";");
			if(data['txt']==0)
			{
				alert(data['text']);
				_('account').focus();
				return;
			}
			else
				document.getElementById('wish_panel').style.display='none'
				document.getElementById('wish_pane2').style.display='block'				
				return;
			
		}
	)
}
function ok()
{
	 window.location.href='show_list.php';
		
}