// JavaScript Document function ajaxCall(post, refreshOnSuccess) { if (post.indexOf('token=') == -1) post += '&token='+$('#token').val() var res = $.ajax({type:"POST", url:"ajax.html", contentType:'application/x-www-form-urlencoded; charset=UTF-8', data:post, processData:false, async:false}).responseText if (refreshOnSuccess) if (res == 1) window.location.reload() else reportError(res) else return res } function serializeForm(obj) { return $($(obj).parents('form')).serialize(); } function populateTarget(tgt,tkn){ $(tgt).html(ajaxCall(tkn)) } function populateJSON(tgt,tkn) { $(tgt).html(buildContent( $.parseJSON(ajaxCall(tkn)) )) } var getUniqueId = (function() {var id=0;return function() {if (arguments[0]==0) {id=1;return 0;} else return id++;}})(); var modalWindows = new Array(); function getModalNum($obj) { if ($($obj).parents('.modalWindow').attr('id')) return $($obj).parents('.modalWindow').attr('id').replace('modalWindow',''); else return null; } function loadModal(postData,opener,callback) { modalNum = getUniqueId() if(opener == undefined) { closeAllModals(); opener = -1; } else if(isNaN(opener)) { opener = getModalNum(opener) } if(callback == undefined) { if(modalWindows[opener] != undefined && modalWindows[opener].callback == undefined) { callback = modalWindows[opener].callback; } else { callback = false; } } try{ response = $.parseJSON(ajaxCall(postData+'&modalNum='+modalNum+(callback ? '&callback='+callback : ''))); } catch(err) { msg = 'There was a code error in the response. The error details are below: '; msg += '
'+err+'
'; reportError(msg); return false; } if (response) { if(callback == 'reauthenticate' && modalWindows[opener] != undefined) { if (response.responseCode != 'authenticateFail') { loginWindow = opener; opener = modalWindows[modalWindows[modalWindows[opener].modalNum].modalNum].opener; modalWindows[loginWindow].closeModal(); } } if (response.responseCode == 200 || response.responseCode == 250) { newModal = new modal(response, modalNum, opener); newModal.callback = callback; newModal.loadModal(); } else if (response.responseCode == 150 || response.responseCode == 500) { if(response.success) reportError(response.success); if(response.responseCode == 150) { setTimeout(function(){window.location.reload()},2000); } else { fn = window[callback]; if(typeof fn == 'function') { fn(response.responseFields); if(modalWindows[opener]) { modalWindows[opener].closeModal(); } $('#error').delay(2000).fadeOut(); } else { if (modalWindows[opener]) { modalWindows[opener].response = response; modalWindows[opener].loadModal(); } else { setTimeout(function(){window.location.reload()},2000); } } } } else if (modalWindows[opener]) { modalWindows[opener].response = response; //newModal.callback = callback; modalWindows[opener].loadModal(); } else { reportError(response.error); } } else { alert('There was no response'); } } function reauthenticate(){ } function closeModal(modal) { modalNum = getModalNum(modal) if(modalWindows[modalNum]) { modalWindows[modalNum].closeModal(); } else { alert('This window does not exist.'); } } function closeAllModals() { $('.modalWindow').fadeOut(1000,(function(obj){ return function(){obj.remove()} })($('.modalWindow'))); $('.modalOverlay').fadeOut(1000,(function(obj){ return function(){obj.remove()} })($('.modalOverlay'))); $('#error').fadeOut(1000,(function(obj){ return function(){obj.html('')} })($('#error'))); }; function closeAndRefresh() { window.location.reload(); } function modal(result, thisNum, thisOpener) { this.modalNum = thisNum; this.modalWindow; this.modalOverlay; this.response = result; this.opener = (modalWindows[thisOpener] ? thisOpener : null); this.callback = false if(!modalWindows[this.modalNum]) modalWindows[this.modalNum] = this; this.updateResponse = function(postData) { this.response = $.parseJSON(ajaxCall(postData+'&modalNum='+this.modalNum)); } this.loadModal = function() { $(document).scrollTop(0); var obj; switch(this.response.responseCode) { //Show success message, then refresh page case '100': if (!this.modalWindow.children('.modalWindowContent').children('.successMsg').attr('class')) { this.modalWindow.find('form').before(''+response.description+'
'+"\r\n"; if(response.success) modalContent += ''+response.success+''; else if(response.error) modalContent += ''+response.error+''; modalContent += ''+"\r\n" } $('.errorClose').bind("click", function() { $("#error").fadeOut() }) function reportError(error){ $('#error').html(error+'Close').slideDown(250); $('.errorClose').bind("click", function() { $("#error").fadeOut() }) } $(document).ready( function(){ $('a[rel*="external"]').click(function(){return !window.open(this.href);}); }); /* File Manager Module 11-03-30 */ function toggleChildrenList(o) { $('> ul', o).slideToggle('fast',function() { if ($('> ul', o).css('display') == 'none') { $(o).children('.listToggler').html('Expand'); } else { $(o).children('.listToggler').html('Collapse'); } }); } /* Register Module 11-03-30 */ function registerGoBack(url,token) { $('#token').val(token); $('#registerForm').attr('action',url).submit(); } function detectInternetExplorerVersion() // Returns the version of Internet Explorer or a -1 // (indicating the use of another browser). { var rv = -1; // Return value assumes failure. if (navigator.appName == 'Microsoft Internet Explorer') { var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); if (re.exec(ua) != null) rv = parseFloat( RegExp.$1 ); } return rv; } function checkIE() { var ver = detectInternetExplorerVersion(); if ( ver > -1 ) { if ( ver >= 8.0 ) return ver } else { return false; } } /* This script contains embed functions for common plugins. This scripts are complety free to use for any purpose. */ function writeFlash(p) {writeEmbed('D27CDB6E-AE6D-11cf-96B8-444553540000','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0','application/x-shockwave-flash',p);} function writeShockWave(p) {writeEmbed('166B1BCA-3F9C-11CF-8075-444553540000','http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0','application/x-director',p);} function writeQuickTime(p) { writeEmbed('02BF25D5-8C17-4B23-BC80-D3488ABDDC6B','http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0','video/quicktime',p);} function writeRealMedia(p) {writeEmbed('CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0', 'audio/x-pn-realaudio-plugin',p);} function writeWindowsMedia(p) {p.url = p.src;writeEmbed('6BF52A52-394A-11D3-B153-00C04F79FAA6','http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701', 'application/x-mplayer2',p);} function writeEmbed(cls, cb, mt, p) {var h = '',n;h+= '';document.write(h);} /* Modernizr 2.5.2 (Custom Build) | MIT & BSD * Build: http://www.modernizr.com/download/#-draganddrop-hasevent */ ;window.Modernizr=function(a,b,c){function u(a){i.cssText=a}function v(a,b){return u(prefixes.join(a+";")+(b||""))}function w(a,b){return typeof a===b}function x(a,b){return!!~(""+a).indexOf(b)}function y(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:w(f,"function")?f.bind(d||b):f}return!1}var d="2.5.2",e={},f=b.documentElement,g="modernizr",h=b.createElement(g),i=h.style,j,k={}.toString,l={},m={},n={},o=[],p=o.slice,q,r=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=w(e[d],"function"),w(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),s={}.hasOwnProperty,t;!w(s,"undefined")&&!w(s.call,"undefined")?t=function(a,b){return s.call(a,b)}:t=function(a,b){return b in a&&w(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=p.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(p.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(p.call(arguments)))};return e}),l.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a};for(var z in l)t(l,z)&&(q=z.toLowerCase(),e[q]=l[z](),o.push((e[q]?"":"no-")+q));return u(""),h=j=null,e._version=d,e.hasEvent=r,e}(this,this.document); (function(b){var e,d,a=[],c=window;b.fn.tinymce=function(j){var p=this,g,k,h,m,i,l="",n="";if(!p.length){return p}if(!j){return tinyMCE.get(p[0].id)}p.css("visibility","hidden");function o(){var r=[],q=0;if(f){f();f=null}p.each(function(t,u){var s,w=u.id,v=j.oninit;if(!w){u.id=w=tinymce.DOM.uniqueId()}s=new tinymce.Editor(w,j);r.push(s);s.onInit.add(function(){var x,y=v;p.css("visibility","");if(v){if(++q==r.length){if(tinymce.is(y,"string")){x=(y.indexOf(".")===-1)?null:tinymce.resolve(y.replace(/\.\w+$/,""));y=tinymce.resolve(y)}y.apply(x||tinymce,r)}}})});b.each(r,function(t,s){s.render()})}if(!c.tinymce&&!d&&(g=j.script_url)){d=1;h=g.substring(0,g.lastIndexOf("/"));if(/_(src|dev)\.js/g.test(g)){n="_src"}m=g.lastIndexOf("?");if(m!=-1){l=g.substring(m+1)}c.tinyMCEPreInit=c.tinyMCEPreInit||{base:h,suffix:n,query:l};if(g.indexOf("gzip")!=-1){i=j.language||"en";g=g+(/\?/.test(g)?"&":"?")+"js=true&core=true&suffix="+escape(n)+"&themes="+escape(j.theme)+"&plugins="+escape(j.plugins)+"&languages="+i;if(!c.tinyMCE_GZ){tinyMCE_GZ={start:function(){tinymce.suffix=n;function q(r){tinymce.ScriptLoader.markDone(tinyMCE.baseURI.toAbsolute(r))}q("langs/"+i+".js");q("themes/"+j.theme+"/editor_template"+n+".js");q("themes/"+j.theme+"/langs/"+i+".js");b.each(j.plugins.split(","),function(s,r){if(r){q("plugins/"+r+"/editor_plugin"+n+".js");q("plugins/"+r+"/langs/"+i+".js")}})},end:function(){}}}}b.ajax({type:"GET",url:g,dataType:"script",cache:true,success:function(){tinymce.dom.Event.domLoaded=1;d=2;if(j.script_loaded){j.script_loaded()}o();b.each(a,function(q,r){r()})}})}else{if(d===1){a.push(o)}else{o()}}return p};b.extend(b.expr[":"],{tinymce:function(g){return g.id&&!!tinyMCE.get(g.id)}});function f(){function i(l){if(l==="remove"){this.each(function(n,o){var m=h(o);if(m){m.remove()}})}this.find("span.mceEditor,div.mceEditor").each(function(n,o){var m=tinyMCE.get(o.id.replace(/_parent$/,""));if(m){m.remove()}})}function k(n){var m=this,l;if(n!==e){i.call(m);m.each(function(p,q){var o;if(o=tinyMCE.get(q.id)){o.setContent(n)}})}else{if(m.length>0){if(l=tinyMCE.get(m[0].id)){return l.getContent()}}}}function h(m){var l=null;(m)&&(m.id)&&(c.tinymce)&&(l=tinyMCE.get(m.id));return l}function g(l){return !!((l)&&(l.length)&&(c.tinymce)&&(l.is(":tinymce")))}var j={};b.each(["text","html","val"],function(n,l){var o=j[l]=b.fn[l],m=(l==="text");b.fn[l]=function(s){var p=this;if(!g(p)){return o.apply(p,arguments)}if(s!==e){k.call(p.filter(":tinymce"),s);o.apply(p.not(":tinymce"),arguments);return p}else{var r="";var q=arguments;(m?p:p.eq(0)).each(function(u,v){var t=h(v);r+=t?(m?t.getContent().replace(/<(?:"[^"]*"|'[^']*'|[^'">])*>/g,""):t.getContent()):o.apply(b(v),q)});return r}}});b.each(["append","prepend"],function(n,m){var o=j[m]=b.fn[m],l=(m==="prepend");b.fn[m]=function(q){var p=this;if(!g(p)){return o.apply(p,arguments)}if(q!==e){p.filter(":tinymce").each(function(s,t){var r=h(t);r&&r.setContent(l?q+r.getContent():r.getContent()+q)});o.apply(p.not(":tinymce"),arguments);return p}}});b.each(["remove","replaceWith","replaceAll","empty"],function(m,l){var n=j[l]=b.fn[l];b.fn[l]=function(){i.call(this,l);return n.apply(this,arguments)}});j.attr=b.fn.attr;b.fn.attr=function(n,q,o){var m=this;if((!n)||(n!=="value")||(!g(m))){return j.attr.call(m,n,q,o)}if(q!==e){k.call(m.filter(":tinymce"),q);j.attr.call(m.not(":tinymce"),n,q,o);return m}else{var p=m[0],l=h(p);return l?l.getContent():j.attr.call(b(p),n,q,o)}}}})(jQuery);