document.title="新奇迹世界(SUN:World Edition) 资料站";
//左边栏
//collectweb page
var gShowResultPage = "http://vote.the9.com/Collect/ShowResult.aspx";
var gIsCorrectAnswer = "http://vote.the9.com/Collect/IsCorrectAnswer.aspx";

var gNowDateTime = new Date();


function CheckForm(oForm)
{
    var els = oForm.elements;
    for(var i=0;i<els.length;i++)
    {
        if(typeof(Global[els[i].name]) != "undefined")
        {
			//is complex input
			if ((/Survey_(R|C)T_(\d+)_(\d+)/ig).test(els[i].name))
			{
					var reg = /Survey_T_(\d+)_(\d+)/;
					reg.exec(els[i].name);
					var issueID = RegExp.$2;
					var optionID = RegExp.$3;
					var el = null;
					if (els[i].name.indexOf('Survey_RT')>-1)
					{
					    el = document.getElementById(els[i].name.replace("RT","R")) == null ? null : document.getElementById(els[i].name.replace("RT","R"));
					}
					if (els[i].name.indexOf('Survey_CT')>-1)
					{
					    el = document.getElementById(els[i].name.replace("CT","C")) == null ? null : document.getElementById(els[i].name.replace("CT","C"));
					}
					if (el != null && !el.checked)
					{
						continue;
					}
			}
            var sReg = Global[els[i].name].check;
            var sVal = GetValue(els[i]);
            var reg = new RegExp(sReg,"i");
            if(!reg.test(sVal))
            {
                alert(Global[els[i].name].warning);
                GoBack(els[i])
				return false;
            }
        }
    }
}

function GetValue(el)
{
    var sType = el.type;
    switch(sType)
    {
        case "text":
        case "hidden":
        case "password":
        case "file":
        case "textarea": return el.value;
        case "checkbox":
        case "radio": return GetValueChoose(el);
        case "select-one":
        case "select-multiple": return GetValueSel(el);
    }
    function GetValueChoose(el)
    {
        var sValue = "";
        var tmpels = document.getElementsByName(el.name);
        for(var i=0;i<tmpels.length;i++)
        {
            if(tmpels[i].checked)
            {
                sValue += "0";
            }
        }
        return sValue;
    }
    function GetValueSel(el)
    {
        var sValue = "";
        for(var i=0;i<el.options.length;i++)
        {
            if(el.options[i].selected && el.options[i].value!="")
            {
                sValue += "0";
            }
        }
        return sValue;
    }
}

function GoBack(el)
{
    var sType = el.type;
    switch(sType)
    {
        case "text":
        case "hidden":
        case "password":
        case "file":
        case "textarea": el.focus(); /*var rng = el.createTextRange(); rng.collapse(false); rng.select();*/return false;
        case "checkbox":
        case "radio": var els = document.getElementsByName(el.name);els[0].focus();return false;
        case "select-one":
        case "select-multiple":el.focus();return false;
    }
}

var Global = new Object();
var aGlobal = new Array();
function SetProperty(oName, sCheck, sWarning)
{
	var oElement = new Object();
	oElement.check = sCheck;
	oElement.warning = sWarning;
	oElement.name = oName;
	Global[oName] = oElement;
	aGlobal[aGlobal.length] = oElement;
}

function Request(key)
{
	var value = "";
	var reg = new RegExp(key + "\\=([^&]+)", "g");
	var url = location.href;
	reg.test(url);
	value = RegExp.$1;
	return value;
}

