/*
	公共的变量
*/
	/** 全球通 */
	var _GOTONE = 1;
	/** 神州行 */
	var _EASYOWN = 2;
	/** 动感地带 */
	var _MZONE = 3;
	/** 大众卡 */
	var _EASYOWN_DZ = 5;
	/**是否是办理类*/
	var _isTransactBiz = false;
	/**用户手机号码*/
	var _userMobileNumber = "";
	
	//b2m随机验证码
	var s_rsms_code="";
/**
	功能：业务办理失败后的调用的方法
	m_id：消息提示的id
	f_id：业务表单的id
	b_id：功能按钮的id
	c_id：推荐信息的id
	msg：消息提示
*/
function show_fail(m_id,f_id,b_id,c_id,msg){
	var _show_faile_t = function(){
		document.getElementById(f_id).style.display = "none";
		document.getElementById('biz_op_139').style.display = "none";
		//隐藏b2m随机短信
		hide_b2m_sms();
		re_write_biz_div(b_id,'button');
		document.getElementById(b_id).style.display = "";
		show_message(m_id,msg,false);
		query_common_navigation(c_id);
	};
	setTimeout(_show_faile_t,300);
	return true;
}
/**
	功能：业务办理成功后的调用的方法
	m_id：消息提示的id
	f_id：业务表单的id
	b_id：功能按钮的id
	c_id：推荐信息的id
	msg：消息提示
*/
function show_success(m_id,f_id,b_id,c_id,msg){
	
	document.getElementById(f_id).style.display = "none";
	re_write_biz_div(b_id,'button');
	document.getElementById(b_id).style.display = "";
	document.getElementById('biz_op_139').style.display = "none";
	//隐藏b2m随机短信
	hide_b2m_sms();
	show_message(m_id,msg,true);
	query_common_navigation(c_id);
}
/*
	功能：展示业务办理层
	t_id：业务标题id
	c_id：业务办理层的id
	b_id：功能按钮id
	t：业务标题（中文）
	c：业务办理层的内容（html代码窜）
	b：功能按钮（html代码窜）
*/
function show_operation(t_id,c_id,b_id,t,c,b){
	var tdiv = document.getElementById(t_id);
	var cdiv = document.getElementById(c_id);
	var bdiv = document.getElementById(b_id);
	
	tdiv.innerHTML = t;
	cdiv.innerHTML = c;
	bdiv.innerHTML = b;
}
/*
	功能：弹出框效果函数
	t_id：弹出div层的标题id
	c_id：弹出div层的内容id
	b_id：弹出div层的按钮id
	title：弹出div层的标题（html代码窜,包括关闭按钮）
	content：弹出div层的内容（html代码窜）
	button：弹出div层的按钮（html代码窜）
*/
function open_window(t_id,c_id,b_id,title,content,button){
	document.getElementById(t_id).innerHTML = title;
	document.getElementById(c_id).innerHTML = content;
	document.getElementById(b_id).innerHTML = button
	
	showorhide('pop_open_window','pop_op');
}//end function
/*
	功能：展示业务办理的提示信息
	d_div：展示提示信息的id。
	msg：提示信息
	b_s：是否成功
	
*/
function show_message(d_id,msg,b_s){
	var div = document.getElementById(d_id);
	var c = "";
	var i = "";
	var t = ""
	if(b_s){
		i = '/v2008/images/public/icon_right.gif';
		t = 'green';
	}else{
		i = '/v2008/images/public/icon_wrong.gif';
		t = 'red_01';
	}
	c += "<table>";
	c += "<tr>";
	c += "<td class='bFtd_02' valign='top'><img src='"+i+"' /></td><td> <b class='"+t+"'>"+msg+"</b> </td>";
	c += "</tr>";
	c += "</table>";
	
	div.innerHTML = c;
}
/*
	功能：营业厅业务类型查询
	t_id：业务类型div的id
	f_id：相关功能div的id
	r_id：温馨提醒div的id
	o_id：业务操作div的id
	c_id：具体内容div的id
	is_a：是否异步
	brand：品牌
	is_index：是否是营业厅首页
	is_login：是否需要登录
*/
var _a_biz_type;	//业务类型数组 
var _o_biz_id = null;//业务操作div的id
var _s_biz_suf = 'biz_type_';//业务类型标签id前缀
var _b_is_login = true;	//是否需要登录

function query_bizType(t_id,f_id,r_id,o_id,c_id,is_a,is_index,brand,bizCode,is_login){
	
	//暂时隐藏
	//document.getElementById("tabMenu").style.display = "none";
	
	if (arguments.length == 10) {
		_b_is_login = is_login;
	}
	
	//将流程隐藏掉
	var o_f = document.getElementById('biz_op_flow');
	if(o_f != null){
		o_f.style.display = "none";
	}
	//获得用户选择的品牌
	var brand = GetCookie('BizBrand');
	if(brand == null ){brand = _GOTONE;}
	
	var url = "/services/biztype?bizCode="+bizCode+"&bizBrand="+brand;
	var isSuccess = false;
	var handleSuccess = function(response){
		//after_response();
		isSuccess = response.result;
		_a_biz_type = response.bizType;
		//alert(_a_biz_type.length);
		show_bizType(t_id,c_id,_a_biz_type,is_index,0);
		//alert(!is_index); 
		//b2m随机短信显示
		query_is_b2m_biz(bizCode,'b2m');
		display_b2m_sms();
		query_bizInfo(t_id,f_id,r_id,o_id,c_id,is_a,is_index,brand,bizCode,response);
	};
	var handleFail = function(response){
		alert("网厅基本信息加载失败，请重试。");
		//location.reload();
	};
	//请求参数
	var handlePostData = {};
	
	before_request(0,'正在加载网厅基本信息，请稍候。');
	//请求
	common_send_ajax(url,handlePostData,is_a,handleSuccess,handleFail);
	return isSuccess;
}//end function
/*
	功能：展示业务类型标签
	t_id：业务类型div的id
	c_id：具体内容div的id
	a_type：业务类型数组
	is_index：是否是营业厅首页
	p：起始的业务类型
*/
function show_bizType(t_id,c_id,a_type,is_index,p){
	var tdiv = document.getElementById(t_id);
	var size = a_type.length;
	var content = "";
	
	for(var i=0;i<size;i++){
		var t = a_type[i];
		var n = t.name;
		var c = "";
		var a = "";
		if(i == p){
			c = 'on';
		}
		var id = _s_biz_suf+i;
		if(is_index){a = "onclick=\"check_bizType('"+_o_biz_id+"','"+c_id+"',"+i+",'"+id+"')\"";}
		else
		{	
			if(i != p)
				a = "onclick=\"check_bizType('"+_o_biz_id+"','"+c_id+"',"+i+",'"+id+"')\"";
			else
				a = "onclick=\"check_bizOperation('"+c_id+"','"+_o_biz_id+"','"+id+"')\"";
		}
		content += "<li id='"+id+"' class='"+c+"' "+a+"> <span>"+n+"</span> </li>";
	}//end for
	//alert('展示业务类型: '+content);
	tdiv.innerHTML = content;
	
}//end function

