//首页中间图片切换
var counts;var xtime;var nowNum=-3;var PicObj;var UrlObj;
var IE=(navigator.userAgent.indexOf("MSIE")!=-1);
//搜索
function CheckSearch(objs)
{
    var Keyword=Obj("Keyword");var SearchType=Obj("SearchType");
    if((Keyword.value=="")||(Keyword.value=="输入搜索关键字"))
    {
        try{ShowAlert(3,"提示","请输入搜索关键字！","")}
        catch(e){alert("请输入搜索关键字！");}
        return false;
    }
    var url="";
    switch(SearchType.value)
    {
        //case "2":objs.action="/BeginSchool/InteractionIndex.aspx";break;
        //case "3":objs.action="/ShowRescoursePage1.aspx?id=&did=0&isMoney=0";break;
        //default:objs.action="/Teacher.htm?Keyword="+objs.Keyword.value;break;
        case "2":url="/BeginSchool/InteractionIndex.aspx?Keyword="+Keyword.value;break;
        case "3":url="/ShowRescoursePage1.aspx?id=&did=0&isMoney=0&title="+Keyword.value;break;
        default:url="/Teacher.htm?Keyword="+Keyword.value;break;
    }
    //objs.target="_blank";objs.submit();
    window.open(url)
}

//体验教室切换
function SetBg(objs,otherobj){objs.className="set";Obj(otherobj).className="";}
function Niming(roomid,xpassword,event)
{
    var number = Math.floor(Math.random()*100);
	var roomname=roomid==1?"教师体验教室":"学生体验教室"
	var param = "IA#" + serverip + ";匿名用户"+number+";" + xpassword + ";" + roomid.toString() + ";11010;"+roomname + ";0;欢迎登录体验教室！;0;1;1;0;1;Normal;;0.0.0.0;";
    EnterRoom(param,event); 
}
//宣传视频
var vedios;var imgobj;
function XuanCVideo11()
{
    var IE=(navigator.appName.indexOf("Microsoft") != -1);
    var swf_width=IE?"100%":"251";
    var swf_height="185";
    var ppstr='<p style="margin:5px 0px 0px 8px;"><a onclick=\'vedios.playPause();\'>播放/暂停</a>&nbsp;'+
    '<a onclick=\'vedios.videoStop();\'>停止</a>&nbsp;'+
    '<a onclick=\'vedios.ff();\'>快进</a>&nbsp;'+
    '<a onclick=\'vedios.rew();\'>快退</a>'+
    '</p>'
    document.write('<dl class="Kkxx InR News">');
    document.write('<dt>网站介绍<a style="margin-left:35px;color:red">(双击播放窗口全屏)</a></dt><dd style="line-height:0px;">');
    document.write('<object type="application/x-shockwave-flash" data="/FLVPlayer/vcastr3.swf" width="'+swf_width+'" height="'+swf_height+'" id="vcastr3">');
    document.write('<param name="movie" value="/FLVPlayer/vcastr3.swf"/>');
	document.write('<param name="allowFullScreen" value="true" /><param name="wmode" value="opaque">');
	document.write('<param name="FlashVars" value="xml=/Js/vcastr.xml" /></object>'+ppstr+'</dd></dl>');
	vedios=IE?window["vcastr3"]:document["vcastr3"];
}

