// MakeCallBack
function MakeCallBack(type, mpic)
{

  // update the image source
  if (type == 'ok')
  {
	$('MakeImg').src = mpic;
	
	$('loading').style.display='none';
	$('demoTab').style.display='none';
	$('BtnMake').disabled = true;
    $('BtnCopy').disabled = false;
    $('BtnSave').disabled = false;
	$('BtnBbs').disabled = false;
	$('BtnReset').disabled = true;
	wait = 10;
	updateinfo();
  }
  else
  {
    alert('抱歉，图片生成失败，请重新操作!');
    TOI_update();
    TOI_img.src = TOI_isrc.src;
    TOI_img.width = TOI_isrc.width;
    TOI_img.height = TOI_isrc.height;
  }
}

// Reset the form
function MakeReset()
{
	$('MakeImg').src="../Material/QFace/" + $("Id").value + ".gif";
	$('demoTab').style.display = '';

  	$('BtnCopy').disabled = true;
  	$('BtnSave').disabled = true;
    $('BtnBbs').disabled = true;
	$('BtnMake').disabled = false;
}

function MakePic(mfile)
{
    
    var ashxfile
	if (mfile=='gif')
		ashxfile= "../ashx/QFace/Gif.ashx";
	else if (mfile=='Regular2')
		ashxfile= "../ashx/QFace/Regular2.ashx";
	else
		ashxfile= "../ashx/QFace/Regular.ashx";
	var err = false;
	if ($('txtInput1')){
		if ($('txtInput1').value.length>30) {alert("抱歉，您输入的文字太多了"); err=true;}
		}
	if ($('txtInput2')){
		if ($('txtInput2').value.length>30) {alert("抱歉，您输入的文字太多了"); err=true;}
		}

	if (!err)
	{		
		var param_url =  Form.serialize('form1');
		if ($('divbtn')!=null) Form.disable('divbtn');
		$('loading').style.display='';
	
		new Ajax.Request(
                ashxfile,
                {
                        method: 'post',
                        postBody: param_url,
                        onComplete: function(response){
                            
                            if (response.responseText != "-1")
                            {
                                 Form.enable('divbtn');
								 MakeCallBack('ok',response.responseText);
                            }
                        }
                }
        );  
	}
}
