﻿// JScript 文件
//分行业显示企业视频交换特效函数，obj是被点击的控件对象
function GetNextCompanyTypeId(obj)
{
    //获取控件的行标示
    var row = obj.id.substring(0,obj.id.indexOf("TopH"));
    //获取分类行业的编号
    var classId = obj.id.substring(obj.id.indexOf("TopH") + 4);
    document.getElementById("CV_"+row).innerHTML = "<div style=\"margin:40px auto; width:40px; height:60px;\"><img src=\"/images/loadding_indicator_big.gif\" border=\"0\" style=\"height:60px; width:60px;\" /></div>";
    GetResponse('../AjaxVideo.ashx?cid=' + classId ,'1','txt', 'CV_'+row);
    
    
//    //获取控件所在行的隐藏域的值
//    var before = document.getElementById("Hidden"+row).value;
//    //将之前显示的div隐藏
//    document.getElementById("CV_"+before).style.display = "none";
//    //为控件所在行的隐藏域从新赋值
//    document.getElementById("Hidden"+row).value = classId;
//    //使新的div显示
//    document.getElementById("CV_"+classId).style.display = "block";

}

    function ShowDiv(doc,whichobjid)
     {
         
         document.getElementById(whichobjid).innerHTML = doc;
     }
     
     
//设置热门企业隐藏或显示函数
function HotVideoDispalyOrHidden(obj)
{
    //获取控件所在的行数
    var row = obj.id.substring(5);
    //获取之前显示的行数
    var before = document.getElementById("HotHidden").value;
    //将之前显示的行的图片隐藏
    document.getElementById("Topli"+before+"1").style.display = "none";
    //从新设置之前显示的行的文字说明的宽度
    document.getElementById("Topli"+before+"2").style.width="255px";
    document.getElementById("q_qk"+before).style.height="20px";

    //从新设置之前显示的行的对其方式
    document.getElementById("Topli"+before+"2").style.margin="auto"; 
    //重新设置隐藏域的值
    document.getElementById("HotHidden").value = row;
    //将新选中行设为显示行
    document.getElementById("Topli"+row+"1").style.display = "block";
    //从新设置当前显示的行的文字说明的宽度
    document.getElementById("Topli"+row+"2").style.width="150px";
    document.getElementById("q_qk"+row).style.height="65px";

    //从新设置当前显示的行的对其方式
    document.getElementById("Topli"+row+"2").style.marginTop="0px";
    document.getElementById("Topli"+row+"2").style.marginLeft="10px";
}
//以下代码是实现页面图片特效功能
var $ = function(id) {
	return document.getElementById(id);
};
Function.prototype.bind = function() {
	if (arguments.length < 2 && arguments[0] == null) {
		return this;
	}
    var __method = this, args = $A(arguments), object = args.shift();
    return function() {
		return __method.apply(object, args.concat($A(arguments)));
    };
};
var isArray = function(testVar) {
	return Array == testVar.constructor ? 1 : String != testVar.constructor && null != testVar.length && !testVar.alert && !testVar.nodeType ? 2 : 0;
};
var $A = function(variable) {
	switch (isArray(variable)) {
		case 1:
			return variable;
		case 2:
			var arr = [], i = -1, len = variable.length;
			while (++i < len) {
				arr[i] = variable[i];
			}
			return arr;
		default:
			return [variable];
	}
};
var addClass = function(elem, className) {
	if ((" " + elem.className + " ").indexOf(" " + className + " ") == -1) {
		if (elem.className == "") {
			elem.className = className;
		} else {
			elem.className += (" " + className);
		}
	}
};
var removeClass = function(elem, className) {
	var newClass = (" " + elem.className + " ").replace(" " + className + " ", " ");
	elem.className = newClass.substr(1, newClass.length - 2);
};
var addEvent = function(elem, eventName, handler) {
	if (elem.addEventListener) {
		elem.addEventListener(eventName, handler, false);
	} else if (elem.attachEvent) {
		elem.attachEvent("on" + eventName, handler);
	}
};
function Slide(menus, contents, css, eventName, interval) {
	var curSeq = 0, length = contents.length, timerIds = [], isStopped;
	if (menus && length != menus.length) {
		throw new Error("the amount of menus and contents is not equal");
	}
	
	var hide = function(seq) {
		removeClass(contents[seq], css);
		if (menus) {
			removeClass(menus[seq], css);
		}
	};
	
	var show = function(seq) {
		addClass(contents[seq], css);
		if (menus) {
			addClass(menus[seq], css);
		}
		curSeq = seq;
	};
	
	this.showNext = function() {
		var next = curSeq + 1;
		if (next >= length) {
			next = 0;
		}
		var i = length;
		while (--i >= 0) {
			if (i != next) {
				hide(i);
			} else {
				show(i);
			}
		}
	};
	
	this.change = function(event) {
		if (this != menus[curSeq]) {
			var i = length;
			while (--i >= 0) {
				if (menus[i] != this) {
					hide(i);
				} else {
					show(i);
				}
			}
		}
		e = window.event || event;
		e.cancelBubble = true;
	};
	
	this.play = function(speed) {
		isStopped = false;
		timerIds.push(setInterval(this.showNext.bind(this), speed));
	};
	
	this.pause = function() {
		isStopped = true;
		var i = length;
		while (--i >= 0) {
			clearInterval(timerIds[i]);
			timerIds.splice(i, 1);
		}
	};
	
	var i = length;
	while (--i >= 0) {
		addEvent(menus[i], eventName, this.change.bind(menus[i]));
		if (interval > 0) {
			addEvent(menus[i], "mouseover", this.pause);
			addEvent(menus[i], "mouseout", this.play.bind(this, interval));
		}
	}
	if (interval > 0) {
		this.play(interval);
	}
}