function copy_url() {
	var c=window.location.href;
  if (window.clipboardData) {
    window.clipboardData.setData("Text", c);
	alert("当前页面地址复制成功！");
  } else {
  alert("此复制功能仅支持IE浏览器，请您手动复制以上奖品兑换码。\n给您带来的不便，敬请谅解！");
  }
}
function leftmenu(){
	$("#menu").empty();
	$("#menu").append("<iframe src=http://sun.the9.com/topic/data/leftmenu.shtml width=195 height=1120  frameborder=0 scrolling=no></iframe>");
	var listOut="";
	listOut+="<li><a href=\"http://sun.the9.com/system/index.shtml\" target=\"_blank\">系统</a><ul><li><a href=\"http://sun.the9.com/system/index.shtml\" target=\"_blank\">特色活动</a><ul><li><a href=\"http://sun.the9.com/system/xuese.shtml\" target=\"_blank\">血色之塔</a></li><li><a href=\"http://sun.the9.com/system/chise.shtml\" target=\"_blank\">赤色要塞</a></li><li><a href=\"http://sun.the9.com/system/emo.shtml\" target=\"_blank\">恶魔广场</a></li><li><a href=\"http://sun.the9.com/system/shiguang.shtml\" target=\"_blank\">时光城堡</a></li></ul></li><li><a href=\"http://sun.the9.com/system/ac.shtml\" target=\"_blank\">AC系统</a></li><li><a href=\"http://sun.the9.com/system/renwu.shtml\" target=\"_blank\">任务系统</a></li><li><a href=\"http://sun.the9.com/system/qianghua.shtml\" target=\"_blank\">强化系统</a></li><li><a href=\"http://sun.the9.com/system/shengji.shtml\" target=\"_blank\">升级系统</a></li><li><a href=\"http://sun.the9.com/system/zhizao.shtml\" target=\"_blank\">制造系统</a></li><li><a href=\"http://sun.the9.com/system/fenjie.shtml\" target=\"_blank\">分解系统</a></li><li><a href=\"http://sun.the9.com/system/chongwu.shtml\" target=\"_blank\">宠物系统</a></li><li><a href=\"http://sun.the9.com/system/fuben.shtml\" target=\"_blank\">副本系统</a></li><li><a href=\"http://sun.the9.com/system/gonghui.shtml\" target=\"_blank\">公会系统</a></li><li><a href=\"http://sun.the9.com/system/shejiao.shtml\" target=\"_blank\">社交系统</a></li><li><a href=\"http://sun.the9.com/system/liaotian.shtml\" target=\"_blank\">聊天系统</a></li></ul></li>";
	$("#list").append(listOut);
	if ($("#list").parent().attr("id")=="index_search") {
	$("#list>li").eq(6).children("ul").prepend("<li><a href=\"http://sun.the9.com/system/worldmap.shtml\" target=\"_blank\">世界地图</a></li>");
    }
	else{
	$("#list>li").eq(7).children("ul").prepend("<li><a href=\"http://sun.the9.com/system/worldmap.shtml\" target=\"_blank\">世界地图</a></li>");
	}
	if ($("#list").parent().attr("id")=="index_search") {
	$("#main").append("<div id=\"index_content\"></div>");
	$("#index_content").append("<iframe src=http://sun.the9.com/topic/data/main.shtml width=780 height=1600  frameborder=0 scrolling=no></iframe>");
	}
	$("#main").append("<div id=\"jubao\" style=\"position:absolute; z-index:100; top:45px; left:500px;width:260px; height:120px;display:none;\"></div>");
	$("#jubao").html("<form class=\"formClass\" name=\"Survey_72a8ee62-2d8f-481f-a051-4601ad073276\" action=\"http://vote.the9.com/Collect/CollectAnswer.aspx\" onSubmit=\"return CheckForm(this)\" method=\"post\" ><input type=\"hidden\" name=\"Survey_PaperID\" value=\"72a8ee62-2d8f-481f-a051-4601ad073276\"><input type=\"hidden\" name=\"Survey_Seconds\" value=\"0\"><input type=\"hidden\" name=\"Survey_ActionType\" value=\"0\"><input type=\"hidden\" name=\"Survey_ActionText\" value=\"提交成功\"><input type=\"hidden\" name=\"Survey_Charset\" value=\"UTF-8\"><textarea name=\"Survey_T_1720_8034\" id=\"Survey_T_1720_8034\" style=\"text-align:left;padding:3px;width:250px;height:80px; overflow:hidden;color:#fff; background:#272421; border:1px solid #4e473d;margin-bottom:10px;\"></textarea><script>SetProperty(\"Survey_T_1720_8034\", \"^.+$\", \"请填写完整\");</script><script>SetProperty(\"Survey_T_1720\", \"^0{1,}$\", \"请填写完整表单\");</script><br /><input class=\"surveySubmitClass\" type=\"button\"  name=\"Submit\" value=\"提交\" style=\"width:50px;height:20px;color:#fff; background:#272421; border:1px solid #4e473d;text-align:center;padding:3px;\" /><input  type=\"button\" onclick=\"$('#jubao').hide();\" value=\"关闭\" style=\"margin-left:15px;width:50px;height:20px;color:#fff; background:#272421; border:1px solid #4e473d;text-align:center;padding:3px;\" /></form>");
	
	$(".surveySubmitClass").click(
		function()
		{
			isAnswerOver = true;
			var elForm = $(this).parents("form").get(0);
			elForm.elements["Survey_Seconds"].value = parseInt( ((new Date()).getTime() - gNowDateTime.getTime())/1000);
			var id = "a_"+parseInt(Math.random()*10000);
			$(this).before("<input type='submit' id='"+id+"' style='display:none'>");
			$("#"+id).click();
			return false;
		}
	);
	var _jubao="<span onclick=\"$('#jubao').toggle();\" onmouseover=\"$(this).css('color','#f7fa00');\" onmouseout=\"$(this).css('color','#fff');\" style=\"padding:5px;padding-left:10px; padding-right:10px;color:#fff; background:#272421; border:1px solid #4e473d; cursor:pointer; font-size:12px; float:right; font-weight:normal; margin-right:15px;font-family:'宋体';\">资料站Bug提交入口</span>";
	var _copy="<span onclick=\"copy_url();\" onmouseover=\"$(this).css('color','#f7fa00');\" onmouseout=\"$(this).css('color','#fff');\" style=\"padding:5px;padding-left:10px; padding-right:10px;color:#fff; background:#272421; border:1px solid #4e473d; cursor:pointer; font-size:12px; float:right; font-weight:normal;font-family:'宋体';\">点击复制当前页面地址</span>";
	$(".in_class").append(_copy+_jubao);
	$(".in_list").siblings("h2").append(_copy+_jubao);
	$("#main").show();
}

