var version = null ;
var cName = "duowan_Notice";
var cTitle_link = "http://bbs.duowan.com/"; // 头条链接
var cTitle_title = "头条标题"; // 头条标题
var cPic_src = "pic_07.jpg"; // 头图地址

String.prototype.replaceAll = replaceAll;

function replaceAll(oldText,replaceText){
raRegExp = new RegExp(oldText,"g");
return this.replace(raRegExp,replaceText);
}

var cTitle = "" ;
var tValue  = "" ;
        tValue = '暴雪答熊猫人质问';
    tValue = tValue.replaceAll("\"","'");
    
    cTitle = cTitle  + "<a style='font-family:宋体; font-size:13px;' href='http://www.duowan.com' target='_blank'>"+tValue+"</a>";
    cTitle = cTitle + " ";
    version = '2012-02-09 10:05:06.0'; 
        
            
        tValue = '博瑞代理劲舞团续作';
    tValue = tValue.replaceAll("\"","'");
    cTitle = cTitle  + "<a style='font-family:宋体; font-size:13px;' href='http://newgame.duowan.com/1202/192707165188.html' target='_blank'>"+tValue+"</a>";
    cTitle = cTitle + " ";
    
var cPic_link = "http://bbs.duowan.com/ "; // 头图链接
var cPic_title = "头图标题 说明"; // 头图标题 说明

var cPic = "";
<!--头图获取-->
    cPic_src = "http://pic.duowan.com/newgame/1101/160324928641/160324939549.jpg"; 
    cPic_title = "魔导师齐扮兔女郎 愿玩家开心快乐"; 
    //cPic_link = "http://news.duowan.com/1101/160322022205.html"; 
    cPic_link = "http://www.duowan.com/?88#pic"; 

    cPic = '<a target="_blank" href="' + cPic_link + '"><img src="'+ cPic_src + '" /></a></div><div id="pic_text-bluebox"><a target="_blank" href="'
			+ cPic_link + '">' + cPic_title + '</a>'; 

    version2 = "2011-02-03 07:59:58.0" ;
    if(version2>version){
      version=version2;
    }

var nums = 3; // 区域1新闻数量
var nums_line = 3; // 区域2新闻数量

function SetCookie(name, value)// 两个参数，一个是cookie的名子，一个是值
{
	var Days = 30; // 此 cookie 将被保存 30 天
	var exp = new Date(); // new Date("December 31, 9998");
     	exp.setTime(exp.getTime() + 4 * 60 * 60 * 1000);
           	document.cookie = name + "=" + escape(value) + ";expires="
			+ exp.toGMTString()+";domain=."+getRootDomain()+";path=/";
}
function getCookie(name)// 取cookies函数
{
      	var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));

	if (arr != null)
	{
		return unescape(arr[2]);

	}
	return null;

}function delCookie(name)// 删除cookie
{
	var exp = new Date();
	exp.setTime(exp.getTime() - 1);
	var cval = getCookie(name);
	if (cval != null)
		document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
}

