//站点基础参数
function Page(){
	
	Page.Site = "http://an.91.com/"; //站点地址
	
	Page.ImgUrl = "../Lib/images/"; //站点图片地址
	Page.isIE = (document.all);
	Page.isIE6 = (navigator.appVersion.indexOf("MSIE 6") > -1);
	Page.BaseCode = "an_"; //JS产生ID值前缀
	Page.BaseNum = 1; //JS重复调用函数避免重复ID的自增数初始数
	Page.NoError = false; //是否屏蔽错误
	Page.AspxPageType = ".aspx"; //所有可能成为aspx页面的当前静态页扩展名，开发测试时用，发布后编辑撤消（仅对JS内导航）
	Page.isIE = (document.all);
	Page.isIE6 = (navigator.appVersion.indexOf("MSIE 6") > -1);
	
	Page.NavItems = [
		{ name:"",url:Page.Site + "index.html", target:"_self", color:null, id:0 },
		{ name:"", url:Page.SiteVIP + "Pay/Buy" + Page.AspxPageType, target:"_self", color:null, id:1 },
		{ name:"", url:Page.SiteVIP + "Pay/VIPStorePay" + Page.AspxPageType, target:"_self", color:null, id:2 }
		
];
	
	
	Page.SideBarNav = [
		{ title:"　　密保操作", id:Page.BaseCode + "_new_sideNav", url:"https://vipshop.91.com/Pay/MobileProtectServiceBuyNew.aspx", target:"_self",childs:[
				{ name:"帐号绑定", url:"https://vipshop.91.com/Pay/MobileProtectServiceBuyNew.aspx" , target:"_self", focusID:45,txt:"" },
				{ name:"帐号解绑", url:"https://aq.91.com/NDUser_PhoneSafeUnBind.aspx?ISNDUserCenter=1" , target:"_self", focusID:41,txt:"" },
				{ name:"游戏加锁、解锁", url:"introduction_AddSuo.html", target:"_self", focusID:42,txt:"" },
				{ name:"短信包月服务", url:"introduction_mibaodxby.html", target:"_self", focusID:47,txt:"" },
<!--				{ name:"游戏解锁", url:"introduction_JieSuo.html", target:"_self", focusID:40,txt:"" },-->
				{ name:"取回密码",url:"SJ_Pw.html", target:"_self", focusID:43,txt:"银行卡绑定游戏帐号，一次绑定，10秒快速充值" }
				
			]
		},
		{ title:"　　密保信息", id:Page.BaseCode + "_pay_sideNav", url:"https://aq.91.com/NDUser_PhoneSafeShow.aspx",childs:[
				{ name:"我的密保", url:"https://aq.91.com/NDUser_Login.aspx?SiteFlag=183&ISNDUserCenter=1", target:"_self", focusID:21,txt:""  },
				{ name:"新版ID小助", url:"https://vipshop.91.com/Pay/MobileProtectServiceBuyNew.aspx" , target:"_self", focusID:23,txt:""  }
			]
		},
		{ title:"　　使用指南", id:Page.BaseCode + "_91_siceNav",url:"introduction.html", childs:[
				{ name:"密保简介", url:"introduction.html", target:"_self", focusID:31,txt:"" },
				{ name:"帐号绑定",url:"introduction_Bingding.html",target:"_self",focusID:46,txt:"" },
				{ name:"帐号解绑", url:"introduction_JieBing.html", target:"_self", focusID:33,txt:"" },
				{ name:"短信包月服务", url:"introduction_dxby.html", target:"_self", focusID:32,txt:"" },
				{ name:"帐号加锁、解锁", url:"locking.html", target:"_self", focusID:35,txt:"" },
				{ name:"取回密码", url:"retrievePs.html", target:"_self", focusID:36,txt:"" },
				{ name:"常见问题", url:"introduction_Faq.html", target:"_self", focusID:34,txt:"" }
			]
		}
];
	//侧边栏登录内嵌页
	Page.SidebarFrame = { name:Page.BaseCode + "login_frame", id:Page.BaseCode + "login_frame", url:"https://shop.91.com/Include/LoginPage.aspx", width:0, height:0 };
	
	
	//初始执行代码块
	if(Page.NoError){ window.onerror = function(){ return true; } }
}Page();

