﻿var cnMenu      =["义务咨讯","销售推广","广告宣传","客户管理","重要报告","系统设定","信息交流","人员管理","资源预定","My车易","工单管理","大众龙卡","cae"];
var menuArray   =["training","sales_promotion","advertising","hot_sales_leads","report","content","info_exchange","person_admin","book_source","mye","as","svw_card","cae"];

if(getRight()==1){//rssc
    cnMenu      =["义务咨讯","销售推广","广告宣传","客户管理","重要报告","信息交流","人员管理","现场代表","大众龙卡"];
    menuArray   =["training","sales_promotion","advertising","hot_sales_leads","report","info_exchange","person_admin","live_report","svw_card"];
}
if(getRight()==2){//excom
    cnMenu      =["义务咨讯","销售推广","广告宣传","客户管理","重要报告","信息交流","人员管理","现场代表","商铺管理"];
    menuArray   =["training","sales_promotion","advertising","hot_sales_leads","report","info_exchange","person_admin","live_report","protype"];
}
if(getRight()==3){//rsscrep
    cnMenu      =["义务咨讯","销售推广","广告宣传","重要报告","信息交流","现场代表"];
    menuArray   =["training","sales_promotion","advertising","report","info_exchange","live_report"];
}

if(getRight()==5){//psi
    cnMenu.push("销售信息");
    menuArray.push("sales_information");
}

if(getRight()==6 || getRight()==7 || getRight()==8 || getRight()==9 || getRight()==13 || getRight()==15 || getRight()==18 || getRight()==19 || getRight()==20 ||  getRight()==21 ){//sst
	cnMenu      =["义务咨讯","销售推广","广告宣传","信息交流"];
	menuArray   =["training","sales_promotion","advertising","info_exchange"];

    cnMenu.push("工单管理");
    menuArray.push("as");
}

if(getRight()==10){//provider
    cnMenu      =["义务咨讯","广告宣传","商铺管理"];
    menuArray   =["training","advertising","protype"];
}

if(getRight()==11){//prom
    cnMenu      =["义务咨讯","销售推广","广告宣传","重要报告","商铺管理","人员管理","资源预定","系统设定","大众龙卡"];
    menuArray   =["training","sales_promotion","advertising","report","protype","person_admin","book_source","content","svw_card"];
}
if(getRight()==14){//commissioner
    cnMenu      =["义务咨讯","销售推广","广告宣传","客户管理","重要报告","信息交流","人员管理","现场代表","大众龙卡"];
    menuArray   =["training","sales_promotion","advertising","hot_sales_leads","report","info_exchange","person_admin","live_report","svw_card"];
}



var l=menuArray.length;
var url=location.href;

function isIE() { return (navigator.appName == "Microsoft Internet Explorer"); }

function getSectionStr(testURL){
    if(typeof testURL=="undefined") testURL=url
	pattern=/(\/+)(.+)(\/+)(.*)$/
	pattern.test(testURL)
	realstr=RegExp.$2
	realstr=realstr.substring(realstr.lastIndexOf("/")+1)
	return realstr
}

function drawLeftMenu(){
	var str='<table id="leftMenu" cellspacing="0" align="left">'
//	str+='<tr><td><img src="../images/logo.gif" width="165" height="85" border="0" alt="Logo" /></td></tr><tr><td>&nbsp;</td></tr>'
	for(i=0;i<l;i++){
		str+='<tr><td>'
		str+='<a href="../'+menuArray[i]+'/index.htm">'
		if(menuArray[i]==getSectionStr()) imgsrc=menuArray[i]+"a" //黑色图片显示当前栏目
		else imgsrc=menuArray[i]
		str+='<img src="../images/leftmenu/'+imgsrc+'.gif" width="165" height="25" alt="'+menuArray[i]+'" border="0" />'
		str+='</a></td></tr>'
	}
	str+='</table>'
	document.write(str)
}


function getTitleImg(){
	realstr='<div style="position:relative"><img src="../images/'+getSectionStr()+'_title.gif" alt="'+realstr+'" />'
	realstr+=getHisUrl()
	realstr+='</div>'
	document.write(realstr)
}

