//document.domain="91.com";

//全布变量
var SiteUrl = "../"; //站点主目录
var SiteUrlForArea = "../VIP_area/";  //VIP专区站主目录
var ImgUrl = "../Lib/images/"; //站点图片位置目录
var GGUrl = "https://hsimage.91.com/vipbar91/images/_tmp/"; //站点广告图位置目录
var aspxPageType = ".html";  //所有可能开发为aspx页面当前文件的扩展名（方便程序员修改用，仅对公共导航启效），发布后此参数由编辑取消

var isIE = (document.all) ? true : false;
var isIE6 = (navigator.appVersion.indexOf("MSIE 6") > -1) ? true : false;

//全站头部导航（当前选定项）
function Top(num){
	var Items = [
		{ name:"首页", url:SiteUrl + "Pay/index.html", id:1 },
		{ name:"商品购买", url:SiteUrl + "Pay/Buy" + aspxPageType, id:2 },
		{ name:"VIP帐户充值", url:SiteUrl + "Pay/Pay_NetBank" + aspxPageType, id:3 },
		{ name:"VIP专区", url:SiteUrlForArea + "index.html", id:6 },
		{ name:"我的帐户", url:SiteUrl + "Account/MyAccount" + aspxPageType, id:4 },
		{ name:"帮助中心", url:SiteUrl + "Help/bank_index.html", id:5 }
	];
	document.writeln("<div class=\"top\"><div style=\"position:relative;left:390px !important;left:400px;top:50px;\"><img src=\"" + ImgUrl + "hot_icon.png\" alt=\"\" onload=\"transPNGPic(this);\" \/><\/div><div class=\"top_txt\" id=\"top_login_info\"><h1 id=\"top_login_info_h1\">欢迎您！<\/h1><h2 id=\"top_login_info_h2\"><a href=\"javascript:;\" id=\"login_href\">登录<\/a> | <a href=\"javascript:;\">注册<\/a><\/h2><\/div>");
	document.writeln("<div class=\"top_nav\"><div><img src=\"" + ImgUrl + "nav_l.gif\" alt=\"\" \/><\/div><ul id=\"top_nav\">");
	for(var i = 0; i < Items.length; i++)
		document.writeln("<li" + ((num == Items[i].id) ? " class=\"nav_selected\"" : "") + ((i == Items.length - 1) ? " style=\"background:url();\"" : "") + "><div>" + Items[i].name + "<\/d4iv><\/li>");
	document.writeln("<\/ul><\/div><\/div>");
	var items = $id("top_nav").getElementsByTagName("div");
	function mouseover(){ this.style.backgroundImage = "url(" + ImgUrl + "nav_bg.gif)"; this.style.color = "#000"; }
	function mouseout(){ this.style.backgroundImage = "url()"; this.style.color = "#fff"; }
	function mouseclick(){ setLocation(Items[parseInt(this.id.replace("topNav_", ""))].url, false); }
	for(var i = 0; i < items.length; i++){
		items[i].id = "topNav_" + i.toString();
		if(items[i].parentNode.className != "nav_selected"){
			items[i].onmouseover = mouseover;
			items[i].onmouseout = mouseout;
			items[i].onclick = mouseclick;
		}
	}
	setOverLayer();
	
	//异步获取登录信息部分
	var returnValue = null;
	var h1 = $id("top_login_info_h1");
	var h2 = $id("top_login_info_h2");
	var setInfo = function(){
		if(this.readyState == 4){
			if(this.status == 200){
				returnValue = this.responseText;
				if(returnValue){
					var value = returnValue.split("||");
					if(value[0])
						h2.innerHTML = value[0] + " | ";
					else{
						return;
					}
					if(value[1])
						h2.innerHTML += "人民币余额：" + value[1] + "元 | ";
					if(value[2])
						h2.innerHTML += "91币余额：" + value[2] + "币 | ";
					h2.innerHTML += "<a href=\"" + SiteUrl + "Account/MyAccount" + aspxPageType + "\">我的帐户<\/a> <a href=\"javascript:;\">退出<\/a>";
				}
				return;
			}else{
				h1.innerHTML = "";
				h2.innerHTML = "登录信息提取出错！ | <a href=\"javascript:document.location.reload();\">刷新本页<\/a>";
			}
		}
	}
	//var ajax = new AjaxData(SiteUrl + "Include/LoginInforamtion.aspx", "GET", setInfo, null);
	var ajax = new AjaxData(SiteUrl + "AjaxTest.aspx?n=我很帅&m=122&b=4864", "GET", setInfo, null);
	ajax.send();
}



