$(function(){$('#showlist').load('showList.php?do=list');})
function changeorder()
{
	$('#showlist').load('showList.php?do=list&order='+$('#order').val());
}
function ajaxPage(url)
{
	$('#showlist').load(url);
}
function dosearch()
{
	var name = $('#word').val();
	if(name=='')
	{
		alert('please input the key word for search');
		return;
	}
	$('#showlist').load('showList.php?do=list&order='+$('#order').val()+'&key='+name+'&type='+$('#select').val());
}
function showDiv(id)
{
	alert('The event ended');
	return;
	/*
	initServerList();
	$('#hid').val(id);
	var width = document.body.scrollWidth;
	var height = document.body.scrollHeight;
	$('#bg').width(width).height(height).css('opacity','0.3').show();
	$('#showaccount').css({top:300,left:width/2-100}).fadeIn();
	$('#account').val('');
	$('#vcode').val('');
	changeCode();*/
}
function doVote()
{
	alert('The event ended');
	return;
	/*
	var account = $('#account').val();
	var vcode = $('#vcode').val();
	var id = $('#hid').val();
	if(account=='' || vcode=='')
	{
		alert('please input your account and valication code');
		return;
	}
	$('#submit').attr('disabled','disabled');
	$.getJSON
	(
	 	'showList.php?do=vote',
		{account:account,vcode:vcode,area_id:$('#area_id').val(),server_id:$('#server_id').val(),id:id},
		function(data)
		{
			if(data['txt']=='0')
			{
				alert(data['text']);
				$('#submit').attr('disabled','');
				changeCode();
				return;
			}
			else
			{
				alert('submitted successfully');
				var num = parseInt($('#num_'+id).html())+1;
				$('#num_'+id).html(num);
				closeDiv();
			}
		}
	)*/
}
function closeDiv()
{
	$('#showaccount').hide();
	$('#bg').fadeOut();
}
function changeCode()
{
	_('_code').src='index.php?do=code&'+Math.random();
}
//init the server list
function areaChanged(value, type) 
{
	oAreaId = _('area_id');
	oServerId = _('server_id');

    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;
        }
    }
}
//document.getElementById
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);
}
//初始化服务器列表
function initServerList()
{
	try
	{
		oAreaId = _('area_id');
		oServerId = _('server_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,0);		
	}
	catch(e){}	
}
