
/////////////////////////////////////////////////
//                                             //
//                    biz                      //
//                                             //
/////////////////////////////////////////////////

/*==*/
//全局变量
var iAWidth = screen.availWidth;
var iAHeight = screen.availHeight-32;
/*==jsb 登录框==*/
/*==
public:sLogReturnAdd 登陆后返回的返回地址。
public:display 登录框显示。
==*/
var sLoginType =1;//1:页面跳转式登录;2:ajax登录
var sXForm_nextStep;//储存Xform 名称。
function jsbLogin()
{
	this.sLogReturnAdd = document.URL;//登录后的返回地址
	this.sPagetype = 0;
	this.sMessagecode='';	
	this.sFormname = "Login";
	this.sLT = 1;//loginType 正常或ajax
	this.loginPage=1;//1不显示登录后的信息
	this.display =function()
{	
	sLoginType=this.sLT;//确定提交方式。
	var sinaproFlag = 0;
	var sinapro = getCookie("SINAPRO");
	var paysidFlag = 0;
	var paysid = getCookie("PAYSID");
	var payloginFlag = 0;
	

	if(this.sPagetype!=0)
		this.sLogReturnAdd+="&pagetype=" + this.sPagetype;
	if(this.sMessagecode!='')
		this.sLogReturnAdd+="&messagecode=" + this.sMessagecode;
	
	
	//=====================unipro check


	var noLoginStr = ''
+' <div id="div_jsblogin">'
+'<div id="div_jsblogin_alert" style="display:none"></div>'
+'		<form id='+this.sFormname+' name='+this.sFormname+' action=https://pay.sina.com.cn/cgi-bin/login.cgi?rurl='
+			this.sLogReturnAdd
+' 		method=POST>'
+'	<input type=hidden name=payRequestValue />'
+'	<input type=hidden name=serial />'
+'	<input   type=hidden value=1 name=inputflag />'
+'	<input type=hidden name="check" value="" />	'
+'	<ul id=ul_jsblogin>'
+'	<li id=li_jsblogin1>'
+'		<span class="span_block_jsblogin0 g_ff_gray">登录名'
+'		</span><input style="width:110px" id=input_login_jsblogin1 class=inputone onkeydown=if(event.keyCode==13)checkLoginUser('+this.sFormname+') onblur=if(this.value==&quot;&quot;)this.value=&quot;会员名/UC号/手机&quot; onfocus=if(this.value==&quot;会员名/UC号/手机&quot;)this.value=&quot;&quot; tabIndex=1 size=18 value=会员名/UC号/手机 name=user> '
+'	</li>'
+'	<li id=li_jsblogin2>'
+'		<span class="span_block_jsblogin0 g_ff_gray">密&nbsp;&nbsp;&nbsp;&nbsp;码'
+'		</span><input id=input_login_jsblogin2 class=inputone onkeydown=if(event.keyCode==13)checkLoginUser('+this.sFormname+') tabIndex=2 type=password size=19 value name=psw> '
+'	</li>'
+'	<li id=li_jsblogin3>'
+'		<table cellSpacing="0" height=20px width=151px><tr><td width=43px align=right><span class="span_block_jsblogin0 g_ff_gray">验证码&nbsp;&nbsp; </span><span></td>'
+'		<td >'
+'				<span class="span_block_jsblogin0 g_ff_gray" style="float: left;padding-right:2px">'
+'				<input class="inputone" id="input_login_jsblogin3" onkeydown="if(event.keyCode==13)checkLoginUser('+this.sFormname+')" onblur="if(this.value==&quot;&quot;)this.value=&quot;输入数字&quot;" onfocus="if(this.value==&quot;输入数字&quot;)this.value=&quot;&quot;" tabIndex="3" size="8" value="输入数字" name="confcode"></span></td>'
+'				<td >'
+'				<iframe style="border:1px solid gray" border="0" name="I1" frameBorder="0" width="52" scrolling="no" height="20" src="https://pay.sina.com.cn/other/check.html">浏览器不支持嵌入式框架，或被配置为不显示嵌入式框架。'
+'				</iframe></td>'
+'			</tr>'
+'		</table>'
+'	</li>'
+'	<li id=li_jsblogin4>'
+'		<span class=span_block_jsblogin></span><input style="height:30px" onkeydown=if(event.keyCode==13)checkLoginUser(Login) onclick=checkLoginUser('+this.sFormname+') tabIndex=4 type=button value="   登  录   "  name=B1>'
+'	</li>'
+'	<li id=li_jsblogin5>'
+'		<span class=span_block_jsblogin></span><a target=_blank href=http://unipro.sina.com.cn/cgi-bin/regist0.cgi?url1=&url2=&id1=1&id2=0&entry=sinapay&mcheck=36aff1cc217517552d6b349072eea0d3>'
+'			申请通行证</a><span color=#464646>|</span><a target=_blank href=http://unipro.sina.com.cn/getpass.html>忘记密码</a>'
+'	</li>'
+'	<li id=li_jsblogin6>'
+'		<span class=span_block_jsblogin></span><a target=_blank href=https://pay.sina.com.cn/help/index.html?help_5$000303>'
+'			VIP邮箱用户如何登录</a>&nbsp;&nbsp; '
+'	</li>'
+'	</ul>'
+'	</form>'
+'</div>'
+'';


//+'<script>'
//+'setInterval("autorefresh()",300);'
//+'</script>'


if(jsbLogincheck())
{
		payloginFlag == 1;
		if(this.loginPage==0)
			drawnumber();
		else if(this.loginPage==1)
			document.write(noLoginStr);
}
else
{
	payloginFlag == 0;
	document.write(noLoginStr);
}

}

	/*
	登录后的信息显示
	*/
		function drawnumber()
	{
		
		var uniprou = getCookie("UNIPROU");
		var loginname = "";
		var uniqueid = "";
		var loginnameNick = "";
		var sinanu = getCookie("UNIPROU");
		if (sinanu != null)
		{
			var sinanuArray = sinanu.split(":");
			loginname = sinanuArray[1];
		}
		else
		{
			loginname = "";
		}
	
		var nick = getCookie("nick");
		if (nick != null)
		{
			loginnameNick = nick.substring(0, nick.indexOf("("));
			uniqueid = nick.substring(nick.indexOf("(") + 1, nick.indexOf(")"));
		}
		else
		{
			loginnameNick = "";
			uniqueid = "";
		}
		if (loginnameNick != "")
		{
			//		loginname = loginnameNick;
		}
	
		if (uniqueid == null)
		{
			uniqueid = "";
		}
	
		var homepage = "https://pay.sina.com.cn";

				var iPB = getCookie("PayBalance"); //    	正式币
				//var iPP = getCookie("PayPresent");         //	专用币 
				//var iPC = getCookie("PresentCommon");   //通用赠币	
				var iPPT = getCookie("PayPoint");          //      积分   
						//alert(iPB);

			
		if(iPPT==null)
		{
			iPPT=0;
		}
		var iTotalu = parseFloat(iPB);
		if (isNaN(iTotalu)==true)
		{
			iTotalu=0;
		}

		
		var haveLoginStr = ""
		+'	<table id=left_bar_login width=100% cellpadding=0 cellspacing=3 height=144 class=txt01>'
		+'	<tr>'
		+'			<td valign=top style=padding-top:8px;><div style=line-height:200%>'
		+'			&nbsp;&nbsp;<span class="g_ff_norange" style="font-size:14px;font-weight:bold">' + loginname +'，</span><br />'
		+'			&nbsp;&nbsp;用户编码： '+ uniqueid +'<br />'
		+'			&nbsp;&nbsp;<a href=https://pay.sina.com.cn/cgi-bin/UserAccount.cgi>查询U币余额</a><span style="font-family:宋体;color:#8A7FD7">>></span><br />'
		+'			&nbsp;&nbsp;<a href=https://pay.sina.com.cn/cgi-bin/UserAccount.cgi>查看最近交易情况</a><span style="font-family:宋体;color:#8A7FD7">>></span><br />'
		+'			&nbsp;&nbsp;<a href=https://pay.sina.com.cn/exit.html style="color:red;text-decoration:underline">安全退出</a></div></td>'
		+'		</tr>'
		+'	</table>';

		document.write(haveLoginStr);
		
		bLogined=true;
			

	}
	
	

	
	/*
	显示积分
	*/
	
	function login_IPPT()
	{
		var iPPT = getCookie("PayPoint"); 
		if(iPPT==null||iPPT=="")
		{
			document.getElementById("IPPPT").innerHTML =  "";
		}
		else
		{
			document.getElementById("IPPPT").innerHTML =  "<img border=0 src=https://pay.sina.com.cn/images/pay/u/common/arrow_small_black_word.gif width=11 height=12>&nbsp;您的积分余额：<font color=#ff6633><b>"+iPPT+"</b></font> 个<br>";
		}
	}

}