//设置iframe自适应
Page.SetFrameHeight = function(id, num){
	try{
		num = (num) ? num : 18;
		top.document.getElementById(id).height = (document.documentElement.scrollHeight > 0) ? document.documentElement.scrollHeight + num : document.documentElement.offsetHeight + num;
	}catch(e){  }
}
/*************************************************** 页面函数 ****************************************************************/

//站点统一头部
Page.Nav = function(){
	
	document.write("<div class=\"top font_12\"><div class=\"login\"><a href=\"https://shop.91.com\" target=\"_blank\">91充值平台</a> | <a href=\"https://reg.91.com/NDUser_Register.aspx?url=http://www.91.com\" target=\"_blank\">注册</a></div>")
	document.write("</div><\/div>")
};
//站点支付页侧边栏
Page.SideBar = function(focusID, isIndex){
	Page.Side(Page.SideBarNav, focusID, !isIndex, true, true);
};

//站点公共侧边栏实现
Page.Side = function(SideBarNav, focusID, isNav, isLogin, isService){
	var focusConID = null;
	document.writeln("<div class=\"side\"><div><img src=\"" + Page.ImgUrl + "side_top_1.gif\" alt=\"\" \/><\/div>");
	if(isNav)
		for(var i = 0; i < SideBarNav.length; i++){
			document.writeln("<div class=\"side_con2\"><div class=\"title\"  id=\"" + SideBarNav[i].url + "\">" + SideBarNav[i].title + "<\/div><br class=\"cbr\" \/><ul class=\"side_pay_ul\" style=\"display:block;\">");
			for(var k = 0; k < SideBarNav[i].childs.length; k++){
				document.writeln("<li class=\"" + SideBarNav[i].childs[k].target + "\" id=\"" + SideBarNav[i].childs[k].url + "\" value=\"" + SideBarNav[i].childs[k].focusID + "\" " + ((SideBarNav[i].childs[k].focusID == focusID) ? "style=\"background-image:url(" + Page.ImgUrl + "side_con2_bg2.jpg); color:#c30;font-weight:bold;\"" : "") + ">" + SideBarNav[i].childs[k].name + "<\/li>");
				if(SideBarNav[i].childs[k].focusID == focusID) focusConID = i;
			}
			document.writeln("<\/ul>" + ((SideBarNav[i + 1]) ? "" : "<div><img src=\"" + Page.ImgUrl + "side_con2_bm.jpg\" alt=\"\" \/><\/div>") + "<\/div>");
		}
	document.writeln("<\/div>");

	var sides = Fun.$cl("side_con2", "div"), titles = [], cons = [], imgs = [], temp;
	for(var i = 0; i < sides.length; i++){
		titles.push(Fun.$cl("title", "div", sides[i])[0]);
		titles[i].id = Page.BaseCode + "title" + i.toString();
		cons.push(Fun.$cl("side_pay_ul", "ul", sides[i])[0]);
		imgs.push(Fun.$tag("img", titles[i])[0]);
	}

	if(isNav){
		function mouseover(){ if(focusID != this.value) this.style.backgroundImage = "url(" + Page.ImgUrl + "side_con2_bg2.jpg)"; }
		function mouseout(){ if(focusID != this.value) this.style.backgroundImage = "url(" + Page.ImgUrl + "side_con2_bg1.jpg)"; }
		function mouseclick(){ Fun.$target(this.id, this.className); }
		function titleclick(){
			temp = cons[parseInt(this.id.replace(Page.BaseCode + "title", ""))];
			temp.style.display = (temp.style.display == "block") ? "block" : "block";
			window.location.href = Page.SideBarNav[parseInt(this.id.replace(Page.BaseCode + "title", ""))].url;	
			
		}
		var items = Fun.$cl("side_con2", "div");
		for(var i = 0; i < items.length; i++) Fun.$action(Fun.$tag("li", items[i]), mouseover, mouseout, mouseclick);
		Fun.$action(titles, null, null, titleclick);
		if(focusConID == 0 || focusConID){
			cons[focusConID].style.display = "block";
		
		}
	}
}
//设置iframe自适应
Page.SetFrameHeight = function(id, num){
	try{
		num = (num) ? num : 18;
		top.document.getElementById(id).height = (document.documentElement.scrollHeight > 0) ? document.documentElement.scrollHeight + num : document.documentElement.offsetHeight + num;
	}catch(e){  }
}