/*
	功能：展示业务类型的功能
	c_id：具体内容div的id
	t_d：业务类型的描述
	a_f：功能的型数组
*/
function show_bizContent(c_id,t_d,t){
	//alert('展示相关业务的功能a_f = '+a_f);
	var cdiv = document.getElementById(c_id);
	
	var f = t.functions;	//功能列表
	var i = t.image;
	var n = t.name;
	
	var content = "";
	var url = '/v2008/images/service/public/pic_80x60.gif';
	if(i!=null && i != ''){
		url = i;
	}
	
	content += "<div class='info clearfix'>"; 
	content += "<span class='fl'>";
	content += "<img src='"+url+"' alt='"+name+"' width='80' height='60'  />";
	content += "</span>";
	content += "<div class='fr_p'>";
	content += t_d;
	content += "</div>";
	content += "</div>";
	content += "<ul class='relatedBusiness clearfix'>";
	if(f.length >0){
		for(var i=0;i<f.length;i++){
			var f1 = f[i];
			var n = f1.name;
			var u = f1.url;
			content += "<li>·<a href='"+u+"'>"+n+"</a></li>";	
		}
	}
	content += "</ul>";
	
	cdiv.innerHTML = content;
}//end function
/*
	功能：查询某个业务类型
	o_id: 业务操作的div的id
	c_id：具体内容div的id
	p：某个业务类型在业务类型数组中的索引
	id：某个具体业务类型的id
*/
function check_bizType(o_id,c_id,p,id){
	//alert('切换标签 '+id+" p = "+p);
	var t = _a_biz_type[p];	
	var t_d = t.describtion;//业务类型描述
	for(var i=0;i<_a_biz_type.length;i++){
		var d = _s_biz_suf+i;
		document.getElementById(d).className = '';
	}
	document.getElementById(id).className = 'on';
	show_bizContent(c_id,t_d,t);
	
	document.getElementById(c_id).className = 'tabBoxs_content_02';
	if(o_id != 'null')
	document.getElementById(o_id).className = 'tabBoxs_content hide';
	
}//end function
/*
	功能：展示业务操作框
*/
function check_bizOperation(c_id,o_id,id){
	//alert('展示业务操作框');
	for(var i=0;i<_a_biz_type.length;i++){
		var d = _s_biz_suf+i;
		document.getElementById(d).className = '';
	}
	document.getElementById(id).className = 'on';
	document.getElementById(o_id).className = 'tabBoxs_content';
	document.getElementById(c_id).className = 'tabBoxs_content_02 hide';
}
/*
	功能：查询某个具体业务的信息
	t_id：业务类型div的id
	f_id：相关功能div的id
	r_id：温馨提醒div的id
	o_id：业务操作div的id
	c_id：其他业务类型div的id
	is_index：是否是首页
	brand：品牌
	bizCode：业务编码
	is_a：是否异步
	
*/
function query_bizInfo(t_id,f_id,r_id,o_id,c_id,is_a,is_index,brand,bizCode,response){
	_o_biz_id = o_id;
		
	var info = response.bizInfo;
	var state = response.userState;
	
	var size = _a_biz_type.length;
	//1.得到该业务所属类型的type值
	var type = info.type;
	//2.得到在数组中的索引
	var p = 0;
	for(var i=0;i<size;i++){
		var t = _a_biz_type[i];
		var tt = t.type;
		if(tt == type){
			p = i;
		}
	}
	//3.相关类型显示高亮
	show_bizType(t_id,c_id,_a_biz_type,is_index,p);
	
	for(var i=0;i<_a_biz_type.length;i++){
		var d = _s_biz_suf+i;
		document.getElementById(d).className = '';
	}
	var id = _s_biz_suf+p;
	if(size > 0)
	document.getElementById(id).className = 'on'
	//4.展示相关功能
	var f = info.functions;
	show_bizFunction(f_id,f);
	//5.展示温馨提醒
	var r = info.reminds;
	show_bizRemind(r_id,r);
	
	//如果用户没有登录并且该业务是需要登录的就去查询该业务的信息
	if(!state && _b_is_login){
		//alert("查询该业务的信息");
		query_bizIntro(info);
	}else{
		//alert("显示操作界面");
		//如果登录就显示操作界面
		document.getElementById('biz_op_expand1').style.display = "none";
		document.getElementById('biz_op_forms').style.display = "";
		document.getElementById('biz_op_message').style.display = "";
		document.getElementById('biz_op_commond').style.display = "";
		document.getElementById('biz_op_button').style.display = "";
		
		//query_is_transact_biz(bizCode,'email');	//查询业务类型，显示邮箱
	}
}//end function

/*
	功能：当用户还没登陆时就去查询业务信息
	bc：业务编码
*/
function query_bizIntro(info){
	document.getElementById('biz_op_forms').style.display = "none";
	document.getElementById('biz_op_message').style.display = "none";
	document.getElementById('biz_op_commond').style.display = "none";
	document.getElementById('biz_op_button').style.display = "none";
	
	var div = document.getElementById('biz_op_expand1');
	var desc = info.describtion;
	var image= info.image;
	var name = info.name;
	
	var content = "";
	var url = "/v2008/images/service/public/pic_80x60.gif";
	if(image != null && image != ''){
		url = image;
	}
	content += "<div class='info clearfix'>"; 
	content += "<span class='fl'>";
	content += "<img src='"+url+"' alt='"+name+"' width='80' height='60'  /><br/>";
	content += "</span>";
	content += "<div class=\"fr_p\">";
	content += desc;
	content += "尊敬的用户如想办理该业务请先点击<a  href=\"javascript:void(0)\" onclick=\"showorhide('pop_filter_login','pop_login')\">登录</a>。谢谢。";
	//content += " <button  class=\"btn_blue_75\" onclick=\"showorhide('pop_filter_login','pop_login')\">登录</button>";
	content += "</div>";
	content += "</div>";
	
	div.innerHTML = content;
}