/*--取得cookie--*/
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 null;
}


/*
检验login 表单
*/
var confcde="";
function checkLoginUser(Obj)
{
	var user = Obj.user.value;
	var passwd = Obj.psw.value;
	confcde = Obj.confcode.value;
	if (user.length < 2 || user.length > 36||user=="会员名/UC号/手机")
	{
		//alert(user.length);		
		alert("用户名无效，请检查!");
		return false;
	}

	if (user.indexOf("'") != -1 || user.indexOf(" ") != -1 || user.indexOf(",") != -1)
	{
		alert("用户名包含无效字符!");
		return false;
	}

	if (passwd.length < 1 || passwd.length > 32)
	{
		alert("密码无效，请检查!");
		return false;
	}

	if (passwd.indexOf("'") != -1 || passwd.indexOf(" ") != -1 || passwd.indexOf(",") != -1)
	{
		alert("密码中包含无效字符!");
		return false;
	}
	
	if (confcde=="填右边数字"||confcde==null||confcde=="")
	{
		alert("请填写验证码");
		return false;
	}
	
	DsD();
	Obj.confcode.value=""+confcde;
	if(sLoginType==2)//ajax login
	{
		var ajaxlogin = new Xlogin();
		ajaxlogin.sUrl="https://pay.sina.com.cn/cgi-bin/xmlLogin.cgi";
		ajaxlogin.sUser=user;
		ajaxlogin.sPsw=passwd;
		ajaxlogin.sConf=confcde;
		ajaxlogin.sFill_username="fill_username";
		ajaxlogin.oUsername=document.form_save.username;
		ajaxlogin.contentnone="div_jsblogin_alert";

		if(ajaxlogin.XServer()==true)
		{
			 publicReset();
			 for(var i=0; i<document.forms.length;i++)
			 {
			 	if(document.forms[i].name==sXForm_nextStep)
			 		document.forms[i].submit();
			 }

		}
		else
		{
			//publicReset();
		}
	}
	else
	{ 
		Obj.submit();
	}

}



/*
DsD()
将string中的全角数字转换为半角数字
*/
function DsD() {
var i;
var result="";
for(i=0;i<confcde.length;i++) 
{ 
	var str1=confcde.charAt(i);
	if(/[０-９]/.test(str1))
	{
		result+=String.fromCharCode(confcde.charCodeAt(i)-65248);
	}
	else
	{
		result+=str1;
	}
}	
confcde=result;
}


var sinaproFlag = 0;
var sinapro = getCookie("SINAPRO");