//普通非内嵌页通用加载
Page.Init = function(){
	if(Page.isIE6) document.writeln("<br class=\"clearBR\" \/><style type=\"text\/css\">.cover_con{ position:absolute;bottom:auto;clear:both;top:expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ? documentElement.scrollTop + 200 : document.body.scrollTop + 200); }<\/style>");
};


function setFlexMenu(){
	var items = Fun.$cl("Help_flexMenu", "div");
	var node = null;
	function mouseclick(){
		node = (Page.isIE) ? this.parentNode.nextSibling : this.parentNode.nextSibling.nextSibling;
		if(node){
			node.style.display = (node.style.display == "block") ? "none" : "block";
			this.parentNode.style.backgroundImage = (node.style.display == "block") ? "url(" + Page.ImgUrl + "help_icon2.gif)" : "url(" + Page.ImgUrl + "help_icon1.gif)";
		}
	}
	function objfocus(){ this.blur(); }
	for(var i = 0; i < items.length; i++){
		node = items[i].getElementsByTagName("a")[0];
		node.onclick = mouseclick;
		node.onfocus = objfocus;
	}
	items = Fun.$cl("Help_txt_con", "div");
	function mouseover(){ this.style.borderColor = "#ccc"; this.style.backgroundColor = "#F5FAFA"; }
	function mouseout(){ this.style.borderColor = "#fff"; this.style.backgroundColor = "#fff"; }
	for(var i = 0; i < items.length; i++){
		items[i].onmouseover = mouseover;
		items[i].onmouseout = mouseout;
	}
}
//帮助中心问题定位
function pramforhelp(){
		var thisUrl="";
		thisUrl = window.location;
		thisUrl = thisUrl.toString() ;
		try {	
				thisclsName=thisUrl.split("?");
				var items = Fun.$cl("Help_txt_con", "div");
				var items1 = Fun.$cl("Help_flexMenu", "div");
				var obj = items[thisclsName[1]];
				var obj1 = items1[thisclsName[1]];
//				obj.style.display="block";
				obj.style.display = (obj.style.display == "block") ? "none" : "block";
				this.location.href="#faq_"+thisclsName[1];	
						
				obj1.style.backgroundImage = (obj.style.display == "block") ? "url(" + ImgUrl + "Help_icon2.GIF)" : "url(" + ImgUrl + "Help_icon1.GIF)";

			}
		catch(e){}
		
	}
	

//常见问题FAQ
function faq(){
   document.writeln("<h3>常见问题</h3>");
   document.writeln("<div class=\"line_img\"><\/div><br class=\"cbr\">");
   document.writeln("<p><a href=\"introduction_Faq.html?0\">帐号与手机绑定相关问题？</a></p>");
   document.writeln("<p><a href=\"introduction_Faq.html?4\">手机使用和资费相关问题？</a></p>");
   document.writeln("<p><a href=\"introduction_Faq.html?1\">忘记了游戏密码怎么办？</a></p>");
	 document.writeln("<h4><a href=\"introduction_Faq.html\">查看更多</a></h4>");
}
function faqxz(){
   document.writeln("<h3>常见问题</h3>");
   document.writeln("<p><a href=\"introduction_Faq.html?2\">为什么操作的时候收到的短信内容提示服务器信息不存在？</a></p>");
   document.writeln("<p><a href=\"introduction_Faq.html?2\">为什么不能重设服务器？</a></p>");
	 document.writeln("<h4><a href=\"introduction_Faq.html\">查看更多</a></h4>");
}