//详情页底部
function itemfaqInner(tempSubList){
	var _faq;
/*	switch(tempSubList){
		case 0:
		case 1:
		_faq=classArr[tempSubList];
		$(".itemfaq").append("<li><a href=\"http://sun.the9.com/data/xitong/hecheng/hecheng_01.html\" target=\"_blank\">什么是"+_faq+"强化？</a></li><li><a href=\"http://sun.the9.com/data/xitong/hecheng/hecheng_02.html\" target=\"_blank\">什么是"+_faq+"升级？</a></li><li><a href=\"http://sun.the9.com/data/xitong/hecheng/hecheng_03.html\" target=\"_blank\">什么是"+_faq+"分解？</a></li><li><a href=\"http://sun.the9.com/data/xitong/hecheng/hecheng_04.html\" target=\"_blank\">什么是"+_faq+"制造？</a></li>");
		break;
		case 2:
		case 3:
		_faq="物品";
		$(".itemfaq").append("<li><a href=\"http://sun.the9.com/data/xitong/hecheng/hecheng_01.html\" target=\"_blank\">什么是"+_faq+"强化？</a></li><li><a href=\"http://sun.the9.com/data/xitong/hecheng/hecheng_02.html\" target=\"_blank\">什么是"+_faq+"升级？</a></li><li><a href=\"http://sun.the9.com/data/xitong/hecheng/hecheng_03.html\" target=\"_blank\">什么是"+_faq+"分解？</a></li><li><a href=\"http://sun.the9.com/data/xitong/hecheng/hecheng_04.html\" target=\"_blank\">什么是"+_faq+"制造？</a></li>");
		break;
		case 4:
		case 5:
		$(".itemfaq").append("<li><a href=\"\" target=\"_blank\">玩家交流</a></li>");
		break;
	}*/
}

//顶部
function topCont(){
	$("#top").append("<iframe src=http://sun.the9.com/topic/data/top.shtml width=1000 height=152  frameborder=0 scrolling=no></iframe>");
}

function footer(){
	$("#footer").append("<br />*一切数据以游戏内为准*<br />");
	$("#footer").append("<img src=\"http://images1.sun.the9.com/images_sunv4/topic/2008mar/foot_copy.png\" class=\"png\" />");
}

function indexsearch(){
	$("#index_search").prepend("<ul class=\"index_title\"></ul>");
	$("#hot").append("<li><strong>近期热点：</strong><a href=\"http://db.sun.the9.com/Search.aspx?l=2,3,4,5,8,7,6,9,1&s=v/HVvcq/\" target=\"_blank\">狂战士</a>　<a href=\"http://db.sun.the9.com/Search.aspx?l=2,3,4,5,8,7,6,9,1&s=wfrG78q/\" target=\"_blank\">龙骑士</a>　<a href=\"http://db.sun.the9.com/Search.aspx?l=2,3,4,5,8,7,6,9,1&s=yqXJ5MrW\" target=\"_blank\">圣射手</a>　<a href=\"http://db.sun.the9.com/Search.aspx?l=2,3,4,5,8,7,6,9,1&s=xKe3qMqm\" target=\"_blank\">魔法师</a>　<a href=\"http://db.sun.the9.com/Search.aspx?l=2,3,4,5,8,7,6,9,1&s=sLXTsA==\" target=\"_blank\">暗影</a>　<a href=\"http://sun.the9.com/topic/equips/\" target=\"_blank\">装备秀</a>　<a href=\"http://sun.the9.com/topic/skills/\" target=\"_blank\">技能秀</a>　<a href=\"http://sun.the9.com/topic/new_age/chongwu.html\" target=\"_blank\">宠物秀</a></li>");
	$("#hot>li").eq(0).addClass("top");
	$("#hot").append("<li class=\"btm\"></li>");
}