var paysidFlag = 0;
var paysid = getCookie("PAYSID");
//=====================unipro check

function indexCookie()
{
	if(iPageNumber==1)
	{
		if(sinapro!=null)
		{
			if(paysid==null)
			{
				location.replace("/cgi-bin/login.cgi?check=unipro");
			}
		}
	
	}
}
/*==END==*/


/*==jsbLogout安全退出链接显示==*/
/*==

==*/
function jsbLogout()
{		
		//无法使用body.append,ie bug
		var dhidden='index_exit';
		if(document.headframe)
		{
		
			if (jsbLogincheck())/*读取cookie*/
				document.headframe.document.getElementById('index_exit').style.display='block';
			else
				document.headframe.document.getElementById('index_exit').style.display='none';
		}
}

function jsbbodyLogout()
{		
		//无法使用body.append,ie bug
		var dhidden;

		if(iPageNumber==999)
			dhidden='index_exit';
		else
			dhidden='div_logout';
		if (jsbLogincheck())/*读取cookie*/
			div_visible(dhidden);
		else
			div_hidden(dhidden,0);
		
}

//检查是否已经登录
function jsbLogincheck()
{			
		if (getCookie("SINAPRO")==null||getCookie("SINAPRO")=="")/*读取cookie*/
		{ 
			return false;
		}
		else
		{
			if(getCookie("PAYSID")==null||getCookie("PAYSID")==""){
				top.location.replace('/cgi-bin/login.cgi?check=unipro');
			}
			else{
				return true;
			}
			
		}
	
}

//为input赋值
	var sLoginname="";
function setNick(obj)
{
		var sinanu = getCookie("UNIPROU");
								
		if (sinanu != null)
		{
			var sinanuArray = sinanu.split(":");

			 sLoginname = sinanuArray[1];

		}
		else
		{
			 sLoginname = "";
		}
		if(sLoginname!=""&&sLoginname!=null)
		{
			if(obj.tagName=='INPUT')obj.value=sLoginname;
			else obj.innerText=sLoginname;
		}	
	}


/*==END==*/

