function copyTo(meintext){
	if (window.clipboardData){
		window.clipboardData.setData("Text", meintext);
		alert("您已经成功复制链接地址，请直接粘贴推荐给您的朋友!");
	}else{
		alert("无法完成自动复制，请手动复制发送给您的朋友!");
	}
}
function AddLink(Url){
	if(navigator.userAgent.indexOf('MSIE')>0){
		try{
			var com;
			com = new ActiveXObject("Zyzzyva.Control.1");
			com.Download(Url, "", "", "");
		}catch(e){
			install_msg();
			return;
		}
	}else if(navigator.userAgent.indexOf('Firefox')>0){
		if(navigator.mimeTypes['application/namipan-scriptable-plugin'] != null ){
			var a={"cmd":"GetVersion","params":[]};
			try{
				robot_version = embed1.RpcCall("4990272A-0655-4D80-90A7-C18D0FF7A4A9",JSON.encode(a));
			}catch(e){
				install_msg();
				return;
			}
			if(embed1.RpcCall("4990272A-0655-4D80-90A7-C18D0FF7A4A9",JSON.encode(a)) >= '1.0.0.4'){
				var dl_str={
					"cmd": "Download",
					"params":[
					{"value":Url,"type":"str"},
					{"value":'',"type":"str"},
					{"value":'',"type":"str"},
					{"value":'',"type":"str"}
					]
				};
				if(typeof(embed1.RpcCall2) == 'function'){
					try{
						embed1.RpcCall2("30FA9641-9CFE-4D71-A3AA-DF8B6FA02FCC",JSON.encode(dl_str),"1");
					}catch(e){

						return;
					}
				}else{
					if(confirm("请安装最新版本的Firefox插件来完成此操作!")){
						window.location = xpi_dl_url;
					}
					return;
				}
			}else{
				install_msg();
				return;
			}
		}else{
			if(confirm("请安装Firefox插件来完成此操作!")){
				window.location = xpi_dl_url;
			}
			return;
		}
	}else{
		alert("请使用IE或者Firefox浏览器来完成此操作!");
	}
}
function install_msg(){
	if(confirm("请安装米人软件来完成此操作!")){
		window.location = 'http://www.namipan.com/download.html';
	}
}
// the follow is for pop
function getExpDate(days, hours, minutes)
{
	var expDate = new Date();
	if(typeof(days) == "number" && typeof(hours) == "number" && typeof(hours) == "number")
	{
		expDate.setDate(expDate.getDate() + parseInt(days));
		expDate.setHours(expDate.getHours() + parseInt(hours));
		expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
		return expDate.toGMTString();
	}
}
function getCookieVal(offset)
{
	var endstr = document.cookie.indexOf(";", offset);
	if(endstr == -1)
	{
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}
function getCookie(name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while(i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		{
			return getCookieVal(j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if(i == 0) break;
	}
	return "";
}
function setCookie(name, value, expires, path, domain, secure)
{
	document.cookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}
function deleteCookie(name,path,domain) 
{
	if(getCookie(name))
	{
		document.cookie = name + "=" +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
var obj;
var pop_count = 0;
var pop_sum = 1;//允许弹出的次数
//var kw = null;
var pop_chance = 100;//弹出概率
var close_pop = 0;//关闭弹出

var today = new Date(); 
var seed = today.getTime();
function rnd(){
	seed = (seed*9301+49297) % 233280;
	return seed/(233280.0);
}
function rand(number) {
	return Math.ceil(rnd()*number);
}

function popad(){
	if(close_pop == 1)return;
	if(rand(100)>pop_chance)return;
	//if(kw == null)return;
	obj =new Date();
	obj.setTime(obj.getTime() + (10 * 24 * 60 * 60 * 1000));
	if(getCookie('first_pop_time') == ''){
		setCookie('pop_count',0,obj.toUTCString(),'/','.namipan.com','')
			setCookie('first_pop_time',new Date().getDay(),obj.toUTCString(),'/','.namipan.com','')
	}
	if(getCookie('first_pop_time') == new Date().getDay()){
		pop_count = parseInt(getCookie('pop_count')) || 0;
		if(pop_count < pop_sum){
			setCookie('pop_count',++pop_count,obj.toUTCString(),'/','.namipan.com','')
			pop_win();
		}
	}else{
		setCookie('pop_count',0,obj.toUTCString(),'/','.namipan.com','')
		setCookie('first_pop_time',new Date().getDay(),obj.toUTCString(),'/','.namipan.com','')
		pop_win();
	}
}
function pop_win(){
	var winpops=window.open(random_url(),'abc',"location=yes,resizable=yes,toolbar=yes,scrollbars=yes,menubar=yes,status=yes,directories=yes,width=1000,height=760,left=0,top=0")
		winpops.blur()
		window.focus()
		/*var newElement = document.createElement('img'); 
	newElement.setAttribute('src', 'http://xml.namipan.com/stat_word_list.php');
	newElement.style.display = 'none';
	document.body.appendChild(newElement);*/
}

function random_url(){
	var url = [];
	url.push('http://www.namipan.com/inc_page/un/nmp.html');
	url.push('http://www.namipan.com/inc_page/un/nmp.html');
	var i = rand(100);
	var j = 0;
	if(i>90){
		j = 1;
	}
	return url[j]; 
}

document.domain = 'namipan.com';
/*var newElement = document.createElement('iframe'); 
newElement.setAttribute('src', 'http://xml.namipan.com/get_word_list.php');
newElement.style.display = 'none';
document.body.appendChild(newElement);*/
document.onclick = function(){popad();}