/*
	功能：展示某个业务的相关功能
	f_id：相关功能div的id
	f：相关功能数组
*/
function show_bizFunction(f_id,f){
	var fdiv = document.getElementById(f_id);
	
	var content = "";
	content += "<h2>相关业务功能</h2>";
	content += "<ul class='relatedBusiness clearfix'>";
	if(f.length >0 ){
		for(var i=0;i<f.length;i++){
			var t = f[i];
			var n = t.name;
			var u = t.url;
			//20081225在连接前暂时加/v08/
			content += "<li>·<a href='"+u+"'>"+n+"</a></li>";
		}
	}
	else{
		content += "暂无相关业务"
	}
	content += "</ul>";
	fdiv.innerHTML = content;
}//end function 
/*
	功能：展示某个业务的温馨提醒
	r_id：温馨提醒div的id
	r：温馨提醒数组
*/
function show_bizRemind(r_id,r){
	var rdiv = document.getElementById(r_id);
	var content = ""
	
	content += "<h2>温馨提醒</h2>";
	content += "<div class='reminder'>";
	if(r.length >0 ){
		content += r[0].name;
	}
	else{content += "暂无温馨提醒。"}
	content += "</div>";
	rdiv.innerHTML = content;
}//end function
/*
	功能：查询用户积分
*/
function query_common_uesr_integral(u_id){
	var url = "/services/function?action=QueryIntegral";
	var handleSuccess = function(response){
		if(response.result){
			//将积分设置Cookie中。
			var cookieValue = response.UserMobile +"|"+response.UserIntegral;
			SetCookie('LoginMember',cookieValue,false,'/');
			
			var c = "您的积分：<i>"+response.UserIntegral+"</i>分";
			document.getElementById(u_id).innerHTML = c;
		}
	};
	var handleFail = function(response){};
	//请求参数
	var handlePostData = {};
	//请求
	common_send_ajax(url,handlePostData,true,handleSuccess,handleFail);
}//end function
/*
	功能：查询导航信息。
*/
function query_common_navigation(c_id){
	var content = "";
	content += "<table class='navigation'>";
	content += "<tr >";
	content += "<td class='bFtd_02' ><a href='/' title='转去网站首页'>1、转去网站首页；</a></td>";
	content += "<td class='bFtd_02'><a href='/service/' title='转去网厅首页'>2、转去网厅首页；</a></td>";
	content += "</tr>";
	
	content += "<tr >";
	content += "<td class='bFtd_02'><a href='/shop/' title='转去移动商城'>3、转去移动商城；</a></td>";
	content += "<td class='bFtd_02'><a href='/e100/index.jsp' title='转去E100个人专区'>4、转去E100个人专区；</a></td>";
	content += "</tr>";
	
	content += "<tr >";
	content += "<td class='bFtd_02'><a href='/whatsnew/discount/' title='转去最新优惠'>5、转去最新优惠；</a></td>";
	content += "<td class='bFtd_02'><a href='/10086/' title='转去服务与支持'>6、转去服务与支持；</a></td>";
	content += "</tr>";
	content += "</table>";
	document.getElementById(c_id).innerHTML = content;
	
	return content;
}//end function
/*
	功能：签订协议
	p_id :协议签订框的id;
*/
function signed_biz_agreement(p_id,s_id){
	var url = "/services/function?action=SignedAgreement";
	var handleSuccess = function(response){
		if(response.result){
			var title = "<h4>信息提示<span onclick=\"showorhide('pop_open_window','pop_op')\" title='点击关闭'>关闭</span></h4>";
			var content = '<center>'+response.message+'</center>';
			var button = "<button onclick=\"showorhide('pop_open_window','pop_op')\>确定</button>";
			open_window('pop_op_title','pop_op_content','pop_op_button',title,content,button);
			
			document.getElementById(p_id).disabled= "none";
			document.getElementById(s_id).innerHTML= "尊敬的用户您已<a href=\"/service/agreement.shtml\" target=\"_blank\">阅读</a>并接受业务办理协议";
		}
	};
	var handleFail = function(response){};
	//请求参数
	var handlePostData = {};
	//请求
	common_send_ajax(url,handlePostData,true,handleSuccess,handleFail);
}//end function
/*
	功能：弹出用户退出网站二次确认
*/
function show_logout_gmcc(){
	//<span onclick=\"showorhide('pop_open_window','pop_op')\" title='点击关闭'>关闭</span>
	var title = "<h4>信息提示</h4>";
	var content = "<center id='_user_logout_msg'>尊敬的客户，您确认要退出网上服务厅吗？</center>";
	var button = "<button onclick=\"user_logout_gmcc();\">确定</button>";
		button += "<button onclick=\"showorhide('pop_open_window','pop_op')\">取消</button>";
		
	open_window('pop_op_title','pop_op_content','pop_op_button',title,content,button);
}
/*
	功能：用户退出网站
*/
function user_logout_gmcc(){
	document.getElementById("_user_logout_msg").innerHTML = "<span class=loading>正在退出中，请稍候。</span>";
	handle_biz_button("pop_op_button",true);
	
	var url = "/services/function?action=Logout";
	//退出成功
	var handleSuccess = function(response){
		showorhide('pop_open_window','pop_op');
		
		var title = "<h4>信息提示<span onclick=\"showorhide('pop_open_window','pop_op');location.reload()\" title='点击关闭'>关闭</span></h4>";
		var content = '<center><h2>您已经成功退出网上服务厅，请选择：</h2><br/><span id=\"_gmcc_n_info\"></span></center>';
		var button = "<button onclick=\"showorhide('pop_open_window','pop_op');location.reload()\">关闭</button>";
		open_window('pop_op_title','pop_op_content','pop_op_button',title,content,button);
		query_common_navigation('_gmcc_n_info');
		
		//删除Cookie
		DelCookie('LoginMember','/');
		//alert("delete BizBrand");
		DelCookie('BizBrand','/');
		
	};
	//退出失败
	var handleFail = function(response){
		showorhide('pop_open_window','pop_op');
		
		var title = "<h4>信息提示<span onclick=\"showorhide('pop_open_window','pop_op');\" title='点击关闭'>关闭</span></h4>";
		var content = '<center>退出失败</center>';
		var button = "<button onclick=\"showorhide('pop_open_window','pop_op')\">关闭</button>";
		open_window('pop_op_title','pop_op_content','pop_op_button',title,content,button);
		
	};
	//请求参数
	var handlePostData = {};
	//请求
	common_send_ajax(url,handlePostData,true,handleSuccess,handleFail);
}//end function
/*
	功能：查询某个业务是否是办理类业务
	t：回调方法类型
		email: 显示邮箱
*/
function query_is_transact_biz(bizCode,t){
	var url = "/services/function?action=IsTransactBiz&BizCode="+bizCode;
	var handleSuccess = function(response){
		var b_r = response.result;
		_userMobileNumber = response.UserMobile;
		
		if(t == 'email'){//显示邮箱
			if(b_r){
				show_biz_email('biz_op_139')
			}	
		}
		
		_isTransactBiz = b_r;
	};
	var handleFail = function(response){};
	//请求参数
	var handlePostData = {};
	//请求
	common_send_ajax(url,handlePostData,true,handleSuccess,handleFail);
}//end function
/*
	功能：展示邮箱
*/
function show_biz_email(e_id){
	var c = "<table width=\"80%\"><tr><td class=\"blue_01\" align='center'>";
	c += "<input type=\"checkbox\" id='_is_check_email' name='_is_check_email'/> ";
    c += "<span class=\"red_01\">您是否将记录保存到邮箱：</span>";
    c += "<input type=\"text\" class=\"text_01\" id='_biz_prefix_email' value='"+_userMobileNumber+"'/> ";
    c += "<select id='_biz_postfix_email'>";
    c += "<option value='@139.com' selected='selected'>@139.com</option>";
    c += "<option value='@sina.com' >@sina.com</option>";
    c += "<option value='@yahoo.com.cn'>@yahoo.com.cn</option>";
    c += "<option value='0'>其他</option>";
    c += "</select>";
    c += "</td></tr></table>";
             
	document.getElementById(e_id).innerHTML = c;
}
/*
	功能：进度提示信息
	n_t：
		 1，正在查询中，请稍候。
		 2，正在办理中，请稍候。
		 3，正在修改中，请稍候。
		 4，正在取消中，请稍候。
		 5，正在删除中，请稍候。
*/
function before_request(n_t,s_m){
    //隐藏b2m随机短信输入框
    hide_b2m_sms();

	var msg = "数据加载中，请稍候。";
	
	if(arguments.length == 1){
		switch (n_t) {
	        case 1:
	            msg = "正在查询中，请稍候。";
	            break;  
	        case 2:
	            msg = "正在办理中，请稍候。";
	            break;
	        case 3:
	            msg = "正在修改中，请稍候。";
	            break;
	        case 4:
	            msg = "正在取消中，请稍候。";
	            break;
	        case 5:
	           msg = "正在删除中，请稍候。";
	           break;
	    }
    }
    else if(arguments.length == 2){
    	msg = s_m;
    }
    //alert(msg);
	document.getElementById("biz_op_message").innerHTML = "<center><span class=loading>"+msg+"</span></center>";
	var d = document.getElementById("biz_op_button");
	if(d != null){
		var bs = d.getElementsByTagName("button");
		for(var i=0;i<bs.length;i++){
			bs[i].disabled = "disabled";
		}
	}
}

function after_response(){
	//显示b2m随机短信输入框
    display_b2m_sms();
	var m = document.getElementById("biz_op_message");
		m.innerHTML = "";
	var d = document.getElementById("biz_op_button");
	if(d != null){
		var bs = d.getElementsByTagName("button");
		for(var i=0;i<bs.length;i++){
			bs[i].disabled = "";
		}
	}
}
/*
	处理功能按钮
*/
function handle_biz_button(d_id,b_ish){
	var table = document.getElementById(d_id);
	if(table != null){
		var t = "";
		if(b_ish){
			t = "disabled";
		}
		var b = table.getElementsByTagName("button");
		for(var i=0;i<b.length;i++){
			b[i].disabled = t;
		}
	}
}
/*
	功能：重写div中的内容
	d_id：div的id
	t：重写内容
*/
function re_write_biz_div(d_id,t){
	var div = document.getElementById(d_id);
	var c = "";
	
	if(t == "button"){//重写button
		var msg = "重新查询";
		var click = "onclick = \"location.reload()\"";
		if(_isTransactBiz)//是办理类
			msg = "重新办理";
		c += "<table class=\"tfootBtn\">";
        c += "<tr>";
        c += "<td>";
        c += "<button class=\"btn_blue_75\" onmouseover=\"shover(this,'btn_blue_75_02')\" onmouseout=\"shover(this,'btn_blue_75')\" "+click+">"+msg+"</button>";
        c += "<button class=\"btn_online\" onmouseover=\"shover(this,'btn_online_02')\" onmouseout=\"shover(this,'btn_online')\" onclick=\"javascipt:window.open('http://www.gd.chinamobile.com/branches/gd/changehttp/index.jsp','','width=650,height=480,scrollbars=yes')\">网上客服</button>";
        c += "</td>";
        c += "</tr>";
    	c += "</table>";
	}
	div.innerHTML = c;
}
/*

	检查邮箱，成功返回邮箱地址，不成功则返回"",如果用户没有选择则返回“none”
	c_id（checkbox的id）,t_id（text的id）,s_id（select的id）
*/
function check_biz_email(c_id,t_id,s_id){
	var e = "";
	var o_cb = document.getElementsByName(c_id);
    if(o_cb != null){
    	if(o_cb[0].checked){
    		var s_e = document.getElementById(t_id).value;
    		var n_t = document.getElementById(s_id).value;
    		
    		if(n_t == '0'){
    			e = s_e;
    		}
    		else{
    			e = s_e + n_t;
    		}
    		//139邮箱的验证
    		if(n_t == '@139.com'){
    			var is = new SunRise.Validate();
    			if(!is.isMobile(s_e)){return "";}
    		}
    		//验证邮箱：
    		var is = new SunRise.Validate();
    		if(is.isEmail(e)){
    			return e;
    		}
    		else{
    			return "";
    		}
    		
    	}
    	else{
    		return "none";
    	}
    } 
}//end function
/*=======================20081218 添加/service/public.js=======================*/
//网厅公共JS
/* 选项卡函数
 * 参数说明：
 * tabBoxId,选项卡大容器Id
 * tabMenuId,选项卡菜单Id 【必须为ul元素】
 * tc_className，选项卡内容容器className 【必须为div元素】  
 */
