/*
hecws常用js包
修改:duoffu(http://www.duoffu.com)
更新:2014-10-02
*/
var useragent = navigator.useragent.tolowercase();
var isfirefox=/mozilla/.test(useragent) && !/(compatible|webkit)/.test(useragent);
function getos()
{
if(navigator.useragent.indexof("msie")>0)return 1;
if(isfirefox=navigator.useragent.indexof("firefox")>0)return 2;
if(issafari=navigator.useragent.indexof("safari")>0)return 3;
if(iscamino=navigator.useragent.indexof("camino")>0)return 4;
if(ismozilla=navigator.useragent.indexof("gecko/")>0)return 5;
return 0;
}
function addfavorite()
{
var title = document.title;
var url = document.location.href;
try{window.external.addfavorite(url, title);}
catch (e){
try
{
window.sidebar.addpanel(title, url, "");
}
catch (e)
{
alert("加入收藏失败,请使用ctrl+d进行添加");
}
}
}
function sethome(obj,siteurl){
try {
obj.style.behavior ='url(#default#homepage)';
obj.sethomepage(siteurl);
} 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', siteurl);
}
}
}
/*获得元素*/
function $i(el)
{
if(typeof el=='string')return document.getelementbyid(el);
else if(typeof el=='object')return el;
return null;
}
//tab控制函数
function tabs(tabobj) {
var tabnum = $(tabobj).parent().index("li.it");
//设置点击后的切换样式
$(tabobj).parent().parent().find("li a").removeclass("cur");
$(tabobj).addclass("cur");
//根据参数决定显示内容
$(".tab_content").hide();
$(".tab_content").eq(tabnum).show();
}
/*滑动门*/
function settab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=$("#"+name+ "_tab_" +i);
var con=$("#"+name+"_tabcon_"+i);
if(i==cursel){
menu.addclass("tabcur");
con.show();
}else
{
menu.removeclass("tabcur");
con.hide();
}
}
}
//遮罩提示窗口
function popmsg(msg,msgcss) {
$("#popmsg").remove();
var cssname = "";
switch (msgcss) {
case "success":
cssname = "pcent ok";
break;
case "error":
cssname = "pcent error";
break;
default:
cssname = "pcent hint";
break;
}
var str = "
" + msg + "
";
var w = $("#popmsg").width();
var h = $("#popmsg").height();
var l= ($(window).width() - w)/2;
var t = ($(window).height() - h)/2 + $(document).scrolltop() ;
$("body").append(str);
$("#popmsg").css({"top": t+"px", "left": l+"px"});
$("#popmsg").show();
//3秒后清除提示
settimeout(function() {
$("#popmsg").fadeout(1000);
if (!$("#popmsg").is(":animated")) {
$("#popmsg").remove();
}
}, 3000);
}
//遮罩提示窗口
function jslaymsg(w, h, options) {
$("#jslaymsg").remove();
var cssname = "";
//提示窗口的样式
switch (options.mscss) {
case "success":
cssname = "icon-01";
break;
case "error":
cssname = "icon-02";
break;
default:
cssname = "icon-03";
break;
}
//向页面插入标记
var str = "";
$("body").append(str);
$("#jslaymsg").dialog({
//title: null,
//show: null,
bgiframe: true,
autoopen: false,
width: w,
//height: h,
resizable: false,
closeonescape: false,
draggable:false,
buttons: { "确定": function() { $(this).dialog("close"); }},
close: function() {
if (options.url == "back") {
history.back(-1);
} else if (options.url != "") {
location.href = options.url;
}
},
modal: true
});
$("#jslaymsg").dialog("open");
}
function seturlrefresh(url)
{
if(url.indexof("?") > 0)
return url+"&rnd="+math.random();
else
return url+"?rnd="+math.random();
}
/*刷新验证码*/
function refreshvcode(obj, h){
if(!h)
$i(obj).src=seturlrefresh("/tools/captcha.ashx");
else
$i(obj).src=seturlrefresh("/tools/captcha.ashx?h="+h);
}
var jduoffu=new object();
/*-------弹出提示、窗口基于lhgdialog插件,进行封装主要为了今后维护比较方便-----*/
function popmsg(msgtitle, url, msgcss, callback) {
var iconurl = "";
switch (msgcss) {
case "success":
iconurl = "32x32/succ.png";
break;
case "error":
iconurl = "32x32/fail.png";
break;
default:
iconurl = "32x32/hits.png";
break;
}
$.dialog.tips(msgtitle, 2, iconurl);
if (url == "back") {
frames["mainframe"].history.back(-1);
} else if (url != "") {
frames["mainframe"].location.href = url;
}
//执行回调函数
if (arguments.length == 4) {
callback();
}
}
jduoffu.opendialog=function(txt, url) {
$.dialog({title: txt,content: 'url:'+url});
}
jduoffu.opendialog =function(txt, url,w,h) {
$.dialog({title: txt,content: 'url:'+url,width:w,height:h,min:false,max:false});
}
/*弹出一个dialog窗口*/
jduoffu.jsdialog =function(msgtitle, msgcontent, msgcss, url,callback) {
var iconurl = "";
var argnum = arguments.length;
switch (msgcss) {
case "success":
iconurl = "success.gif";
break;
case "error":
iconurl = "error.gif";
break;
default:
iconurl = "alert.gif";
break;
}
var dialog = $.dialog({
title: msgtitle,
content: msgcontent,
fixed: true,
min: false,
max: false,
lock: true,
icon: iconurl,
ok: true,
close: function () {
if (url == "back") {
history.back(-1);
} else if (url != "") {
location.href = url;
}
//执行回调函数
if (argnum == 5) {
callback();
}
}
});
}
//打开一个最大化的dialog
jduoffu.showmaxdialog =function(tit, url) {
$.dialog({
title: tit,
content: 'url:' + url,
min: false,
max: false,
lock: false
}).max();
}
/////////////////////////////
//弹出消息框
/////////////////////////////
jduoffu.message=function(msg, success){
var iconurl = "";
switch (success) {
case "success":
iconurl = "32x32/succ.png";
break;
case "error":
iconurl = "32x32/fail.png";
break;
default:
iconurl = "32x32/hits.png";
break;
}
$.dialog.tips(msg, 2, iconurl);
};
/////////////////////////////
//弹出提示框
/////////////////////////////
jduoffu.alert=function(msg){
$.dialog.alert(msg);
};
/////////////////////////////
//弹出确认框
//例如:
//1、jduoffu.confirm("是否操作", act, null) //函数不加()
//2、jduoffu.confirm("是否操作", "alert('yes')", "alert('no')")
/////////////////////////////
jduoffu.confirm=function(msg, returnsubmitfunc, returncancelfunc)
{
};
/////////////////////////////
//弹出模拟窗口
/////////////////////////////
jduoffu.popwin={
show:function(url, width, height, showclosebox, showtitle, returnfunc)
{
},
hide:function(callreturnfunc){
}
};
/////////////////////////////
//弹出加载层
/////////////////////////////
jduoffu.loading={
show:function(msgstr, width, height)
{
},
hide:function(callreturnfunc){
}
};