//首页FLAH轮换广告
function playFlash(){
	var pic_width = 271;
	var pic_height = 182;
	var button_pos = 4;
	var stop_time = 6000;
	var show_text = 1; 
	var txtcolor = "dddddd";
	var bgcolor = "000000";
	var imag = new Array();
	var link = new Array();
	var text = new Array();
	
	var flashUrl = GGUrl + 'update.swf';
	
	imag[1] = GGUrl + "275X182_091021.jpg";
	link[1] = "http://activity.vip.91.com/RecruitNetBarToBindVip/Default.aspx";
	text[1] = "";

	
	
	imag[2] = GGUrl + "275x182_090518.jpg";
	link[2] = "http://sms.91.com/activity/card/index.html";
	text[2] = "";
	

	
	imag[3] = GGUrl + "275x182_090731.jpg";
	link[3] = "http://sms.91.com/activity/myxr/";
	text[3] = "";
	
	imag[4] = GGUrl + "275x182_0901027.jpg";
	link[4] = "http://www.geppay.com/news1.aspx";
	text[4] = "";
	
	imag[5] = GGUrl + "275x182_091030.jpg";
	link[5] = "http://activity.vip.91.com/activity01/index.aspx";
	text[5] = "";
	
	
	imag[6] = GGUrl + "275x182_0901116.jpg";
	link[6] = "http://qz.kx.91.com/";
	text[6] = "";
	
	var swf_height=show_text==1?pic_height+0:pic_height;
	var pics="", links="", texts="";
	for(var i=1; i<imag.length; i++){
		pics=pics+("|"+imag[i]);
		links=links+("|"+link[i]);
		texts=texts+("|"+text[i]);
	}
	pics=pics.substring(1);
	links=links.substring(1);
	texts=texts.substring(1);
	
	var flash = '<embed wmode=\"transparent\" src="' + flashUrl + '" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&pic_width='+pic_width+'&pic_height='+pic_height+'&show_text='+show_text+'&txtcolor='+txtcolor+'&bgcolor='+bgcolor+'&button_pos='+button_pos+'&stop_time='+stop_time+'" quality="high" width="'+ pic_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	document.writeln(flash);
}


//获取ID对象
function $id(obj){ return document.getElementById(obj); }

//获取class属性对象（样式名，该样式的对象tagName，父对象）
var $cl = function(cl, objName, parentNodeObj) {
	var retnode = [];
	var myclass = new RegExp('\\b' + cl + '\\b');
	var elem = (parentNodeObj == null) ? document.getElementsByTagName(objName) : parentNodeObj.getElementsByTagName(objName);
	for (var j = 0; j < elem.length; j++) {
		var classes = elem[j].className;
		if (myclass.test(classes)) retnode.push(elem[j]);
	}
	return retnode;
}

//设置页面跳转
function setLocation(url, isTopWindow){
	if(!isTopWindow)
		window.location.href = url;
	else
		top.window.location.href = url;
}

//判断是否为空对象或空值字符串
function isEmptyStr(str){
	return (str == null) ? true : (str == "") ? true : false;
}

