/*================================png透明化程序==========================================
=====================识别IE浏览器版本在5.5与小于7之间执行png透明化程序===================*/
var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);
if (version >= 5.5 && version < 7.0){
  window.attachEvent("onload", CorrectPNG);   
}

function CorrectPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var j=0; j<document.images.length; j++)
      {
         var img = document.images[j]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            j = j-1
         }
      }
   }    
}
/*png透明化程序结束*/

/*=============================在SCA商机里：点小图片显示大图片================================================*/
function showpic(i,w)
{
	var obj=document.getElementById("bigpic");
	obj.innerHTML="<img src="+i+" onload='javascript:if(this.width>"+w+"){this.width="+w+"}' border=0>";
}

/*=====================================版权声明中：选中下拉列表弹出新页面========================================*/
function chg(v){
	if (v.value!=""){
		window.open(v.value,'_blank');
	}
}

/*================================FLASH激活显示，不带虚框====================================*/
function writeflashhtml(arg){
	var parm = []
	var _default_version = "8,0,24,0";
	var _default_quality = "high";
	var _default_align = "middle";
	var _default_menu = "false";
	
	for(i = 0; i < arguments.length; i ++)
	{
		parm[i] = arguments[i].split(' ').join('').split('=')
		for (var j = parm[i].length-1; j > 1; j --){
			parm[i][j-1]+="="+parm[i].pop();
		}
		switch (parm[i][0])
		{
			case '_version' : var _version = parm[i][1] ; break ; 
			case '_swf' : var _swf = parm[i][1] ; break ; 
			case '_base' : var _base = parm[i][1] ; break ; 
			case '_quality' : var _quality = parm[i][1] ; break ; 
			case '_loop' : var _loop = parm[i][1] ; break ; 
			case '_bgcolor' : var _bgcolor = parm[i][1] ; break ; 
			case '_wmode' : var _wmode = parm[i][1] ; break ; 
			case '_play' : var _play = parm[i][1] ; break ; 
			case '_menu' : var _menu = parm[i][1] ; break ; 
			case '_scale' : var _scale = parm[i][1] ; break ; 
			case '_salign' : var _salign = parm[i][1] ; break ; 
			case '_height' : var _height = parm[i][1] ; break ; 
			case '_width' : var _width = parm[i][1] ; break ; 
			case '_hspace' : var _hspace = parm[i][1] ; break ; 
			case '_vspace' : var _vspace = parm[i][1] ; break ; 
			case '_align' : var _align = parm[i][1] ; break ; 
			case '_class' : var _class = parm[i][1] ; break ; 
			case '_id' : var _id = parm[i][1] ; break ; 
			case '_name' : var _name = parm[i][1] ; break ; 
			case '_style' : var _style = parm[i][1] ; break ; 
			case '_declare' : var _declare = parm[i][1] ; break ; 
			case '_flashvars' : var _flashvars = parm[i][1] ; break ; 
			default :;
		}
	}
	var thtml = "";
	thtml += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + ((_version)?_version:_default_version) + "'"
	if(_width) thtml += " width='" + _width + "'"
	if(_height) thtml += " height='" + _height + "'"
	if(_hspace) thtml += " hspace='" + _hspace + "'"
	if(_vspace) thtml += " vspace='" + _vspace + "'"
	if(_align) thtml += " align='" + _align + "'"
	else thtml += " align='" + _default_align + "'"
	if(_class) thtml += " class='" + _class + "'"
	if(_id) thtml += " id='" + _id + "'"
	if(_name) thtml += " name='" + _name + "'"
	if(_style) thtml += " style='" + _style + "'"
	if(_declare) thtml += " " + _declare
	thtml += ">"
	if(_swf) thtml += "<param name='movie' value='" + _swf + "'>"
	if(_quality) thtml += "<param name='quality' value='" + _quality + "'>" 
	else thtml += "<param name='quality' value ='" + _default_quality + "'>"
	if(_loop) thtml += "<param name='loop' value='" + _loop + "'>"
	if(_bgcolor) thtml += "<param name='bgcolor' value='" + _bgcolor + "'>"
	if(_play) thtml += "<param name='play' value='" + _play + "'>"
	if(_menu) thtml += "<param name='menu' value='" + _menu + "'>"
	else thtml += "<param name='menu' value='" + _default_menu + "'>"
	if(_scale) thtml += "<param name='scale' value='" + _scale + "'>"
	if(_salign) thtml += "<param name='salign' value='" + _salign + "'>"
	if(_wmode) thtml += "<param name='wmode' value='" + _wmode + "'>"
	if(_base) thtml += "<param name='base' value='" + _base + "'>"
	if(_flashvars) thtml += "<param name='flashvars' value='" + _flashvars + "'>"
	thtml += "<embed pluginspage='http://www.macromedia.com/go/getflashplayer'"
	if(_width) thtml += " width='" + _width + "'"
	if(_height) thtml += " height='" + _height + "'"
	if(_hspace) thtml += " hspace='" + _hspace + "'"
	if(_vspace) thtml += " vspace='" + _vspace + "'"
	if(_align) thtml += " align='" + _align + "'"
	else thtml += " align='" + _default_align + "'"
	if(_class) thtml += " class='" + _class + "'"
	if(_id) thtml += " id='" + _id + "'"
	if(_name) thtml += " name='" + _name + "'"
	if(_style) thtml += " style='" + _style + "'"
	thtml += " type='application/x-shockwave-flash'"
	if(_declare) thtml += " " + _declare 
	if(_swf) thtml += " src='" + _swf + "'"
	if(_quality) thtml += " quality='" + _quality + "'"
	else thtml += " quality='" + _default_quality + "'"
	if(_loop) thtml += " loop='" + _loop + "'"
	if(_bgcolor) thtml += " bgcolor='" + _bgcolor + "'"
	if(_play) thtml += " play='" + _play + "'"
	if(_menu) thtml += " menu='" + _menu + "'"
	else thtml += " menu='" + _default_menu + "'"
	if(_scale) thtml += " scale='" + _scale + "'"
	if(_salign) thtml += " salign='" + _salign + "'"
	if(_wmode) thtml += " wmode='" + _wmode + "'"
	if(_base) thtml += " base='" + _base + "'"
	if(_flashvars) thtml += " flashvars='" + _flashvars + "'"
	thtml += "></embed>"
	thtml += "</object>"
	document.write(thtml);
}