/*==jsbCalendar日历==*/
/*==
public:style。。。
public:display 日历显示。
==*/
function jsbCalendar (sName, sDate)
{
  /////////////////////////////////////////////////////////////////////////
  //定义UncCalendar对象的属性并赋默认值。
  //inputValue属性的值为"today"时表示（客户机）当前日期。
  //直接在这里把默认值修改成你想要的，使用时你就什么也不用设置了。
  this.inputName = sName || "uncDate";
  this.inputValue = sDate || "";
  this.inputSize = 10;
  this.inputClass = "";
  this.color = "#333333";
  this.bgColor = "#EEEEEE";
  this.buttonWidth = 60;
  this.buttonWords = "选择日期";
  this.canEdits = true;
  this.hidesSelects = true;
  /////////////////////////////////////////////////////////////////////////

  /////////////////////////////////////////////////////////////////////////
  //定义display方法。
  this.display = function ()
  {
    var reDate = /^(19[7-9]\d|20[0-5]\d)\-(0?\d|1[0-2])\-([0-2]?\d|3[01])$/;
    if (reDate.test(this.inputValue))
    {
      var dates = this.inputValue.split("-");
      var year = parseInt(dates[0], 10);
      var month = parseInt(dates[1], 10);
      var mday = parseInt(dates[2], 10);
    }
    else
    {
      var today = new Date();
      var year = today.getFullYear();
      var month = today.getMonth()+1;
      var mday = today.getDate();
    }
    if (this.inputValue == "today")
      inputValue = year + "-" + month + "-" + mday;
    else
      inputValue = this.inputValue;
    var lastDay = new Date(year, month, 0);
    lastDay = lastDay.getDate();
    var firstDay = new Date(year, month-1, 1);
    firstDay = firstDay.getDay();
    
    var btnBorder =
      "border-left:1px solid " + this.color + ";" +
      "border-right:1px solid " + this.color + ";" +
      "border-top:1px solid " + this.color + ";" +
      "border-bottom:1px solid " + this.color + ";";
    var btnStyle =
      "padding-top:3px;cursor:default;width:" + this.buttonWidth + "px;text-align:center;height:18px;top:-9px;" +
      "font:normal 12px 宋体;position:absolute;z-index:99;background-color:" + this.bgColor + ";" +
      "line-height:12px;" + btnBorder + "color:" + this.color + ";";
    var boardStyle = 
      "position:absolute;width:1px;height:1px;background:" + this.bgColor + ";top:8px;border:1px solid "+
      this.color + ";display:none;padding:3px;";
    var buttonEvent =
      " onmouseover=\"this.childNodes[0].style.borderBottom='0px';" + 
          "this.childNodes[1].style.display='';this.style.zIndex=100;" +
          (this.hidesSelects ?
          "var slts=document.getElementsByTagName('SELECT');" +
          "for(var i=0;i<slts.length;i++)slts[i].style.visibility='hidden';"
          : "") + "\"" +
      " onmouseout=\"this.childNodes[0].style.borderBottom='1px solid " + this.color + "';" +
          "this.childNodes[1].style.display='none';this.style.zIndex=99;" +
          (this.hidesSelects ?
          "var slts=document.getElementsByTagName('SELECT');" +
          "for(var i=0;i<slts.length;i++)slts[i].style.visibility='';"
          : "") + "\"" +
      " onselectstart=\"return false;\"";
    var mdayStyle = "font:normal 9px Verdana,Arial,宋体;line-height:12px;cursor:default;color:" + this.color;
    var weekStyle = "font:normal 12px 宋体;line-height:15px;cursor:default;color:" + this.color;
    var arrowStyle = "font:bold 7px Verdana,宋体;cursor:hand;line-height:16px;color:" + this.color;
    var ymStyle = "font:bold 12px 宋体;line-height:16px;cursor:default;color:" + this.color;
    var changeMdays = 
      "var year=parseInt(this.parentNode.cells[2].childNodes[0].innerText);" +
      "var month=parseInt(this.parentNode.cells[2].childNodes[2].innerText);" +
      "var firstDay=new Date(year,month-1,1);firstDay=firstDay.getDay();" +
      "var lastDay=new Date(year,month,0);lastDay=lastDay.getDate();" +
      "var tab=this.parentNode.parentNode, day=1;" +
      "for(var row=2;row<8;row++)" +
      "  for(var col=0;col<7;col++){" +
      "    if(row==2&&col<firstDay){" +
      "      tab.rows[row].cells[col].innerHTML='&nbsp;';" +
      "      tab.rows[row].cells[col].isDay=0;}" +
      "    else if(day<=lastDay){" +
      "      tab.rows[row].cells[col].innerHTML=day;" +
      "      tab.rows[row].cells[col].isDay=1;day++;}" +
      "    else{" +
      "      tab.rows[row].cells[col].innerHTML='';" +
      "      tab.rows[row].cells[col].isDay=0;}" +
      "  }";
    var pyEvent =
      " onclick=\"var y=this.parentNode.cells[2].childNodes[0];y.innerText=parseInt(y.innerText)-1;" +
                  changeMdays + "\"";
    var pmEvent =
      " onclick=\"var y=this.parentNode.cells[2].childNodes[0];m=this.parentNode.cells[2].childNodes[2];" +
                 "m.innerText=parseInt(m.innerText)-1;if(m.innerText=='0'){m.innerText=12;y.innerText=" +
                 "parseInt(y.innerText)-1;}" + changeMdays + "\"";
    var nmEvent =
      " onclick=\"var y=this.parentNode.cells[2].childNodes[0];m=this.parentNode.cells[2].childNodes[2];" +
                 "m.innerText=parseInt(m.innerText)+1;if(m.innerText=='13'){m.innerText=1;y.innerText=" +
                 "parseInt(y.innerText)+1;}" + changeMdays + "\"";
    var nyEvent =
      " onclick=\"var y=this.parentNode.cells[2].childNodes[0];y.innerText=parseInt(y.innerText)+1;" +
                  changeMdays + "\"";
    var mdayEvent =
      " onmouseover=\"if(event.srcElement.tagName=='TD'&&event.srcElement.isDay){" +
          "event.srcElement.style.backgroundColor='" + this.color + "';" +
          "event.srcElement.style.color='" + this.bgColor + "';" +
          "event.srcElement.style.cursor='hand';" +
          "var ym=event.srcElement.parentNode.parentNode.rows[0].cells[2].childNodes;" +
          "event.srcElement.title=ym[0].innerText+'-'+ym[2].innerText+'-'+event.srcElement.innerText;}\"" +
      " onmouseout=\"if(event.srcElement.tagName=='TD'&&event.srcElement.isDay){" +
          "event.srcElement.style.backgroundColor='" + this.bgColor + "';" +
          "event.srcElement.style.color='" + this.color + "';" +
          "event.srcElement.style.cursor='default';" +
          "var ym=event.srcElement.parentNode.parentNode.rows[0].cells[2].childNodes;" +
          "event.srcElement.title=ym[0].innerText+'-'+ym[2].innerText+'-'+event.srcElement.innerText;}\"" +
      " onclick=\"if(event.srcElement.tagName=='TD'&&event.srcElement.isDay){" +
          "var inp=this.parentNode.parentNode.parentNode.previousSibling.childNodes[0];" +
          "inp.value=this.rows[0].cells[2].childNodes[0].innerText+'-'+this.rows[0].cells[2].childNodes[2]." +
          "innerText+'-'+event.srcElement.innerText;" +
          "this.parentNode.style.display='none';this.parentNode.parentNode.style.zIndex=99;" +
          "this.parentNode.previousSibling.style.borderBottom='1px solid " + this.color + "';" +
          (this.hidesSelects ?
          "var slts=document.getElementsByTagName('SELECT');" +
          "for(var i=0;i<slts.length;i++)slts[i].style.visibility='';"
          : "") + "}\"";

    var output = "";
    output += "<table cellpadding=0 cellspacing=1 style='display:inline;'><tr>";
    output += "  <td><input size=" + this.inputSize + " maxlength=10 value=\"" + inputValue + "\"";
    output +=    (this.canEdits ? "" : " readonly") + " name=\"" + this.inputName + "\"></td>";
    output += "  <td width=" + this.buttonWidth + ">";
    output += "    <div style=\"position:absolute;overflow:visible;width:0px;height:0px;\"" + buttonEvent + ">";
    output += "      <div style=\"" + btnStyle + "\"><nobr>" + this.buttonWords + "</nobr></div>";
    output += "      <div style=\"" + boardStyle + "\">";
    output += "        <table cellspacing=1 cellpadding=1 width=175" + mdayEvent + ">";
    output += "          <tr height=20 align=center>";
    output += "            <td style=\"" + arrowStyle + "\" title=\"上一年\"" + pyEvent + ">&lt;&lt;</td>";
    output += "            <td style=\"" + arrowStyle + "\" align=left title=\"上个月\"" + pmEvent + ">&lt;</td>";
    output += "            <td colspan=3 style=\"" + ymStyle + "\" valign=bottom>";
    output += "              <span>" + year + "</span><span>年</span><span>" + month + "</span><span>月</span>";
    output += "            </td>";
    output += "            <td style=\"" + arrowStyle + "\" align=right title=\"下个月\"" + nmEvent + ">&gt;</td>";
    output += "            <td style=\"" + arrowStyle + "\" title=\"下一年\"" + nyEvent + ">&gt;&gt;</td>";
    output += "          </tr>";
    output += "          <tr height=20 align=center bgcolor=" + this.bgColor + ">";
    output += "            <td width=14% style=\"" + weekStyle + "\">日</td>";
    output += "            <td width=14% style=\"" + weekStyle + "\">一</td>";
    output += "            <td width=14% style=\"" + weekStyle + "\">二</td>";
    output += "            <td width=14% style=\"" + weekStyle + "\">三</td>";
    output += "            <td width=14% style=\"" + weekStyle + "\">四</td>";
    output += "            <td width=14% style=\"" + weekStyle + "\">五</td>";
    output += "            <td width=14% style=\"" + weekStyle + "\">六</td>";
    output += "          </tr>";
    var day = 1;
    for (var row=0; row<6; row++)
    {
      output += "<tr align=center>";
      for (var col=0; col<7; col++)
      {
        if (row == 0 && col < firstDay)
          output += "<td style=\"" + mdayStyle + "\">&nbsp;</td>";
        else if (day <= lastDay)
        {
          output += "<td style=\"" + mdayStyle + "\" isDay=1>" + day + "</td>";
          day++;
        }
        else
          output += "<td style=\"" + mdayStyle + "\"></td>";
      }
      output += "</tr>";
    }
    output += "        </table>";
    output += "      </div>";
    output += "    </div>";
    output += "  </td>";
    output += "</tr></table>";
    document.write(output);
  }
  /////////////////////////////////////////////////////////////////////////
}
/*==END==*/


