﻿
/*<![CDATA[*/
// ajax 全局函数
$.ajaxSetup({
  url: "/xmlhttp/",
  global: false,
  cache: false,
  type: "GET",
  timeout:6000
});

// 首页视频类型
function videoType(div,typeid,gs,len)
{
	$.ajax({
	  url: "playJavascript/videoTypeList"+typeid+".ashx?typeid="+typeid+"&gsid="+gs+"&len="+len+"",
	  success: function(XMLHttpRequest){
		$("#"+div+"").html(XMLHttpRequest);
	  },
	  beforeSend:function(){
		$("#"+div+"").html("<div style=\"text-align:center;\"><img src='images/ajax-loader.gif'/></div>");
　　　　　　},
	  error:function(){
　　　　　　　//错误处理
		$("#"+div+"").html("<div style=\"text-align:center;\">加载失败！<a href=\"#\" onclick=\"videoType('"+div+"',"+typeid+","+gs+","+len+")\">点击重新加载</a></div>");
　　　　　　}
	}); 
}


// 首页视频点击排行
function videoTop(div,gs,len)
{
	$.ajax({
	  url: "playJavascript/ClickRanking.ashx?gsid="+gs+"&len="+len+"",
	  success: function(XMLHttpRequest){
		$("#"+div+"").html(XMLHttpRequest);
	  },
	  beforeSend:function(){
		$("#"+div+"").html("<div style=\"text-align:center;\"><img src='images/ajax-loader.gif'/></div>");
　　　　　　},
	  error:function(){
　　　　　　　//错误处理
		$("#"+div+"").html("<div style=\"text-align:center;\">加载失败！<a href=\"#\" onclick=\"videoTop('"+div+"',"+gs+","+len+")\">点击重新加载</a></div>");
　　　　　　}
	}); 
}

// 首页教师排行
function teacherTop(div,typeid,gs,len)
{
	$.ajax({
	  url: "playJavascript/teacherTypeList"+typeid+".ashx?typename="+typeid+"&gsid="+gs+"&len="+len+"",
	  //url: "playJavascript/teacherTypeList11.ashx?typename="+typeid+"&gsid="+gs+"&len="+len+"",
	  success: function(XMLHttpRequest){
		$("#"+div+"").html(XMLHttpRequest);
	  },
	  beforeSend:function(){
		$("#"+div+"").html("<div style=\"text-align:center;\"><img src='images/ajax-loader.gif'/></div>");
　　　　　　},
	  error:function(){
　　　　　　　//错误处理
		$("#"+div+"").html("<div style=\"text-align:center;\">加载失败！<a href=\"#\" onclick=\"teacherTop('"+div+"',"+typeid+","+gs+","+len+")\">点击重新加载</a></div>");
　　　　　　}
	}); 
}

// 添加收藏 调用AddFavorite(window.location,document.title)
function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
// 设为首页 调用SetHome(this,window.location)
function SetHome(obj,vrl){
        try{
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
        }
        catch(e){
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
                        }  
                        catch (e)  { 
                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'");  
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                 }
        }
}

// 首页图片新闻
//arryer
$(function() {
		var len = $("#PhotoNewsimg li").length;
		var index = 0;
		var adTimer;
		//广告先
		$("#PhotoNewsimgBig").hover(function() {
			clearInterval(adTimer);
		}, function() {
			adTimer = setInterval(function() {
				showImg(index);
				index++;
				if (index == len) { index = 0; }
			}, 4000);
		}).trigger("mouseleave");
		//再导航
		$("#PhotoNewsimg li").mouseover(function() {
			index = $("#PhotoNewsimg li").index(this);
			showImg(index);
		}).eq(0).mouseover();
		// 教师
		var indexs = 0;
		$("#mainBody_part6_content1>ul").not(":first").hide(); // 隐藏除了第一个以外的所有UL
		$("#TeacherTibs span:first").addClass("tabLink0");   // 给默认的教师类型加上样式
		$("#TeacherTibs span").not(":first").addClass("tabLink1");  // 给其余的加上样式
		$("#TeacherTibs span").mouseover(function() {
			indexs = $("#TeacherTibs>span").index(this);
			showTeacher(indexs);
		});
		// 搜索		
		$("#search_btn").click(function(){
			window.location.href="result.aspx?wd=" + $("#search_txt").val();
		});
		// 排序方式
		var Sortid = $.query.get("sort");
		if(Sortid != "")
		{
			$("#listContent>div>div>a").removeClass("keysLink01").eq(Sortid).addClass("keysLink01");
		}
		else
		{
			$("#listContent>div>div>a").removeClass("keysLink01").eq(0).addClass("keysLink01");
		}
		$("#listContent>div>div>a").click(function(){
			 var lista = $("#listContent>div>div>a").index(this)
			 var url = $.query.set("sort",lista).toString();
			 location.href=url;			 
		});
		
	})
function showImg(index) {
	//var adHeight = $("#PhotoNewsimgBig").width();
	//$("#PhotoNewsimgBig>ul").stop(true, false).animate({ left: -adHeight * index+"px" },100); //必须配合position:absolute
	$("#PhotoNewsimgBig li").hide().eq(index).show();
	$("#PhotoNewsimgTxt li").hide().eq(index).show();
	$("#PhotoNewsimg li").removeClass("PhotoNewson").eq(index).addClass("PhotoNewson");
}
// 图片新闻结束

// 老师选项卡
function showTeacher(indexs) {	
	$("#TeacherTibs>span").not("#TeacherTibs>span["+indexs+"]").addClass("tabLink1").eq(indexs).removeAttr("class").addClass("tabLink0")
	$("#mainBody_part6_content1>ul").hide().eq(indexs).show();	
}
// 老师选项卡
/*]]>*/ 