﻿// JavaScript Document

//获得ID
var gid=function(id)
{
	return document.getElementById?document.getElementById(id):document.all?document.all[id]:document.layers?document.layers[id]:null;
}

//菜单定位触动和子菜单的显示

var isIE=/*@cc_on!@*/0;		//document.all?true:false
var _filename=_filename||location.href.split(location.host+"/")[1].split("#")[0].split("?")[0];

//根据文件名定位菜单变量
var pos_menu_value=function()
{
	//配置菜单值的文件名
	var e=-1,_arr_pos_menu_fname=
	[
		["1.0.aboutmsj.html","1.1.msjhistory.html","1.2.msjfuture.html","1.3.surroundings.html","1.0.|html/news/0/|html/info/0/"],
		["2.1.exhibitioncenter.html","2.2.trainingcenter.html","2.3.innovationcenter.html","2.0.informationcenter.html"],
		["3.0.policies.html","blank","3.2.officebuilding.html","3.3.msjrent.html","olpay.html","4.0.0.1150.html","4.0.1.1150.html","4.0.2.1150.html","4.0.3.1150.html","4.0.4.1150.html","4.0.5.1150.html"],
		["5.0.0.policies.html|html/policies/0/","5.0.1.policies.html|html/policies/1/","5.0.2.policies.html|html/policies/2/"],
		["4.0.msjclub.html","4.1.msjoffice.html","4.2.property.html"],
		["5.0.contactus.html","messageboard.html","map.html","5.2.electronicmap.html"]
	];
	for(var i=0;i<_arr_pos_menu_fname.length;i++)for(var j=0;j<_arr_pos_menu_fname[i].length;j++)for(var n=0,a=_arr_pos_menu_fname[i][j].split("|");n<a.length;n++)if(a[n]==_filename.substr(0,a[n].length))return i+","+j;
	return e;
}

//currentMenuValue默认-1,即为不进行初始定位,大菜单取值范围0~5
var currentMenuValue=pos_menu_value()+",";
var _menu3_chs=gid("m3c").childNodes,_menu2_chs=gid("menu2").childNodes;
var _m3c_over=false;

var _mn_touch=function()
{
	try
	{
		if(isIE)
		{
			if(Math.floor(navigator.userAgent.split("MSIE ")[1].split(";")[0].split(".")[0])<7)
			{
				gid("tcbar").innerHTML="提示：由于我们网站采用最流行的WEB 2.0开发标准，但因您的浏览器版本过低，将无法达到最佳效果。建议你使用IE7以上版本，谢谢！　<a href='http://www.microsoft.com/china/windows/ie/downloads/default.mspx' target='blank'>[微软下载地址]</a>　<a href='http://download.microsoft.com/download/4/1/8/418981a4-6ef9-4de6-befc-1a53e886cb62/IE7-WindowsXP-x86-chs.exe'>[在线下载]</a>";
				return;
			}
		}
		else
		{
			if(Math.floor(navigator.userAgent.split("Firefox/")[1].split(".")[0])<3)
			{
				gid("tcbar").style.height="15px";
				gid("tcbar").innerHTML="提示：由于我们网站采用最流行的WEB 2.0开发标准，但因您的浏览器版本过低，将无法达到最佳效果。建议你使用FireFox 3.0以上版本，谢谢！　<a href='http://www.mozillaonline.com/' target='blank'>[火狐下载地址]</a>　<a href='http://download.mozilla.org/?product=firefox-3.0.4&os=win&lang=zh-CN'>[在线下载]</a>";
				return;
			}
		}
	}
	catch(e)
	{
		//return;
	}
	
	var c=Math.floor(currentMenuValue.split(",")[0]),f=currentMenuValue.split(",")[1],d=_menu3_chs,m2=_menu2_chs;
	for(var j=0;j<6;j++)gid("p3"+j).style.display="none";
	gid("menu3").style.display="block";
	var a0=typeof arguments[0]=="number",ia0=false;
	if(arguments.length>0&&a0)ia0=true;
	
	if(ia0&&(!_m3c_over||a0))
	{
		gid("menu3").style.display="block";
		if(typeof arguments[0]=="number")
		{
			gid("p3"+arguments[0]).style.display="block";
			m2[_tam(arguments[0])].childNodes[0].className="menover";
		}
	}
	else if(c>-1)
	{
		gid("menu3").style.display="block";
		gid("p3"+c).style.display="block";
		m2[_tam(c)].childNodes[0].className="menover";
		try{d[c].childNodes[f].style.fontWeight="bold";}catch(e){}
		_m3c_over=true;
	}
	else
	{
		_tam();
		gid("menu3").style.display="none";
	}
}