function drawRightMenu(curArray){
	var l2=curArray.length
	var str="";padding="&nbsp;&nbsp;"
	for(i=0;i<l2;i++){
		name=curArray[i][0]
		path=curArray[i][1]
		depth=curArray[i][2]

		for(j=0;j<depth;j++) padding+="&nbsp;&nbsp;" 

		if(path==0){
			path="javascript:"
			if(depth==0) style=getSectionStr()+"_menuTitle"
			else style=getSectionStr()+"_nourl"
		}
		else{
			path=path+".htm"
			if(depth==0) style=getSectionStr()+"_menuTitle"
			else style=getSectionStr()+"_normal"
		}

		if(name=="在线测试" && depth==1){
			str+='<a href="'+path+'" class="'+style+'" target="_blank">'+padding+name+'</a>'
		}
		else{
			str+='<a href="'+path+'" class="'+style+'">'+padding+name+'</a>'
		}		
		padding="&nbsp;&nbsp;";
	}
	str+='<div style="margin-top:110px;background:#BBBBBB">&nbsp;&nbsp;最后更新时间</div>'
	str+='<div style="margin:5px 0 25px 0;">&nbsp;&nbsp;'+document.lastModified+'</div>'
	document.write (str)
}

function getNowDate(){
	var nowdate=new Date()
	var yy=nowdate.getYear()
	var mm=nowdate.getMonth()+1
	var dd=nowdate.getDate()
	var hh=nowdate.getHours()
	var mi=nowdate.getMinutes()
	var se=nowdate.getSeconds()
	showdate=yy+"/"+mm+"/"+dd+" "+hh+":"+mi+":"+se
	return showdate
}
function goTop(bg){
	var str="";
	str+='<a href="#" class="'+bg+' goTop">'
	str+='回到顶部'
	str+='&nbsp;<img src="../images/totoparrowa.gif" border="0" />&nbsp;&nbsp;&nbsp;</a>'
	document.write(str)
}

function goBack(bg){
	var str="";
	str+='<a href="#" class="'+bg+' goTop">'
	str+='回到顶部'
	str+='&nbsp;<img src="../images/totoparrowa.gif" border="0" />&nbsp;&nbsp;&nbsp;</a>'
	document.write(str)
}

function goBack1(bg){
	var str="";
	str+='<a href="#" class="'+bg+' goTop">'
	str+='回到顶部'
	str+='&nbsp;<img src="../images/totoparrowa.gif" border="0" />&nbsp;&nbsp;&nbsp;</a>'
	document.write(str)
}

function goBack2(bg){
	var str="";
	str+='<a href="../cen_sustain/index.htm" class="'+bg+' goTop">'
	str+='返回'
	str+='&nbsp;<img src="../images/totoparrowa.gif" border="0" />&nbsp;&nbsp;&nbsp;</a>'
	document.write(str)
}

function showTab(obj){
	html=document.getElementById(obj).innerHTML
	document.getElementById("righTab").innerHTML=html
} 

function GetText(url){
    if (window.XMLHttpRequest) target=new XMLHttpRequest();// Gecko
    else if(window.ActiveXObject) target=new ActiveXObject("MsXml2.XmlHttp");//IE
	url=(url.indexOf("?")==-1) ? url+"?rdn="+Math.random() : url+"&rdn="+Math.random();
	target.open("GET", url, false)
	target.send(null)
	if(target.status!=200) document.write("XML request error: " + target.statusText + " (" + target.status + ")")
	else document.write(target.responseText)

	//else document.write("<p style='color:red;font-weight:bold;text-align:center'>对不起，访问失败！<br />该页面采用了XMLHTTP读取文章内容，您的浏览器不支持此ActiveXObject，请使用IE5+版本的浏览器！</p>")
}

function textList(inputArray,detail){
	var str='<ul id="text">'
	for(i=0;i<inputArray.length;i++){
		str+='<li><a href="'+detail+'.htm?id='+i+'">'+inputArray[i]
		str+='</a></li>'
	}
	str+='</ul>'
	document.write(str)
}

function getArgument(argu){
	if(url.indexOf("#")==-1) urlstr=url.substring(url.indexOf("?")+1).split("&");
	else urlstr=url.substring(url.indexOf("?")+1,url.indexOf("#")).split("&");

	var arguValue="";

	for(i=0;i<urlstr.length;i++){
		if(urlstr[i].indexOf(argu+"=")!=-1){
			subCell=urlstr[i].split("=");
			arguValue=subCell[1];
		}
	}
	return arguValue
}

function getArgu(){
	pattern=/id=(\d+)/
	pattern.test(url)
	argu=RegExp.$1

	p2=/\d+/
	r=p2.test(argu)
	if(!r) argu=0
	return argu
}

function getColNo(){
    p=url.lastIndexOf(".htm")
    if (p==-1){
        colno=0;
        return colno;
    }
    colno=url.substring(p-1,p)
    colno-=0;
    return colno
}

function getPage(){
	pattern=/curpage=(\d+)/
	pattern.test(url)
	argu=RegExp.$1

	p2=/\d+/
	r=p2.test(argu)
	if(!r) argu=1
	return argu
}