//站点统一底部
function Bottom(){
	document.writeln("<div class=\"bm\"><div class=\"bm_con\"><a href=\"http:\/\/www.91.com\/about\/\" target=\"_blank\">关于91.com<\/a>┊<a href=\"http:\/\/us.91.com\/\" target=\"_blank\">91 US<\/a>┊<a href=\"http:\/\/eu.91.com\/\" target=\"_blank\">91 EU<\/a>┊<a href=\"http:\/\/www.91.com\/about\/contact.shtml\" target=\"_blank\">联系我们<\/a>┊<a href=\"http:\/\/hr.nd.com.cn\/\" target=\"_blank\">高薪诚聘<\/a>┊<a href=\"https:\/\/reg.91.com\/\" target=\"_blank\">会员注册<\/a>┊<a href=\"https:\/\/vip.91.com\/pay\/help.html\" target=\"_blank\">产品答疑<\/a>┊<a href=\"http:\/\/gm.91.com\/\" target=\"_blank\">客户服务<\/a>┊<a href=\"http:\/\/www.91.com\/about\/business.shtml\" target=\"_blank\">商务合作<\/a><br \/>重要客户呼叫中心号码：0591-88085999　充值客服电话：0591-87085777-1<br \/><a href=\"http:\/\/www.91.com\/about\/licence.shtml\" target=\"_blank\">增值电信业务经营许可证B2-20050038号<\/a> <a href=\"http:\/\/www.91.com\/about\/telecom.shtml\" target=\"_blank\">文网文『2003』0048号<\/a><br \/>图文系“<a href=\"http:\/\/www.tqdigital.com\/\" target=\"_blank\">天晴数码<\/a>”公司所有. 2000-2008 &copy; TQdigital All rights reserved.<\/div><div class=\"bm_icon\"><a href=\"http:\/\/www.fuzhou.cyberpolice.cn\/\" target=\"_blank\"><img src=\"..\/Lib\/images\/NetPolice.gif\" alt=\"报警岗亭\" title=\"报警岗亭\" \/><\/a><br \/><a href=\"http:\/\/www.fuzhou.cyberpolice.cn\/\" target=\"_blank\">报警岗亭<\/a><\/div><div class=\"bm_icon\" style=\"padding-top:8px;\"><a href=\"http:\/\/www.miibeian.gov.cn\/\" target=\"_blank\"><img src=\"..\/Lib\/images\/icp.gif\" alt=\"闽ICP证B2-20050038\" title=\"闽ICP证B2-20050038\" \/><\/a><br \/>闽ICP证<a href=\"http:\/\/www.miibeian.gov.cn\/\" target=\"_blank\">B2-20050038<\/a><\/div><\/div>");
}

//处理PNG（图片对象）
function transPNGPic(myImage){
	if (isIE6 && (document.body.filters)){
		var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
		var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
		var imgTitle = (myImage.title) ? 
				   "title='" + myImage.title   + "' " : "title='" + myImage.alt + "' "
		var imgStyle = "display:inline-block;" + myImage.style.cssText
		var strNewHTML = "<span " + imgID + imgClass + imgTitle
					   + " style=\"" + "cursor:hand;width:" + myImage.width 
					   + "px; height:" + myImage.height 
					   + "px;" + imgStyle + ";"
					   + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					   + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
		myImage.outerHTML = strNewHTML;
	}
}



//设置按钮效果（按钮样式名）
function setBtn(btnName){
	var items = $cl(btnName, "input");
	function mouseover(){ this.style.backgroundImage = "url(" + ImgUrl + btnName + "bg2.gif)"; }
	function mouseout(){ this.style.backgroundImage = "url(" + ImgUrl + btnName + "bg1.gif)"; }
	for(var i = 0; i < items.length; i++){
		items[i].onmouseover = mouseover;
		items[i].onmouseout = mouseout;
	}
}




//设置固定电话地图选择焦点
function setMapFocus(){
	var items = $id("mapContent").getElementsByTagName("li");
	function mouseover(){ this.style.backgroundImage = "url(" + ImgUrl + "map_focus2.gif)"; }
	function mouseout(){ this.style.backgroundImage = "url(" + ImgUrl + "map_focus1.gif)"; }
	for(var i = 0; i < items.length; i++){
		items[i].onmouseover = mouseover;
		items[i].onmouseout = mouseout;
	}
}



//设置领卡帮助页FLASH及图片切换效果
function setGetCardHelp(){
	var a = $id("Help_content").getElementsByTagName("a");
	var img, flash, isTxt, smov, tempImg, tempFlash;
	function Aclick(){
		img = this.parentNode.previousSibling.previousSibling;
		flash = this.parentNode.previousSibling.getElementsByTagName("object")[0];
		isTxt = (this.innerHTML == "查看图片提示");
		img.style.display = (isTxt) ? "block" : "none";
		flash.parentNode.style.display = (isTxt) ? "none" : "block";
		this.innerHTML = (isTxt) ? "查看视频帮助" : "查看图片提示";
		if(tempFlash && tempFlash != flash){
			tempFlash.stop();
			tempFlash.LoadMovie(1, ImgUrl + "HelpImg/HelpPic/blank.swf");
			tempImg.style.display = "block";
			tempFlash.parentNode.style.display = "none";
		}
		tempFlash = flash;
		tempImg = img;
		flash.LoadMovie(1, (!isTxt) ? ImgUrl + "HelpImg/HelpPic/" + this.id + ".swf" : ImgUrl + "HelpImg/HelpPic/blank.swf");
		(!isTxt) ? flash.play() : flash.stop();
	}
	for(var i = 0; i < a.length; i++)
		a[i].onclick = Aclick;
}




//获取URL参数函数
function getUrl(name){
	var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if (r!=null) return unescape(r[2]);return 1;
}