function XuanCVideo()
{
    var IE=(navigator.appName.indexOf("Microsoft") != -1);
    var swf_width=IE?"100%":"251";
    var swf_height="185";
    var ppstr='<p style="margin:5px 0px 0px 8px;"><a onclick=\'ShowObj(imgobj,"vedios.playPause()",true);\' title="播放或暂停视频">播放/暂停</a>&nbsp;'+
    //'<a onclick=\'ShowObj(imgobj,"vedios.videoStop()")\'>停止</a>&nbsp;'+
    '<a onclick=\'ShowStop()\' title="停止播放视频">停止</a>&nbsp;'+
    '<a onclick=\'ShowObj(imgobj,"vedios.ff()")\' title="快速前进">快进</a>&nbsp;'+
    '<a onclick=\'ShowObj(imgobj,"vedios.rew()")\' title="快速后退">快退</a>'+
    '</p>'
    document.write('<dl class="Kkxx InR News">');
    document.write('<dt>网站介绍<a style="margin-left:35px;color:red">(双击播放窗口全屏)</a></dt><dd style="line-height:0px;">');
    document.write('<img src="/Images/Banner/video.jpg" style="margin:0px 0px 5px 0px;cursor:pointer;float:left" alt="播放或暂停视频" onclick="ShowObj(this,\'vedios.playPause()\',true)" id="imgobj"><object type="application/x-shockwave-flash" data="/FLVPlayer/vcastr3.swf" width="'+swf_width+'" height="'+swf_height+'" id="vcastr3" style="display:none">');
    document.write('<param name="movie" value="/FLVPlayer/vcastr3.swf"/>');
	document.write('<param name="allowFullScreen" value="true" /><param name="wmode" value="opaque">');
	document.write('<param name="FlashVars" value="xml=');
	document.write('<vcastr><config><isAutoPlay>true</isAutoPlay><isLoadBegin>true</isLoadBegin><defautVolume>1</defautVolume><controlPanelMode>none</controlPanelMode></config>');
	document.write('	<plugIns>');
	document.write('		<javaScriptPlugIn>');
	document.write('			<url>/FLVPlayer/javaScriptPlugIn.swf</url>');
	document.write('		</javaScriptPlugIn>');
	document.write('	</plugIns>');
	document.write('	<channel>');
	document.write('		<item>');
	document.write('			<source>/upload/HelpFLV/Video.flv</source>');
	document.write('		</item>');
	document.write('	</channel>');
	document.write('</vcastr>" /></object>'+ppstr+'</dd></dl>');
	vedios=IE?window["vcastr3"]:document["vcastr3"];
	imgobj=document.getElementById("imgobj")
}
function ShowStop()
{
    if(imgobj.style.display=="none")
    {
        vedios.videoStop();vedios.style.display="none";imgobj.style.display="block";
    }
}
function ShowObj(imgobj,str,play)
{
    if(imgobj.style.display!="none")
    {
        imgobj.style.display="none";
        vedios.style.display="block";
        try{
        if(play){vedios.playPause()}
        }
        catch(e){}
    }
    else{eval(str)}
}

//状元图片特效
function ScrollImgLeft()
{
    var speed=20
    var scroll_begin = document.getElementById("scroll_begin");
    var scroll_end = document.getElementById("scroll_end");
    var scroll_div = document.getElementById("scroll_div");
    scroll_end.innerHTML=scroll_begin.innerHTML;
    var Isright=Math.random()>0.5;
    function MarqueeR()
    {
        if(Isright)
        {
            if(scroll_div.scrollLeft<=0)scroll_div.scrollLeft+=scroll_end.offsetWidth;
            else scroll_div.scrollLeft--;
        }
        else
        {
            if(scroll_end.offsetWidth-scroll_div.scrollLeft<=0)scroll_div.scrollLeft-=scroll_begin.offsetWidth;
            else scroll_div.scrollLeft++;
        }
    }
    var MyMar=setInterval(MarqueeR,speed)
    scroll_div.onmouseover=function() {clearInterval(MyMar)}
    scroll_div.onmouseout=function() {MyMar=setInterval(MarqueeR,speed)}
}
//var ListDiv;var y;var ListArray = new Array();
//function ShowZhangy()
//{
//    var obj=ClearFireFOx(document.getElementById(tempid).nextSibling);
//    ListDiv=document.getElementById(Showid);ListDiv.className="downs";
//    var str="";var i=0;var u=0;
//    while(obj.tagName=="DD")
//    {
//        if(i++<6){str+="<dd>"+obj.innerHTML+"</dd>";}
//        else{ListArray.push(setinnerstr(str,u++));i=1;str="<dd>"+obj.innerHTML+"</dd>";}
//        obj=ClearFireFOx(obj.nextSibling);
//    }
//    if(i>0)ListArray.push(setinnerstr(str,u));
//    y=ListArray.length-1;
//    var stylenum=Math.round (Math.random()*y+0.5);
//    //alert(stylenum)
//    if(y>0)Show(stylenum-1);
//}
//function ClearFireFOx(obj1){while(obj1.nodeType!=1){obj1=obj1.nextSibling;}return obj1;}
//function setinnerstr1(str,n){return "<dl class=\"zhuangy\"><dt></dt>"+str+"<dd class=\"right\"><img src=\"Images/goup.gif\" alt=\"上一页\" onclick=\"ShowPage("+(n-1)+",true)\"><img src=\"Images/godown.gif\" alt=\"下一页\" onclick=\"ShowPage("+(n+1)+")\"></dd></dl>";}
//function setinnerstr(str,n){return "<dl class=\"zhuangy\"><dt></dt>"+str+"<dd class=\"right\"><img src=\"Images/D_up.jpg\" alt=\"上一页\" onclick=\"ShowPage("+(n-1)+",true)\"><img src=\"Images/D_down.jpg\" alt=\"下一页\" onclick=\"ShowPage("+(n+1)+")\"></dd></dl>";}
//function ShowPage(n,type){if(n<0)n=y-1;else if(n==y)n=0;if(type){ListDiv.className="ups";}else{ListDiv.className="downs";}
////window.clearInterval(ttst);
//Show(n);
//}
//function Show(n){if(IE){ListDiv.filters[0].apply();ListDiv.innerHTML=ListArray[n];ListDiv.filters[0].play(0.5);}else{ListDiv.innerHTML=ListArray[n];}if(++n>=y)n=0;
////ttst=setTimeout('eval("Show('+n+')")',8000);
//}