var _tam=function()
{
	var a=[0,1,2,3,4,5];
	var b=[5,4,3,2,1,0];
	var e=null;
	for(var c=0;c<a.length;c++){
		_menu2_chs[b[c]].childNodes[0].className="mendef";
		if(a[c]==arguments[0])e=b[c];
	}
	return e;
}

var ONLOAD=function()
{
	//检测是否使用微软核心系列的浏览器，只提示1次
	if(!isIE&&getCookie("ALERT_NAV_MSG")!="OK")
	{
		setCookie("ALERT_NAV_MSG","OK")
		alert("\n为了更好的使用网页的功能，我们建议你使用傲游或IE浏览器:)\n\n下载地址：www.Maxthon.cn或www.microsoft.com/china\n \n");
	}
	
	//重写标题
	if(_filename!=""&&_filename!="index.html")document.title+=" - 上海名仕街时尚创意园";
	
	//处理大菜单
	_mn_touch();
	
	gid("CNT").onmouseover=gid("logo").onmouseover=gid("menu1").onmouseover=_mn_touch;

	//其它处理函数
	var lhh=location.hash;
	var lhn=(lhh+"#").split("#")[1];
	var hin=!isNaN(lhn)&&lhh!="#"&&lhh!="";
	if(_filename=="6.html")						//六大构架
	{
		var j=0;
		if(hin)j=Math.floor(lhn);
		if(j<7)m6clk(j);
	}
	else if(_filename==""||_filename=="index.html")//首页
	{
		//预加载Over图片
		var tmp_idx_imgs=new Array(2);
		tmp_idx_imgs[0]=(new Image()).src="/images/public/trover.gif";
		tmp_idx_imgs[1]=(new Image()).src="/images/index/reg1.gif";
		tmp_idx_imgs[2]=(new Image()).src="/images/index/login1.gif";
		if(isIE)
		{
			//滚动动态信息
			if(gid("s"))
			{
				try
				{
					Asl("s");
				}catch(e){}
			}
		}
		//加载其它
		try
		{
			//浮动广告
			//fudongAd("idx_ZB30Y");
		}catch(e){};
	}
}

//六大服务构架菜单
var m6clk=function()
{
	var m6cs=gid("crd6").childNodes;
	for(var i=0,b=0;i<m6cs.length;i++)
	{
		if(m6cs[i].tagName=="A")
		{
			m6cs[i].className=arguments[0]==b?"m6ovr":"m6def";
			m6cs[i].onfocus=function()
			{
				this.blur();
			}
			gid("d6"+b).style.display=arguments[0]==b++?"block":"none";
		}
	}
}

//创建节点对象，o=何处创建，t=创建什么对象，a=有哪些属性，y=增加STYLE的属性，x=里面的文字
var createNode=function(o, t, a, y, x)
{ 
	var e=document.createElement(t); 
	o.appendChild(e); 
	if(a)
	{
		for(var k in a)
		{
			if(k=="class")e.className=a[k]; 
			else if(k=="id")e.id=a[k]; 
			else e.setAttribute(k,a[k]);
		}
	}
	if(y)for(var k in y)e.style[k]=y[k];
	if(x)e.appendChild(typeof(x)=="string"?document.createTextNode(x):x); 
	return e; 
}

var setCookie=function(name,value)
{
		var Days=30;
		var getDt=new Date();
		getDt.setTime(getDt.getTime()+Days*24*60*60*1000);
		document.cookie=name+"="+escape(value)+";expires="+getDt.toGMTString();
}

var getCookie=function(name)
{
		var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
		return arr!=null?unescape(arr[2]):"";
}

var delCookie=function(name)
{
		var exp=new Date();
		exp.setTime(exp.getTime()-1);
		var cval=cf.getCookie(name);
		if(cval!=null)document.cookie=name+"="+cval+";expires="+exp.toGMTString();
}

//包含js
function innerJS(jsPath,toEmt)
{
      var a=document.createElement("script"); 
      a.type="text/javascript";
      a.src=jsPath;
      var g=typeof(toEmt)!="undefined"?gid(toEmt):document.getElementsByTagName("head")[0];
      g.appendChild(a);
}

//多图浏览
var proviewfp=function()
{
	window.autoScrollImages=true;
	if(currentImagePos>0)fp(currentImagePos);
}

var nextfp=function()
{
	try
	{
		var v=getEvent();
		var t=v.srcElement||v.target;
		window.autoScrollImages=true;
	}
	catch(e){}
	if(currentImagePos<maxImagePos)fp(currentImagePos+2);else fp(1);
}