function tabFunc(tabBoxId,tabMenuId,tc_className)
{
	//var o =  SunRise.Dom.get(tabBoxId);	
	var D = SunRise.Dom;
	var tabBoxs = D.getElementsByClassName(tc_className,"div",D.get(tabBoxId));
	var lis = D.get(tabMenuId).getElementsByTagName("li");
	for(var i=0,j=lis.length;i<j;i++)
	{
		
		//E.addListener(lis[i],'click',tab(i));
		lis[i].onclick = tab(i);
		
	}	
	
	function tab(i)
	{
		return function()
			{
				for(var k=0,t=lis.length;k<t;k++)
				{
					lis[k].className = k == i?"on":"";
					//tabBoxs[k].className = k == i?(SunRise.Dom.removeClass(tabBoxs[k],"hide")):(SunRise.Dom.addClass(tabBoxs[k],"hide"));
					tabBoxs[k].className = k == i?tabBoxs[k].className.replace(/ hide/g,""):(tabBoxs[k].className+" hide");
				}
			}
	}
}



function autoFixMenu(o)//修复IE6.0下，不能遮住下拉框的问题
	{
		if(!D){var D = SunRise.Dom;}
		if($){var $ = D.get;}
		
		if(!o.getElementsByTagName("iframe")[0])return;
		
		//try{
		
		var _iframe= o.getElementsByTagName("iframe")[0];		
		var ul = o.getElementsByTagName("ul")[0];
		var ulOffset = Offset(ul);	
				
		D.setStyle(_iframe,'zIndex','5');
		D.setStyle(ul,'zIndex','10');	
		D.setStyle(_iframe,'left',D.getStyle(ul,'left'));
		//D.setStyle(_iframe,'top',D.getStyle(ul,'top'));
		//D.setStyle(_iframe,'bottom',D.getStyle(ul,'bottom'));
		
		if(ul.style.top=="0")
		{
			_iframe.style.top=0;
			ulo.style.bottom="auto";
		}
		else
		{
			_iframe.style.top="auto";
			ulo.style.bottom=0;
		}
		
		D.setStyle(_iframe,'width',ulOffset.width);
		D.setStyle(_iframe,'height',ulOffset.height);
	
		D.setStyle(_iframe,'display','block');
		D.setStyle(_iframe,'zIndex','5');
		D.setStyle(ul,'zIndex','10');	
		
		//}
	//	catch(e){}
		
	}
	

	
function createIframe(o)
	{
		try
		{
			var oiframe = document.createElement("iframe");
			oiframe.className="iframefilter";
			//oiframe.style.display = "none";
			oiframe.style.left = -9000+"em";
			oiframe.style.top = -9000+"em";
			o.appendChild(oiframe);
		}
		catch(e){}
		
	}

//侧边栏菜单脚本(id固定)===========================
function funcleftMenu()
	{
		if(!document.getElementById("leftMenu"))return;
		var lis = document.getElementById("leftMenu").getElementsByTagName("li");
		var timeoutttt;
		function _onmouseout(o)
		{
			//timeoutttt = setTimeout(function(){
				
				o.className = o.className.replace(/on/g,"");										
				if(o.getElementsByTagName("iframe")[0])
					{
						o.getElementsByTagName("iframe")[0].style.left = -9000+"em";
						o.getElementsByTagName("iframe")[0].style.top = -9000+"em";												
					}
			//},1000);
		}
		
		
		function _onmouseover(o)
		{
			if(o.className.indexOf("hastree")!=-1)
				{
					
					o.className="on "+o.className;		
					var ooffset = Offset(o);
					var ulo = o.getElementsByTagName("ul")[0];
					var ulOffset = Offset(ulo);	
					
					//alert(ooffset.top+ulOffset.height)
					//alert(D.getViewportHeight())
					
					//alert(ulo.scrollHeight);
					if((ooffset.top+ulOffset.height)>D.getViewportHeight())
					{
						ulo.style.top="auto";
						ulo.style.bottom=0;
						
					//	alert("向上")
					}
					else
					{
						ulo.style.bottom="auto";
						ulo.style.top=0;
						
						//alert("向xia")
					}
						/*
					if(SunRise.ua.ie=="6"&&o.getElementsByTagName("ul")[0])//修复IE6.0下，不能遮住下拉框的问题
						{	
						
								//autoFixMenu(o);
							
							
							
						}
						*/
													
				}
		}
		
		for(var i = 0,j=lis.length;i<j;i++)
			{			
				if(lis[i].getElementsByTagName("ul").length>0)
					{
						lis[i].className="hastree";	
						
						if(SunRise.ua.ie=="6")
						{
							createIframe(lis[i]);
						}
						
					}
				lis[i].onmouseover = (function(o)
									{								
										
										return function(){								
												
										//if(timeoutttt){  clearTimeout(timeoutttt); }				
										_onmouseover(o);
										/*if(SunRise.ua.ie=="6"&&o.getElementsByTagName("ul")[0])//修复IE6.0下，不能遮住下拉框的问题
											{	
												
												//autoFixMenu(o);
											}
											*/
										}
																		
									})(lis[i]);
									
				lis[i].onmouseout = (function(o)
									{		
																
										return function()
											{						
												//alert(o.className)					
												_onmouseout(o);
												
											}							
									}	)(lis[i]);
			}		
			
	}






/*信息提示函数
 * 转入的参数格式必须为json格式
 * 参数格式{url:str_url,text:str_text,tget:str_tget,func:str_func} url为链接，text为文本,tget为窗口打开的方式,func为onclick方法名
 * 参数长度不限
 * 调用示例：tips({url:'/service/gotone/',text:'停机开机'},{url:'/service/gotone/',text:'解除黑名单'},{url:'/service/gotone/',text:'备卡激活'},{url:'/service/gotone/',text:'补卡SIM卡(广州)'})
 */
