var domain = "";

function getCookie(name) {
	var allcookies = document.cookie;
	var cookie_pos = allcookies.indexOf(name);
	var value = "";
	if (cookie_pos != -1) {
		cookie_pos += name.length + 1;
		var cookie_end = allcookies.indexOf(";", cookie_pos);
		if (cookie_end == -1) {
			cookie_end = allcookies.length;
		}
		value = unescape(allcookies.substring(cookie_pos, cookie_end));
	}
	return value;
}

function stateInfo(state,name){
	var info
	if(state==0){
		info="<h3 id=\"h4\">欢迎使用纽顿兰呼叫中心</h3>";
		info+="<div style=\"margin-top:-20px;width:100%;border-bottom:1px solid #E5E5E5;margin-bottom:5px;height:24px;line-height:24px;\">您好，请先登陆！</div>";
		info+="<form  id=\"login\" method=\"POST\" action=\"/vcc_self_service/account/authUser.do\" target=\"_blank\" onsubmit=\"return submitForm()\">";
		info+="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
		info+="<tr height=\"28\">";
		info+="<td align=\"left\" width=\"38\">帐号:</td>";
		info+="<td align=\"left\"><input type=\"text\" name=\"user.name\" maxlength=\"20\" tabindex=\"1\" value=\"\" id=\"user.name\" style=\"ime-mode: disabled;width:140px;height:19px;border:1px solid #D2D2D2;\" ></td>";
		info+="</tr>";
		info+="<tr height=\"28\">";
		info+="<td align=\"left\">密码:</td>";
		info+="<td align=\"left\"><input type=\"password\" name=\"user.password\" maxlength=\"16\" tabindex=\"2\" value=\"\" id=\"user.password\" style=\"width:140px;height:19px;border:1px solid #D2D2D2;\"><a href=\"javascript:alert('请与客服联系，客服热线：400-679-0060 ');\">&nbsp;忘记密码？</a></td>";
		info+="</tr>";
		info+="<tr>";
		info+="<td></td>";
		info+="<td align=\"left\" height=\"48\" valign=\"middle\">";
		info+="<ul id=\"user_ul\"><li><input type=\"submit\"  value=\"\" class=\"login_but\"/></li>";
		info+="<li><a href=\"http://www.51vcc.com/vcc_self_service/account/register.do\" target=\"_blank\"><img src=\"images/vcc_zzz_10.jpg\"  /></a></li></ul>";					
		info+="</td>";
		info+="</tr>";
		info+="</table>";
		info+="</form>";
	}
	else{
		info="<h3 id=\"h4\">欢迎使用纽顿兰呼叫中心</h3>";
		info+="<span id=\"logout\">";
		info+="您好，<font>"+name;
		info+="</font> [<a href=\"http://www.51vcc.com/vcc_self_service/account/logout.do\">退出</a>]";
		info+="</span>";
		info+="<a href=\"http://www.51vcc.com/vcc_self_service/jsp/frame.jsp\" target=\"_blank\" ><img src=\"images/vcc_regsuc_14.jpg\" style=\"margin-top:12px;\"/></a>";
	}
	return info;
}

