?
/* 驗證數字 */
function validateNum(str) {
var re = /^[\d]+$/
return re.test(str);
}
/* 驗證是否有此ID */
function exist(id) {
var s = document.getElementById(id);
if (s) {
return true;
}
else {
return false;
}
}
//分頁
function GetPageSql(serach,pageType,shtml) {
var pagea = document.getElementById("tiaozhuan").value;
if (validateNum(pagea)) {
if (pagea != "") {
if (pagea < 1) {
alert("對不起,請輸入正確的頁數");
}
else {
location.href = serach + "" + pageType + "" + pagea + "" + shtml + "";
}
}
else {
alert("對不起,請輸入正確的頁數");
}
} else
{ alert("對不起,請輸入正確的頁數"); }
}
/*滾動圖片*/
var sina = {
$: function(objName) {
if (document.getElementById) {
return eval('document.getElementById("' + objName + '")')
} else {
return eval('document.all.' + objName)
}
},
isIE: navigator.appVersion.indexOf("MSIE") != -1 ? true : false,
addEvent: function(l, i, I) {
if (l.attachEvent) {
l.attachEvent("on" + i, I)
} else {
l.addEventListener(i, I, false)
}
},
delEvent: function(l, i, I) {
if (l.detachEvent) {
l.detachEvent("on" + i, I)
} else {
l.removeEventListener(i, I, false)
}
},
readCookie: function(O) {
var o = "",
l = O + "=";
if (document.cookie.length > 0) {
var i = document.cookie.indexOf(l);
if (i != -1) {
i += l.length;
var I = document.cookie.indexOf(";", i);
if (I == -1) I = document.cookie.length;
o = unescape(document.cookie.substring(i, I))
}
};
return o
},
writeCookie: function(i, l, o, c) {
var O = "",
I = "";
if (o != null) {
O = new Date((new Date).getTime() + o * 3600000);
O = "; expires=" + O.toGMTString()
};
if (c != null) {
I = ";domain=" + c
};
document.cookie = i + "=" + escape(l) + O + I
},
readStyle: function(I, l) {
if (I.style[l]) {
return I.style[l]
} else if (I.currentStyle) {
return I.currentStyle[l]
} else if (document.defaultView && document.defaultView.getComputedStyle) {
var i = document.defaultView.getComputedStyle(I, null);
return i.getPropertyValue(l)
} else {
return null
}
}
};
//滾動圖片構造函數
function ScrollPic(scrollContId, arrLeftId, arrRightId, dotListId) {
this.scrollContId = scrollContId;
this.arrLeftId = arrLeftId;
this.arrRightId = arrRightId;
this.dotListId = dotListId;
this.dotClassName = "dotItem";
this.dotOnClassName = "dotItemOn";
this.dotObjArr = [];
this.pageWidth = 0;
this.frameWidth = 0;
this.speed = 10;
this.space = 10;
this.pageIndex = 0;
this.autoPlay = true;
this.autoPlayTime = 5;
var _autoTimeObj, _scrollTimeObj, _state = "ready";
this.stripDiv = document.createElement("div");
this.listDiv01 = document.createElement("div");
this.listDiv02 = document.createElement("div");
if (!ScrollPic.childs) {
ScrollPic.childs = []
};
this.ID = ScrollPic.childs.length;
ScrollPic.childs.push(this);
this.initialize = function() {
if (!this.scrollContId) {
throw new Error("必須指定scrollContId.");
return
};
this.scrollContDiv = sina.$(this.scrollContId);
if (!this.scrollContDiv) {
throw new Error("scrollContId不是正確的對象.(scrollContId = \"" + this.scrollContId + "\")");
return
};
this.scrollContDiv.style.width = this.frameWidth + "px";
this.scrollContDiv.style.overflow = "hidden";
this.listDiv01.innerHTML = this.listDiv02.innerHTML = this.scrollContDiv.innerHTML;
this.scrollContDiv.innerHTML = "";
this.scrollContDiv.appendChild(this.stripDiv);
this.stripDiv.appendChild(this.listDiv01);
this.stripDiv.appendChild(this.listDiv02);
this.stripDiv.style.overflow = "hidden";
this.stripDiv.style.zoom = "1";
this.stripDiv.style.width = "32766px";
this.listDiv01.style.cssFloat = "left";
this.listDiv02.style.cssFloat = "left";
sina.addEvent(this.scrollContDiv, "mouseover", Function("ScrollPic.childs[" + this.ID + "].stop()"));
sina.addEvent(this.scrollContDiv, "mouseout", Function("ScrollPic.childs[" + this.ID + "].play()"));
if (this.arrLeftId) {
this.arrLeftObj = sina.$(this.arrLeftId);
if (this.arrLeftObj) {
sina.addEvent(this.arrLeftObj, "mousedown", Function("ScrollPic.childs[" + this.ID + "].rightMouseDown()"));
sina.addEvent(this.arrLeftObj, "mouseup", Function("ScrollPic.childs[" + this.ID + "].rightEnd()"));
sina.addEvent(this.arrLeftObj, "mouseout", Function("ScrollPic.childs[" + this.ID + "].rightEnd()"))
}
};
if (this.arrRightId) {
this.arrRightObj = sina.$(this.arrRightId);
if (this.arrRightObj) {
sina.addEvent(this.arrRightObj, "mousedown", Function("ScrollPic.childs[" + this.ID + "].leftMouseDown()"));
sina.addEvent(this.arrRightObj, "mouseup", Function("ScrollPic.childs[" + this.ID + "].leftEnd()"));
sina.addEvent(this.arrRightObj, "mouseout", Function("ScrollPic.childs[" + this.ID + "].leftEnd()"))
}
};
if (this.dotListId) {
this.dotListObj = sina.$(this.dotListId);
if (this.dotListObj) {
var pages = Math.round(this.listDiv01.offsetWidth / this.frameWidth + 0.4), i, tempObj;
for (i = 0; i < pages; i++) {
tempObj = document.createElement("span");
this.dotListObj.appendChild(tempObj);
this.dotObjArr.push(tempObj);
if (i == this.pageIndex) {
tempObj.className = this.dotClassName
} else {
tempObj.className = this.dotOnClassName
}
//tempObj.title="第"+(i+1)+"頁";
sina.addEvent(tempObj, "click", Function("ScrollPic.childs[" + this.ID + "].pageTo(" + i + ")"));
}
}
}
if (this.autoPlay) {
this.play();
}
};
this.leftMouseDown = function() {
if (_state != "ready") {
return
};
_state = "floating";
_scrollTimeObj = setInterval("ScrollPic.childs[" + this.ID + "].moveLeft()", this.speed)
};
this.rightMouseDown = function() {
if (_state != "ready") {
return
};
_state = "floating";
_scrollTimeObj = setInterval("ScrollPic.childs[" + this.ID + "].moveRight()", this.speed)
};
this.moveLeft = function() {
if (this.scrollContDiv.scrollLeft + this.space >= this.listDiv01.scrollWidth) {
this.scrollContDiv.scrollLeft = this.scrollContDiv.scrollLeft + this.space - this.listDiv01.scrollWidth
} else {
this.scrollContDiv.scrollLeft += this.space
};
this.accountPageIndex()
};
this.moveRight = function() {
if (this.scrollContDiv.scrollLeft - this.space <= 0) {
this.scrollContDiv.scrollLeft = this.listDiv01.scrollWidth + this.scrollContDiv.scrollLeft - this.space
} else {
this.scrollContDiv.scrollLeft -= this.space
};
this.accountPageIndex()
};
this.leftEnd = function() {
if (_state != "floating") {
return
};
_state = "stoping";
clearInterval(_scrollTimeObj);
var fill = this.pageWidth - this.scrollContDiv.scrollLeft % this.pageWidth;
this.move(fill)
};
this.rightEnd = function() {
if (_state != "floating") {
return
};
_state = "stoping";
clearInterval(_scrollTimeObj);
var fill = -this.scrollContDiv.scrollLeft % this.pageWidth;
this.move(fill)
};
this.move = function(num, quick) {
var thisMove = num / 5;
if (!quick) {
if (thisMove > this.space) {
thisMove = this.space
};
if (thisMove < -this.space) {
thisMove = -this.space
}
};
if (Math.abs(thisMove) < 1 && thisMove != 0) {
thisMove = thisMove >= 0 ? 1 : -1
} else {
thisMove = Math.round(thisMove)
};
var temp = this.scrollContDiv.scrollLeft + thisMove;
if (thisMove > 0) {
if (this.scrollContDiv.scrollLeft + thisMove >= this.listDiv01.scrollWidth) {
this.scrollContDiv.scrollLeft = this.scrollContDiv.scrollLeft + thisMove - this.listDiv01.scrollWidth
} else {
this.scrollContDiv.scrollLeft += thisMove
}
} else {
if (this.scrollContDiv.scrollLeft - thisMove <= 0) {
this.scrollContDiv.scrollLeft = this.listDiv01.scrollWidth + this.scrollContDiv.scrollLeft - thisMove
} else {
this.scrollContDiv.scrollLeft += thisMove
}
};
num -= thisMove;
if (Math.abs(num) == 0) {
_state = "ready";
if (this.autoPlay) {
this.play()
};
this.accountPageIndex();
return
} else {
this.accountPageIndex();
setTimeout("ScrollPic.childs[" + this.ID + "].move(" + num + "," + quick + ")", this.speed)
}
};
this.next = function() {
if (_state != "ready") {
return
};
_state = "stoping";
this.move(this.pageWidth, true)
};
this.play = function() {
if (!this.autoPlay) {
return
};
clearInterval(_autoTimeObj);
_autoTimeObj = setInterval("ScrollPic.childs[" + this.ID + "].next()", this.autoPlayTime * 1000)
};
this.stop = function() {
clearInterval(_autoTimeObj)
};
this.pageTo = function(num) {
if (_state != "ready") {
return
};
_state = "stoping";
var fill = num * this.frameWidth - this.scrollContDiv.scrollLeft;
this.move(fill, true)
};
this.accountPageIndex = function() {
this.pageIndex = Math.round(this.scrollContDiv.scrollLeft / this.frameWidth);
if (this.pageIndex > Math.round(this.listDiv01.offsetWidth / this.frameWidth + 0.4) - 1) {
this.pageIndex = 0
};
var i;
for (i = 0; i < this.dotObjArr.length; i++) {
if (i == this.pageIndex) {
this.dotObjArr[i].className = this.dotClassName
} else {
this.dotObjArr[i].className = this.dotOnClassName
}
}
}
}
/* 三張圖片滾動 */
var myScroll = new function() {
function $id(id) { return document.getElementById(id); };
this.scrollBox = function(auto, obj, _scroll, _width, second, speed, type) {
var target = $id(obj).getElementsByTagName("a");
var interval, timeout, left;
var time = 1;
var speed = speed
var sum = target.length;
var a = 0;
var delay = second * 1000;
//myScroll.scrollBox(true, "img_icon", "show_pic", 1450, 8, 0.1, "left");
//$id(obj).style.display = "none";
$id(_scroll).parentNode.onmouseover = function() { $id(obj).style.display = "block"; }
//$id(_scroll).onmouseout = function() { $id(obj).style.display = "none"; }
var setValLeft = function(b) {
return function() {
left = Math.abs(parseInt($id(_scroll).style[type]));
$id(_scroll).style[type] = -Math.floor(left + (parseInt(b * _width) - left) * speed) + "px";
if (left == [(_width * b)]) {
clearInterval(interval);
a = b;
}
}
};
var setValRight = function(b) {
return function() {
left = Math.abs(parseInt($id(_scroll).style[type]));
$id(_scroll).style[type] = -Math.ceil(left + (parseInt(b * _width) - left) * speed) + "px";
if (left == [(_width * b)]) {
clearInterval(interval);
a = b;
}
}
}
function autoScroll() {
for (var c = 0; c < sum; c++) { target[c].className = ""; };
clearTimeout(interval);
if (a == (parseInt(sum) - 1)) {
for (var c = 0; c < sum; c++) { target[c].className = ""; };
a = 0;
target[a].className = "active";
interval = setInterval(setValLeft(a), time);
timeout = setTimeout(autoScroll, delay);
} else {
a++;
target[a].className = "active";
interval = setInterval(setValRight(a), time);
timeout = setTimeout(autoScroll, delay);
}
}
if (auto) { timeout = setTimeout(autoScroll, delay); };
for (var i = 0; i < sum; i++) {
target[i].onmouseover = (function(i) {
return function() {
//alert(i);
//$("#img_icon a").eq(i).find("img").attr("src", "http://www.askci.com/images/images_zszy/tp_dt.gif");
for (var c = 0; c < sum; c++) { target[c].className = ""; };
clearTimeout(timeout);
clearInterval(interval);
target[i].className = "active";
if (Math.abs(parseInt($id(_scroll).style[type])) > [(_width * i)]) {
interval = setInterval(setValLeft(i), time);
//alert(i);
this.onmouseout = function() { if (auto) { timeout = setTimeout(autoScroll, delay); }; };
} else if (Math.abs(parseInt($id(_scroll).style[type])) < [(_width * i)]) {
interval = setInterval(setValRight(i), time);
this.onmouseout = function() { if (auto) { timeout = setTimeout(autoScroll, delay); }; };
}
}
})(i)
// function() {
// $("#img_icon a").eq(i).find("img").attr("src", "http://www.askci.com/images/images_zszy/tp_d.gif");
// }
}
}
}
$(function() {
if (exist("showHtml2")) {
$("#showHtml2").html(showHtml2);
}
})
var showHtml2 = "分享到:騰訊 網易 新浪 搜狐 空間 開心網 百度貼吧 人人網 MSN";
/**************************分享**************************/
/*QQ微博 | 新浪微博客 | 網易博客 | 搜狐博客*/
function postToWb(obj_id) {
var _t = encodeURI(document.title);
var _url = encodeURI(document.location);
var _appkey = encodeURI("appkey"); //你從騰訊獲得的appkey
var _pic = encodeURI(''); //(列如:var _pic='圖片url1|圖片url2|圖片url3....)
var _site = ''; //你的網站地址
if (obj_id == "tencent") {
var _u = 'http://v.t.qq.com/share/share.php?title=' + _t + '&url=' + _url + '&appkey=' + _appkey + '&site=' + _site + '&pic=' + _pic;
window.open(_u, '轉播到騰訊微博', 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no');
}
else if (obj_id == "sina") {
var _u = 'http://service.weibo.com/share/share.php?title=' + _t + '&url=' + _url;
window.open(_u, '轉播到新浪微博', 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no');
}
else if (obj_id == "wy") {
var url = 'link=http://news.163.com/&source=' + _t + '&info=' + _t + '' + _url;
var _url = "http://t.163.com/article/user/checkLogin.do?" + url + "&" + new Date().getTime();
window.open(_url + url, '轉播到網易微博', 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no');
}
else if (obj_id = "sohu") {
var url = "http://t.sohu.com/third/post.jsp?url=" + _url + "&title=" + _t + "&pic=" + _pic + "&content=utf-8";
window.open(url, '轉播到搜狐微博', 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no');
}
else {
}
}
$(function() {
$(".menuLian li").hover(function() {
$(this).children("ul").show().css("z-index", "1");
}, function() {
$(this).children("ul").hide();
});
})
/* 手機訪問 */
function Phonebrowser(xurl) {
var bs = {
versions: function() {
var u = navigator.userAgent, app = navigator.appVersion;
return {//移動終端瀏覽器版本信息
trident: u.indexOf('Trident') > -1, //IE內核
presto: u.indexOf('Presto') > -1, //opera內核
webKit: u.indexOf('AppleWebKit') > -1, //蘋果、谷歌內核
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐內核
mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), //是否為移動終端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios終端
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android終端或者uc瀏覽器
iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否為iPhone或者QQHD瀏覽器
iPad: u.indexOf('iPad') > -1, //是否iPad
webApp: u.indexOf('Safari') == -1 //是否web應該程序,沒有頭部與底部
};
} (),
language: (navigator.browserLanguage || navigator.language).toLowerCase()
}
var xCookies = getCookie("xsite");
if (bs.versions.mobile) {
if (bs.versions.android || bs.versions.iPhone || bs.versions.iPad || bs.versions.ios) {
if (xCookies != "pc") {
window.location.href = xurl;
}
}
}
}
function setCookie(c_name, value, expiredays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + expiredays);
document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()) + ";path=/;domain=askci.com";
}
function getCookie(c_name) {
if (document.cookie.length > 0) {
c_start = document.cookie.indexOf(c_name + "=");
if (c_start != -1) {
c_start = c_start + c_name.length + 1;
c_end = document.cookie.indexOf(";", c_start);
if (c_end == -1) c_end = document.cookie.length;
return unescape(document.cookie.substring(c_start, c_end));
}
}
return "";
}