var tips_box; //存储信息提示对象的全局变量
function tips(){
	if( arguments.length==0||!document.body) return;//如果无参数和没有得到body 则返回
	
	tips_box = tips_box||document.createElement("div");	
	tips_box.className = "tips_box";
		
	var con_01 = "<div class=\"tips_con\"><ul>";
	var con_02 = "";
	var con_03 = "</ul></div><div class=\"tips_b\"></div>";
	for( var i=0,j=arguments.length;i<j;i++)
		{
			con_02 += "<li><a href=\"" + arguments[i].url +"\""+" "+"target=\""+arguments[i].tget+"\""+" onclick=\""+arguments[i].func+"\""+">·"+ arguments[i].text + "</a></li>";
			
		}		
		
	var con = con_01 + con_02 +con_03;	
	
	tips_box.innerHTML = con;
	var ev = getEl()
	var offset = Offset(ev);
	var T = offset.top + 20;
	var L = offset.left + 20
	tips_box.style.top = T +"px";
	tips_box.style.left = L +"px";	
	
	try
	{
		document.body.appendChild(tips_box);
	}
	catch(e){};
	function settipsTimeout()
	{
		tipstt = setTimeout(function(){
			
			if(tips_box)
			{
				try
					{
						document.body.removeChild(tips_box);
					}
				catch(e){};
			}
			
			
			
		},1000);
	}
	ev.onmouseout = settipsTimeout;
	
	
	try
			{
				if(tipstt)
				{
					clearTimeout(tipstt);
					
				}
			}
			catch(e){};
	
	tips_box.onmouseover = function()
		{
			try
			{
				if(tipstt)
				{
					clearTimeout(tipstt);
					
				}
			}
			catch(e){};
			
			tips_box.onmouseout = settipsTimeout;
			
		};
}//end function
/*=======================20081218 添加CommonAjax.js=======================*/
/*
	功能：向服务端发送请求
	url: 请求url
	handlePostData：发送的json对象
	isAsynchronism：是否异步
	handleSuccess：回调的方法
	handleFail：调用失败的回调方法
*/
var n_unlogin = 30;//还未登录
var n_err_loginty=32;//登陆方式错误
var n_must_protocol=33;//必须签定电子协议 
function common_send_ajax(url, handlePostData,isAsynchronism,handleSuccess, handleFail, handleTimeout){
	
	var sending = false;
    var handleResult = function(o){
        if (o.readyState == 4) { 
            if (o.status == 200) {
				if(sending){
					sending = false;
				}else{
					return;
				}
                var response = o.responseText.parseJSON();
               	var code = response.resultCode;
				if(response.result){
					handleSuccess(response);
				}else{
                    if(code == n_unlogin){//还未登录，弹出登录框
                    	showorhide('pop_filter_login','pop_login');
						var _loginType = document.getElementById("_loginType");
						_loginType.value = response.lessLoginType;
						document.getElementById("_login_backurl").value = "";
						document.getElementById("_login_target").style.display = "none";
						_s_l_m_p(_loginType,'service_pwd','check_code','message_code');
                    }else if(code == n_err_loginty){
						if(response.updateLoginType == 1){
							showorhide('pop_message_rnsms','pop_msg_rnsms');
						}else{
							showorhide('pop_message_pwd','pop_msg_pwd');
						}
					}else if(code == n_must_protocol){
						showorhide('pop_agreement_biz','pop_agr_biz');
					}else{
						handleFail(response);
					}
				}
            }
            else {//调用失败统一处理  
            	if(sending){
					sending = false;
				}else{
					return;
				}
				if (handleFail) {
					handleFail();
				}else{
					//alert('系统异常，请稍后再试');
					var m = document.getElementById('biz_op_message');
					if(m != null){
						m.innerHTML = "<center><b class='red_01'>系统异常，请稍后再试</b></center>";
					}
				}
            }
        }
    };
	
	//请求超时处理
	var timeout = function(){
		if(sending){
			sending = false;
			if(handleTimeout){
				handleTimeout();
			}else{
				showorhide('pop_timeout_msg','pop_timeout_req');
			}
		}
	}

    var callback = {
        success: handleResult,
        postData: "_request_json="+encodeURIComponent(handlePostData.toJSONString())
    };
    
    var ajax = new SunRise.Ajax({
        URL: url,
        isAsynchronism: isAsynchronism,
        method: 'POST'
    });
    ajax.send(callback);
	sending = true;
	window.setTimeout(function() {timeout();}, 45*1000);
}

function update_login_type(n){
	var p = 0;
	var t = "";
	var _lem = null;
	var d = null;
	var o = "";
	if(n == 1 ){
		t = "随机短信密码";
		_lem = document.getElementById("_up_smsrnd_login_type");
		p = document.getElementById("_update_smsrnd").value;
		d = document.getElementById("pop_msg_rnsms");
		o = "checksms";
	}else{
		t = "服务密码";
		_lem = document.getElementById("_up_pwd_login_type");
		p = document.getElementById("_pwd_update_logintype").value;
		d = document.getElementById("pop_msg_pwd");
		o = "checkpwd";
	}
	
	var v1 = new SunRise.Validate();
	var v = function(p){
        if (p == "") {
            _lem.innerHTML ="<img src=\"/v2008/images/public/icon_wrong.gif\" /> <b class=\" red_01\"> "+ t+"不能为空</b>";
            return false;
        }
        if (!v1.isNumber(p)) {
            _lem.innerHTML ="<img src=\"/v2008/images/public/icon_wrong.gif\" /> <b class=\" red_01\"> "+ t+"必须为数字</b>";
            return false;
        }
        return true;
    }
	
	if(!v(p)){
		return;
	}
	
	var url = "/ServicesServlet/UPDATE_LOGIN_TYPE";
	
	if(d != null){
		_lem.innerHTML = "正在验证中，请稍候......";
		var bs = d.getElementsByTagName("button");
		for(var i=0;i<bs.length;i++){
			bs[i].disabled = "disabled";
		}
	}
	
	var handlePostData = {
        operation: o,
		isProtocol:true,
		checkstr:p
    };
	
	var handleSuccess = function(o){
		location.reload();
    };
	
	var handleFail = function(o){
		var m = null;
		if(o.type == 1){
			m = document.getElementById("_up_smsrnd_login_type");
		}else{
			m = document.getElementById("_up_pwd_login_type");
		}
		m.innerHTML ="<img src=\"/v2008/images/public/icon_wrong.gif\" /> <b class=\" red_01\"> "+ o.message +"</b>";
		if(d != null){
			var bs = d.getElementsByTagName("button");
			for(var i=0;i<bs.length;i++){
				bs[i].disabled = "";
			}
		}
    };
	common_send_ajax(url,handlePostData,true,handleSuccess,handleFail);
}

//showCommonError
function _show_common_error(m){
	var t = "<h4>信息提示<span onclick=\"showorhide('pop_open_window','pop_op')\" title='点击关闭'>关闭</span></h4>";
	var c = m;
	var b = "<button type='submit' onclick=\"showorhide('pop_open_window','pop_op')\" id='submit_button'>确定</button>";
	open_window('pop_op_title','pop_op_content','pop_op_button',t,c,b);
}
// popForm

//重写window.onscroll事件
function addScrollEvent(func){
    var oldonscroll = window.onscroll;
    if (typeof window.onscroll != 'function') {
        window.onscroll = func;
    }
    else {
        window.onscroll = function(){
            oldonscroll();
            func();
        }
    }
}

var _obj02 = "";
function autoCenter(o1,o){
	
	o1.style.height = document.documentElement.scrollHeight + "px";
    //o.style.left = (document.documentElement.scrollLeft + (document.documentElement.clientWidth - o.offsetWidth) / 80) + "px";//左右居中		
	o.style.left = " 512px ";
    //o.style.top = (document.documentElement.scrollTop + (document.documentElement.clientHeight - o.offsetHeight) / 2 - 100) + "px";
    //o.style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-o.offsetHeight)/50)+"px";
	o.style.top=" 64px ";

    //上下居中	
}



var objFilters = [];
/*
*
*   判断在数组中是否含有给定的一个变量值
*   参数说明：
*   needle：需要查询的值
*   haystack：被查询的数组
*   在haystack中查询needle是否存在，如果找到返回true，否则返回false。
*   此函数只能对字符和数字有效
*
*/
function in_array(needle,haystack) 
{
    // 得到needle的类型
    var type = typeof needle;

    if(type == "object" ) 
    {
        for(var i in haystack) 
        {
            if(haystack[i] == needle) 
            {
                return true;
            }
        }
    }
    return false;
	
}

/*功能说明：显示和隐藏某个层
 *参数说明： _id01为要显示/隐藏的id
 *           _id02为要左右居中的id
 **/
var showorhide = function(_id01, _id02){
	
	//if((_id01 ==""||typeof _id01 !="string")&&(_id02 ==""||typeof _id02 !="string")) return;
	_obj01 = document.getElementById(_id01);	
	_obj02 = document.getElementById(_id02);
	
    
    if(_id01!="pop_filter_login")	
		{
			if(objFilters.length<1)
				{
					objFilters.push(_obj01);
				}
			else
				{
					if(!in_array(_obj01,objFilters))
					{
						objFilters.push(_obj01);				
					}
				}
		}
	else
		{
			for( var i=0,j=objFilters.length;i<j;i++)
				{
					if(objFilters[i].className.indexOf("hide")==-1)
					{
						objFilters[i].className+=" hide";	
					}
				}
		}	
	
    
    var _obj = _obj01;
    if (_obj.className.indexOf("hide") != -1) {
        _obj.className = (_obj.className).replace("hide", "");
        _obj.style.height = document.documentElement.scrollHeight + "px";
        autoCenter(_obj,_obj02);
        function center(){
            autoCenter(_obj,_obj02);
        }
        addScrollEvent(center);
    }
    else 
        if (_obj.className.indexOf("hide") == -1) {
            _obj.className += " hide";
        }
    
};
/*
 * t : 登陆方式ID
 * n : 手机号码ID
 * p : 服务密码ID
 * sr : 随机短信密码
 * ir : 图形校验码
 * lb : 登陆后的跳转地址
 * m : 信息提示ID
 * b : 提交按扭ID
 * reb : 密码重置按扭
 * a : 电子协议ID
 */