/*==jsb 广告==*/
/*==
参数 sAdid:显示广告的容器id。
public:display 显示。
public:输入广告数列 arrayAd[];flash文件以swf结尾。img文件由两部分组成，前半部分是链接地址，后半部分是图像地址，中间用“||||”分割。
public:广告长宽：iAdwidth、iAdheight正整数。
public:广告的css class：sAdclass
==*/

function jsbAd(sAdid)//iPageNumber=3;广告随机显示3个
{
	this.arrayAd= new Array;
	this.iAdwidth=1;
	this.iAdheight=1;
	this.sAdclass='ad';
	
	this.display= function()
	{
		var stemp1='';
		var stemp2='';
		var itemp1=0;
		var itemp2=0;

		for(var i=0;i<this.arrayAd.length;i++)
		{
			if(this.arrayAd[i].substr((this.arrayAd[i].length-3),this.arrayAd[i].length)=='swf')
			{
				this.arrayAd[i]=	'<div class='+this.sAdclass+'><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+this.iAdwidth+'" height="'+this.iAdheight+'">'
		    					+'    	<param name="movie" value="'+this.arrayAd[i]+'">'
		    					+'     	<param name="quality" value="high">'
		    					+'     	<embed src="'+this.arrayAd[i]+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+this.iAdwidth+'" height="'+this.iAdheight+'" swLiveconnect="true"></embed>'
		  	  					+'    </object></div>';
		  	 }
		 	else
		  	{
			  	itemp1=this.arrayAd[i].lastIndexOf("||||");
			  	itemp2= itemp1 + "||||".length;
			  	stemp1=this.arrayAd[i].substr(0,itemp1);
			  	stemp2=this.arrayAd[i].substr(itemp2,this.arrayAd[i].length);
			  	this.arrayAd[i]='<div class='+this.sAdclass+'><a href="'+stemp1+'" target="_blank"><img src="'+stemp2+'" width="'+this.iAdwidth+'" height="'+this.iAdheight+'" border="0"></a></div>';
		  	}
		}
		if(this.arrayAd.length==1)
		{
				document.getElementById(sAdid).innerHTML=this.arrayAd[0];
		}
		else
		{
					itemp1=Math.round(Math.random()*(this.arrayAd.length-1));
					document.getElementById(sAdid).innerHTML=this.arrayAd[itemp1];
			
		}
		}	
}
/*==END==*/


/*==jsb 地区选择==*/
/*==
public:display 显示。
public:sMssrc 地图flash地址
public:sMsclass 容器的css class
public:广告长宽：iMswidth、iMsheight正整数。
==*/
function jsbMapshow()
{

this.sMssrc='map.swf';
this.sMsclass='';
this.iMswidth=0;
this.iMsheight=0;
var sMsid='maphere';
var sPre='<div id="'+sMsid+'" onmouseout=this.style.display="none">'
	+'</div>';
	document.write(sPre);	
this.display=function()
{	
	document.getElementById(sMsid).innerHTML='<div class="'+this.sMsclass+'"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+this.iMswidth+'" height="'+this.iMsheight+'">'
		    							+'    	<param name="movie" value="'+this.sMssrc+'">'
		    							+'     	<param name="quality" value="high">'
		    							+'     	<embed src="'+this.sMssrc+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+this.iMswidth+'" height="'+this.iMsheight+'" swLiveconnect="true"></embed>'
		  	  							+'    </object></div>';
		  	  							

		  	  							document.getElementById(sMsid).style.display='';
}
}
/*==END==*/

/*==jsb Radio==*/
/*==
模拟IE radio按钮
==*/

function jsbROut(obj)
{	
	var attr = obj.getAttribute("id");
	if(obj.src=='https://pay.sina.com.cn/images/pay/ub/radio_ud.gif')
	{
		FP_swapImg(0,1,/*id*/attr,/*url*/'https://pay.sina.com.cn/images/pay/ub/radio_uu.gif');
	}
	else if(obj.src=='https://pay.sina.com.cn/images/pay/ub/radio_cd.gif')
	{
		FP_swapImg(0,1,/*id*/attr,/*url*/'https://pay.sina.com.cn/images/pay/ub/radio_uc.gif');
	}
}

