var shSite={preloadImages:[],initFunctions:[],loaded:false,init:function(){shSite.loaded=true;var a=[];$.each(this.preloadImages,function(c,b){a[c]=new Image();a[c].src=b});$.each(this.initFunctions,function(b,c){c()})},alert:function(a,b){if(shSite.loaded){var c=!b?function(){}:($.isFunction(b)?b:function(){b.focus()});if($.ui&&$.ui.dialog){a=a.replace("\n","<br />\n");shSite.dialog("Alert",a,c)}else{alert(a);c()}}else{this.hookInitFunction(function(){shSite.alert(a,b)})}},dialog:function(title,content,options){if(!options){options={}}$("body").append("<div></div>");var jAlert=$("body > div").last();jAlert.css("display","none");jAlert.attr("title",title);jAlert.html(content);var defaultOptions={resizable:false,minHeight:false,modal:true,show:"fade",buttons:{OK:function(){$(this).dialog("close")}},close:function(){jAlert.detach()},zindex:10000};$.each(defaultOptions,function(key,val){var prop="options."+key;eval("if (typeof "+prop+' == "undefined") '+prop+" = val;")});jAlert.dialog(options)},addPreloadImage:function(a){if($.isArray(a)){this.preloadImages.concat(a)}else{this.preloadImages.push(a)}},addInitFunction:function(a){if($.isArray(a)){this.initFunctions.concat(a)}else{this.initFunctions.push(a)}},getXML:function(a){if(window.DOMParser){xml=new DOMParser().parseFromString(a,"text/xml")}else{xml=new ActiveXObject("Microsoft.XMLDOM");xml.async="false";xml.loadXML(a)}return xml},transferSelectOptions:function(h,g){var b=[];var f=0;var d,e,c,a;for(c=0;c<h.length;c++){if(h.options[c].selected){b[b.length]=c}}$.each(b,function(k,l){d=h.options[l-f];e=new Option(d.text,d.value);if(!g.length){try{g.add(e,null)}catch(n){g.add(e)}}else{var m=false;for(k=0;k<g.length;k++){if(d.text<g.options[k].text){m=true;try{g.add(e,g.options[k])}catch(n){g.add(e,k)}break}}if(!m){try{g.add(e,null)}catch(n){g.add(e)}}}h.remove(l-f++)})},humanSize:function(a){if(a<1024){a=a.toString()+" B"}else{if(a<1048576){a/=1024;a=parseInt(a).toString()+" KB"}else{if(a<1073741824){a/=1048576;a=parseInt(a).toString()+" MB"}else{if(a<1099511627776){a/=1073741824;a=parseInt(a).toString()+" GB"}else{a/=1099511627776;a=parseInt(a).toString()+" TB"}}}}return a},no_px:function(a){return parseInt(a.replace(/^(\-?\d+)(px)$/,"$1"))},jsValue:function(a){a=a.replace(/\r?\n/g,"\\n").replace(/\'/g,"'").replace(/\"/g,'\\"');return a},htmlValue:function(a){return a.replace(/\"/g,"&quot;")},ltrim:function(a){return a.replace(/^\s+/,"")},rtrim:function(a){return a.replace(/\s+$/,"")},trim:function(a){return this.ltrim(this.rtrim(a))},clearWhitespaces:function(a){a=this.trim(a);return a.replace(/\s+/g," ")},loadCSS:function(b){var a=document.createElement("link");a.setAttribute("rel","stylesheet");a.setAttribute("type","text/css");a.setAttribute("href",b);document.getElementsByTagName("head")[0].appendChild(a)},fieldToggle:function(e,d,a,b,c){if(!b){b=""}$(e).focus(function(){if($(this).attr("value")==d){$(this).attr("value",b)}if(c){c()}});$(e).blur(function(){$(this).attr("value",shSite.normalizeValue($(this).attr("value")));if(($(this).attr("value")==b)||($(this).attr("value")=="")){$(this).attr("value",d)}if(a){a()}})},getCaretPos:function(d){var e=0;if(document.selection){d.focus();var b=document.selection.createRange();if(b==null){return 0}var a=d.createTextRange(),c=a.duplicate();a.moveToBookmark(b.getBookmark());c.setEndPoint("EndToStart",a);e=c.text.length}else{if(d.selectionStart||(d.selectionStart=="0")){e=d.selectionStart}}return e},setCaretPos:function(b,c){if(b.setSelectionRange){b.focus();b.setSelectionRange(c,c)}else{if(b.createTextRange){var a=b.createTextRange();a.collapse(true);a.moveEnd("character",c);a.moveStart("character",c);a.select()}}},httpPost:function(a,c){var b='<form method="post" action="'+a+'">';$.each(c,function(d,e){d=d.toString();e=e.toString();b+='<input type="hidden" name="'+shSite.htmlValue(d)+'" value="'+shSite.htmlValue(e)+'" />'});b+="</form>";$("body").append(b);$("body form").last().get(0).submit()},kuki:{prefix:"KCF_",duration:365,domain:"kcfinder.sunhater.com",path:"/",secure:false,set:function(b,h,e,f,i,a){b=this.prefix+b;if(e==null){e=this.duration}if(a==null){a=this.secure}if((f==null)&&this.domain){f=this.domain}if((i==null)&&this.path){i=this.path}a=a?true:false;var d=new Date();d.setTime(d.getTime()+(e*86400000));var c=d.toGMTString();var g=b+"="+h+"; expires="+c;if(f!=null){g+="; domain="+f}if(i!=null){g+="; path="+i}if(a){g+="; secure"}return(document.cookie=g)?true:false},get:function(c){c=this.prefix+c;var e=c+"=";var b=document.cookie.split(";");var a;for(var d=0;d<b.length;d++){a=b[d];while(a.charAt(0)==" "){a=a.substring(1,a.length)}if(a.indexOf(e)==0){return a.substring(e.length,a.length)}}return null},del:function(a){return this.set(a,"",-1)},isSet:function(a){return(this.get(a)!=null)}},parseURLs:function(a,c,b){a=a.replace(/(http(s?)\:\/\/|(www\.))([^\s]+)/g,"<a"+(c?'rel="nofollow"':"")+' target="_blank" href="http$2://$3$4">http$2://$3$4</a>');if(b){var d="";do{if(d){a=d}d=a.replace("<a"+(c?'rel="nofollow"':"")+' target="_blank" href="http://'+b+"/",'<a href="http://'+b+"/")}while(d!=a)}return a}};$(document).ready(function(){shSite.init()});