function on_web_login(t,n,p,sr,ir,lb,m,b,reb,a){
    web_login(t,n,p,sr,ir,lb,m,b,reb,a);
    return false;
}


function web_login(t,n,p,sr,ir,lb,m,b,reb,a){
    
    var login_info = {
        _loginType: document.getElementById(t).value,
        _logonName: document.getElementById(n).value,
        _password: document.getElementById(p).value,
        _smsRND: document.getElementById(sr).value,
        _imageCode: document.getElementById(ir).value,
		_channel:0,
		_login_backurl:document.getElementById(lb).value
    };   
	var _lem = document.getElementById(m);
    
    var v = new SunRise.Validate();
    if (login_info._logonName == "") {
        _lem.innerHTML = "请输入手机号码";
        return false;
    }
    
    if (!v.isMobile(login_info._logonName)) {
        _lem.innerHTML = "请输正确的手机号码";
        return false;
    } 
    
    var vPwd = function(n){
        if (n == "") {
            _lem.innerHTML = "服务密码不能为空";
            return false;
        }
        if (!v.isNumber(n)) {
            _lem.innerHTML = "服务密码必须为数字";
            return false;
        }
		
        return true;
    }
    
	  var vRndSms = function(n){
        if (n == "") {
            _lem.innerHTML = "随机短信码不能为空";
            return false;
        }
        if (!v.isNumber(n)) {
            _lem.innerHTML = "随机短信码必须为数字";
            return false;
        }
        return true;
     }
	
    if (login_info._loginType == 2) {
        if (!vPwd(login_info._password)) {
            return;
        }
    }
    //Login By Mobile
    else if(login_info._loginType == 0){
    	
    }
    else if (login_info._loginType == 1) {
       if (!vRndSms(login_info._smsRND)) {
           return;
       }
    }
    else if (login_info._loginType == 3) { 
       if (!vPwd(login_info._password)) {
             return;
       }else if (!vRndSms(login_info._smsRND)) {
         return;
       }
    }
    else {
       _lem.innerHTML = "请以正确的方式登陆";
       return;
    }
  
  //Login By Mobile not check Image Code
  if(login_info._loginType != 0){
    if (login_info._imageCode == "" || login_info._imageCode.length != 4 || login_info._imageCode == '点击输入') {
        _lem.innerHTML = "请输入正确的图形校验码";
        return;
    }
  }
    var _sb = document.getElementById(b);
    var _fp = document.getElementById(reb); 
    _sb.disabled = true;
    _fp.disabled = true;
	 
//	var h_d = document.getElementById("h_login_mode");
//	h_d.style.display = "none";
//	var h_c = document.getElementById("h_login_content");
//	h_c.style.display = "none";
    _lem.innerHTML = "正在登陆中，请稍候......";
    
    var url = "/ServicesServlet/LOGIN";
    
    var handlePostData = {
        operation: "login",
		isProtocol:document.getElementById(a).checked,
        _loginInfo: login_info.toJSONString()
    };
    
    var handleSuccess = function(response){
		try{
			var cookieValue = login_info._logonName + "|-1";
			SetCookie('LoginMember',cookieValue,false,'/');
		}catch(e){
			alert(e);
		}
		if(response._login_backurl != ""){
			window.location = response._login_backurl;
		}else{
			location.reload();
		}
    };
	
	var handleFail = function(response){
        _sb.disabled = false;
        _fp.disabled = false;
        _lem.innerHTML = response.message;
//		h_d.style.display = "";
//		h_c.style.display = "";
		if(login_info._loginType != 0)
			getVerify('verifyIMG_0','0');
  		hiddenVerify();
	}
	
	var handleTimeout = function(){
        _sb.disabled = false;
        _fp.disabled = false;
        _lem.innerHTML = "请求超时，请重新登陆！";
//		h_d.style.display = "";
//		h_c.style.display = "";
		if(login_info._loginType != 0)
			getVerify('verifyIMG_0','0');
  		hiddenVerify();
	}
	
	common_send_ajax(url,handlePostData,true,handleSuccess,handleFail,handleTimeout);
}

function check_login(u){
	var handleSuccess = function(o){
	        if (o.readyState == 4) {
				if (o.status == 200) {
					var response = o.responseText.parseJSON();
					if (response.resultCode == 100) {
						document.getElementById('_login_backurl').value = response.targetUrl;
						showorhide('pop_filter_login','pop_login');
					}else{
						window.location=response.targetUrl;
					}
				}
			}
	}
	var handlePostData = {
        operation: "check"
    };
	
	var callback = {
        success: handleSuccess,
        postData: handlePostData.toJSONString()
    };
	
 	var ajax = new SunRise.Ajax({
        URL: "/login/checkLogin.jsp?targetUrl="+u,
        isAsynchronism: true,
        method: 'POST'
    });
    ajax.send(callback);
}

function _show_loginform(s,h){
    document.getElementById(h).style.display = "none";
    document.getElementById(s).style.display = "";
}

function _s_l_m_p(o,p,c,m){
    var _value = o.value;
    var service_pwd = document.getElementById(p);
    var check_code = document.getElementById(c);
    var mesage_code = document.getElementById(m);
    switch (_value) {
    
        case "0":
            service_pwd.style.display = "none";
            mesage_code.style.display = "none";
            check_code.style.display = "none";
            break;  
        case "1":
            service_pwd.style.display = "none";
            mesage_code.style.display = "";
            check_code.style.display = "";
            break;
        case "2":
            service_pwd.style.display = "";
            mesage_code.style.display = "none";
            check_code.style.display = "";
            break;
        case "3":
            service_pwd.style.display = "";
            mesage_code.style.display = "";
            check_code.style.display = "";
            break;
    }
}


function s_l_m_g(o){
    var _value = o.value;
    var mobileNo = document.getElementById("mobileNo");
    var service_pwd2 = document.getElementById("service_pwd2");
    var userName = document.getElementById("userName");
    var userPsw = document.getElementById("userPsw");
    switch (_value) {
    
        case "0":
            mobileNo.style.display = "";
            service_pwd2.style.display = "";
            userName.style.display = "none";
            userPsw.style.display = "none";
            break;
            
        case "1":
            
            mobileNo.style.display = "none";
            service_pwd2.style.display = "none";
            userName.style.display = "";
            userPsw.style.display = "";
            break;
    }
}

function s_agr_onclick(){
	var c = document.getElementById("s_biz_agreement");
	var b = document.getElementById("s_agr_but");
	if(c.checked){
		b.disabled = "";
	}else{
		b.disabled = "disabled";
	}
}

function s_agr_submit(){
	var url = "/services/function?action=SignedAgreement";
	var handleSuccess = function(response){
		if(response.result){		
			document.getElementById('_s_agreement').disabled= "none";
			document.getElementById('_s_agreement').checked= "checked";
			document.getElementById('_s_agreement_info').innerHTML= "尊敬的用户您已<a href=\"/service/agreement.shtml\" target=\"_blank\">阅读</a>并接受业务办理协议";
			location.reload();
		}
	};
	var handleFail = function(response){};
	//请求参数
	var handlePostData = {};
	//请求
	common_send_ajax(url,handlePostData,true,handleSuccess,handleFail);
}//end function

function h_login_info(d){
	var i = document.getElementById(d);
	var l = GetCookie("id");
	var c = "";
	if(l == null){
		c += "<p><img src=\"http://www.99hr.net/images/h_announce_shop.gif\" align=\"absmiddle\" border=\"0\" />&nbsp;<a href=\"javascript:void(0);\" class=\"a:hover\" onclick=\"showorhide('pop_filter_login','pop_login');\">登录</a> &nbsp;&nbsp;&nbsp;&nbsp;<a href=\"javascript:void(0);\" class=\"a:hover\" onclick=\"showorhide('pop_filter_loginA','pop_loginA');\">注册</a></p>";
		c += "";
	}
	else
	{
		c+="<p><img src=\"http://demo.99hr.net/images/h_announce_shop.gif\" align=\"absmiddle\" border=\"0\" />&nbsp;<a href=\"javascript:void(0);\" class=\"a:hover\" onclick=\"Default.aspx?Logout\">登出</a> &nbsp;&nbsp;&nbsp;&nbsp;</p>";
		c+="<p><img src=\"http://demo.99hr.net/images/h_announce_shop.gif\" align=\"absmiddle\" border=\"0\" />&nbsp;<a href=\"javascript:void(0);\" class=\"a:hover\" onclick=\"Default.aspx?CDR\">通话记录</a> &nbsp;&nbsp;&nbsp;&nbsp;<a href=\"javascript:void(0);\" class=\"a:hover\" onclick=\"showorhide('pop_filter_passwd','pop_passwd');\">密码修改</a></p>";
	}
	i.innerHTML = c;
}