/* ==== slider nameSpace ==== */
var slider = function() {
	/* ==== private methods ==== */
	function getElementsByClass(object, tag, className) {
		var o = object.getElementsByTagName(tag);
		for ( var i = 0, n = o.length, ret = []; i < n; i++) {
			if (o[i].className == className) ret.push(o[i]);
		}
		if (ret.length == 1) ret = ret[0];
		return ret;
	}
	function setOpacity (obj,o) {
		if (obj.filters) obj.filters.alpha.opacity = Math.round(o);
		else obj.style.opacity = o / 100;
	}
	/* ==== Slider Constructor ==== */
	function Slider(oCont, speed, iW, iH, oP) {
		this.slides = [];
		this.over   = false;
		this.S      = this.S0 = speed;
		this.iW     = iW;
		this.iH     = iH;
		this.oP     = oP;
		this.oc     = document.getElementById(oCont);
		this.frm    = getElementsByClass(this.oc, 'div', 'slide');
		this.NF     = this.frm.length;
		this.resize();
		for (var i = 0; i < this.NF; i++) {
			this.slides[i] = new Slide(this, i);
		}
		this.oc.parent = this;
		this.view      = this.slides[0];
		this.Z         = this.mx;
		/* ==== on mouse out event ==== */
		this.oc.onmouseout = function () {
			this.parent.mouseout();
			return false;
		}
	}
	Slider.prototype = {
		/* ==== animation loop ==== */
		run : function () {
			this.Z += this.over ? (this.mn - this.Z) * .5 : (this.mx - this.Z) * .5;
			this.view.calc();
			var i = this.NF;
			while (i--) this.slides[i].move();
		},
		/* ==== resize  ==== */
		resize : function () {
			this.wh = this.oc.clientWidth;
			this.ht = this.oc.clientHeight;
			this.wr = this.wh * this.iW;
			this.r  = this.ht / this.wr;
			this.mx = this.wh / this.NF;
			this.mn = (this.wh * (1 - this.iW)) / (this.NF - 1);
		},
		/* ==== rest  ==== */
		mouseout : function () {
			this.over      = false;
			setOpacity(this.view.img, this.oP);
		}
	}
	/* ==== Slide Constructor ==== */
	Slide = function (parent, N) {
		this.parent = parent;
		this.N      = N;
		this.x0     = this.x1 = N * parent.mx;
		this.v      = 0;
		this.loaded = false;
		this.cpt    = 0;
		this.start  = new Date();
		this.obj    = parent.frm[N];
		this.txt    = getElementsByClass(this.obj, 'div', 'text');
		this.img    = getElementsByClass(this.obj, 'img', 'diapo');
		this.bkg    = document.createElement('div');
		this.bkg.className = 'backgroundText';
		this.obj.insertBefore(this.bkg, this.txt);
		if (N == 0) this.obj.style.borderLeft = 'none';
		this.obj.style.left = Math.floor(this.x0) + 'px';
		setOpacity(this.img, parent.oP);
		/* ==== mouse events ==== */
		this.obj.parent = this;
		this.obj.onmouseover = function() {
			this.parent.over();
			return false;
		}
	}
	Slide.prototype = {
		/* ==== target positions ==== */
		calc : function() {
			var that = this.parent;
			// left slides
			for (var i = 0; i <= this.N; i++) {
				that.slides[i].x1 = i * that.Z;
			}
			// right slides
			for (var i = this.N + 1; i < that.NF; i++) {
				that.slides[i].x1 = that.wh - (that.NF - i) * that.Z;
			}
		},
		/* ==== HTML animation : move slides ==== */
		move : function() {
			var that = this.parent;
			var s = (this.x1 - this.x0) / that.S;
			/* ==== lateral slide ==== */
			if (this.N && Math.abs(s) > .5) {
				this.obj.style.left = Math.floor(this.x0 += s) + 'px';
			}
			/* ==== vertical text ==== */
			var v = (this.N < that.NF - 1) ? that.slides[this.N + 1].x0 - this.x0 : that.wh - this.x0;
			if (Math.abs(v - this.v) > .5) {
				this.bkg.style.top = this.txt.style.top = Math.floor(2 + that.ht - (v - that.Z) * that.iH * that.r) + 'px';
				this.v = v;
				this.cpt++;
			} else {
				if (!this.pro) {
					/* ==== adjust speed ==== */
					this.pro = true;
					var tps = new Date() - this.start;
					if(this.cpt > 1) {
						that.S = Math.max(2, (28 / (tps / this.cpt)) * that.S0);
					}
				}
			}
			if (!this.loaded) {
				if (this.img.complete) {
					this.img.style.visibility = 'visible';
					this.loaded = true;
				}
			}
		},
		/* ==== light ==== */
		over : function () {
			this.parent.resize();
			this.parent.over = true;
			setOpacity(this.parent.view.img, this.parent.oP);
			this.parent.view = this;
			this.start = new Date();
			this.cpt = 0;
			this.pro = false;
			this.calc();
			setOpacity(this.img, 100);
		}
	}
	/* ==== public method - script initialization ==== */
	return {
		init : function() {
			// create instances of sliders here
			// parameters : HTMLcontainer name, speed (2 fast - 20 slow), Horizontal ratio, vertical text ratio, opacity
			this.s1 = new Slider("slider", 12, 1.84/3, 1/3.2, 70);
			setInterval("slider.s1.run();", 16);
		}
	}
}();