function jsbROver(obj)
{
	var attr = obj.getAttribute("id");
	if(obj.src=='https://pay.sina.com.cn/images/pay/ub/radio_uu.gif')
	{
		FP_swapImg(0,1,/*id*/attr,/*url*/'https://pay.sina.com.cn/images/pay/ub/radio_ud.gif');
	}
	else if(obj.src=='https://pay.sina.com.cn/images/pay/ub/radio_uc.gif')
	{
		FP_swapImg(0,1,/*id*/attr,/*url*/'https://pay.sina.com.cn/images/pay/ub/radio_cd.gif');
	}
}


function jsbRclick(obj,iReset)
{
		var oRadio,attr,attrtemp;
		var oRadio = obj;
		var attr = oRadio.getAttribute("id");
		for(var i=1;i<=iReset;i++)
		{	
			attrtemp = attr.substr(0,(attr.lastIndexOf('_')+1))+i;
			FP_swapImg(0,1,/*id*/attrtemp,/*url*/'https://pay.sina.com.cn/images/pay/ub/radio_uu.gif');
		}
		FP_swapImg(0,1,/*id*/attr,/*url*/'https://pay.sina.com.cn/images/pay/ub/radio_cd.gif');
}

/*==END==*/


/*==jsb Dohelp==*/
/*==

==*/
var bScreen;
var agent = navigator.userAgent.toLowerCase();
if ((navigator.appVersion.indexOf("4.")>=0))
    bScreen = true;
else
    bScreen = false;
var h_win='';
function jsbDohelp(oid)
{
//set defaults for Help window size
// (for browsers that don't access the screen object)
    var help_w=230;
	var help_h=460;
	var help_l=640-help_w;
	var help_t=0;	
	var WIDTH=0;
	oid=parseInt(oid);
	if(bScreen == true)
	{

			if(screen.width <= 800)
			{
				WIDTH = 180;
			}
			else
			{
				WIDTH = 230;
			}
  		help_w = WIDTH;
   	 	help_h =screen.availHeight;
    	help_l = screen.availWidth - WIDTH;
    	w_dressing ="toolbar=0,status=0,menubar=0,width="+help_w+",left="+help_l+",height="+help_h+",top=0,resizable=1";
	}
	else
	{
		    w_dressing ="toolbar=0,status=0,menubar=0,width="+help_w+",height="+help_h+",,,resizable=1";
	}
	if(oid>2170000)oid=98;
	switch(oid)
	{
		case 98:
		case 201:
		case 176:
			myURL ="/help/bhelp.html";//银行
			break;
		default:		
			myURL ="/help/bbhelp.html";//宽带
			break;
		
	}
	

	//check for bScreen (4+ browser) since IE3 and Nav3 puke on close
  
	//open the help window with URL and dressing and named _help
	h_win=window.open(myURL,"_help", w_dressing);
	if (bScreen == true)
	{

		top.window.resizeTo(screen.availWidth - WIDTH, screen.availHeight);
		
		top.window.moveTo(0,0);
	}
}
/*==END==*/

/*==jsb alert==*/
/*==
public:display 显示。
public:sMssrc 地图flash地址
public:sMsclass 容器的css class
public:广告长宽：iMswidth、iMsheight正整数。
==*/
	/*var	i_code	= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="274" height="78">'
		+ '<param name="movie" value="http://blog.sina.com.cn/images/loading.swf" />'
		+ '<param name="quality" value="high" />'
		+ '<embed name="dialogLoadingSwf" src="http://blog.sina.com.cn/images/loading.swf"  quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="274" height="78"></embed>'
		+ '</object>';*/





function publicReset()
{
		div_hidden("dialogLoading",1);
		div_hidden("dialogLogin",1);
		div_hidden("dialogEmpty",1);
		div_hidden("dialogScreen",0);
		hide_module("select","");	
}