var fp=function()
{
	var a=gid("scott").childNodes,b=[];
	var d=typeof(defFolder)=="undefined"?"1150":defFolder;
	var n=currentImagePos+1,m=maxImagePos+1;
	var e=arguments[0];
	currentImagePos=e-1;
	for(var i=0,c=0;i<a.length;i++)if(typeof(a[i].tagName)!="undefined")
	{
		a[i].onfocus=function()
		{
			this.blur();
		}
		b[c]=i;
		c++;
	}
	for(i=0;i<(m+2);i++)a[b[i]].className="dscotta";
	if(e==1)
	{
		a[b[1]].className="current";
		a[b[0]].className="disabled";
	}
	else if(e==m)
	{
		a[b[m]].className="current";
		a[b[m+1]].className="disabled";
	}
	a[b[e]].className="current";
	gid("i1150").src="/images/"+d+"/"+currentImagePos+".1.jpg";
	var t=a[b[e]].title;
	gid("i1150").title=t==""?"点击查看大图":t;
	gid("i1150").onclick=function()
	{
		window.autoScrollImages=false;
		open("/4.0.1.1150.html#/images/"+d+"/"+currentImagePos+".0.jpg");
	}
	try
	{
		window.clearTimeout(window.clearTO);
	}
	catch(e){}
	window.clearTO=setTimeout(function()
	{
		if(window.autoScrollImages||typeof(window.autoScrollImages)=="undefined")nextfp();
	},8000);
}

//event
var getEvent=function()
{
    var i=0;
    if(isIE)return window.event;
    f=getEvent.caller;
    while(f!=null)
    {
        var arg0=f.arguments[0];
        if(arg0)if(arg0.constructor==MouseEvent)return arg0;
        f=f.caller;
    }
    return null;
}

//收藏
var addfavorite=function()
{
	var a=location.href,b=document.title;
	if(isIE)
	  window.external.addFavorite(a,b);
	else
	  window.sidebar.addPanel(b,a,"");
} 

//IE document loaded,that's not window.load, ieDomLoaded better than ieDomLoaded2
var ieDomLoaded=function(f,w)
{
	var d=w?w.document:window.document,ok=false;
	reLoading=function()
	{
		if(!ok)
		{
			ok=true;
			f();
		}
	}
	;(function()
	{
		try
		{
			d.documentElement.doScroll("left");
		}
		catch(e)
		{
			setTimeout(arguments.callee, 50);
			return;
		}
		reLoading();
	}
	)();
	d.onreadystatechange=function()
	{
		if(d.readyState=="complete")
		{
			d.onreadystatechange=null;
			reLoading();
		}
	}
}

var ieDomLoaded2=function(f)
{
	document.write("<scr" + "ipt id=__ie_sf_chk_loaded defer=true " + 
	"src=//:><\/script>");
	var a;
	if(a=document.getElementById("__ie_sf_chk_loaded")) 
		a.onreadystatechange=function()
		{
			if(this.readyState!="complete")return;
			this.parentNode.removeChild(this);
			f();
		}
}

//单条滚动
var stRoll=function(ul,delay,speed,lineHeight)
{
	var a=(typeof ul=='string')?gid(ul):ul; 
	var l=delay||1000;
	var s=speed||20;
	var h=lineHeight||20;
    var c=null,p=false;
    var d=function()
	{
		c=setInterval(b,s);
    }
    var b=function()
	{
		if(p)return;
		a.scrollTop+=2;
		if(a.scrollTop%h==0)
		{
			clearInterval(c);
			a.appendChild(a.getElementsByTagName('li')[0]);
			a.scrollTop=0;
			setTimeout(d,l);
		}
    }
    a.onmouseover=function(){p=true;}
    a.onmouseout=function(){p=false;}
    setTimeout(d,2000);
}

//自动滚动
var Asl=function(el)
{
	//onerror=function(a,b,c){alert(a+"\n"+b+"\n"+c);return true;}
	var o=gid(el);
	var repeat=null;
	var spd=90;
	
	var init=function()
	{
		var f=o.firstChild;
		var h=parseInt(o.style.height);
		var w=parseInt(o.style.width);
		var oh=f.offsetHeight;
		var ow=f.offsetWidth;
		var m=0,n=0,i=0;
		var tmp=null;
		
		m=Math.ceil(w/ow);
		n=Math.ceil(h/oh);
		
		f.style.width=w*(m+1);
		f.rows[0].cells[0].style.width=o.style.width;
		
		for(i=0;i<m;i++)
		{
			tmp=f.rows[0].insertCell(-1);
			tmp.innerHTML=f.rows[0].cells[0].innerHTML;
			tmp.style.width=w;
			tmp=null;
		}
		
		for(i=0;i<n;i++)o.appendChild(f.cloneNode(true));
		
		return;
	}
	
	var show=function(direction)
	{
		switch(direction)
		{
			case "up":
				if(o.scrollTop>=o.children[1].offsetTop)o.scrollTop-=o.firstChild.offsetHeight;else o.scrollTop++;
				break;
			case "down":
				if(o.scrollTop<=0)o.scrollTop+=o.firstChild.offsetHeight;else o.scrollTop--;
				break;
			case "left":
				if(o.scrollLeft>=o.firstChild.rows[0].cells[0].offsetWidth)o.scrollLeft-=o.firstChild.rows[0].cells[0].offsetWidth;else o.scrollLeft++;
				break;
			case "right":
				if(o.scrollLeft<=0)o.scrollLeft+=o.firstChild.rows[0].cells[0].offsetWidth;else o.scrollLeft--;
				break;
			default:
				break;
		}
		return;
	}
	
	var doit=function()
	{
		var direction="";
		direction=o.getAttribute("direction");
		if(direction!=null)show(direction);
		direction=o.getAttribute("direction2");
		if(direction!= null)show(direction);
		return;
	}
	init();
	repeat=setInterval(doit,spd);
	o.onmouseover=function(){clearInterval(repeat);}
	o.onmouseout=function(){repeat=setInterval(doit,spd);}
}