//两侧浮动广告，对联广告==========================================
function initEcAdRight() {
	document.getElementById('AdRightLayer').style.posTop = -200;
	document.getElementById('AdRightLayer').style.visibility = 'visible'
	MoveRightLayer('AdRightLayer');
}
function initEcAd() {
	document.getElementById('AdLeftLayer').style.posTop = -200;
	document.getElementById('AdLeftLayer').style.visibility = 'visible'
	document.getElementById('AdRightLayer').style.posTop = -200;
	document.getElementById('AdRightLayer').style.visibility = 'visible'
	MoveLeftLayer('AdLeftLayer');
	MoveRightLayer('AdRightLayer');
}
function MoveLeftLayer(layerName) {
	var x = 5;
	var y = 150;// 左侧广告距离页首高度
	var obj=document.getElementById(layerName); 
	var diff = (document.body.scrollTop + y -  obj.style.posTop)*.40;
	var y = document.body.scrollTop + y - diff;
	obj.style.posTop = parseInt(y);
	obj.style.posLeft = x;
	setTimeout("MoveLeftLayer('AdLeftLayer');", 20);
}
function MoveRightLayer(layerName) {
	var x = 5;
	var y = 150;// 右侧广告距离页首高度
	var obj=document.getElementById(layerName); 
	var diff = (document.body.scrollTop + y - obj.style.posTop)*.40;
	var y = document.body.scrollTop + y - diff;
	obj.style.posTop =  parseInt(y);
	obj.style.posRight = x;
	setTimeout("MoveRightLayer('AdRightLayer');", 20);
}

/*marquee频率滚动高度*/
/**startmarquee(一次滚动高度,速度,停留时间,图层标记);**/ 
function startmarquee(lh,speed,delay,id){ 
	var t; 
	var p=false; 
	var o=document.getElementById(id); 
	o.innerHTML+=o.innerHTML; 
	o.onmouseover=function(){p=true} 
	o.onmouseout=function(){p=false} 
	o.scrollTop = 0; 
	function start(){ 
		t=setInterval(scrolling,speed); 
		if(!p) o.scrollTop += 2; 
	} 
	function scrolling(){ 
		if(o.scrollTop%lh!=0){ 
			o.scrollTop += 2; 
			if(o.scrollTop>=o.scrollHeight/2) o.scrollTop = 0; 
		}else{ 
			clearInterval(t); 
			setTimeout(start,delay); 
		} 
	} 
	setTimeout(start,delay); 
}

function DemoScrolling(){
	var speed=10; //数字越大速度越慢
	var tab=document.getElementById("demo");
	var tab1=document.getElementById("demo1");
	var tab2=document.getElementById("demo2");
	tab2.innerHTML=tab1.innerHTML;
	function Marquee(){
	if(tab2.offsetWidth-tab.scrollLeft<=0)
	tab.scrollLeft-=tab1.offsetWidth;
	else{
	tab.scrollLeft++;
	}
	}
	var MyMar=setInterval(Marquee,speed);
	tab.onmouseover=function() {clearInterval(MyMar)};
	tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};	
}

function getPicURL(str){
	if (str.substr(0,7)=="http://"){
		return str
	}else{
		return "/"+str
	}
}
function overPic(s,w){
	document.getElementById("bigPicture").innerHTML="<img src='"+s+"' onload='if(this.width>"+w+"){this.width="+w+";}'/>";
}