//=========================cookie 操作=============================
//设置Cookie
function SetCookie(name, value, expires, path, domain, secure) 
{ 
  var today = new Date();
  today.setTime(today.getTime()); 
  if(expires) { expires *= 86400000; } 
  var expires_date = new Date(today.getTime() + (expires));    
  document.cookie = name + "=" + escape(value) + (expires ? ";expires=" + expires_date.toGMTString() : "")    + (path ?";path=" + path : "")    + (domain ? ";domain=" + domain : "")    + (secure ? ";secure" : "");
}
 
//获取Cookie
function GetCookie(name) 
{  
 var cookies = document.cookie.split(';');  
 var cookie = ''; 
 for(var i=0; i<cookies.length; i++)
  {   
   cookie = cookies[i].split('='); 
   if(cookie[0].replace(/^\s+|\s+$/g, '') == name)
    { 
     return (cookie.length <= 1) ? "" : unescape(cookie[1].replace(/^\s+|\s+$/g, '')); 
    }
  }
 return null;
}
 
//删除Cookie
function DelCookie(name, path, domain) 
{  
	document.cookie = name + "=" + (path ? ";path=" + path : "") + (domain ? ";domain=" + domain : "") + ";expires=Thu,01-Jan-1970 00:00:01 GMT";
}

function cookieEnabled()
{
  return (navigator.cookieEnabled)? true : false;
}
//============================cookie 操作结束=================

/*===================================20081218 添加：json.js===========================*/
if (!this.JSON) {

// Create a JSON object only if one does not already exist. We create the
// object in a closure to avoid global variables.

    JSON = function () {

        function f(n) {
            // Format integers to have at least two digits.
            return n < 10 ? '0' + n : n;
        }

        Date.prototype.toJSON = function (key) {

            return this.getUTCFullYear()   + '-' +
                 f(this.getUTCMonth() + 1) + '-' +
                 f(this.getUTCDate())      + 'T' +
                 f(this.getUTCHours())     + ':' +
                 f(this.getUTCMinutes())   + ':' +
                 f(this.getUTCSeconds())   + 'Z';
        };

        var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
            escapeable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
            gap,
            indent,
            meta = {    // table of character substitutions
                '\b': '\\b',
                '\t': '\\t',
                '\n': '\\n',
                '\f': '\\f',
                '\r': '\\r',
                '"' : '\\"',
                '\\': '\\\\'
            },
            rep;


        function quote(string) {

// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.

            escapeable.lastIndex = 0;
            return escapeable.test(string) ?
                '"' + string.replace(escapeable, function (a) {
                    var c = meta[a];
                    if (typeof c === 'string') {
                        return c;
                    }
                    return '\\u' + ('0000' +
                            (+(a.charCodeAt(0))).toString(16)).slice(-4);
                }) + '"' :
                '"' + string + '"';
        }


        function str(key, holder) {

// Produce a string from holder[key].

            var i,          // The loop counter.
                k,          // The member key.
                v,          // The member value.
                length,
                mind = gap,
                partial,
                value = holder[key];

// If the value has a toJSON method, call it to obtain a replacement value.

            if (value && typeof value === 'object' &&
                    typeof value.toJSON === 'function') {
                value = value.toJSON(key);
            }

// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.

            if (typeof rep === 'function') {
                value = rep.call(holder, key, value);
            }

// What happens next depends on the value's type.

            switch (typeof value) {
            case 'string':
                return quote(value);

            case 'number':

// JSON numbers must be finite. Encode non-finite numbers as null.

                return isFinite(value) ? String(value) : 'null';

            case 'boolean':
            case 'null':

// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.

                return String(value);

// If the type is 'object', we might be dealing with an object or an array or
// null.

            case 'object':

// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.

                if (!value) {
                    return 'null';
                }

// Make an array to hold the partial results of stringifying this object value.

                gap += indent;
                partial = [];

// If the object has a dontEnum length property, we'll treat it as an array.

                if (typeof value.length === 'number' &&
                        !(value.propertyIsEnumerable('length'))) {

// The object is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.

                    length = value.length;
                    for (i = 0; i < length; i += 1) {
                        partial[i] = str(i, value) || 'null';
                    }

// Join all of the elements together, separated with commas, and wrap them in
// brackets.

                    v = partial.length === 0 ? '[]' :
                        gap ? '[\n' + gap +
                                partial.join(',\n' + gap) + '\n' +
                                    mind + ']' :
                              '[' + partial.join(',') + ']';
                    gap = mind;
                    return v;
                }

// If the replacer is an array, use it to select the members to be stringified.

                if (rep && typeof rep === 'object') {
                    length = rep.length;
                    for (i = 0; i < length; i += 1) {
                        k = rep[i];
                        if (typeof k === 'string') {
                            v = str(k, value, rep);
                            if (v) {
                                partial.push(quote(k) + (gap ? ': ' : ':') + v);
                            }
                        }
                    }
                } else {

// Otherwise, iterate through all of the keys in the object.

                    for (k in value) {
                        if (Object.hasOwnProperty.call(value, k)) {
                            v = str(k, value, rep);
                            if (v) {
                                partial.push(quote(k) + (gap ? ': ' : ':') + v);
                            }
                        }
                    }
                }

// Join all of the member texts together, separated with commas,
// and wrap them in braces.

                v = partial.length === 0 ? '{}' :
                    gap ? '{\n' + gap +
                            partial.join(',\n' + gap) + '\n' +
                            mind + '}' :
                          '{' + partial.join(',') + '}';
                gap = mind;
                return v;
            }
        }


// Return the JSON object containing the stringify and parse methods.

        return {
            stringify: function (value, replacer, space) {

// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.

                var i;
                gap = '';
                indent = '';

// If the space parameter is a number, make an indent string containing that
// many spaces.

                if (typeof space === 'number') {
                    for (i = 0; i < space; i += 1) {
                        indent += ' ';
                    }

// If the space parameter is a string, it will be used as the indent string.

                } else if (typeof space === 'string') {
                    indent = space;
                }

// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.

                rep = replacer;
                if (replacer && typeof replacer !== 'function' &&
                        (typeof replacer !== 'object' ||
                         typeof replacer.length !== 'number')) {
                    throw new Error('JSON.stringify');
                }

// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.

                return str('', {'': value});
            },


            parse: function (text, reviver) {

// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.

                var j;

                function walk(holder, key) {

// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.

                    var k, v, value = holder[key];
                    if (value && typeof value === 'object') {
                        for (k in value) {
                            if (Object.hasOwnProperty.call(value, k)) {
                                v = walk(value, k);
                                if (v !== undefined) {
                                    value[k] = v;
                                } else {
                                    delete value[k];
                                }
                            }
                        }
                    }
                    return reviver.call(holder, key, value);
                }


// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.

                cx.lastIndex = 0;
                if (cx.test(text)) {
                    text = text.replace(cx, function (a) {
                        return '\\u' + ('0000' +
                                (+(a.charCodeAt(0))).toString(16)).slice(-4);
                    });
                }

// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.

// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.

                if (/^[\],:{}\s]*$/.
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {

// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.

                    j = eval('(' + text + ')');

// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.

                    return typeof reviver === 'function' ?
                        walk({'': j}, '') : j;
                }

// If the text is not JSON parseable, then a SyntaxError is thrown.

                throw new SyntaxError('JSON.parse');
            }
        };
    }();
}


// Augment the basic prototypes if they have not already been augmented.
// These forms are obsolete. It is recommended that JSON.stringify and
// JSON.parse be used instead.

if (!Object.prototype.toJSONString) {
    Object.prototype.toJSONString = function (filter) {
        return JSON.stringify(this, filter);
    };
    Object.prototype.parseJSON = function (filter) {
        return JSON.parse(this, filter);
    };
}

