/* * realway javascript library * copyright(c)2009 ~ 2012 realway * email:realway@gmail.com */ /* * function:windows libs */ var $$=function(obj){return(typeof obj !='object')? document.getelementbyid(obj):obj;}; var ie=function(){var v=4,div=document.createelement('div'),i=div.getelementsbytagname('i');do{div.innerhtml='';}while(i[0]);return v>5 ? v:false;}();/* * function:shuffle * return shuffle array */ var shuffle=function(v){for(var j,x,i=v.length;i;j=parseint(math.random()* i),x=v[--i],v[i]=v[j],v[j]=x);return v;};/* * ie6 js function trim */ if(typeof string.prototype.trim !=='function'){string.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,'');}}; var getscrollpos=function(){var clientscrolltop=window.pageyoffset||document.documentelement.scrolltop||document.body.scrolltop||0;return clientscrolltop;};var win_height=function(){if(self.innerheight)return self.innerheight;else if(document.documentelement && document.documentelement.clientheight)return document.documentelement.clientheight;else if(document.body)return document.body.clientheight;};/* * tabs('.ui-tabs');**
1
2
*/ var tabs=function(sobject,sevents,callback){sevents='click '+sevents||'click';$(sobject+'>li').on(sevents,function(){if(!$(this).find('a').attr('href')){var opanel=$(sobject+'-panel>div');$(this).addclass('active').siblings().removeclass('active');opanel.eq($(this).index()).show().siblings().hide();(callback && typeof(callback)==="function")&& callback($(this).index());}});$(sobject+'>li').eq(0).click();return false;};/* * preload images * $.preload(["{v}/images/home/nav_home_news_active.gif"],{loaded_all:function(loaded,total){...}});*/(function($){var imglist=[];$.extend({preload:function(imgarr,option){var setting=$.extend({init:function(loaded,total){},loaded:function(img,loaded,total){},loaded_all:function(loaded,total){}},option);var total=imgarr.length;var loaded=0;setting.init(0,total);for(var i in imgarr){imglist.push($("").attr("src",imgarr[i]).load(function(){loaded++;setting.loaded(this,loaded,total);if(loaded==total){setting.loaded_all(loaded,total);}}));}}});})(jquery);/* * cookies */ function cookie(){};/* * 参数:cookie名,值,生存天数,生存小时数 */ cookie.setcookie=function(name,value,years,days,hours){years=years||0;days=days||0;hours=hours||12;var exptime=new date();exptime.setfullyear(exptime.getfullyear()+years);exptime.setdate(exptime.getdate()+days);exptime.sethours(exptime.gethours()+hours);ct=escape(name)+"="+escape(value)+";path=/;"+"expires="+exptime.togmtstring();document.cookie=ct;};/* * 获取某个cookie值 * 返回:cookie值或undefined */ cookie.getcookie=function(name){var rs=document.cookie.match(new regexp("(?:^|)"+escape(name)+"=([^;]*)(?:;|$)","i"));return rs ? unescape(rs[1]):"undefined";};cookie.deletecookie=function(name){document.cookie=escape(name)+"=;expires="+new date().togmtstring();};cookie.clearcookie=function(){var expstr=new date().togmtstring();var rs=document.cookie.match(new regexp("([^;][^;]*)(?=(=[^;]*)(;|$))","gi"));for(var i in rs)document.cookie=rs[i]+"=;expires="+expstr;};/* * */(function($){$.geturlparam=function(name){var reg=new regexp("(^|&)"+name+"=([^&]*)(&|$)");var r=window.location.search.substr(1).match(reg);if(r!=null)return unescape(r[2]);return null;}})(jquery);