/*************************************************** 通用函数 ****************************************************************/
//公共功能模块
function Fun(){
	//获取ID对象值：（对象ID名）
	Fun.$id = function(id){ return document.getElementById(id); }
	//获取tag对象名集合：（对象Tag标签名），[父对象限定]
	Fun.$tag = function(tagName, parent){ return (parent) ? parent.getElementsByTagName(tagName) : document.getElementsByTagName(tagName) ; }
	//获取Class样式名对象集合：（class样式名），[Tag标签限定]，[父对象限定]
	Fun.$cl = function(cl, objName, parentNodeObj){
		var retnode = [], myclass = new RegExp('\\b' + cl + '\\b'), elem = (parentNodeObj == null) ? document.getElementsByTagName(objName) : parentNodeObj.getElementsByTagName(objName), classes;
		for (var j = 0; j < elem.length; j++) { classes = elem[j].className; if (myclass.test(classes)) retnode.push(elem[j]); }
		return retnode;
	}
	//设置链接文本：（待设置的文本），[链接目标地址]，[链接目标窗口]，[样式]
	Fun.$link = function(txt, url, target, style){ return (url) ? "<a href=\"" + url + "\" " + ((style) ? "style=\"" + style + "\"" : "") + ((target) ? " target=\"" + target + "\"" : "") + ">" + txt + "<\/a>" : txt; }
	//设置打开目标：（目标URL地址），[打开方式]
	Fun.$target = function(url, target){
		switch(target){
			case "_blank": window.open(url); break;
			case "_self": window.location.href = url; break;
		}
	}
	//设置对象集合事件：（待设置的对象集合），[鼠标覆盖事件]，[鼠标移开事件]，[鼠标点击事件]
	Fun.$action = function(objArray, mouseoverHandle, mouseoutHandle, mouseclickHandle){
		if(!objArray || objArray.length < 1) return;
		for(var i = 0; i < objArray.length; i++){
			if(mouseoverHandle) objArray[i].onmouseover = mouseoverHandle;
			if(mouseoutHandle) objArray[i].onmouseout = mouseoutHandle;
			if(mouseclickHandle) objArray[i].onclick = mouseclickHandle;
		}
	}
	//设置目标相对浮动：（对比源对象），（待设置目标对象），[左偏移量]，[上偏移量]
	Fun.$position = function(obj, targetObj, leftOffset, topOffset){
		var temp = obj.offsetParent, left = obj.offsetLeft, top = obj.offsetTop;
		while(temp = temp.offsetParent){ left += temp.offsetLeft; top += temp.offsetTop; }
		targetObj.style.left = (left + leftOffset) + "px";targetObj.style.top = (top + topOffset) + "px";
	}
	//设置添加收藏效果：（收藏地址），（收藏标题）
	Fun.$fav = function(url, title){ try{ (Fun.$ie) ? window.external.addFavorite(url, title) : window.sidebar.addPanel(url, title); }catch(e){ alert("收藏失败！请手动操作"); } }
	//设置设为首页效果：（触发源对象），（首页地址）
	Fun.$home = function(obj, url){ try{ obj.style.behavior = "url(#default#homepage)"; obj.setHomePage(url); }catch(e){ if(window.netscape) try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }catch(e){ alert("您的浏览器不支持此功能！"); } } }
	//获取地址栏中域名
	Fun.$domain = function(url){ return (url.indexOf("http") > -1) ? url.split("/")[2] : url.split("/")[0]; }
	//获取URL参数函数
	Fun.$url = function(name){
		var reg = new RegExp("(^|&)"+ name.toLowerCase() +"=([^&]*)(&|$)"), r = window.location.search.substr(1).toLowerCase().match(reg);
		if (r != null) return unescape(r[2]); return null;
	}
}Fun();