/**
	功能：查询某个业务是否b2m业务，并且是否第一次登陆办理b2m
	t：回调方法类型
	b2m: 显示下发短信输入框
*/
function query_is_b2m_biz(bizCode,t){
	var url = "/services/function?action=IsB2MBiz&BizCode="+bizCode;
	var handleSuccess = function(response){
		var b_r = response.result;
		_userMobileNumber = response.UserMobile;
		
		if(t == 'b2m'){//显示随机短信输入框
			if(b_r){
				show_biz_b2m('biz_op_expand2')//div ID，用扩展标签1
			}	
		}
	};
	var handleFail = function(response){};
	//请求参数
	var handlePostData = {};
	//请求
	common_send_ajax(url,handlePostData,true,handleSuccess,handleFail);
}

/**
  功能：显示b2m办理业务输入的随机短信码框
*/
function show_biz_b2m(b2m_id){
	var c = "<table width='80%'>";
	c += "<tr>";
	c += "<td class='blue_01' align='center'><span class='blue_01'>随机短信密码：</span>";
	c += "<input type='text' class='text_01' id='_bbc_rsmsRND' onfocus=\"shover(this,'text_01_02')\" onblur=\"shover(this,'text_01')\" />";
	c += "<button class='btn_blue'  onmouseover=\"shover(this,'btn_blue_02')\" onmouseout=\"shover(this,'btn_blue')\" onClick=\"sendSMSRnd('B2MSMS','/services/SMSRndSend')\" >获取随机短信密码</button></td>";
	c += "</tr>";
	c += "</table>";
             
	document.getElementById(b2m_id).innerHTML = c;
}

/**
 功能：隐藏b2m随机短信输入框
*/
function hide_b2m_sms(){
	document.getElementById("biz_op_expand2").style.display='none';
}

/**
 功能：显示b2m随机短信输入框
*/
function display_b2m_sms(){
	document.getElementById("biz_op_expand2").style.display = "";
}

/**
 功能：检查b2m随机短信是否正确
*/
function is_bbc_RndSms(){
		try{
			s_rsms_code = document.getElementById('_bbc_rsmsRND').value;
			var v = new SunRise.Validate();
			if (s_rsms_code == "") {
		     	return '1';
		    }
		    if (!v.isNumber(s_rsms_code)) {
		        return '2';
		    }
		    return '0';
	    }catch(e){
	    	//不存在_bbc_rsmsRND导致出错
	    	s_rsms_code='';
	    	return '0';
	    }
}

 /**
 功能：b2m随机短信检查提示
*/
function check_b2m_sms(){
    var s_sms=is_bbc_RndSms();
    if(s_sms=='1'){
    	show_message('biz_op_message',"尊敬的客户：随机验证码不能为空，请重新输入！",false);
    	return false;
    }else if(s_sms=='2'){
    	show_message('biz_op_message',"尊敬的客户：随机验证码只能为数字，请重新输入！",false);
    	return false;
    }else{
    	return true;
    }
}
/*
 * choose DL100 login way 
 * @param {Object} _tp 
 * @param {Object} _u
 * @param {Object} _p
 */
function _choose_ec_lg_tp(_tp,_u,_p){ 
	var o_u=document.getElementById(_u);
	var o_p=document.getElementById(_p);
	if(_tp=='2'){ 
		o_u.innerHTML = "手机号码：";
		o_p.innerHTML = "服务密码：";
	}
	if(_tp=='5'){  
		o_u.innerHTML = "用 户 名：";
		o_p.innerHTML = "密&nbsp;&nbsp;&nbsp;&nbsp;码：";
	} 
} 
/*
 * DL100 login check
 * @param {Object} _tp 登陆方式ID
 * @param {Object} _u 手机号码ID
 * @param {Object} _p 服务密码ID
 * @param {Object} _cd 图形校验码 
 * @param {Object} m  信息提示ID
 * @param {Object} b 登陆按钮ID
 * @param {Object} reb 密码重置按扭 
 * @param {Object} _fm 表单的ID
 */
function _check_ec_lg(_tp,_u,_p,_cd,m,b,reb,_fm){    	
  var _logonName=document.getElementById(_u).value;   
  var _password=document.getElementById(_p).value; 
  var _imageCode=document.getElementById(_cd).value;  
    
  var _lgty=document.getElementById(_tp).value;//登陆类型   
  var _lem = document.getElementById(m);
	 
    var v = new SunRise.Validate(); 
    if(_lgty=='2'){//mobile+password 
	  	if (_logonName == "") {
	        _lem.innerHTML = "请输入手机号码!";
	        return false;
	    } 
	    if (!v.isMobile(_logonName)) {
	        _lem.innerHTML = "请输入正确的手机号,必须是中国移动号码!";
	        return false;
	    } 
    }
    if(_lgty=='5'){// ecname+ecpasswd
	  	if (_logonName == "") {
	        _lem.innerHTML = "请输入用户名!";
	        return false;
	    }  
    }
   if(_password == '' || _password.length<6){
	    _lem.innerHTML = "请输入正确的密码!";
	    return false;
    }     
    if(_imageCode == '' || _imageCode == '点击输入'||_imageCode.length!=4){
	    _lem.innerHTML = "请输入正确的验证码!";
		return false;
    } 
    var _sb = document.getElementById(b); 
    var _fp = document.getElementById(reb); 
    _sb.disabled = true; 
   // _fp.disabled = true;alert(7);
  
    _lem.innerHTML = "正在登陆中，请稍候......";
    //document.getElementById(_fm).method="post";
	//document.getElementById(_fm).action="/group/register"; 
	//  alert(document.getElementById(_fm));
	 
	var _dl100fm=eval("document.forms."+_fm); 
    _dl100fm.submit()
}
//updateLoginType.jsp
function _p_update_login_type(n){
	var p = 0;
	var t = "";
	var u=document.getElementById('_p_backUrl').value; 
	var _lem = document.getElementById("_p_message");  
	var o = "";
	if(n == 1 ){
		t = "随机短信密码"; 
		p = document.getElementById("_p_update_smsrnd").value; 
		o = "checksms";
	}else{
		t = "服务密码"; 
		p = document.getElementById("_p_pwd_update_logintype").value; 
		o = "checkpwd";
	}
	
	var v1 = new SunRise.Validate();
	var v = function(p){
        if (p == "") {
            _lem.innerHTML ="<img src=\"/v2008/images/public/icon_wrong.gif\" /> <b class=\" red_01\"> "+ t+"不能为空</b>";
            return false;
        }
        if (!v1.isNumber(p)) {
            _lem.innerHTML ="<img src=\"/v2008/images/public/icon_wrong.gif\" /> <b class=\" red_01\"> "+ t+"必须为数字</b>";
            return false;
        }
        return true;
    }
	
	if(!v(p)){
		return;
	}
	
	var url = "/ServicesServlet/UPDATE_LOGIN_TYPE";
	var d=document.getElementById('_p_table');
	if(d != null){
		_lem.innerHTML = "正在验证中，请稍候......";
		var bs = d.getElementsByTagName("button");
		for(var i=0;i<bs.length;i++){
			bs[i].disabled = "disabled";
		}
	}
	
	var handlePostData = {
        operation: o, 
		checkstr:p
    };
	
	var handleSuccess = function(o){ 
		 top.location.href=u;
    };
	
	var handleFail = function(o){ 
	    _lem.innerHTML = "<img src=\"/v2008/images/public/icon_wrong.gif\" /> <b class=\" red_01\"> "+ o.message +"</b>"; 
		if(d != null){
			var bs = d.getElementsByTagName("button");
			for(var i=0;i<bs.length;i++){
				bs[i].disabled = "";
			}
		}
    };	 
	common_send_ajax(url,handlePostData,true,handleSuccess,handleFail); 
}

function sendBosstestSMS(m,c){
	var url = "/bosstest/Sendsms.jsp";
	var handlePostData = {
		mobile:m,
		content:c
	}
	var handleSuccess = function(o){
		alert("短信已经成功发送，请注意查收！");
	}
	
	var handleFail = function(o){ 
		alert("短信发送失败，请稍后再试！");
	}
	common_send_ajax(url,handlePostData,true,handleSuccess,handleFail); 
}
