var speed = 1000; //速度
var wait = 0; //停留时间
function SetAValue(value,obj)
{
	$('AValue').value = value;	
	
	
	var tagElements = document.getElementsByTagName("img");
      for (var j = 0; j < tagElements.length; j++)
        tagElements[j].style.borderColor="#666666";

	obj.style.borderColor="#0f0";
	


}
function updateinfo(){
if(wait == 0){
	$("btnMake").src = "images/make.gif";
	$("makeing").style.display='none';
}
else{
    wait--;
	$("makeing").innerText = "请稍候" + wait;
    window.setTimeout("updateinfo()",speed);
}
}

function MakeQFlash()
{
	if ($("hdbgImg").value != "")
	{
		var ashxfile
			ashxfile= "ashx/QText/QFlash.ashx";
	   if (wait == 0)
	   {
		var param_url =  Form.serialize('form1');
		//if ($('divbtn')) Form.disable('divbtn');
		$("btnMake").src = "images/make2.gif";
		$("makeing").style.display='';
		new Ajax.Request(
					ashxfile,
					{
							method: 'post',
							postBody: param_url,
							onComplete: function(response){
								
								if (response.responseText != "-1")
								{
									 //Form.enable('divbtn');
									 
									 
									 $('MakeImg').src = response.responseText;
									 $("uploading0").innerHTML="<input type=\"button\" value=\"复制到QQ\" class=\"input\" name=\"BtnSave\" id=\"BtnCopy\" onclick=\"CopyImage(document.getElementById('MakeImg'))\"/> <input type=\"button\" value=\"保存到本地\" class=\"input\" name=\"BtnSave\" id=\"BtnSave\" onclick=\"SaveImage(document.getElementById('MakeImg'))\"/> <input type=\"button\" value=\"重新上传\" class=\"input\" name=\"BtnReload\" id=\"BtnReload\" onclick=\"$('ifUpload0').style.display=''; $('mpindex').style.display='none'\"/>"
									 	wait = 10;
										updateinfo();
									 //$("btnMake").src = "images/make.gif";
								}
							}
					}
			);  
	   }
	   else
	   {	
			alert("不要急，服务器也需要休息的!");	
	   }
	}
	else
	{
		alert("您好像忘记先上传照片了!");	
	}
}

// Save the image to Local disk
function SaveImage(img)
{
	var win = document.getElementById('genFrm').contentWindow;
	if (!win || img.tagName != 'IMG') return;
	win.location.href = img.src;
	setTimeout(function() { win.document.execCommand("SaveAs"); }, 200);
}

// 复制图片到剪贴版
function CopyImage(img)
{
  if (img.tagName != 'IMG') return;
  if (typeof img.contentEditable == 'undefined' || !document.body.createControlRange)
  {
	alert('抱歉，浏览器不支持直接复制图片！\n请将鼠标移到图片上方，单击鼠标右键在弹出菜单中选择“复制”');
  }
  else
  {
	var ctrl = document.body.createControlRange();
	img.contentEditable = true;
	ctrl.addElement(img);
	ctrl.execCommand('Copy');
	img.contentEditable = false;
	alert('复制完成，到QQ对话框里按Ctrl-V就可以啦！\n\n若不能粘贴请重复尝试或用鼠标右键选复制');
  }
}