/*function getHisUrl(){
    
   if(url.lastIndexOf("/training/")!=-1){
       if(url.lastIndexOf("/training/sal_")==-1 && url.lastIndexOf("/training/faq_")==-1 && url.lastIndexOf("/training/info_")==-1 && url.lastIndexOf("/training/gd_")==-1){
            str=url.substring(url.lastIndexOf("/")+1)
            str=str.indexOf("_")
        }
        else{
            str=url.substring(url.lastIndexOf("/")+1)
            str=str.replace("_","")
            str=str.indexOf("_")
        }
    }
    else{
        str=url.substring(url.lastIndexOf("/")+1)
        str=str.replace("_","")
        str=str.indexOf("_")
    }

	if(str!=-1){
		p=url.lastIndexOf("_")
		backurl=url.substring(0,p)+".htm"
		if(url.lastIndexOf("detail")!=-1) backurl="javascript:history.back()"
		html='<div id="getback">'
		html+='<a href="'+backurl+'" class="subtitle">←返回'
		html+='</a></div>'
	}
	else html=""
    str=url.substring(url.lastIndexOf("/")+1);
    //str=str.replace("_","");
    str=str.indexOf("_");

    if(str!=-1){
        backurl="javascript:history.back();"
        html='<div id="getback">'
        html+='<a href="'+backurl+'" class="subtitle" id="backurl">←返回'
        html+='</a></div>'
    }
    else html=""

	return html
}*/

function getHisUrl(){
    var ifIndex=((url.lastIndexOf("index")!=-1) || ((url.lastIndexOf("/")+1)==url.length));//栏目首页
    if(!ifIndex){
        backurl="javascript:history.back();"
        html='<div id="getback">'
        html+='<a href="'+backurl+'" class="subtitle" id="backurl">←返回'
        html+='</a></div>'
    }
    else html=""
    return html
}

function infoList_DESC(getData,urlargu,pagesize){//倒序显示列表内容
	var curpage=getArgument("curpage");//当前页

	if(curpage=="") curpage=1
	var pro=getData;
    
    var realLength=0
    for(i=0;i<pro.length;i++) {
        if(pro[i]!="") realLength++
    }
    //alert(realLength)

	bList=pro.length-1
	realpages=Math.ceil(realLength/pagesize);
    pages=Math.ceil(pro.length/pagesize);


	if (curpage==1 && realpages==1){
		proid=bList;
		proNo=-1;
	}
	else {
		if (curpage!=realpages){
			proid=bList-curpage*pagesize+pagesize;
			proNo=proid-pagesize;
		}
		else{
			proid=bList-pagesize*(curpage-1);
			proNo=-1; 
		}
	}
    if(urlargu.indexOf("?")!=-1) suf="&";
    else suf="?";

	tab1='<div id="showpages">页码：| ';
	for(i=1;i<=realpages;i++) {
        if(url.indexOf("?")!=-1) {
            pattern=/&curpage=(\d+)/;
		    url=url.replace(pattern,"")+"&curpage="+i;
        }
        else{
            pattern=/\?(curpage=)(\d+)/;
		    url=url.replace(pattern,"")+"?curpage="+i;
        }

		if(curpage==i) tab1+='<b>'+i+'</b> | ';
		else tab1+='<a href="'+url+'">'+i+'</a> | ';
	}
	tab1+='</div>'
	//if(realpages==1) tab1="";
  	var str=tab1+'<ul id="text">'
	for(i=proid;i>proNo;i--){
        if(i>=0 && pro[i]!=""){
            href=urlargu+suf+'id='+i;
            str+='<li><a href="'+href+'">'+pro[i]
            str+='</a></li>'
        }
	}
	str+='</ul>'
	str+=tab1
	document.write(str)
}

function winpop(url,popname){ //open Popwin
	if(typeof popname=="undefined") popname="pop"
	var popwidth=600;popheight=450 //defind the size of the popwin
	poptop=(screen.availHeight-popheight)/2
	popleft=(screen.availWidth-popwidth)/2
	var oWin=window.open(url,popname,"width="+popwidth+",height="+popheight+",scrollbars=yes,top="+poptop+",left="+popleft)
	oWin.focus()
}