function closeDiv(id) {
	document.getElementById(id).style.display='none';
}
function playDiv(divID) {
	var divStr = '<div id="frame02-bluebox"><div id="onclick-bluebox" style="float:right" onclick="closeDiv(\'frame01-bluebox\');"></div></div><div id="frame03-bluebox"><div style="width:100%; height:16px; margin-top:12px; margin-bottom:12px; font-family:宋体; font-size:13px; overflow:hidden; float:left;font-weight:bold;"><font color=#333333>[头条]</font>'
			+ cTitle
			+ '</div><div style="float:left; width:108px;"><div id="pic-bluebox">'
		        + cPic + '</div></div><div id="content-bluebox"><ul>';

          
                	    divStr += '<li><a target="_blank" href="http://news.duowan.com/1101/157979602010.html">失聪魔兽世界玩家无缘副本</a></li>';
        	    divStr += '<li><a target="_blank" href="http://news.duowan.com/1101/157980383542.html">《龙之心》大陆设定及故事公开</a></li>';
        	    divStr += '<li><a target="_blank" href="http://news.duowan.com/1101/157977561649.html">《御龙在天》预告视频曝光</a></li>';
        
	divStr += '</ul><div id="content_line-bluebox"></div><ul>';
       
                	    divStr += '<li><a target="_blank" href="http://newgame.duowan.com/1101/157978689196.html">《英雄联盟》新角色凯瑟琳公布</a></li>';
        	    divStr += '<li><a target="_blank" href="http://newgame.duowan.com/yxqz110103/">每周共有9款游戏开测</a></li>';
        	    divStr += '<li><a target="_blank" href="http://news.duowan.com/1012/157634184487.html">多玩游戏网 手机WAP新版上线</a></li>';
        
	divStr += '</ul><div id="search-bluebox"><label><input class="searchstyle01-bluebox" onclick="nameSearch(1,this)" onblur="nameSearch(2,this)" type="text" id="q" value="网游最佳雇主" size="26" /></label><span><img src="http://www.duowan.com/s/i/bt_19.gif" width="35" height="18" class="searchstyle02-bluebox" onclick="search1()" /></span></div></div></div>';
	
	var style = document.createElement("link");
	style.rel = "stylesheet";
	style.type = "text/css";
	style.href = "http://www.duowan.com/s/i/maincss01.css";
	document.body.appendChild(style);
	var container = document.createElement("div");
	container.id = "frame01-bluebox";
	container.innerHTML = divStr;
	document.body.appendChild(container);
}

var cGetValue = getCookie(cName);
if ((cGetValue == '' || cGetValue != version) && version!=null) {
    if (window.addEventListener) {
		window.addEventListener("load", playDiv, false);
	} else {
		window.attachEvent("onload", playDiv);
	}

    SetCookie(cName, version);
}


	function nameSearch(type,obj){
					  if(type==1&&obj.value=="请输入游戏关键字") obj.value="";
					  if(type==2&&obj.value=="") obj.value="请输入游戏关键字";
					}
					
					function search1(){
					  var href=document.location.href;
					  var re=/http:\/\/.+.duowan.com\/(.+\/)?((.+).html)?/ig;
					  var arr=re.exec(href);
					  if(!arr) return;
					    //http://so.duowan.com/search.do?channel=&keyWord=%E6%88%91%E5%8F%ABMT&type=0
						var ss=["channel","type","keyWord"];
						var ps=["","0",""];
						var chk=false;
						ps[2]=document.getElementById("q").value;
						
						var f=document.createElement("form");
						f.action="http://so.duowan.com/search.do";
						f.method="get";
						for(var j=0;j<ss.length;j++){
						  var i=document.createElement("input");
						  i.type= "hidden";
						  i.name= ss[j];
						  i.value= ps[j];
						  f.appendChild(i);
						}
						document.body.appendChild(f);
						f.target="_blank";
						f.submit();
						document.body.removeChild(f);
					  
					}

function getRootDomain(name){
    if(name == ''|| name == null || typeof(name) == 'undefined'){
        name = document.location.host;
    }
    tmp = name.split('.');
    last = tmp.pop();
    if(last == 'cn' && tmp.length >= 2){
        domain = tmp.pop();
	if(domain == 'com' || domain =='net' || domain =='org' || domain =='gov' || domain =='mobi')
	{
		if(tmp.length >= 1)
		{
			sub = tmp.pop();
			result = sub+'.'+domain+'.'+last;
		}
		else
		{
			result = sub+'.'+domain+'.'+last;
		}
	}
	else
	{
		 result = domain+'.'+last;
	}
       
        
    }
    else if(last == 'cn' && tmp.length < 2){
    	domain = tmp.pop();
        result = domain+'.'+last;
    }else{
        domain = tmp.pop();
        result = domain+'.'+last;
    }
    return result;
}