function IndexFlash()
{
    var links="AboutUs/Index.shtml|AboutUs/Index.shtml|AboutUs/Index.shtml|AboutUs/Index.shtml|AboutUs/Index.shtml";
    var texts='#text1|#text2|#text3|#text4';
    //var pics='Images/Banner/db7.jpg|Images/Banner/db6.jpg|Images/Banner/db1.jpg'
    //ShowFlash(810,95,pics,links,texts)
    var pics='Images/Banner/N1.jpg|Images/Banner/N2.jpg|Images/Banner/N3.jpg'
    ShowFlash(737,74,pics,links,texts)
    //ymPrompt.alert({message:"异地家教网将于今天下午17点30升级维护，维护时间10分钟！<br>正常开放时间为：17点40分",showMask:false,title:"温馨提示",winPos:'rb'});
}

function ShowCenter()
{
    //var images=['Images/Banner/zb12.jpg','Images/Banner/zb16.jpg','Images/Banner/zb10.jpg','Images/Banner/zb9.jpg','Images/Banner/zb11.jpg','Images/Banner/zb5.jpg'];
    //var urls=['AboutUs/Index.shtml','AboutUs/Yxt.shtml','UserRegister.aspx?userType=0','UserRegister.aspx?userType=0','AboutUs/DownLoad_ftsetup.shtml','AboutUs/Index.shtml'];
    var images=['Images/Banner/zb21.jpg','Images/Banner/zb17.jpg','Images/Banner/zb18.jpg','Images/Banner/zb16.jpg','Images/Banner/zb10.jpg','Images/Banner/zb9.jpg','Images/Banner/zb11.jpg'];
    var urls=['AboutUs/Wuli.shtml','AboutUs/Index.shtml','AboutUs/Index.shtml','AboutUs/Yxt.shtml','UserRegister.aspx?userType=0','UserRegister.aspx?userType=0','AboutUs/DownLoad_ftsetup.shtml'];
    var widths=461;var heights=233;var times=20000;
    for(i=0;i<images.length;i++){eval('img'+i+'=new Image ();img'+i+'.src="'+images[i]+'";');}
    document.write('<div class="container" id="CenterImg"  style="width:'+widths+'px;height:'+heights+'px;">');
    document.write('<table id="ImgTable" border="0" cellpadding="0" cellspacing="0"><tr>');
    for(i=0;i<images.length;i++){document.write('<td><a href="'+urls[i]+'" target="_blank"><img src="'+images[i]+'" width='+widths+' height='+heights+' /></a></td>');}
	document.write('</tr></table><ul class="num" id="idNum"></ul></div>');
    var st = new SlideTrans("CenterImg", "ImgTable", i,times,{ Vertical: false });
    var forEach = function(array, callback, thisObject){
	    if(array.forEach){array.forEach(callback, thisObject);}
	    else{for (var i = 0, len = array.length; i < len; i++) { callback.call(thisObject, array[i], i, array); }}
    }
    var nums = [];
    for(var i = 0, n = st._count - 1; i <= n;){(nums[i] = $("idNum").appendChild(document.createElement("li"))).innerHTML = ++i;}
    forEach(nums, function(o, i){
	    o.onmouseover = function(){ o.className = "on"; st.Auto = false; st.Run(i); }
	    o.onmouseout = function(){ o.className = ""; st.Auto = true; st.Run(); }
    })
    st.onStart = function(){forEach(nums, function(o, i){ o.className = st.Index == i ? "on" : ""; })}
    st.Run();
}

