(function(f){f.extend({Util:{range:function(a,b,c){a=parseInt(a,10);b=parseInt(b,10);if(isNaN(a)||isNaN(b))return false;var d=[];if(c==null)c=1;c=parseInt(c,10);if(isNaN(c))return false;if(c===0)c=1;if(a>b&&c>0)c=-1*c;for(i=a;;i+=c){if(a>b){if(i<b)break}else if(i>b)break;d.push(i)}return d},pause:function(a){if(typeof a!="number"||isNaN(a))a=1E3;var b=new Date;for(a=b.getTime()+a;;){b=new Date;if(b.getTime()>a)return}},urlValue:function(a,b){if(typeof a!="string"&&typeof a!="number")return"";b=b||
window.location.href;a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");a=(new RegExp("[\\?&]"+a+"=([^&#]*)")).exec(b);return a!=null?a[1]:null},debug:function(a){if(typeof console!="undefined"&&typeof console.log!="undefined")console.log(a);else if(typeof opera!="undefined"&&typeof opera.postError!="undefined")opera.postError(a);else{if(!document.msgDebug)document.msgDebug=[];document.msgDebug.push(a);document.msgDebug.length>5&&document.msgDebug.shift();window.status=document.msgDebug.join(". ")}},
simpleUnique:function(a){if(!(a instanceof Array))return a;a=a.sort();for(var b=[],c=0;c<a.length;c++)f.inArray(a[c],b)<0&&b.push(a[c]);return b},id:function(a){var b=a instanceof jQuery?a:f(a);a=f(a)[0];if(!f.trim(b.attr("id")).length){var c,d=document.getElementsByTagName(a.tagName).length||100;d=Math.pow(d,2);do c=Math.floor(Math.random()*d);while(document.getElementById(a.tagName+"-"+c));b.attr("id",a.tagName+"-"+c)}return b.attr("id")},objectLength:function(a){var b=0;if(typeof a!="object")return false;
for(var c in a)b++;return b},objectSort:function(a,b){var c=[],d=[],e={};b=b||"asc";for(var g in a){c.push(g);d.push(a[g])}for(g=0;g<d.length;g++)for(a=g+1;a<d.length;a++){var h=false;switch(b){case "asc":h=d[a]<d[g];break;case "desc":h=d[a]>d[g];break;default:if(typeof b=="function")h=b.call(null,d[g],d[a]);break}if(h===true){h=d[g];d[g]=d[a];d[a]=h;h=c[g];c[g]=c[a];c[a]=h}}for(g=0;g<c.length;g++)e[c[g]]=d[g];return e},objectKeys:function(a){var b=[];for(var c in a)b.push(c);return b},objectValues:function(a){var b=
[];for(var c in a)b.push(a[c]);return b},strRight:function(a,b){a+="";b=b<=a.length?b:a.length;return a.substr(a.length-b)},strLeft:function(a,b){a+="";b=b<=a.length?b:a.length;return a.substr(0,b)},checkDate:function(a,b,c){a*=1;b*=1;c*=1;if(a<1||a>12)return false;if(b<1||b>31)return false;if((a==4||a==6||a==9||a==11)&&b==31)return false;if(a==2){if(b>29)return false;a=c/4;if(isNaN(a))return false;if(b==29&&a!=parseInt(a,10))return false}return true},daysInMonth:function(a,b){var c=[31,28,31,30,
31,30,31,31,30,31,30,31];if(a!=2)return c[a-1];if(b%4!=0)return c[1];if(b%100==0&&b%400!=0)return c[1];return c[1]+1},arrayIndexOf:function(a,b,c){if(!(a instanceof Array))return-1;c=(c||0)*1;c=!isNaN(c)&&c>=0&&c<=a.length-1?c*1:0;if(typeof Array.indexOf=="function")return a.indexOf(b,c);for(c=c;c<a.length;c++)if(a[c]==b)return c;return-1},isNull:function(a){return a===null},setElementTitle:function(a,b,c,d){b+="";if(!b.length)return false;d=d||"";a=a instanceof jQuery?a:f(a);c=f.Util.arrayIndexOf(["prepend",
"append","replace"],(c+"").toLowerCase())==-1?"append":(c+"").toLowerCase();var e=typeof a.attr("title")=="undefined"||a.attr("title").length<1?null:a.attr("title");switch(c){case "prepend":e=b+(f.Util.isNull(e)?"":d+e);break;case "append":e=(f.Util.isNull(e)?"":e+d)+b;break;case "replace":e=b;break}a.attr("title",e);return true},isAjax:function(a){return a instanceof(window.ActiveXObject?ActiveXObject:window.XDomainRequest?XDomainRequest:XMLHttpRequest)},childrenHeight:function(a){a=a instanceof
jQuery?a:f(a);var b=0;a.children().each(function(){b+=f(this).outerHeight(true)});return b==0?a.outerHeight(true):b},round:function(a,b){if(isNaN(a))return false;var c=1;a=parseFloat(a);for(b=b=isNaN(b)?1:parseInt(b,10);b>0;b--)c*=10;b=c;return Math.round(a*b)/b},strCapitalize:function(a){return a.replace(/\w+/g,function(b){return b.charAt(0).toUpperCase()+b.slice(1).toLowerCase()})},dateFormat:function(a,b){if(typeof a!="string")return false;a=a.split("");b=new Date(b);var c=[],d;for(var e in a){d=
a[e];switch(d){case "d":c.push(b.getDate());break;case "D":d=b.getDate();if(parseInt(d,10)<10)d="0"+d;c.push(d);break;case "m":c.push(b.getMonth()+1);break;case "M":d=b.getMonth()+1;if(parseInt(d,10)<10)d="0"+d;c.push(d);break;case "y":c.push(b.getYear());break;case "Y":c.push(b.getFullYear());break;default:c.push(d);break}}return c.join("")},strRepeat:function(a,b){var c=[];for(i=0;i<b;i++)c.push(a);return c.join("")},getCookie:function(a){a+="=";for(var b,c=document.cookie.split(";"),d=0;d<c.length;d++){for(b=
c[d];b.charAt(0)==" ";)b=b.substring(1,b.length);if(b.indexOf(a)==0)return b.substring(a.length,b.length)}return null},setCookie:function(a,b,c,d,e){var g=[];g.push(a+"="+b);if(c){a=new Date;a.setTime(a.getTime()+c*24*60*60*1E3);g.push("expires="+a.toGMTString())}e=typeof e=="string"?e:"/";g.push("path="+e);typeof d=="string"&&g.push("domain="+d);document.cookie=g.join("; ")},delCookie:function(a){f.Util.setCookie(a,"",-1)},arrayFill:function(a,b,c,d){if(!(a instanceof Array)||isNaN(b)||isNaN(c)||
parseInt(c,10)<1)return false;for(var e=0;e<parseInt(c,10);){a[b+e]=d;e++}},stringCounter:function(a,b){var c=[],d,e;if(typeof a=="string"){f.Util.stringCounter.charString=a;f.Util.stringCounter.charArray&&delete f.Util.stringCounter.charArray}else if(f.Util.stringCounter.charString)a=f.Util.stringCounter.charString;else{a="ABCDEFGHIJKLMNOPQRSTUVWXYZ";f.Util.stringCounter.charString=a;f.Util.stringCounter.charArray&&delete f.Util.stringCounter.charArray}e=a.length;if(b instanceof Array)f.Util.stringCounter.charArray=
b;else if(f.Util.stringCounter.charArray)b=f.Util.stringCounter.charArray;else{b=[-1];f.Util.stringCounter.charArray=b}++b[b.length-1];if(b[b.length-1]>=e)for(d=b.length;d>0;d--)if(b[d]>=e){b[d-1]++;b[d]=0}if(b[0]>=e){for(d=0;d<b.length;d++)b[d]=0;b[b.length]=0}for(d=0;d<b.length;d++)c.push(a.charAt(b[d]));return c.join("")}}})})(jQuery);