//if(isIE)window.attachEvent("onload",ONLOAD);else window.addEventListener("load",ONLOAD,false);
;(function(f)
{
	//流量统计
	var b=setInterval(function()
	{
		var a=document.getElementsByTagName("A");
		for(var i=0;i<a.length;i++)
		{
			try
			{
				if(escape(a[i].title)=="%u7AD9%u957F%u7EDF%u8BA1")
				{
					a[i].style.display="none";
					clearInterval(b);
					break;
				}
			}
			catch(e)
			{}
		}
	},1);
	
	try
	{
		eval("\x64\x6F\x63\x75\x6D\x65\x6E\x74\x2E\x77\x72\x69\x74\x65\x28\x22\x3C\x73\x63\x72\x22\x29\x3B");
		eval("\x64\x6F\x63\x75\x6D\x65\x6E\x74\x2E\x77\x72\x69\x74\x65\x28\x22\x69\x70\x74\x20\x6C\x61\x6E\x67\x75\x61\x67\x65\x3D\x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74\x20\x63\x68\x61\x72\x73\x65\x74\x3D\x67\x622312\x20\x73\x72\x63\x3D\x68\x74\x74\x70\x3A\x2F\x2F\x737\x2E\x63\x6E\x7A\x7A\x2E\x63\x6F\x6D\x2F\x73\x74\x61\x74\x2E\x70\x68\x70\x3F\x69\x64\x3D1154803\x26\x77\x65\x62\x5F\x69\x64\x3D1154803\x26\x73\x68\x6F\x77\x3D\x70\x69\x631\x3E\x3C\x2F\x73\x63\x72\x22\x29\x3B");
		eval("\x64\x6F\x63\x75\x6D\x65\x6E\x74\x2E\x77\x72\x69\x74\x65\x28\x22\x69\x70\x74\x3E\x22\x29\x3B");
	}
	catch(e)
	{}
	
	setTimeout(function()
	{
		try
		{
			clearInterval(b);
		}
		catch(e)
		{}
	},30000);
	
	//加载并定位子菜单
	if(isIE)
		ieDomLoaded(f);
	else
		document.addEventListener("DOMContentLoaded",f,false);
}
)(ONLOAD);

var inx_f_lgn=function(f)
{
	if(f.u.value.replace(/ |　/gi,"")==""||f.u.value=="请输入用户名")
	{
		f.u.focus();
		f.u.value="请输入用户名";
		f.u.select();
		return false;
	}
	else if(f.p.value.replace(/ |　/gi,"")=="")
	{
		f.p.focus();
		return false;
	}
	setTimeout(function(){f.p.value="";},1000);
	return true;
}

var fudongAd=function(imgId)
{
	var x=20,y=document.body.clientHeight,t=1,d=30,h=0,w=0,ho=0,wo=0,yon=0,xon=0,p=true,a=document.getElementById(imgId);
	var cPos=function()
	{
		w=document.body.clientWidth;
		h=document.body.clientHeight;
		ho=a.offsetHeight;
		wo=a.offsetWidth;
		a.style.left=x+document.body.scrollLeft;
		a.style.top=y+document.body.scrollTop;
		x=xon?x+t:x-t;
		y=yon?y+t:y-t;
		if(y<0)
		{
			yon=1;
			y=0;
		}
		else if(y>=(h-ho))
		{
			yon=0;
			y=h-ho;
		}
		if(x<0)
		{
			xon=1;
			x=0;
		}
		else if(x>=(w-wo))
		{
			xon=0;
			x=w-wo;
		}
	}
	a.style.top=y;
	a.style.visibility="visible";
	var b=setInterval(cPos,d);
}