var xmlHTTP=null;
function selectGIF(td){
	var R=td.firstChild;
	R.checked=true;
	form1.s.value=td.value;
	form1.max.value=td.max;
	document.getElementById("text").focus();
}
function makeGIF(){
	if(document.form1.s.value==""){
		alert("请选择表情类型!");
		return false;
	}
	if(document.form1.text.value==""){
		alert("先输入文字");
		form1.text.focus();
		return false;
	}else if(document.form1.text.value.toString().length>document.form1.max.value){
		alert("文字太长了，最长只能"+form1.max.value+"个字");
		form1.text.value=form1.text.value.toString().substr(1,form1.max.value);
		form1.text.focus();
		return false;
	}
	document.getElementById("ShowImg").src = '/images/title_wait.gif';
	document.getElementById("HTTPCode").value='';
	if(xmlHTTP==null){
		xmlHTTP=new ActiveXObject("MSXML2.XMLHTTP");
	}
	xmlHTTP.abort();
	xmlHTTP.onreadystatechange=checkstate;
	xmlHTTP.open("GET","/inc/gif.php?s="+encodeURI(form1.s.value)+"&w="+encodeURIComponent(form1.text.value),true);
	xmlHTTP.send();
	document.getElementById("ShowDiv").style.display="block";
}
function checkstate(){
	if(xmlHTTP.readyState!=4)
	return;
	document.getElementById("ShowImg").src=xmlHTTP.responseText;
	document.getElementById("HTTPCode").value=xmlHTTP.responseText;
//encodeURI()
}
function checksize(img){
	if(img.height>90){
		img.height=90;
		img.onmouseover=showall;
		img.onmouseout=hidall;
	}
	if(img.width>220){
		img.width=220;
		img.onmouseover=showall;
		img.onmouseout=hidall;
	}
	img.style.marginLeft="2px";
}
function showall(){
	var img=event.srcElement;
	var div=document.getElementById("titleDiv");
	var nimg=new Image();
	nimg.src=img.src;
	div.innerHTML=nimg.outerHTML;
	div.style.display="block";
	div.style.left=event.x+document.body.scrollLeft;
	div.style.top=event.y+document.body.scrollTop-nimg.height-50;
}

function hidall()
{
	var img=event.srcElement;
	var div=document.getElementById("titleDiv");
	div.style.display="none";
}
function CopyValue(input){
	input.select();
	window.clipboardData.setData('text', input.value);
	alert('已经拷入剪贴板！');
}
// 复制图片到剪贴版
function CopyImage(img){
	if (img.tagName != 'IMG') return;
	if (typeof img.contentEditable == 'undefined') return;
	if (!document.body.createControlRange) return;
	var ctrl = document.body.createControlRange();
	img.contentEditable = true;
	ctrl.addElement(img);
	ctrl.execCommand('Copy');
	img.contentEditable = false;
	alert('复制完成，到QQ对话框里按Ctrl-V就可以啦！\n\n若不能粘贴请重复尝试或用鼠标右键选复制');
}