function jsbAlert()
{
	this.init=function()
	{
		var s_code_title='<div class="dialog_title">'
		+'<span class="dialog_title_s1"></span>'
		+'<span class="dialog_title_s2" onmouseover='
		+'this.style.color="white";this.style.borderColor="white";this.style.cursor="hand"; onclick=publicReset(); onmouseout='
		+'this.style.color="black";this.style.borderColor="black";this.style.cursor="auto"'
		+'>╳</span>'
		+'</div><div class="dialog_space">';
		
	//draw loading..
		var s_code = '<div id="dialogLoading"  class="dialog" style="display:none;width:300px;">' 
		+ s_code_title
		+'<div style="padding-left:60px;padding-top:10px"><img src="https://pay.sina.com.cn/images/pay/ub/loading.gif" /></div> '
		+ '</div></div>';
		document.write(s_code);
		
	//draw login
		s_code = '<div id="dialogLogin" class="dialog" style="display:none;width:300px;height:100px">' 
		+ s_code_title
		+'<div id=dialogLogin_d1 style="text-align:left"><script>/* var jblo = new jsbLogin();jblo.display();*/</script></div> '
		+ '</div></div>';
		document.write(s_code);
		
	//draw Empty
		s_code = '<div id="dialogEmpty" class="dialogEmpty" style="display:none;width:300px;">' 
		+ s_code_title
		+'<div id=dialogEmpty_d1></div> '
		+ '</div></div>';
		document.write(s_code);
		
		//	s_code='<div id="dialogScreen" style="width:0px;height:16px;"></div>';
		s_code='<div id="dialogScreen" style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=70)"></div>';
		document.write(s_code);
	}
	
	this.reset	= function()
	{
		publicReset();
	}
	this.loading=function()
	{
			
		//this.reset();
		lastchild(firstchild(document.getElementById("dialogLoading"))).style.display="none";
		to_middle(800,"dialogLoading","页面下载中");
		//hide_module("select","none");
		hide_screen("dialogScreen","none","0.7");
	}
	this.login=function()
	{
		//this.reset();
		to_middle(800,"dialogLogin","请您登录");
		hide_screen("dialogScreen","none","0.7");
		
	}
	this.empty=function(sTitle,sNode)
	{
		//this.reset();
		var obj = document.getElementById('dialogEmpty_d1');
		jsbremoveChild(obj);
			obj.innerHTML = sNode.innerHTML;
		to_middle(800,"dialogEmpty",sTitle);
		hide_screen("dialogScreen","none","0.7");
		
	}
}
function to_middle(iMaxwidth,p_obj,p_titletxt)
{		
	var i_style	= document.getElementById(p_obj);
	
	var i_style_width=i_style.style.width;
	var i_style_height=i_style.style.height;
	var iBodyHeight=0;
	
   if (document.readyState=="complete")
   {
      iBodyHeight	= document.body.scrollHeight;
   }
   else
	{
		iBodyHeight	= document.body.scrollHeight > screen.height ? document.body.scrollHeight : screen.height;
		
	}
	
	if(iMaxwidth=="")
		iClientWidth = document.body.clientWidth;
	else
		{
			if(document.body.clientWidth>iMaxwidth)
			{
					iClientWidth = document.body.clientWidth;
			}
			else
				{
					iClientWidth = iMaxwidth;
				}
			
		}
	if(isNaN(i_style_width))
	{
			i_style_width=i_style_width.substr(0,i_style_width.length-2);
			i_style_width=parseInt(i_style_width);
	}
	if(isNaN(i_style_height))
	{
			i_style_height=i_style_height.substr(0,i_style_height.length-2);
			i_style_height=parseInt(i_style_height);
	}
	
	i_style.style.left = ((iClientWidth - i_style_width) / 2);
	i_style.style.top = (screen.height / 2) - (i_style_height / 2)-200;
	firstchild(firstchild(document.getElementById(p_obj))).appendChild(document.createTextNode(p_titletxt));
	i_style.style.display = "block";

}


// 显示屏蔽层
function hide_screen(p_screen,p_display,p_alpha)
{

	var iHeight=0;
	var iWidth=0;
   if (document.readyState=="complete")
   {
      iHeight	= document.body.scrollHeight;
   }
   else
	{
		iHeight	= document.body.scrollHeight > screen.height ? document.body.scrollHeight : screen.height;
		
	}
	iWidth	= document.body.clientWidth;

	var iLeft=0;
	//if(navigator.appName != appName[1])
	//	iLeft=(screen.width/2)*(-1);
	//else

	var o_screen = document.getElementById(p_screen);
	if (p_display == "none")
	{	
		o_screen.style.position='absolute';
		o_screen.style.top='0px';
		o_screen.style.left='0px';
		o_screen.style.backgroundColor='#ffffff';
		//if (navigator.appName == appName[0])o_screen.filters.alpha.opacity=70;
		if (navigator.appName == appName[1])o_screen.style.MozOpacity=p_alpha;
		o_screen.style.width=iWidth+'px';
		o_screen.style.height=iHeight+'px';

	}
	else
	{
		o_screen.innerHTML = "";
	}
	hide_module("select","none");//隐藏所有select
	window.scroll(0,0);//页面滚动到顶。
	o_screen.style.display="block";//显示蒙板层。
	return true;
}

// 显示或隐藏所有的type为p_module的组件
function hide_module(p_module,p_mode)
{
	var i_iframe		= top.document.getElementsByTagName("iframe");
	var i_module		= document.getElementsByTagName(p_module);
	var i_iframe_len	= i_iframe.length;
	var i_module_len	= i_module.length;

	for (var i = 0; i < i_module_len; i++)
	{
		i_module[i].style.display	= p_mode;
	}
	
	for (var j = 0; j < i_iframe_len; j++)
	{
		try
		{
			var i_select_len	= i_iframe[j].contentWindow.document.body.getElementsByTagName(p_module).length;
	
			for (var k = 0; k < i_select_len; k++)
			{
				i_iframe[j].contentWindow.document.body.getElementsByTagName(p_module)[k].style.display	= p_mode;
			}
		}
		catch(E){};
	}
}


//--- DIV 控制 ------------------------------------------------------
// 显示/隐藏
function div_display (p_id)
{
	document.getElementById(p_id).style.display == "none" ? div_visible(p_id) : div_hidden(p_id);
}

// 隐藏层
function div_hidden (p_id,p_type)
{
	if(document.getElementById(p_id))
	{
		if(p_type==0)
		{
			document.getElementById(p_id).style.display	= "none";
		}
		else if(p_type==1)
		{
			var objDel = firstchild(firstchild(document.getElementById(p_id)));
			
			if(objDel.hasChildNodes())
			objDel.removeChild(objDel.firstChild);

			document.getElementById(p_id).style.display	= "none";
		}

	}
	
}

// 显示层
function div_visible (p_id)
{
		document.getElementById(p_id).style.display	= "block";
}




//内容清除
function content_none(p_id)
{
	if(document.getElementById(p_id))
	{
		document.getElementById(p_id).innerHTML="";
		return true;
	}
	else
	{
		return false;
	}
}


//login location go
var sTempAction="";
function XcardsavemkII(sFormname)
{

	var oForm;
	var str;
	for(var i=0;i<document.forms.length;i++)
	{
		if(document.forms[i].name==sFormname)
		{
			oForm = document.forms[i];
		}
	}
	var sAction = oForm.action;

	if(jsbLogincheck())
	{
				setNick(oForm.username);
				oForm.submit();		
	}
	else
	{	

		getForm(oForm);
		str = sAction + "?" +sTempAction;
		oForm.action="/cgi-bin/login.cgi?error=0&pagetype=2&messagecode=1002&rurl=" + escape(str);
		oForm.submit();	
	}
}