var $ = function (id) {return "string" == typeof id ? document.getElementById(id) : id;};
var Extend = function(destination, source) {for (var property in source) {destination[property] = source[property];}return destination;}
var CurrentStyle = function(element){return element.currentStyle || document.defaultView.getComputedStyle(element, null);}
var Bind = function(object, fun) {var args = Array.prototype.slice.call(arguments).slice(2);return function() {return fun.apply(object, args.concat(Array.prototype.slice.call(arguments)));}}

var Tween = {
	Quart: {
		easeOut: function(t,b,c,d){
			return -c * ((t=t/d-1)*t*t*t - 1) + b;
		}
	},
	Back: {
		easeOut: function(t,b,c,d,s){
			if (s == undefined) s = 1.70158;
			return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
		}
	},
	Bounce: {
		easeOut: function(t,b,c,d){
			if ((t/=d) < (1/2.75)) {
				return c*(7.5625*t*t) + b;
			} else if (t < (2/2.75)) {
				return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
			} else if (t < (2.5/2.75)) {
				return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
			} else {
				return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
			}
		}
	}
}

//撕页广告
var Topwidth=200;
document.write('<div id="Layer1" style="position:absolute; right:0px; top:0px; width:'+Topwidth+'px; height:'+Topwidth+'px; z-index:99"">');
document.write('<embed src="/Images/NewFlash/a.swf" width="'+Topwidth+'" height="'+Topwidth+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>');
document.write('</div>');

//容器对象,滑动对象,切换数量
var SlideTrans = function(container, slider, count,times, options) {
	
	this._slider = $(slider);
	this._container = $(container);//容器对象
	this._timer = null;//定时器
	this._count = Math.abs(count);//切换数量
	this._target = 0;//目标值
	this._t = this._b = this._c = 0;//tween参数
	this.Index = 0;//当前索引
	
	this.SetOptions(options);
	
	this.Auto = !!this.options.Auto;
	this.Duration = Math.abs(this.options.Duration);
	this.Time = Math.abs(this.options.Time);
	if(times)this.Pause = times;
	else this.Pause = Math.abs(this.options.Pause);
	
	this.Tween = this.options.Tween;
	this.onStart = this.options.onStart;
	this.onFinish = this.options.onFinish;
	
	var bVertical = !!this.options.Vertical;
	this._css = bVertical ? "top" : "left";//方向
	
	//样式设置
	var p = CurrentStyle(this._container).position;
	p == "relative" || p == "absolute" || (this._container.style.position = "relative");
	this._container.style.overflow = "hidden";
	this._slider.style.position = "absolute";
	
	this.Change = this.options.Change ? this.options.Change :
		this._slider[bVertical ? "offsetHeight" : "offsetWidth"] / this._count;
};
SlideTrans.prototype = {
  //设置默认属性
  SetOptions: function(options) {
	this.options = {//默认值
		Vertical:	true,//是否垂直方向（方向不能改）
		Auto:		true,//是否自动
		Change:		0,//改变量
		Duration:	100,//滑动持续时间
		Time:		10,//滑动延时
		Pause:		4000,//停顿时间(Auto为true时有效)
		onStart:	function(){},//开始转换时执行
		onFinish:	function(){},//完成转换时执行
		Tween:		Tween.Quart.easeOut//tween算子
	};
	Extend(this.options, options || {});
  },
  //开始切换
  Run: function(index) {
	//修正index
	index == undefined && (index = this.Index);
	index < 0 && (index = this._count - 1) || index >= this._count && (index = 0);
	//设置参数
	this._target = -Math.abs(this.Change) * (this.Index = index);
	this._t = 0;
	this._b = parseInt(CurrentStyle(this._slider)[this.options.Vertical ? "top" : "left"]);
	this._c = this._target - this._b;
	
	this.onStart();
	this.Move();
  },
  //移动
  Move: function() {
	clearTimeout(this._timer);
	//未到达目标继续移动否则进行下一次滑动
	if (this._c && this._t < this.Duration) {
		this.MoveTo(Math.round(this.Tween(this._t++, this._b, this._c, this.Duration)));
		this._timer = setTimeout(Bind(this, this.Move), this.Time);
	}else{
		this.MoveTo(this._target);
		this.Auto && (this._timer = setTimeout(Bind(this, this.Next), this.Pause));
	}
  },
  //移动到
  MoveTo: function(i) {
	this._slider.style[this._css] = i + "px";
  },
  //下一个
  Next: function() {
	this.Run(++this.Index);
  },
  //上一个
  Previous: function() {
	this.Run(--this.Index);
  },
  //停止
  Stop: function() {
	clearTimeout(this._timer); this.MoveTo(this._target);
  }
};