function drawFlash(width,height,src,wmode){//flash
	/*
		width:	宽度
		height:	高度
		src:	Flash路径
		wmode:	0-透明;1-不透明;2-默认值

	*/
	document.writeln('<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="'+width+'" height="'+height+'">')
	document.writeln('<param name="movie" value="'+src+'" />')
	document.writeln('<param name="quality" value="high" />')
	if(wmode==0) {
		document.writeln('<param name="wmode" value="transparent" />')
		componse=' wmode="transparent"'
	}
	if(wmode==1) {
		document.writeln('<param name="wmode" value="opaque" />')
		componse=' wmode="opaque"'
	}
	if(wmode==2) {
		componse=''
	}

	document.writeln('<embed src="'+src+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"'+componse+'></embed>')
	document.writeln('</object>')
}

function tips_pop(tips,maintext,backurl){
    if(tips=="") tips="提示信息"
    if(maintext=="") maintext="信息提交成功!"
    if(backurl=="") backurl="window.opener.history.back()"
    else backurl="window.opener.location='"+backurl+"'"
    openwin=window.open ("","winpop","width=300,height=150");
    openwin.document.write("<html><head>");
	openwin.document.write("<title>Pop Window</title>");
    openwin.document.write('<link href="../scripts/style.css" rel="stylesheet" type="text/css">');
	openwin.document.write('</head>');
	openwin.document.write('<body style="background:white">');
	openwin.document.write('<div class="poptitle">'+tips+'</div>');
	openwin.document.write('<div class="popContent">'+maintext+'</div>');
	openwin.document.write('<div align="center"><input type="button" value="确定" onclick="'+backurl+';self.close()"></div>');
	openwin.document.write('</body>');
	openwin.document.write('</html>');
	openwin.document.close();
	openwin.focus();
 }

var objArray=new Array("showLayer_1","showLayer_2")
function showCalInPage(o,hiddenValue){
	var obj=document.getElementById(o)
	layers=(obj.style.display=="")?1:0;
	setCal('',o,hiddenValue);

	for(i=0;i<objArray.length;i++){
		document.getElementById(objArray[i]).style.display="none";
		document.getElementById(objArray[i]).parentNode.style.zIndex=1;

	}
	if(layers==1) obj.style.display="none"
	else obj.style.display=""
    obj.parentNode.style.zIndex=10;
}

function getLabel(nameArray,linkArray,curLable){
    var html="";
    html+='<table width="100%" cellpadding="8" cellspacing="0" border="0">';
    html+='<tr align="center">';

    for(i=0;i<nameArray.length;i++){
        if(i==nameArray.length-1) oClass="lastTab"
        else oClass="tab"
        if(i==curLable){
            oClass+=" curTab";
            html+='<td class="'+oClass+'">'+nameArray[i]+'</td>'
        }
        else{
            html+='<td class="'+oClass+'"><a href="'+linkArray[i]+'.htm" style="color:red">'+nameArray[i]+'</a></td>';
        }
    }

    html+="</tr></table>"
    document.write(html);
    //alert(html)
}

function getDateSel(y,m,d){
    var html="";
    if(y==1){
        html+='<select style="width:60px">'
        html+='<option>请选择</option>'
        for(i=1940;i<1991;i++) html+='<option value="'+i+'">'+i+'</option>'
        html+='</select> 年 '
    }
    if(y==2){
        html+='<select style="width:60px">'
        html+='<option>请选择</option>'
        for(i=2000;i<2010;i++) html+='<option value="'+i+'">'+i+'</option>'
        html+='</select> 年 '
    }
    if(m==1){
        html+='<select style="width:60px">'
        html+='<option>请选择</option>'
        for(i=1;i<13;i++) html+='<option value="'+i+'">'+i+'</option>'
        html+='</select> 月 '
    }
    if(d==1){
        html+='<select style="width:60px">'
        html+='<option>请选择</option>'
        for(i=1;i<32;i++) html+='<option value="'+i+'">'+i+'</option>'
        html+='</select> 日'
    }
    document.write(html)
}

function setOneDate(datestr,obj){
    var dates=datestr.split(",")
    var dateArray=obj.getElementsByTagName("SELECT");
    for(i=0;i<dateArray.length;i++){
        dateArray[i].value=dates[i]
    }
}

 function checkall(obj){
	for (i=0;i<obj.elements.length;i++){
		var e = obj.elements[i];
		//alert(e.type)
		if (e.type=="checkbox" && e.name != "chkall") e.checked = obj.chkall.checked;
	}
}

/*function setDateCookie(oValue){
    document.cookie="dateRange="+oValue
}

function getDateRagne(cookies){
    if(cookies.indexOf("dateRange")==-1) dateRange="";
    else if(cookies.indexOf("dateRange;")!=-1) dateRange=""
    else dateRange="_"+cookies.substring(cookies.indexOf("dateRange=")+10,cookies.indexOf(";"));
    return dateRange;
}*/

function chgDateSource(id){//载入新数据文件

    var o=document.getElementById(id);
    var sufix=(getCookie("dateRange")==null || getCookie("dateRange")=="")?"":"_"+getCookie("dateRange");
    o.src="../scripts/infodata"+sufix+".js";
}

function setCookie(name,value){//设置COOKIE
    document.cookie=name+"="+value;
}

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) {//取COOKIE值
	if(name == "path" || name == "expires" || name == "domain" || name == "version") name = "badCookieName";

	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;
}
