function test1 () {
var tempStr = document.getElementById('test').value;
if (tempStr === "请输入关键字进行搜索") {
document.getElementById('test').value = "";
}
}
function test2 () {
var tempStr = document.getElementById('test').value;
if (tempStr === "") {
document.getElementById('test').value = "请输入关键字进行搜索";
}
}
$(function () {
$(".focus2").hover(function() {
$(this).find(".prev,.next").fadeTo("show", 0.5);
}, function() {
$(this).find(".prev,.next").show();
})
$(".prev,.next").hover(function() {
$(this).fadeTo("show", 1);
}, function() {
$(this).fadeTo("show", 1);
})
$(".focus2").slide({
titCell: ".num2 ul",
mainCell: ".focuspic2",
effect: "fold",
autoPlay: true,
delayTime: 700,
autoPage: "
"
});
//top下拉
$(".topR dl").hover(function () {
$(this).addClass("hover");
},
function () {
$(this).removeClass("hover");
});
//导航
$(".nav ul li #nav").hide();
$("li.mainMenu").hover(function () {
$(this).find("#nav").stop(true, true);
$(this).find("#nav").slideDown();
}, function () {
$(this).find("#nav").stop(true, true);
$(this).find("#nav").slideUp();
});
$(document).ready(function () {
$(".nav ul li").hover(function () {
$(this).addClass('cur').siblings().removeClass('cur');
});
});
//banner
jQuery(".slideBox1").slide({
mainCell: ".bd ul",
autoPlay: true
});
jQuery(".slideBox2").slide({
mainCell: ".bd ul",
autoPlay: true
});
jQuery(".slideBox3").slide({
mainCell: ".bd ul",
autoPlay: true
});
jQuery(".slideBox4").slide({
mainCell: ".bd ul",
autoPlay: true
});
jQuery(".slideBox5").slide({
mainCell: ".bd ul",
autoPlay: true
});
jQuery(".oneLisImg").slide({
mainCell: ".bd ul",
autoPlay: true
});
jQuery(".tenLisImg").slide({
mainCell: ".bd ul",
autoPlay: true
});
//师资队伍
jQuery(".picScroll-top").slide({
titCell: ".hd ul",
mainCell: ".bd ul",
autoPage: true,
effect: "topLoop",
autoPlay: true,
vis: 2
});
//学院风光
jQuery(".picScroll-left").slide({
titCell: ".hd ul",
mainCell: ".bd ul",
autoPage: true,
effect: "leftLoop",
autoPlay: true,
vis: 3
});
//内页右侧手风琴
jQuery(".sideMenu").slide({
titCell: "h3",
targetCell: "ul",
defaultIndex: 1,
effect: "slideDown",
delayTime: 300,
trigger: "click"
});
//伪类
$(".oner li:nth-child(n+5)").css({
'padding-bottom': '0',
'margin-bottom': '0',
'border-bottom': '0'
});
$(".three-list li:last-child").css({
'margin-right': '0',
'float': 'right'
});
$(".fourr-list li:nth-child(3n)").css({
'margin-right': '0',
'float': 'right'
});
$(".eightr-list li:last-child").css({
'padding-bottom': '0',
'margin-bottom': '0',
'border-bottom': 'none'
});
$(".tenl-list li:last-child a").css({
'border-bottom': 'none'
});
$(".eler-list li:last-child a").css({
'border-bottom': 'none'
});
//tab切换
$(document).ready(function () {
var $tab_li = $('.tab-menu li');
$tab_li.hover(function () {
$(this).addClass('selected').siblings().removeClass('selected');
var index = $tab_li.index(this);
$('div.tab-box > div').eq(index).show().siblings().hide();
});
});
});
//表单
window.onload = function ()
{
var aForm = document.getElementsByTagName("form");
//多个表单
for (var i = 0; i < aForm.length; i++) WellForm(aForm[i]);
};
// 获取class
function getClass(sClass, oParent)
{
var aClass = [];
var reClass = new RegExp("(^| )" + sClass + "( |$)");
var aElem = (oParent || document).getElementsByTagName("*");
for (var i = 0; i < aElem.length; i++) reClass.test(aElem[i].className) && aClass.push(aElem[i]);
return aClass
}
// class是否存在
function hasClass(obj, sClass)
{
var reg = new RegExp("(^|\\s)" + sClass + "(\\s|$)");
return reg.test(obj.className)
}
// 添加class
function addClass(obj, sClass)
{
hasClass(obj, sClass) || (obj.className += " "+sClass)
}
// 删除class
function removeClass(obj, sClass)
{
if (hasClass(obj, sClass))
{
var reg = new RegExp("(^|\\s)" + sClass + "(\\s|$)");
obj.className = obj.className.replace(reg, "");
}
}
// 上一个元素
function prevElement(obj)
{
return obj.previousSibling || obj.previousElementSibling || null
}
// 下一个元素
function nextElement(obj)
{
return obj.nextSibling || obj.nextElementSibling || null
}
// 自定义表单函数
function WellForm(form)
{
var i = 0;
var zIndex = 1;
var aInput = form.getElementsByTagName("input");
var aSelect = form.getElementsByTagName("select");
var aTextArea = form.getElementsByTagName("textarea");
form.className = "WellForm";
/* 单选框 */
var aRadio = [];
for (i = 0; i < aInput.length; i++) aInput[i]["type"] == "radio" && aRadio.push(aInput[i]);
for (i = 0; i < aRadio.length; i++)
{
var oRadio = document.createElement("div");
oRadio.className = "WellRadio";
aRadio[i].parentNode.insertBefore(oRadio, aRadio[i]);
oRadio.appendChild(aRadio[i]);
aRadio[i].checked && addClass(aRadio[i].parentNode, "WellRadioH");
oRadio.onclick = function ()
{
var siblings = getClass("WellRadio", this.parentNode);
for (i = 0; i < siblings.length; i++)
{
removeClass(siblings[i], "WellRadioH");
siblings[i].children[0].checked = false;
}
addClass(this, "WellRadioH");
this.children[0].checked = true
}
}
}