function stateInfo1(state,name){
	 var info;
	 if(state==0){
		 info="<h3 id=\"h1\">纽顿兰后台管理</h3>";
		 info+="	欢迎您，请先登录！<br />";
		 info+="<div id=\"loginzone\">";
		 info+="<form  id=\"login\" method=\"POST\" action=\"/vcc_self_service/account/authUser.do\"  target=\"_blank\" onsubmit=\"return submitForm()\">";
		 info+="<input type=\"hidden\" name=\"needValidCode\" value=\"false\" id=\"needValidCode\">";
		 info+="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
		 info+=" <tr height=\"28\">";
		 info+="<td>帐号:</td>";
		 info+="<td align=\"left\"><input type=\"text\"  name=\"user.name\" tabindex=\"1\" value=\"\" id=\"user.name\" style=\"ime-mode: disabled;width:140px;height:19px;border:1px solid #D2D2D2;\" ></td>";
		 info+="</tr>";
		 info+=" <tr height=\"28\">";
		 info+="<td>密码:</td>";
		 info+="<td align=\"left\"><input type=\"password\" name=\"user.password\" tabindex=\"2\" value=\"\" id=\"user.password\" style=\"width:140px;height:19px;border:1px solid #D2D2D2;\"></td>";
		 info+="</tr>";
		 info+="<tr>";
		 info+="<td></td>";
		 info+="<td align=\"left\"><a href=\"javascript:alert('请与客服联系，客服热线：400-679-0060 ');\">忘记密码？</a></td>";
		 info+="</tr>";
		 info+="<tr>";
		 info+="<td></td>";
		 info+="<td align=\"left\">";
		 info+="<div id=\"login_div_s\"><div style=\"padding-top:10px;\"><input type=\"submit\" value=\"\" class=\"login_but\"/></div>";
		 info+="<div><a href=\"http://www.51vcc.com/vcc_self_service/account/register.do\" target=\"_blank\"><img src=\"images/vcc_shopol_22.jpg\" /></a></div></div>";
		 info+="</td>";
		 info+="</tr>";
		 info+="</table>";
		 info+="</form>";
		 info+="</div>";
	 }
	 else{
		 info="<h3 id=\"h2\">欢迎使用纽顿兰呼叫中心</h3>";
		 info+="<span id=\"logout\">";
		 info+="您好，<font>"+name;
		 info+="</font>[<a href=\"http://www.51vcc.com/vcc_self_service/account/logout.do\">退出</a>]";
		 info+="</span>";
		 info+="<a href=\"http://www.51vcc.com/vcc_self_service/jsp/frame.jsp\" target=\"_blank\" ><img src=\"images/vcc_regsuc_14.jpg\"/></a>";
	 }
	 return info;
}
function stateInfo2(state,name){
	var info="";
	if(state==0){
		info+="您好，请 <a href=\"http://www.51vcc.com/vcc_self_service/account/register.do\" target=\"_blank\">注册新帐号</a> 或 <a href=\"http://www.51vcc.com/vcc_self_service/jsp/frame.jsp \" target=\"_blank\">登录</a>"
	}
	else{
	  	 info+="您好，"+name;
		 info+=" [<a href=\"http://www.51vcc.com/vcc_self_service/jsp/frame.jsp\">自助平台</a>]  [<a href=\"http://www.51vcc.com/vcc_self_service/account/logout.do\">退出</a>]";
	}
	return info;
}
function initState(){
	var username = getCookie("vcc_name");
	var label_user =  document.getElementById("maincon_m_r_m"); 
	if(username != ""){
		label_user.innerHTML = stateInfo(1,username);
	}else{
		label_user.innerHTML = stateInfo(0,"");
	}
}
function initState1(){
	var username = getCookie("vcc_name");
	var label_user =  document.getElementById("userzone_m"); 
	if(username != ""){
		label_user.innerHTML = stateInfo1(1,username);
	}else{
		label_user.innerHTML = stateInfo1(0,"");
	}
}
function initState2(){
	var username = getCookie("vcc_name");
	var label_user =  document.getElementById("top_hotline_r"); 
	if(username != ""){
		label_user.innerHTML = stateInfo2(1,username);
	}else{
		label_user.innerHTML =stateInfo2(0,"");
	}
}
function getParameter(name){
    var url=window.location.href;
	var paramValue;
	var params=url.split(/\?|\&/);
	for(var i=0;i<params.length;i++){
		if(params[i].indexOf(name)!=-1){
			paramValue=params[i].substring(params[i].indexOf('=')+1);
			break;
		}
	}
	return paramValue;
} 
function initCase(paramName){
	var index=getParameter('index');
	if(index==null)
		$("#casebtn").click();
	if(index==1)
		$("#casebtn").click();
	if(index==2)
	    $("#case2btn").click();
	if(index==3)
	    $("#case3btn").click();
}
