function checkMailList(){var m=document.form1.mail.value;if (m==''){alert("用户邮箱不能为空!");document.form1.mail.focus();return false;}else if(!m.match(/^[\w\.\-]+@[0-9a-zA-Z\.\-]+$/)){alert("用户邮箱格式不正确!");document.form1.mail.focus();return false;}return true}

function cp(){
	var card = $("#get_cdkey_value").text();
	copy_clip(card);
	alert("已经复到剪切板中,请按 CTRL+V 粘贴\n\n如果你觉得的我们网站不错请推荐给好友，或者写在你的博客中");
}

function copy_clip(copyText){
	if (window.clipboardData){
    	window.clipboardData.setData("Text", copyText)
    }else{
        var flashcopier = 'flashcopier';
        if(!document.getElementById(flashcopier)){
            var divholder = document.createElement('div');
            divholder.id = flashcopier;
            document.body.appendChild(divholder);
        }
		document.getElementById(flashcopier).innerHTML = '';
		var divinfo = '<embed src="/webui/script/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(copyText)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
		document.getElementById(flashcopier).innerHTML = divinfo;
    }
}

function card(id){
	var msg;

	$.get("/game/ajax_get.php", { id:id},function(data){
		switch (data*1) {
		case 1 :
			msg = '本类新手卡已经发完了';
			break;
		case 2 :
			msg = '您已经领取出1张了,20分钟后才能继续领取';
			break;
		case 3 :
			msg = '这个游戏目前已经停止发放新手卡了!';
			break;
		default :
			msg = '<span id="get_cdkey_value">'+data+'<\/span> <input type="button" value="复制" onclick="cp()" />'
		}
		$("#getCard").html(msg);	
	}); 
}

//首页快速发卡模式
function card1(id,url){
	var msg;
	
	$.get("/game/ajax_get.php", { id:id},function(data){
		switch (data*1) {
		case 1 :
			msg = '本类新手卡已经发完了';
			break;
		case 2 :
			msg = '您已经领取出1张了,20分钟后才能继续领取';
			break;
		case 3 :
			msg = '这个游戏目前已经停止发放新手卡了!';
			break;
		default :
			msg = '<strong id="cd'+id+'">'+data+'<\/strong><input type="button" value="复制并进入使用地址" onclick="cp1(\''+id+'\',\''+url+'\')" />';
		} 
		$("#cd"+id).html(msg);	
	}); 
}

function cp1(id,url){
	var card = $("#cd"+id).text();
	copy_clip(card);
	window.location.href = url;
}