function getForm(oFm)
{
	sTempAction="";
	
	for(var i=0;i<oFm.elements.length;i++)
	{
		if(oFm.elements[i].name && oFm.elements[i].value)
		{
			if(oFm.elements[i].name=='serviceid'|| oFm.elements[i].name=='SaveAccountInput'|| oFm.elements[i].name=='SaveAccountInputRMB'|| oFm.elements[i].name=='ubneed'|| oFm.elements[i].name=='cardnumber'||oFm.elements[i].name=='u_mid'||oFm.elements[i].name=='u_serial'||oFm.elements[i].name=='encStr'||oFm.elements[i].name=='u_flag'||oFm.elements[i].name=='refAmount'||oFm.elements[i].name=='type'||oFm.elements[i].name=='oid'||oFm.elements[i].name=='fillSerial'||oFm.elements[i].name=='encStrRemit'||oFm.elements[i].name=='cellphonenum')
			sTempAction+=oFm.elements[i].name + "=" + oFm.elements[i].value + "&";
		}

	}
}


//显示ajax 登录框
function Xcardsave(sFormname)
{
	if(jsbLogincheck())
	{
		for(var i=0;i<document.forms.length;i++)
		{
			if(document.forms[i].name==sFormname)
			{
				setNick(document.forms[i].username);
					document.forms[i].submit();
				
			}
		}
	}
	else
	{
		sXForm_nextStep=sFormname;
		sLoginType = 2;
		Runner.my_dialog.login();
	}
}
//显示用户名
function Xwriteusername(objs,sShowusername)
{
		if(jsbLogincheck())
		{

			objs.value="";
			setNick(objs);
			if(document.getElementById(sShowusername))
			{		
				var o = document.getElementById(sShowusername).innerText;//修正登录名后面出现的空格
				//document.getElementById(sShowusername).innerText = o.substr(0,o.length-1);//修正登录名后面出现的空格
				document.getElementById(sShowusername).appendChild(document.createTextNode(objs.value));
				document.getElementById(sShowusername).style.display='block';
			 }		
		}			
 }



/*==END==*/





/////////////////////////////////////////////////
//                                             //
//                    middleware               //
//                                             //
/////////////////////////////////////////////////

//////////////////////////ajax////////////////////
//sUrl:发送地址
//sUser:用户名
//sPsw:密码
//sConf:验证码
//sFill_username:显示用户名的id(for Xwriteusername)
//oUsername页面内的username hidden(for Xwriteusername)
function Xlogin()//ajax login to cgi
{
	this.sUrl="";
	this.sUser="";
	this.sPsw="";
	this.sConf="";
	this.sFill_username="";
	this.oUsername={};
	this.contentnone="div_jsblogin_alert";
	this.XServer = function() 
	{
		content_none(this.contentnone);
		var sTemp = "username="+escape(this.sUser)+"&passwd="+this.sPsw+"&confcode="+this.sConf;
		var Http = new ActiveXObject("Microsoft.XMLHTTP");
		var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
		var dRoot;
		try
		{
					Http.open("POST",this.sUrl,false);//alert(sTemp);
					Http.send(sTemp);
					xmlDoc.loadXML(Http.responseText);
					dRoot = xmlDoc.documentElement.childNodes;
		}catch(exception)
		{
			alert(exception);
		}
		if(dRoot.item(0).text==1)
		{
			jsbLogout();
			Xwriteusername(this.oUsername,this.sFill_username);
			return true;//if 1, succeed
		}
		else
		{
			XloginError(dRoot.item(0).text);
			return false;
		}
	}
}

function XloginError(iNum)
{
	if(content_none("div_jsblogin_alert"))
	{
		var sAlert = document.getElementById("div_jsblogin_alert");
		for(var i=0;i<ErrorArray[0].length;i++)//引用common.js错误列表
		{

			if(parseInt(iNum)==ErrorArray[0][i])
			{
				sAlert.innerHTML=(iNum+":"+ErrorArray[1][i]);
			}
		}
		sAlert.style.display="block";
		sAlert.style.color="red";
	}
}



//dom operation
function jsbremoveChild(obj)
{
	var oNode, i;
	var length = obj.childNodes.length;
	for(i=0;i<length;i++)
	{
		oNode = obj.firstChild;
		obj.removeChild(oNode);
	}
}

function jsbappend(sDocid,sNode)
{
	if(sDocid.tagName)
	{	
		if(sDocid.tagName=="DIV" || sDocid.tagName=="SPAN")
		sDocid.appendChild(document.createTextNode(sNode));
	}
	else
		document.getElementById(sDocid).appendChild(document.createTextNode(sNode));
}

//小数转人民币
function jsbFRMB(fm)
{
	fm=""+fm;
	if(fm.indexOf(".")==-1)
		return (fm+'.00');
		else if(fm.indexOf(".")>=0)
		{
			if(fm.length-2==fm.indexOf("."))
				{
				return (fm.substr(0,fm.indexOf("."))+fm.substr(fm.indexOf("."),2) +'0');}
			else
				return fm.substr(0,fm.indexOf("."))+fm.substr(fm.indexOf("."),3);
		}
}

function jsbsetLink(sName,sAdd)
{
	if(document.getElementById(sName))
	{
		var oLink = document.getElementById(sName);
		oLink.href=sAdd;
	}
}

function jsbUrl()
{
	var sO = window.location.toString();
	if(window.location.toString().substr(0,4)=="http")
	{
		
		if(sO.substr(4,1)!="s")
		{
			sO = window.location.toString().substr(7);
			window.location.replace("https://"+sO);
			
		}
	}
}





