/*

vars.php

*/
var _MSG_FAIL="<p class=\"ac\"><img src=\"images/exclamation-dark.jpg\" width=\"120\" height=\"103\" alt=\"Caution\" /></p>";
var _MSG_OK="<p class=\"ac\"><img src=\"images/tick-dark.jpg\" width=\"121\" height=\"102\" alt=\"OK\" /></p>";
var _MSG_INFO="<p class=\"ac\"><img src=\"images/tick-dark.jpg\" width=\"121\" height=\"102\" alt=\"OK\" /></p>";
/*

global.js

*/
with (window.navigator) {
var isIE6=userAgent.match(/MSIE 6\.[0-9]+/),
isIE7=userAgent.match(/MSIE 7\.[0-9]+/),
isIE8=userAgent.match(/MSIE 8\.[0-9]+/),
isMoz=userAgent.match(/Netscape/),
isFF=userAgent.match(/Firefox/),
isOpera=userAgent.match(/Opera/),
isIE=(isIE6||isIE7||isIE8);
}
/*
if(isIE6) {
window.onerror=function(msg,file,line) {
alert("Error: "+msg+"\nFile: "+file+"\nLine: "+line);
return true;
}
}
*/
function $(id)
{
return document.getElementById(id);
}
function go(u)
{
document.location.href=u;
}
function relativeURL()
{
return document.location.pathname+document.location.search;
}
function byTag(tag,obj)
{
if(obj==null) {
obj=document;
}
var col=[];
tag=tag.split(",");
for(var g=0,l=tag.length;g<l;g++) {
var w=obj.getElementsByTagName(tag[g].toUpperCase());
for(var q=0,l2=w.length;q<l2;q++) {
col.push(w[q]);
}
}
return col;
}
function byAttribute(att,value,obj)
{
var re=new RegExp(value);
var r=[];
var els=(obj||document).getElementsByTagName("*");
for(var c=0,l=els.length;c<l;c++) {
var a=els[c].getAttribute(att);
if(a&&a.match(re)) {
r.push(els[c]);
}
}
return r;
}
function create(el)
{
return document.createElement(el);
}
function findParent(obj,tag)
{
tag=tag.toUpperCase();
while(obj&&obj.tagName!=tag) {
obj=obj.parentNode;
}
return obj;
}
function previous(obj,s) {
s=s.toUpperCase();
var x=obj;
do {
x=x.previousSibling;
if(x&&x.tagName&&x.tagName==s) {
return x;
}
} while(1&&x);
return false;
}
function next(obj,s) {
s=s.toUpperCase();
var x=obj;
do {
x=x.nextSibling;
if(x&&x.tagName&&x.tagName==s) {
return x;
}
} while(1&&x);
return false;
}
function addClass(obj,c)
{
var s=obj.className.split(/ /);
for(var q=0,l=s.length;q<l;q++) {
if(s[q]==c) {
return obj;
}
}
s.push(c);
obj.className=s.join(' ');
return obj;
}
function removeClass(obj,c)
{
var r=[];
var s=obj.className.split(/ /);
for(var q=0,l=s.length;q<l;q++) {
if(s[q]!=c) {
r.push(s[q]);
}
}
obj.className=r.join(' ');
return obj;
}
function injectJS(str)
{
var myID=0;
for(var i=0,l=str.length;i<l;i++) {
myID+=str.charCodeAt(i);
}
myID="injektd"+myID;
if(! $(myID)) {
var s=create("SCRIPT");
s.type="text/javascript";
s.id=myID;
try {
s.text=str;
}
catch(e) {
s.textContent=str;
}
byTag("HEAD")[0].appendChild(s);
}
else {
eval(str);
}
return myID;
}
function extend(obj,props,force)
{
for(var x in props) {
if(typeof(obj[x])=="undefined"||force) {
obj[x]=props[x];
}
}
}
function position(obj,type)
{
type=type.toLowerCase().ucFirst();
var orig=obj;
var retval=0;
if(type=="Left"&&obj.x) {
return obj.x;
}
else if(type=="Top"&&obj.y) {
return obj.y;
}
else {
var useType=(type=="Left"||type=="Right"||type=="Center") ? "Left" : "Top";
while(obj.offsetParent) {
retval+=eval("obj.offset"+useType);
obj=obj.offsetParent;
}
switch (type) {
case "Center" : return retval+(orig.offsetWidth / 2);break;
case "Right" : return retval+(orig.offsetWidth);break;
default: return retval;
}
}
return false;
}
function getStyle(obj,s)
{
if(document.defaultView&&document.defaultView.getComputedStyle) {
try {
return document.defaultView.getComputedStyle(obj,null).getPropertyValue(s);
}
catch(e) {
return false;
}
}
else if(obj.currentStyle) {
return eval("obj.currentStyle."+s.camelize());
}
return false;
}
function getStyleAsInt(obj,s) {
var cs=getStyle(obj,s);
if(cs=="auto") {
return 0;
}
return (cs) ? parseInt(String(cs).replace(/px$/,"")) : false;
}
function screenHeight()
{
return screenDimension("Height");
}
function screenWidth()
{
return screenDimension("Width");
}
function decimalsOnly(o,dp)
{
if(dp==null) dp=2;
o.value=o.value.replace(/[^0-9.]/g,"");
var re=new RegExp('([0-9]+)\.([0-9]{'+dp+'})(.*)',"g");
o.value=o.value.replace(re,"$1.$2");
}
function screenDimension(type)
{
return eval("(self.inner"+type+") ? self.inner"+type+" : (document.documentElement&&document.documentElement.client"+type+") ? document.documentElement.client"+type+" : document.body.client"+type);
}
function getScroll()
{
if(document.documentElement&&document.documentElement.scrollTop) {
return document.documentElement.scrollTop;
}
return (document.body.scrollTop) ? document.body.scrollTop : ((window.pageYOffset) ? window.pageYOffset : 0);
}
String.prototype.camelize=function(str) {
var temp=this.split(/-|_/g);
str="";
for(var a=0,l=temp.length;a<l;a++) {
str+=((a!=0) ? temp[a].substring(0,1).toUpperCase() : temp[a].substring(0,1).toLowerCase())+temp[a].substring(1).toLowerCase();
}
return str;
};
String.prototype.ucWords=function()
{
var temp=this.split(/ /g),str=[];
for(var a=0,l=temp.length;a<l;a++) {
str.push(temp[a].substring(0,1).toUpperCase()+temp[a].substring(1).toLowerCase());
}
return str.join(' ');
}
String.prototype.ucFirst=function() {
return this.substring(0,1).toUpperCase()+this.substring(1);
};
String.prototype.trim=function(){
return this.replace(/^\s+|\s+$/g,'');
};
if(! window.Event) {
var Event={};
}
var ev={
events:[],
get:function(e)
{
return (! e) ? window.event : e;
},
target:function(e)
{
e=this.get(e);
return (e.target) ? e.target : (e.srcElement) ? e.srcElement : false;
},
add:function(elm,evType,fn,useCapture)
{
if(elm.addEventListener) {
elm.addEventListener(evType,fn,useCapture);
return this.store(elm,evType,fn,useCapture);
}
else if(elm.attachEvent) {
var r=elm.attachEvent('on'+evType,fn);
return this.store(elm,evType,fn,useCapture);
}
else {
elm['on'+evType]=fn;
return this.store(elm,evType,fn,useCapture);
}
},
tryAdd:function(elm,evType,fn,useCapture)
{
return (elm) ? Event.add(elm,evType,fn,useCapture) : false;
},
key:function(e)
{
e=this.get(e);
return (e.keyCode) ? e.keyCode : (e.which) ? e.which : e.charCode;
},
stop:function(e)
{
e=this.get(e);
if(document.all) {
e.returnValue=false;
e.cancelBubble=true;
}
else {
e.preventDefault();
e.stopPropagation();
}
},
store:function(elm,evType,fn,useCapture)
{
this.events.push({'elm':elm,'type':evType,'fn':fn,'useCapture':useCapture});
return elm;
},
execute:function(ev)
{
if(typeof(ev)!='object') {
ev=[ev];
}
for(var q=0,l=ev.length;q<l;q++) {
try {
ev[q].call();
}
catch(e) {
try {
eval(ev[q]);
}
catch(e2) {
if(_DEBUG) {
var s=[ev[q]];
for(var prop in e2) {
s.push(prop.toUpperCase()+" : "+e2[prop]);
}
alert(s.join("\n\n"));
}
}
}
}
},
cleanup:function()
{
var e=Event.events;
for(var i=0,l=e.length;i<l;i++) {
with (e[i]) {
if(elm.removeEventListener) {
elm.removeEventListener(type,fn,useCapture);
}
else if(elm.detachEvent) {
elm.detachEvent("on"+type,fn);
}
}
}
Event.events=[];
}
};
extend(Event,ev);
Event.add(window,"unload",Event.cleanup,false);
Array.prototype.search=function(value,offset) {
if(typeof(offset)=="undefined") {
offset=0;
}
for(var q=offset,l=this.length;q<l;q++) {
if(this[q]==value||String(this[q]).match(value)) {
return q;
}
}
return-1;
};
Array.prototype.has=function(value) {
return (this.search(value)!=-1);
};
Array.prototype.walk=function(func) {
for(var x=0,l=this.length;x<l;x++) {
func(this[x]);
}
};
Object.prototype.jsonize=function()
{
var s=[];
for(var prop in this) {
if(typeof(this[prop])!='function') {
if(isNaN(this[prop])) {
s.push('"'+prop+'":"'+this[prop].replace(/\'/,'\'')+'"');
}
else {
s.push('"'+prop+'":'+this[prop]);
}
}
}
return "{"+s.join(",")+"}";
}
window.isDomReady=false;
window.readyEvents=[];
if(isIE) {
document.onreadystatechange=function() {
if(this.readyState=="complete") {
window.isDomReady=true;
onReady();
}
}
}
else {
Event.add(window,'DOMContentLoaded',function() { window.isDomReady=true;onReady();},false);
}
function onReady(ev)
{
if(ev) {
window.readyEvents.push(ev);
}
if(window.isDomReady) {
for(var q=0,l=window.readyEvents.length;q<l;q++) {
try {
window.readyEvents[q].call();
}
catch(e) {
eval(window.readyEvents[q]);
}
}
window.readyEvents=[];
}
}
/*

edit.js

*/
var edit={
form:null,
request:[],
objs:[],
obj:null,
infoID: 0,
init:function(x)
{
edit.parse(byTag("*"));
},
parse:function(x)
{
for(var i=0,k=x.length;i<k;i++) {
if(x[i].className) {
var v=x[i].className.split(/ /);
for(var b=0,j=v.length;b<j;b++) {
var m=v[b].match(/xedit\|([^ ]+)/);
if(m) {
x[i].editRule=m[1];
x[i].onclick=edit.show;
if(! x[i].id.length) {
x[i].id="editobj"+edit.objs.length;
}
edit.objs.push(x[i].id);
}
}
}
}
},
hide:function(e)
{
try {
Event.stop(e);
}
catch(e) {};
if(edit.form!=null) {
edit.form.style.display="none";
}
},
invoke:function(id)
{
$(id).onclick();
return false;
},
save:function(e)
{
try {
Event.stop(e);
}
catch(e) {};
var x=edit.obj.editRule.split(/\|/);
var url='index.php?page=ajax&type='+x[0]+'&name='+x[1]+'&id='+x[2]+'&value='+encodeURIComponent(byTag("INPUT",edit.form)[0].value)+'&obj='+edit.obj.id;
Ajax.Request(url,{callback:edit.saveDone});
},
saveDone:function(r)
{
if(r.responseText!="FAIL") {
eval("var d="+r.responseText+";");
$(d.obj).innerHTML=$(d.obj).innerHTML.replace($(d.obj).defaultValue,d.value.replace(/\\'/g,"'"));
}
edit.hide();
},
show:function(e)
{
try {
Event.stop(e);
}
catch(e) {};
if(edit.form==null) {
var d=create("DIV");
var i=create("INPUT");
i.type="text";
i.style.display='block';
d.appendChild(i);
var d2=d.appendChild(create('DIV'));
d2.style.paddingTop='5px';
d2.style.position='relative';
d2.style.right='-10px';
d2.style.background='transparent';
var a=d2.appendChild(create("A"));
a.className=a.innerHTML="add";
a.onclick=edit.save;
a.href='#add';
var a=d2.appendChild(create("A"));
a.className=a.innerHTML="remove";
a.onclick=edit.hide;
a.href='#remove';
document.body.appendChild(d);
edit.form=d;
}
else {
d=edit.form;
}
var rule=this.editRule.split(/\|/);
d.className=(rule[3]) ? "editform "+rule[3] : "editform";
setInfo(0);
var xObj=edit.getContainer(this);
var i=byTag("INPUT",d)[0];
i.style.fontFamily=getStyle(this,"font-family");
i.style.fontSize=getStyle(this,"font-size");
i.style.fontWeight=getStyle(this,"font-weight");
i.style.fontStyle=getStyle(this,"font-style");
var pl=(getStyleAsInt(xObj,"padding-left")||getStyleAsInt(xObj,"padding"));
d.style.top=position(xObj,"Top")+(getStyleAsInt(xObj,"padding-top")||getStyleAsInt(xObj,"padding"))+getStyleAsInt(xObj,"margin-top")+"px";
d.style.left=position(xObj,"Left")+"px";
d.style.width=xObj.offsetWidth+"px";
d.style.paddingLeft=pl+"px";
i.style.width=(xObj.offsetWidth-pl)+"px";
this.defaultValue=i.value=edit.content(this);
this.defaultContent=this.innerHTML;
edit.obj=this;
d.style.display="block";
i.select();
},
getContainer:function(obj)
{
while(obj&&! obj.tagName.match(/DIV|TD|H1|H2|H3|H4|H5|H6/)) {
obj=obj.parentNode;
}
return obj;
},
content:function(o)
{
var s=o.innerHTML;
if(s.match(/</)) {
s=s.replace(/<([^>]*)>/g,"");
}
return s;
}
}
Event.add(window,"load",edit.init,false);
/*

form.js

*/
/*
Auto form handling etc
*/
var form={
autohideTimer: 0,
singleError: false,
okText: "&nbsp;",
erroredFields: [],
/*
init:function()
{
var s=byTag("SELECT");
for(var i=0,l=s.length;i<l;i++) {
if(s[i].disabled) {
form.fixDisabled(s[i]);
}
}
},
*/
setup:function(rules,f)
{
f=$(f);
for(var id in rules) {
if($(id)||f.elements[id+"[]"]) {
var objs=($(id)) ? [$(id)] : f.elements[id+"[]"];
for(var q=0,l2=objs.length;q<l2;q++) {
objs[q].ruleSet=rules[id].rules;
objs[q].errorObj=(rules[id].errorObj) ? rules[id].errorObj : id+"_err";
objs[q].onError=(rules[id].onError) ? rules[id].onError : form.error;
objs[q].validateRules=function() {
this.errorString="";
for(var x=0,l=this.ruleSet.length;x<l;x++) {
if(! form.validateRule(this,this.ruleSet[x])) {
return false;
}
}
return true;
}
if(rules[id].validationEvents) {
for(var p=0,k=rules[id].validationEvents.length;p<k;p++) {
Event.add(objs[q],rules[id].validationEvents[p],function(e) {
var obj=Event.target(e);
var r=obj.validateRules();
if(!r&&typeof(obj.form.submitted)!="undefined") {
obj.onError();
if(form.singleError) {
return false;
}
}
else if(r) {
obj.onError();
}
},false);
}
}
}
}
}
},
/*
enableForm:function(f,obj)
{
obj.innerHTML="SAVE";
for(var q=0,l=f.elements.length;q<l;q++) {
if(f.elements[q].disabled) {
this.enableElement(f.elements[q]);
}
}
var d=["img","iframe"];
for(var x=0,y=d.length;x<y;x++) {
var i=byTag(d[x]);
for(var q=0,l=i.length;q<l;q++) {
if(i[q].className=="fixy") {
i[q].style.display="none";
}
}
}
},
enableElement:function(el)
{
el.disabledState=1;
el.disabled=false;
el.className=el.className.replace(/ ?disabled/,"");
},
fixDisabled:function(el)
{
var eTop=position(el,"Top"),eLeft=position(el,"Left"),eWidth=el.offsetWidth,IE=(document.all) ? 1 : 0,y=0,p=(IE) ? 0 : 2;
var y=0;
do {
for(var x=0;x<2;x++) {
if(x||IE) {
var i=create(x ? "img" : "iframe");
i.src=(x) ? "images/clear.gif" : "about:blank";
i.className="fixy"
i.style.left=eLeft+"px";
i.style.top=(eTop+p)+"px";
switch (y) {
case 0 :
i.style.left=(position(el,"Right")-20)+"px";
break;
case 1 :
i.style.width="3px";
break;
case 2 :
i.style.height="2px";
i.style.width=eWidth+"px";
break;
case 3 :
i.style.top=(eTop-3+el.offsetHeight)+"px";
i.style.height="2px";
i.style.width=eWidth+"px";
break;
}
document.body.appendChild(i);
}
}
y++;
if(y>3||!IE) {
break;
}
} while(1);
if(IE) el.style.visibility="visible";
},
*/
checkCondition:function(con,obj)
{
var oStr=(con.obj=='this') ? "obj" : "$('"+con.obj+"')";
switch (con.type) {
case "length" : eval("var conditionPassed=("+oStr+".value.length "+con.rule+");");break;
default:
eval("var conditionPassed=("+oStr+".value "+con.rule+" '"+con.value+"');");
}
if(! conditionPassed) {
var i=$(obj.id+"_err");
if(i) {
i.style.display="none";
}
return true;
}
return false;
},
validateRule:function(obj,rule)
{
if(rule.condition&&form.checkCondition(rule.condition,obj)) {
return true;
}
switch (rule.type) {
case "length" :
eval("var result=(obj.value.length "+rule.rule+");");
if(! result) {
obj.errorString=form.getErrorStr(rule,"character");
}
return result;
break;
case "email" :
var result=(obj.value.match(/.+@[a-z0-9-]{2,}\.[a-z]+/gi));
if(! result) {
if(rule.error) {
obj.errorString=rule.error;
}
else {
obj.errorString="please provide a valid email";
}
}
return result;
break;
case "url" :
var result=(obj.value.match(/(https?:\/\/)?([a-z0-9-]{2,}\.)?[a-z0-9-]{2,}\.([a-z]{2,})/i));
if(! result) {
if(rule.error) {
obj.errorString=rule.error;
}
else {
obj.errorString="please provide a valid url";
}
}
return result;
break;
case "regexp" :
var re=new RegExp(rule.rule,"i");
var result=obj.value.match(re);
if(! result) {
if(rule.error) {
obj.errorString=rule.error;
}
else {
obj.errorString="invalid format";
}
}
return result;
break;
case "checkbox" :
var c=0;
if(typeof(obj.form[obj.name].length)!="undefined") {
for(var x=0,l=obj.form[obj.name].length;x<l;x++) {
alert(x);
if(obj.form[obj.name][x].checked) {
c++;
}
}
eval("var result=(c "+rule.rule+");");
}
else {
var result=obj.form[obj.name].checked;
}
if(! result) {
obj.errorString=form.getErrorStr(rule,"selection");
}
return result;
break;
case "value" :
eval("var result=(obj.value "+rule.rule+" "+rule.value+");");
if(! result) {
if(rule.error) {
obj.errorString=rule.error;
}
else {
obj.errorString="required";
}
}
return result;
break;
default:
alert("check type "+rule.type+" is not defined");
return false;
}
return true;
},
getErrorStr:function(rule,type)
{
if(rule.error) {
return rule.error;
}
else {
var m=rule.rule.match(/>=? ?([0-9]+)/);
if(m) {
if(!parseInt(m[1])) {
return "required";
}
else {
return "at least "+m[1]+" "+type+((m[1]==1) ? "" : "s");
}
}
else {
var m=rule.rule.match(/([0-9]+)$/);
return "less than "+m[1]+" "+type+((m[1]==1) ? "" : "s");
}
}
},
error:function()
{
var id=(this.id) ? this.id : this.name.replace(/\[\]/,"");
var i=$(this.errorObj);
if(this.errorString.replace(/\s/,"").length) {
if(! i) {
i=create("span");
i.id=this.errorObj;
this.parentNode.insertBefore(i,this.nextSibling);
}
i.className="formError";
i.style.display="";
i.innerHTML=this.errorString;
}
else if(i) {
i.innerHTML=form.okText;
i.className="formOk";
if(form.autohideTimer) {
setTimeout("$('"+id+"_err').style.display='none';",form.autohideTimer);
}
}
},
/*
populate form data-very simple will need to expand on to
improve support for checkboxes,date selects etc
*/
populate:function(f,data,prefix)
{
if(typeof(f)=="string") {
f=$(f);
}
if(f) {
prefix=(prefix==null) ? "" : prefix;
for(var x in data) {
if(f.elements[prefix+x]&&data[x]!=null) {
f.elements[prefix+x].value=data[x];
}
}
}
},
runChecks:function(f)
{
var pass=true;
var multi=[];
var fails=[];
for(var q=0,l=f.elements.length;q<l;q++) {
if(f.elements[q].validateRules) {
if(f.elements[q].name.match(/\[\]$/)) {
if(multi.has(f.elements[q].name)) {
continue;
}
multi.push(f.elements[q].name);
}
if(! f.elements[q].validateRules()) {
fails.push(f.elements[q].name);
f.elements[q].onError();
pass=false;
if(form.singleError) {
break;
}
}
}
}
form.erroredFields=fails;
return pass;
},
autoHandle:function(e,ret)
{
var obj=Event.target(e);
obj.blur();
var f=obj.form;
f.submitted=1;
Event.stop(e);
if(form.runChecks(f)) {
if(ret!=null&&ret) {
return true;
}
form.submit(obj);
}
else if(ret!=null&&ret) {
return false;
}
},
submit:function(obj)
{
var f=obj.form,oType="";
if(obj.type=="submit"||obj.type=="hidden") {
oType=obj.type;
if(document.all) {
var s=create(obj.outerHTML.replace(/type=\"?(submit|image)\"?/,"type=\"hidden\""));
obj.parentNode.replaceChild(s,obj);
}
else {
obj.type="hidden";
}
}
f.submit();
if(oType.length) {
if(document.all) {
obj=create(s.outerHTML.replace(/type=\"?hidden\"?/,"type=\""+oType+"\""));
s.parentNode.replaceChild(obj,s);
}
else {
obj.type=oType;
}
}
}
};
Event.add(window,"load",ajaxAutoSetup,false);
function ajaxAutoSetup()
{
var x=["form","a"];
for(var g=0,l2=x.length;g<l2;g++) {
var els=byTag(x[g]);
for(var q=0,l=els.length;q<l;q++) {
var r=els[q].getAttribute("rel");
if(r) {
var m=r.match(/(ajax):(.+)$/);
if(m&&m[1]=="ajax") {
switch (x[g]) {
case "form" :
els[q].submitCallback=m[2];
els[q].onsubmit=document.forms[q].submit=function() {
if(this.submitCallback&&String(this.submitCallback).length) {
try {
eval(this.submitCallback+"();");
}
catch(e) {
if(! String(e).match(/TypeError:.*is not a function/)) {
eval(this.submitCallback+";");
}
}
}
return false;
}
break;
case "a" :
els[q].clickCallback=m[2];
els[q].onclick=function(e) {
try{
var f=eval(this.clickCallback);
}
catch(e) {
var f=this.clickCallback;
}
Ajax.Request(this.href+(this.href.match(/\?/) ? "&ajax=1" : "?ajax=1"),{form:$("caption"),callback:f});
return false;
}
break;
}
}
}
}
}
}
/*

xml.js

*/
/********************************************************************************
AJAX CORE FUNCTIONALITY CLASS
Nathan Bryant 2006
http://www.dynamicsystems.co.nz
Copyright 2006 Dynamic Systems
All rights reserved. Republication,redistribution,
replication or use of Dynamic Systems content / scripting
is strictly prohibited without the prior written consent of Dynamic Systems.
********************************************************************************/
var xml={
showErrors: false,
reqID: 0,
req: [],
reqTimeouts: [],
reqActive: null,
asynch: true,
queue: [],
timeout: 30,
maxRetry: 3,
crntRetry: 0,
crntID: 0,
/****************************************
*										*
*	  XML DATA REQUEST FUNCTIONS 		*
*										*
****************************************/
execRequest:function(url,func,type,form,id)
{
if(id==null) {
id=xml.reqID++;
xml.reqActive=true;
}
xml.req[id]={};
type=(type==null) ? "GET" : type.toUpperCase();
if(type=="GET"&&url.length>2083&&isIE) {
alert("The request you are sending is larger than the maximum size for GET,you will need to use POST");
}
if(window.XMLHttpRequest) {
xml.req[id]=new XMLHttpRequest();
}
else if(window.ActiveXObject) {
try {
xml.req[id]=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
xml.req[id]=new ActiveXObject("Microsoft.XMLHTTP");
}
}
else {
alert("XML Object is not available");
return false;
}
xml.reqTimeouts[id]=0;
if(xml.req[id]) {
/*var d=new Date();
$("debug").innerHTML="URL: "+url+"-requested : "+d.toString();*/
xml.req[id].onreadystatechange=function() {
try {
var status=xml.req[id].status;
}
catch(e) {
/*for(var prop in xml.req[id]) {
try {
alert(prop+"="+eval("xml.req[id]."+prop));
}
catch(e) {
alert(prop);
}
}*/
/*
xml.endRequest();
xml.queue.unshift({"url":url,"func":func,"type":type,"form":form});
*/
/*if(xml.req[id]==null) {
}*/
}
if(xml.req[id]&&xml.req[id].readyState==4&&typeof(status)=="number") {
switch (status) {
case 200 :
if(typeof(func)!="undefined"&&func!=null) {
try {
func(xml.req[id]);
}
catch(e) {
if(xml.showErrors) {
alert("An error was generated by your callback function\n"+e.message+"\nFile: "+e.fileName+"\nLine: "+e.lineNumber);
}
}
}
xml.endRequest(id);
break;
case 404 :
xml.endRequest(id);
if(xml.showErrors) {
alert("XML file not found: "+url);
}
break;
case 0 : break;
default : if(xml.showErrors) { alert("There was a problem sourcing the request\n\nThe error code returned was : "+xml.req[id].status);}
}
}
}
xml.req[id].open(type,url,xml.asynch);
if(type=="GET"||type=="HEAD") {
if(type=="HEAD"&&! document.all) {
xml.req[id].overrideMimeType("text/plain");
}
xml.req[id].send(null);
}
else {
var postvars=xml.getFormVars(form).join("&");
with (xml.req[id]) {
setRequestHeader("Content-Type","application/x-www-form-urlencoded");
setRequestHeader("Content-length",postvars.length);
setRequestHeader("Connection","close");
send(postvars);
}
}
/*xml.reqTimeouts[id]=setTimeout(
function() {
if(xml.reqActive&&xml.maxRetry<xml.crntRetry++) {
xml.endRequest(id);
xml.execRequest(url,func,type,form,id);
}
else {
alert("RETRY "+xml.crntRetry);
xml.endRequest(id);
alert("MAX XML RETRIES HIT-request failed\n"+url);
}
},
xml.timeout * 1000
);*/
}
return id;
},
endRequest:function(id)
{
clearTimeout(xml.reqTimeouts[id]);
if(xml.req[id]) {
xml.req[id].onreadystatechange=function(){};
xml.req[id].abort();
delete(xml.req[id]);
}
xml.reqActive=false;
},
cancel:function(id)
{
for(var q=0,t=[],x=0,i=xml.queue,l=i.length;x<l;x++) {
if(i[x].id!=id) {
t=i[x];
}
else {
q=1;
}
}
if(! q) {
xml.endRequest();
}
},
getFormVars:function(f)
{
var ft=typeof(f);
if(ft!="undefined") {
if(ft!="object") {
if($(f)) {
f=$(f);
}
else if(document.forms[f]) {
f=document.forms[f];
}
}
if(f.elements) {
var els=f.elements;
var vars=[];
for(var w=0,l=els.length;w<l;w++) {
if(! els[w].disabled) {
if(els[w].type&&(((els[w].type=="radio"||els[w].type=="checkbox")&&els[w].checked)||(els[w].type!="radio"&&els[w].type!="checkbox"))) {
vars.push(els[w].name+"="+encodeURIComponent(els[w].value));
}
}
}
return vars;
}
alert("There is no form available for xml post-"+f);
}
return [];
},
/****************************************
*										*
*	  XML CALL QUEUING FUNCTIONS 		*
*										*
****************************************/
queue_add:function(url,func,type,formvars)
{
var x={
'url': url,
'func': func,
'type': (type==null) ? "GET" : type.toUpperCase(),
'form': formvars,
'id':xml.reqID++
};
xml.queue[xml.queue.length]=x;
xml.queue_do();
return x.id;
},
queue_do:function()
{
if(xml.reqActive) {
setTimeout("xml.queue_do()",50);
}
else if(xml.queue.length!=0) {
xml.reqActive=true;
xml.execRequest(xml.queue[0].url,xml.queue[0].func,xml.queue[0].type,xml.queue[0].form,xml.queue[0].id);
xml.queue.shift();
}
},
expandJSON:function(str,key)
{
for(var tmp=[],x=0,l=str.length;x<l;x++) {
var nd={};
for(var id in key) {
if(typeof(key[id])!='function') {
eval("nd."+key[id]+"=str[x]."+id+";");
}
}
tmp.push(nd);
}
return tmp;
},
/************************************
*									*
*	 DECODES ENCODED CHARACTERS		*
*									*
************************************/
decode:function(str)
{
var find=["&lt;","&gt;","&apos;","&quot;","&amp;"];
var replace=["<",">","'",'"',"&"];
for(var i=0,l=find.length;i<l;i++) {
var sought=new RegExp(find[i]);
do {
str=str.replace(sought,replace[i]);
} while(str.search(sought)!=-1);
}
return str;
}
};
var Ajax={
Request:function(url,options)
{
if(options==null) {
options={};
}
var m=(options.method||"GET");
var callback=(options.onSuccess||options.onComplete||options.callback||null);
var form=(options.parameters||(options.form||false));
var asynch=(options.asynch||false);
if(! form&&m!="GET") {
alert("Please use the form option to pass a form name or the parameter option to specify parameters directly");
return false
}
if(! asynch) {
xml.execRequest(url,callback,m,form);
}
else {
xml.queue_add(url,callback,m,form);
}
}
};
/*

burst.js

*/
var cForm,gmID,lfTimeout;
function setInfo(id)
{
var i=$("infoPane");
if(i) {
var p=byTag("p",i);
for(var q=0,l=p.length;q<l;q++) {
p[q].parentNode.removeChild(p[q]);
}
var msg=[];
switch (id) {
case 'campaign' :
msg.push("Enter the new name for your list and click the green tick icon.");
break;
case "recipient" :
msg.push("Update the details for your recipient and click the green tick icon to save your changes. Click the red cross icon to cancel.");
break;
case "edithelp" :
msg.push("Click on the field in you wish to edit to update stored information.");
break;
default :
if(id!=0) {
alert("set info for "+id+" is not set");
}
id=0;
i.style.display="none";
}
if(id!=0) {
for(var q=0,l=msg.length;q<l;q++) {
var p=create("P");
p.innerHTML=msg[q];
i.appendChild(p);
}
i.style.display="block";
}
}
return false;
}
function updateFormState(state,p)
{
$("ccFormDiv").style.display="none";
$("ccProcessing").style.display="block";
if(p==null) {
p="";
}
pType=(typeof(cForm)!='undefined'&&typeof(cForm.cc_amount)!="undefined") ? "payment" : "credit";
switch (state) {
case "send" : var h3="Processing Send",i="images/processing.gif",w=284,h=15;break;
case "processing" : var h3=(pType=="payment"||cForm.id=="dxListForm") ? "Processing Payment" : "Verifying Card",i="images/processing.gif",w=284,h=15;break;
case "sending" : var h3="SMS Queued",i="images/tick-dark.jpg",w=121,h=102;break;
case "ok" : var h3=(pType=="payment"||cForm.id=="dxListForm") ? "Payment Successful" : "Card addition successful",i="images/tick-dark.jpg",w=121,h=102;break;
case "already-paid" : var h3="Already queued",i="images/exclamation-dark.jpg",w=120,h=103;break;
case "fail" : var h3=(pType=="payment"||cForm.id=="dxListForm") ? "Payment Failed" : "Card addition failed",i="images/exclamation-dark.jpg",w=120,h=103;break;
case "fail-partial" : var h3="Payment Partially Failed",w=120,h=103;break;
}
var myh=byTag("h3",$("ccProcessing"))[0];
myh.innerHTML=h3;
var img=byTag("img",$("ccProcessing"))[0];
img.src=i;
img.alt="";
img.width=w;
img.height=h;
var rp=byTag("div",$("ccProcessing"))[0];
rp.style.display=p.length ? "" : "none";
rp.innerHTML=p;
popup.setPos();
}
function submitReseller(e)
{
var obj=Event.target(e);
obj.blur();
var f=obj.form;
f.submitted=1;
Event.stop(e);
if(form.runChecks(f)) {
var id=($("subdomain")) ? 'subdomain' : 'register_subdomain';
if(subdomains.search($(id).value)!=-1) {
with ($(id+"_err")) {
origHTML=innerHTML;
className="formError";
innerHTML="invalid domain / domain has already been taken";
style.display="";
}
$(id).focus();
window.scrollTo(0,400);
}
else {
f.submit();
}
}
}
function showLogin()
{
clearTimeout(lfTimeout);
if(isIE) {
$('loginhover').parentNode.style.zIndex=6;
}
$('loginhover').style.zIndex=5;
$('loginhover').style.display='block';
}
function hideLogin()
{
lfTimeout=setTimeout(function() {
if($('loginhover')) {
$('loginhover').style.display='none';
}
},500);
}
function conf(x)
{
switch (x) {
case "client" : x='This action cannot be undone!\n\nAre you sure you want to delete this client?';break;
case 'user': x='Are you sure you want to remove this user?';break;
case 'default-card': x="This action will make all client payments be processed with this card\n\nAre you sure you want to set this card as your default card?";break;
case "remove-card": x="Are you sure you want to remove this card?";break;
default: x='Are you sure you want to remove this item?';
}
return confirm(x);
}
/*
Rebuild table using template and json
*/
function rebuildTable(id,d,tplHTML)
{
d.offset=parseInt(d.offset);
d.total_results=parseInt(d.total_results);
if($('tableResultLoader')) {
$('tableResultLoader').parentNode.removeChild($('tableResultLoader'));
}
var t=$("list_"+id);
if(t) {
t.style.display="";
while(t.rows.length>1) {
t.deleteRow(1);
}
for(var x=0,l=d.data.length;x<l;x++) {
var html=template.parse(tplHTML,d.data[x]);
var newRow=template.append(t.rows[0].parentNode,html);
}
}
if(d.total_results) {
$("noResults_"+id).style.display="none";
$("hasResults_"+id).style.display="";
}
else {
$("hasResults_"+id).style.display="none";
$("noResults_"+id).style.display="";
}
$("prevnext_"+id).style.display="table";
$("limitChanger_"+id).value=limit;
var str="Showing "+(d.offset+1)+" to "+((d.offset+limit)<d.total_results ? (d.offset+limit) : d.total_results)+" of "+d.total_results;
$("listInfo_"+id).innerHTML=str;
$("previous_"+id).style.display=(d.offset<=0) ? "none" : "";
$("next_"+id).style.display=((d.offset+limit)<d.total_results) ? "" : "none";
}
function showTableLoader(t)
{
var d=document.body.appendChild(create("div")),
availableHeight=(t.offsetHeight-t.rows[0].offsetHeight-1),
paddingTop=((availableHeight) / 2)-40;
d.id="tableResultLoader";
d.style.top=(position(t,"Top")+1+t.rows[0].offsetHeight)+"px";
d.style.left=(position(t,"Left")+1)+"px";
d.style.width=(t.offsetWidth-2)+"px";
d.style.paddingTop=(paddingTop)+"px";
d.style.height=(availableHeight-paddingTop)+"px";
d.innerHTML="loading results,&nbsp;please wait";
}
function br2nl(str)
{
return str.replace(/<br ?\/?>/ig,"\n");
}
/*
function conf(x,actionURL)
{
onConfURL="";
switch (x) {
case "client" : x='Are you sure you want to delete this client?';break;
case 'user': x='Are you sure you want to remove this user?';break;
case 'default-card': x="This action will make all client payments be processed with this card\n\nAre you sure you want to set this card as your default card?";break;
case "remove-card": x="Are you sure you want to remove this card?";break;
default: x='Are you sure you want to remove this item?';
}
if(actionURL==null) {
return confirm(x);
}
else {
popup.open('confirm');
$("confOK").href=actionURL;
$("confText").innerHTML='<p>'+x+'</p>';
popup.setPos();
return false;
}
}
*/
onReady(function() {
if($('loginhover')&&$('loginlink')) {
Event.add($('loginlink'),'mouseover',showLogin,true);
Event.add($('loginhover'),'mouseover',showLogin,true);
Event.add($('loginlink'),'mouseout',hideLogin,false);
Event.add(document.body,'click',function(e) {
var el=Event.target(e);
if(el.form&&el.form==$('formLoginHover')) {
return;
}
hideLogin(e);;
},false);
}
});
/*

popup.js

*/
var popup={
state:"closed",
parent:null,
obj:null,
current:null,
requestID:0,
posSet:0,
morph:0,
sizeTimer:0,
xState:{},
content:{},
openTimer:0,
onTimeout:null,
closeTimer:0,
allowMorph:false,
modal:false,
fixed:(! window.navigator.appVersion.match(/MSIE ?[0-6]/)),
evalAction:"",
cancelAction:"",
okAction:"",
scripts:[],
cmds:[],
promptHeading:'',
promptStr:'',
add:function(id,settings)
{
popup.content[id]=(typeof(settings)=='string') ? {html:settings} : settings;
},
get:function(id,cfile,open,vars)
{
popup.state="opening";
if(! popup.content[id]) {
var u=location.protocol+"//"+location.host+"/index.php?page=popup-get&content-file="+encodeURIComponent(cfile),q=location.search.substring(1);
if(q.length) {
u+="&"+q;
}
if(vars!=null) {
u+="&setRequestVars="+encodeURIComponent(vars.jsonize());
}
u+='&randomvar='+(Math.random() * 10000);
popup.requestID=xml.queue_add(u,function(r) {
popup.add(id,r.responseText.replace(/\\"/g,'"').replace(/\\'/g,"'"));
if(open) {
popup.open(id);
}
}
);
}
else if(open&&popup.current!=id) {
popup.open(id);
}
return false;
},
getNew:function(id,cfile,open,vars)
{
popup.unload(id);
return popup.get(id,cfile,open,vars);
},
unload:function(id)
{
if(popup.content[id]) {
var ps=popup.scripts;
for(var q=0,l=ps.length;q<l;q++) {
if($(ps[q])) {
$(ps[q]).parentNode.removeChild($(ps[q]));
}
}
popup.scripts=[];
if(id==popup.current) {
popup.current=null;
popup.close();
}
delete(popup.content[id]);
}
},
info:function(str,heading,keep,onOK)
{
if(onOK==null) {
onOK='popup.close()';
}
popup.okAction=onOK;
var px=(keep) ? 'notice-popup' : 'info-popup';
if(! popup.content[px]) {
popup.get(px,px,1);
popup.onload("popup.info('"+str+"','"+heading+"',"+keep+","+onOK+")");
return true;
}

popup.open(px);

setTimeout(function() {
var hasHeading=(heading!=null&&heading!='undefined'&&heading.length);
$("infoHeading").innerHTML=(hasHeading) ? heading : "Info";
$("infoHeading").style.display=(hasHeading) ? "" : "none";
$("infoText").innerHTML=str;
popup.setPos();
},25);
},
prompt:function(str,heading,action,cancelAction)
{
popup.evalAction=action;
if(cancelAction==null) {
cancelAction='popup.close()';
}
popup.cancelAction=cancelAction;
popup.promptHeading=(heading!=null&&heading.length) ? heading : "Info";
popup.promptStr=str;
try {
popup.open('prompt-popup');
popup.promptSetVars();
}
catch(e) {
popup.get('prompt-popup','prompt-popup',1);
popup.onload('popup.promptSetVars()');
}
},
promptSetVars:function(heading,str)
{
$("promptHeading").innerHTML=popup.promptHeading;
$("promptText").innerHTML=popup.promptStr;
popup.setPos();
},
onload:function(cmd)
{
popup.cmds.push(cmd);
/*if(popup.state=="open") {
eval(cmd);
popup.setPos();
}
else {
setTimeout(function() { popup.onload(cmd);},25);
}*/
},
execute:function(cmds)
{
for(var i=0,l=cmds.length;i<l;i++) {
try {
eval(cmds[i]);
}
catch(e) {
var s=[cmds[i]];
for(var prop in e) {
s.push(prop.toUpperCase()+" : "+e[prop]);
}
alert(s.join("\n\n"));
}
}
},
open:function(id)
{
if(isIE&&document.readyState!="complete") {
popup.openTimer=setTimeout('popup.open("'+id+'")',25);
}
else {
popup.morph=(popup.allowMorph&&popup.state=="open");
clearTimeout(popup.openTimer);
clearTimeout(popup.closeTimer);
popup.state="opening";
if(!$("popup")) {
var db=document.body;
var i=create("IFRAME");
i.src=location.protocol+"//"+location.host+"/exit";
db.appendChild(i);
var po=db.appendChild(create("DIV"));
po.id="popupoverlay";
po.style.position="absolute";
po.innerHTML="&nbsp;";
Event.add(document,"keypress",function(e) { popup.isEscape(e);},true);
Event.add(window,"resize",function(e) { if(popup.state=="open") setTimeout('popup.setPos()',100);},true);
i.id="popupparentframe";
i.style.filter="alpha(opacity=0)";
i.style.opacity=0;
i.frameBorder=0;
var d=db.appendChild(create("DIV"));
d.id="popupparent";
d.innerHTML="<a href=\"#\" onclick=\"return popup.close()\">Press&nbsp;<u>ESC</u>&nbsp;to close or click</a>";
/*d.moveCallback=popup.onmove;
drag.add(d);*/
var d2=db.appendChild(create("DIV"));
d2.id="popup";
popup.obj=d2;
}
popup.setContent(id);
if(typeof(edit)!="undefined") {
edit.hide();
}
addClass(document.body,"noSelect");
}
return false;
},
close:function()
{
var save=(popup.current!=null&&popup.content[popup.current].saveState)||false;
if(save) {
popup.content[popup.current].html=$("popup").innerHTML;
popup.saveState(1);
}
popup.state="closed";
removeClass(document.body,"noSelect");
if($("popup")) {
$("popupoverlay").style.display=$("popupparentframe").style.display=$("popup").style.display=$("popupparent").style.display="none";
}
popup.current=null;
},
isEscape:function(e)
{
if(Event.key(e)==27) {
clearTimeout(popup.sizeTimer);
popup.close();
}
},
setContent:function(id)
{
popup.current=id;
popup.scripts=[];
var c= popup.content[id].html;
var sc=[],m=c.match(/(\{js_inject\})(.*)(\{\/js_inject\})/g);
if(m) {
for(var q=0,l=m.length;q<l;q++) {
c=c.replace(m[q],"");
sc.push(m[q].substring(11,m[q].length-12));
}
}
if(popup.morph) {
popup.xState={'width':$("popup").offsetWidth,'height':$("popup").offsetHeight};
}
$("popup").innerHTML=c;
for(var i=0,l=sc.length;i<l;i++) {
popup.scripts.push(injectJS(sc[i]));
}
$("popupparent").className=popup.modal ? "modal" : "";
popup.saveState(0);
popup.setPos();
if(ajaxAutoSetup) ajaxAutoSetup();
},
saveState:function(save)
{
if(popup.current!=null) {
if(save) {
popup.content[popup.current].stateData=[];
}
var obj=popup.content[popup.current];
var state=(obj.stateData) ? obj.stateData : {};
var f=byTag("form",$("popup"));
if(f) {
for(var q=0,l=f.length;q<l;q++) {
for(var x=0,k=f[q].elements.length;x<k;x++) {
var c=f[q].elements[x];
if(c.name) {
if(! state[q]) {
state[q]={};
}
if(save) {
}
else {
/*eval("var set=state[q]."+c.name+";");
if(set) {
f[q].elements[x].value=set;
}*/
}
}
}
}
}
}
},
setPos:function(noSize)
{
var d1=$("popupparent"),d2=$("popup"),d3=$("popupparentframe");
if(d2.innerHTML.length) {
if(! noSize) {
d1.style.position=d2.style.position=d3.style.position="absolute";
d2.firstChild.style.display=d2.style.display="block";
d2.style.overflow="visible";
d2.style.width="auto";
var w=(d2.offsetWidth||getStyleAsInt(d2,"width")||400);
d2.style.display="none";
var h=d2.offsetHeight;
if(! h) {

d2.firstChild.style.display=d2.style.display="block";
d2.style.height="auto";
h=d2.offsetHeight;
}
d2.firstChild.style.display=d2.style.display="none";
d2.style.overflow="hidden";
if(popup.morph) {
/*d2.realHTML=d2.innerHTML;
d2.innerHTML="";
/*d2.style.display="";
d2.style.display="none";*/
}
}
else {
with (popup.xState) {
var w=width,h=height;
}
}
var d1p=getStyleAsInt(d1,"padding-left"),d1t=getStyleAsInt(d1,"padding-top");
if(! popup.posSet) {
var l=Math.floor((screenWidth() / 2)-(w / 2));
d3.style.left=d1.style.left=(l-d1p)+"px";
d2.style.left=l+"px";
var t=(screenHeight() / 2)-(h / 2)+((popup.fixed) ? 0 : popup.getScroll());
if(t<0) {
t=d1t;
}
t=Math.floor(t);
d3.style.top=d1.style.top=(t-d1t)+"px";
d2.style.top=t+"px";
}
d1.style.position=d2.style.position=d3.style.position=(popup.fixed&&h<screenHeight()) ? "fixed" : "absolute";
if(! noSize) {
popup.size(w,h,1);
}
}
},
getScroll:function()
{
if(document.documentElement&&document.documentElement.scrollTop) {
return document.documentElement.scrollTop;
}
return (document.body.scrollTop) ? document.body.scrollTop : ((window.pageYOffset) ? window.pageYOffset : 0);
},
size :function(w,h,fp)
{
clearTimeout(popup.sizeTimer);
var d1=$("popupparent"),d2=$("popup"),d3=$("popupparentframe");
if(popup.morph&&popup.allowMorph) {
with (popup.xState) {
d2.style.overflow="hidden";
var myW=width,
myH=height,
aY=(h-myH),
aX=(w-myW),
d1p=getStyleAsInt(d1,"padding-left"),
d1t=getStyleAsInt(d1,"padding-top");
if(! fp) {
if(aX) {
aX /=(aX<5&&aX>-5) ? 1 : (aX<100&&aX>-100) ? 2 : 5;
width+=Math.floor(aX);
}
if(aY) {
aY /=(aY<5&&aY>-5) ? 1 : (aY<100&&aY>-100) ? 2 : 5;
height+=Math.floor(aY);
}
}
d1.style.width=width+"px";
d1.style.height=height+"px";
d2.style.width=(width-(d1p * 2))+"px";
d2.style.height=(height-(d1t / 2))+"px";
popup.setPos(1);
if(width!=w||height!=h) {
popup.sizeTimer=setTimeout('popup.size('+w+','+h+')',500);
}
else {
popup.morph=false;
d2.firstChild.style.display="";
}
}
}
else {
d1.style.width=w+"px";
d1.style.height=h+"px";
d2.firstChild.style.display="";
}

d2.style.display=d1.style.display=d3.style.display="block";
d3.style.height=d1.offsetHeight+"px";
d3.style.width=d1.offsetWidth+"px";
with ($("popupoverlay").style) {
display=(popup.modal) ? "block" : "";
height=document.body.offsetHeight+"px";
width=document.body.offsetWidth+"px";
}
if(! popup.morph) {
var cmds=popup.cmds;
popup.cmds=[];
popup.execute(cmds);
popup.state="open";
}
},
onmove:function()
{
var d1=$("popupparent"),d2=$("popup"),d3=$("popupparentframe");
d3.style.top=d1.offsetTop+"px";
d3.style.left=d1.offsetLeft+"px";
d2.style.top=d1.offsetTop+getStyleAsInt(d1,"padding-top")+"px";
d2.style.left=d1.offsetLeft+getStyleAsInt(d1,"padding-left")+"px";
d2.style.zIndex=getStyleAsInt(d1,"z-index")+1;
}
};
/*

template.js

*/
var template={
loaded:[],
switches:[],
parse:function(str,data)
{
var m=str.match(/\{data:([^}]+)\}/g);
if(m) {
for(var i=0,l=m.length;i<l;i++) {
var x=m[i].match(/\{data:([^}]+)\}/);
eval("var s=(typeof(data."+x[1]+")!='undefined'&&data."+x[1]+"!=null) ? data."+x[1]+" : false;");
str=str.replace(m[i],s ? s : '');
}
}
var m=str.match(/\{switch:([^}]+)\}/g);
if(m) {
for(var i=0,l=m.length;i<l;i++) {
var p=m[i].substring(8,m[i].length-1).split(/\|/g);
if(! template.switches[m[i]]||template.switches[m[i]]==0) {
template.switches[m[i]]=1;
}
else {
template.switches[m[i]]=0;
}
eval("var s=(p["+template.switches[m[i]]+"]) ? p["+template.switches[m[i]]+"] : '';");
str=str.replace(m[i],s);
}
}
return str;
},
append:function(obj,html)
{
html=template.buildObjectFromHTML(html);
return obj.appendChild(html);
},
replace:function(obj,html)
{
html=html.replace(/\t|\r\n|\n/g,"");
if(typeof(id)=="string") {
obj=$(obj);
}
return obj.parentNode.replaceChild(template.buildObjectFromHTML(html),obj);
},
/*
buildObjectFromHTML:function(html)
{
var subhtml=html;
var obj=null;
var tagInnerStart=0;
var tags=html.match(/<([^>]+)>/g);
for(var q=0,l=tags.length;q<l;q++) {
var inner=tags[q].substr(1,tags[q].length-2);
subhtml=html.substr(tagInnerStart);
tagInnerStart=subhtml.search(/>/)+tagInnerStart;
if(tagInnerStart) {
tagInnerStart++;
}
var str=subhtml.substr(0,subhtml.search(/</));
if(str.length) {
obj.appendChild(document.createTextNode(str));
}
if(inner.substr(0,1)=="/") {
if(obj.parentNode) {
obj=obj.parentNode;
}
continue;
}
else {
var fs=inner.search(/ /);
var nObj=document.createElement(fs==-1 ? inner : inner.substr(0,fs));
if(obj!=null) {
nObj=obj.appendChild(nObj);
if(! nObj.tagName.match("IMG|BR|HR|LINK|AREA|BASE|INPUT")) {
obj=nObj;
}
}
else {
obj=nObj;
}
if(fs!=-1) {
var attributes=inner.match(/([a-z]+)=\"[^"]+\"/g);
if(attributes!=null) {
for(var x=0,j=attributes.length;x<j;x++) {
var att=attributes[x].replace(/^\s/,"").replace(/\s$/,"");
var ep=att.search(/=/);
var n=att.substr(0,ep);
var v=att.substr(ep+1,att.length-2).replace(/\"/g,"");
switch (n.toLowerCase()) {
case "class" :
nObj.className=v;
break;
case "rowspan" : n="rowSpan";
case "colspan" : n="colSpan";
default :
if(n.substring(0,2)=="on"&&isIE) {
nObj.setAttribute("event_"+n,v);
Event.add(nObj,n.substring(2),function(e) { eval(Event.target(e).getAttribute("event_on"+Event.get(e).type));},false);
}
else {
nObj.setAttribute(n,v);
}
}
}
}
}
}
}
return obj;
},
*/
buildObjectFromHTML:function(html,attachObj)
{
var subhtml=html,pobj,obj=null,tagInnerStart=0,tags=html.match(/<([^>]+)>/g);
for(var q=0,l=tags.length;q<l;q++) {
var inner=tags[q].substr(1,tags[q].length-2);
subhtml=html.substr(tagInnerStart);
tagInnerStart=subhtml.search(/>/)+tagInnerStart;
if(tagInnerStart) {
tagInnerStart++;
}
var str=subhtml.substr(0,subhtml.search(/</)).trim();
if(str.length) {
if(typeof(tag)!="undefined"&&tag=="script") {
try {
nObj.text=str;
}
catch(e) {
nObj.textContent=str;
}
}
else {
if(str=="&nbsp;") {
str=" ";
}
obj.appendChild(document.createTextNode(str));
}
}
if(inner.substr(0,1)=="/") {
if(obj.parentNode) {
obj=obj.parentNode;
}
continue;
}
else {
var fs=inner.search(/ /),
tag=(fs==-1 ? inner : inner.substr(0,fs)),
nObj=create(tag);
if(tag=="tr"&&obj!=null&&obj.tagName.toLowerCase()!="tbody") {
obj=obj.appendChild(create("tbody"));
}
if(obj!=null) {
if(nObj.tagName=="SCRIPT") {
nObj=byTag("HEAD")[0].appendChild(nObj);
}
else {
nObj=obj.appendChild(nObj);
}
if(! nObj.tagName.match("IMG|BR|HR|LINK|AREA|BASE|INPUT|SCRIPT")) {
obj=nObj;
}
}
else {
obj=nObj;
}
if(pobj==null) {
pobj=obj;
if(attachObj!=null) {
attachObj.appendChild(pobj);
}
}
if(fs!=-1) {
var attributes=inner.match(/([a-z]+)=\"[^"]+\"/g);
if(attributes) {
for(var x=0,j=attributes.length;x<j;x++) {
var att=attributes[x].replace(/^\s/,"").replace(/\s$/,""),
ep=att.search(/=/),
n=att.substr(0,ep),
v=att.substr(ep+1,att.length-2).replace(/\"/g,"");
if(tag=="input"&&isIE) {
try {
var r=new RegExp(n+"=\"([^\"]+)\""),ohtml="";
if(nObj.outerHTML.match(r)) {
ohtml=nObj.outerHTML.replace(r,n+"=\""+v+"\"");
}
else {
ohtml=nObj.outerHTML.replace(/<([^>]+)/,"<$1 "+n+"=\""+v+"\"");
}
var s=create(ohtml);
nObj.parentNode.replaceChild(s,nObj);
nObj=s;
}
catch(e) {
alert(n+" cannot be setup\n"+nObj.outerHTML);
}
}
else {
switch (n.toLowerCase()) {
case "type" : nObj.type=v;break;
case "class" : nObj.className=v;break;
case "cellpadding" : nObj.cellPadding=v;break;
case "cellspacing" : nObj.cellSpacing=v;break;
case "rowspan" : nObj.rowSpan=v;break;
case "colspan" : nObj.colSpan=v;break;
case "style" :
var s=v.split(/;/g);
for(var v=0,u=s.length;v<u;v++) {
var colPos=s[v].search(/:/);
eval("nObj.style."+s[v].substr(0,colPos).camelize()+"=\""+s[v].substr(colPos+1)+"\";");
}
break;
default :
if(n.substring(0,2)=="on"&&isIE) {
nObj.setAttribute("event_"+n,v);
Event.add(nObj,n.substring(2),function(e) {
var func=Event.target(e).getAttribute("event_on"+Event.get(e).type);
if(func.match(/return false/)) {
func=func.replace(/return false/,'');
Event.stop(e);
}
eval(func);
},false);
}
else {
nObj.setAttribute(n,v);
}
}
}
}
}
}
}
}
return pobj;
},
output:function(id,data)
{
if(! template.loaded[id]) {
Ajax.Request('index.php?page=template-load&js=1',{callback:template.setTemplate});
}
else {
}
},
setTemplate:function(r)
{
}
}