jQuery.fn.exists = function() { return (jQuery(this).length > 0); }
jQuery.fn.visible = function() { return jQuery(this).is(':visible'); }
jQuery.fn.disableSelection = function() { return jQuery(this).css('user-select', 'none').css('-khtml-user-select', 'none').css('-moz-user-select', 'none').css('-o-user-select', 'none').css('-webkit-user-select', 'none'); }
jQuery.fn.enableSelection = function() { return jQuery(this).css('user-select', 'text').css('-khtml-user-select', 'text').css('-moz-user-select', 'text').css('-o-user-select', 'text').css('-webkit-user-select', 'text'); }
jQuery.fn.setBusy = function() { jQuery(this).trigger('restoreCursor'); var cursor = jQuery(this).css('cursor'); jQuery(this).bind('restoreCursor', function() { jQuery(this).css('cursor', cursor).unbind('restoreCursor'); }).css('cursor', 'wait'); return jQuery(this); }
jQuery.fn.unsetBusy = function() { jQuery(this).trigger('restoreCursor'); return jQuery(this); }
jQuery.fn.enableMe = function() { if (jQuery(this).attr('_af_disabled') == 'disabled') jQuery(this).removeAttr('_af_disabled').unsetBusy().fadeTo(0, 1); return jQuery(this); }
jQuery.fn.disableMe = function() { if (jQuery(this).attr('_af_disabled') != 'disabled') jQuery(this).attr('_af_disabled', 'disabled').setBusy().fadeTo(0, 0.4); return jQuery(this); }
jQuery.fn.matchHeight = function() { var maxH = 0; jQuery(this).each(function() { var h = jQuery(this).height(); if (h > maxH) maxH = h; }).height(maxH); }
jQuery.fn.fitText = function(e) {  var t = jQuery(this); t.html('<span>' + t.text() + '</span>'); var s = t.find('span'); var oS = 4; s.css('font-size', oS).css('white-space', 'nowrap'); var sL = s.text().length, nS = Math.floor((t.width() / sL) * (oS / (s.width() / sL))); s.css('font-size', nS); var tH = t.height(), sH = s.height(); if (sH > tH) s.css('font-size', Math.floor(nS * (tH / sH))); };
jQuery.getFirstKey = function(a) { for (var k in a) return k; }
jQuery.getNthKey = function(a,n) { var i=0; for (var k in a) if (i++ == n) return k; }
jQuery.getKeyPos = function(a,k) { var i=0; for (var j in a) if (j == k) return i; else i++; return false; }
jQuery.selectAll = function(id) { var t = jQuery('#' + id); if (t) { t.focus().select(); } }
jQuery.rand = function(min,max) { return Math.floor(Math.random() * (max - min + 1) + min); }
jQuery.preloadImages = function(urls) { var i=0,x,y,z=[]; while(x = arguments[i++]) { y = document.createElement('img'); y.src = x; z.push(y); } }
jQuery.isInteger = function(n) { return (!isNaN(parseFloat(n)) && isFinite(n)); }
jQuery.fn.appendURLContents = function(url) { var x = jQuery(this); x.val(x.val() + jQuery.ajax({ url: url, async: false }).responseText); }
jQuery.getCookie = function(name) { var x = document.cookie.split(';'), y; for (s in x) { y = x[s].split('='); if (jQuery.trim(y[0]) == name) return unescape(y[1]); } return null; }
jQuery.setCookie = function(name, value, duration) { if (!duration) duration = 31536000; var date = new Date(); date.setTime(date.getTime() + (duration * 1000)); var expires = date.toGMTString(); document.cookie = name + '=' + value + '; expires=' + expires + '; path=/'; }
jQuery.removeCookie = function(name) { document.cookie = name + '=' + '; expires=Thu, 1 Jan 1970 12:00:00 UTC; path=/'; }
jQuery.getRelativeTime = function(diff) { var v = Math.floor(diff / 86400); diff -= v * 86400; if (v > 0) return (v == 1 ? 'Yesterday' : v + ' days ago'); v = Math.floor(diff / 3600); diff -= v * 3600; if (v > 0) return v + ' hour' + (v > 1 ? 's' : '') + ' ago'; v = Math.floor(diff / 60); diff -= v * 60; if (v > 0) return v + ' minute' + (v > 1 ? 's' : '') + ' ago'; return 'Just now'; };
jQuery.fn.toRelativeTime = function() { var t = jQuery(this), x = Math.round(Date.parse(t.text()) / 1000); if (x) t.text(jQuery.getRelativeTime(Math.round(new Date().getTime() / 1000) - x)); };
jQuery.fn.n33_formerize=function(){var _fakes=new Array(),_form = jQuery(this);_form.find('input[type=text],textarea').each(function() { var e = jQuery(this); if (e.val() == '' || e.val() == e.attr('placeholder')) { e.addClass('formerize-placeholder'); e.val(e.attr('placeholder')); } }).blur(function() { var e = jQuery(this); if (e.attr('name').match(/_fakeformerizefield$/)) return; if (e.val() == '') { e.addClass('formerize-placeholder'); e.val(e.attr('placeholder')); } }).focus(function() { var e = jQuery(this); if (e.attr('name').match(/_fakeformerizefield$/)) return; if (e.val() == e.attr('placeholder')) { e.removeClass('formerize-placeholder'); e.val(''); } }); _form.find('input[type=password]').each(function() { var e = jQuery(this); var x = jQuery(jQuery('<div>').append(e.clone()).remove().html().replace(/type="password"/i, 'type="text"').replace(/type=password/i, 'type=text')); if (e.attr('id') != '') x.attr('id', e.attr('id') + '_fakeformerizefield'); if (e.attr('name') != '') x.attr('name', e.attr('name') + '_fakeformerizefield'); x.addClass('formerize-placeholder').val(x.attr('placeholder')).insertAfter(e); if (e.val() == '') e.hide(); else x.hide(); e.blur(function(event) { event.preventDefault(); var e = jQuery(this); var x = e.parent().find('input[name=' + e.attr('name') + '_fakeformerizefield]'); if (e.val() == '') { e.hide(); x.show(); } }); x.focus(function(event) { event.preventDefault(); var x = jQuery(this); var e = x.parent().find('input[name=' + x.attr('name').replace('_fakeformerizefield', '') + ']'); x.hide(); e.show().focus(); }); x.keypress(function(event) { event.preventDefault(); x.val(''); }); });  _form.submit(function() { jQuery(this).find('input[type=text],input[type=password],textarea').each(function(event) { var e = jQuery(this); if (e.attr('name').match(/_fakeformerizefield$/)) e.attr('name', ''); if (e.val() == e.attr('placeholder')) { e.removeClass('formerize-placeholder'); e.val(''); } }); }).bind("reset", function(event) { event.preventDefault(); jQuery(this).find('select').val(jQuery('option:first').val()); jQuery(this).find('input,textarea').each(function() { var e = jQuery(this); var x; e.removeClass('formerize-placeholder'); switch (this.type) { case 'submit': case 'reset': break; case 'password': e.val(e.attr('defaultValue')); x = e.parent().find('input[name=' + e.attr('name') + '_fakeformerizefield]'); if (e.val() == '') { e.hide(); x.show(); } else { e.show(); x.hide(); } break; case 'checkbox': case 'radio': e.attr('checked', e.attr('defaultValue')); break; case 'text': case 'textarea': e.val(e.attr('defaultValue')); if (e.val() == '') { e.addClass('formerize-placeholder'); e.val(e.attr('placeholder')); } break; default: e.val(e.attr('defaultValue')); break; } }); window.setTimeout(function() { for (x in _fakes) _fakes[x].trigger('formerize_sync'); }, 10); }); return _form; };
jQuery.toRelativeTime = function(s) { jQuery(s).each(function() { jQuery(this).toRelativeTime(); }); };
var base64={};base64.PADCHAR="=";base64.ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";base64.makeDOMException=function(){var c,b;try{return new DOMException(DOMException.INVALID_CHARACTER_ERR)}catch(b){var a=new Error("DOM Exception 5");a.code=a.number=5;a.name=a.description="INVALID_CHARACTER_ERR";a.toString=function(){return"Error: "+a.name+": "+a.message};return a}};base64.getbyte64=function(c,b){var a=base64.ALPHA.indexOf(c.charAt(b));if(a===-1){throw base64.makeDOMException()}return a};base64.decode=function(d){d=""+d;var g=base64.getbyte64;var f,c,e;var b=d.length;if(b===0){return d}if(b%4!==0){throw base64.makeDOMException()}f=0;if(d.charAt(b-1)===base64.PADCHAR){f=1;if(d.charAt(b-2)===base64.PADCHAR){f=2}b-=4}var a=[];for(c=0;c<b;c+=4){e=(g(d,c)<<18)|(g(d,c+1)<<12)|(g(d,c+2)<<6)|g(d,c+3);a.push(String.fromCharCode(e>>16,(e>>8)&255,e&255))}switch(f){case 1:e=(g(d,c)<<18)|(g(d,c+1)<<12)|(g(d,c+2)<<6);a.push(String.fromCharCode(e>>16,(e>>8)&255));break;case 2:e=(g(d,c)<<18)|(g(d,c+1)<<12);a.push(String.fromCharCode(e>>16));break}return a.join("")};base64.getbyte=function(c,b){var a=c.charCodeAt(b);if(a>255){throw base64.makeDOMException()}return a};base64.encode=function(e){if(arguments.length!==1){throw new SyntaxError("Not enough arguments")}var b=base64.PADCHAR;var g=base64.ALPHA;var f=base64.getbyte;var d,h;var a=[];e=""+e;var c=e.length-e.length%3;if(e.length===0){return e}for(d=0;d<c;d+=3){h=(f(e,d)<<16)|(f(e,d+1)<<8)|f(e,d+2);a.push(g.charAt(h>>18));a.push(g.charAt((h>>12)&63));a.push(g.charAt((h>>6)&63));a.push(g.charAt(h&63))}switch(e.length-c){case 1:h=f(e,d)<<16;a.push(g.charAt(h>>18)+g.charAt((h>>12)&63)+b+b);break;case 2:h=(f(e,d)<<16)|(f(e,d+1)<<8);a.push(g.charAt(h>>18)+g.charAt((h>>12)&63)+g.charAt((h>>6)&63)+b);break}return a.join("")}; if (!window.btoa) window.btoa = base64.encode; if (!window.atob) window.atob = base64.decode; jQuery.base64Encode = function(s) { return btoa(s); }; jQuery._base64Encode = function(s) { return jQuery.base64Encode(s).split('=')[0]; }; jQuery.base64Decode = function(s) { return atob(s); };
jQuery.browser={};(function(){jQuery.browser.msie=false;jQuery.browser.version=0;if(navigator.userAgent.match(/MSIE ([0-9]+)\./)){jQuery.browser.msie=true;jQuery.browser.version=RegExp.$1;}})();
jQuery(function() {
jQuery('.selectOnClick').click(function(e) { jQuery(this).select(); });
jQuery('.disableOnClick').click(function(e) {
var t = jQuery(this);
if (t.attr('_af_disabled') == 'disabled') {
e.preventDefault(); e.stopPropagation(); 
return false;
}
else
{
if (t.is('input:submit'))
t.closest('form').submit(function() { t.disableMe(); });
else if (t.is('a'))
{
t.disableMe();
window.location.href = t.attr('href');
}
}
});
jQuery.fn.simpleHideableArea = function(startHidden, type) {
var x = jQuery(this);
var id = x.attr('id'), className = x.attr('class');
x.attr('id', id + '_old');
var _outer = jQuery('<div id="' + id + '_af_simpleHideableArea" class="' + className + '"></div>').insertBefore(x);
var _heading = x.find('.sha_title').detach();
var _content = jQuery('<div class="sha_content"></div>').appendTo(_outer);
var wait = false;
switch (type) {
case 2:
_content._af_loadurl = x.text();
break;
default:
_content.html(x.html());
break;
}
_heading.prependTo(_outer).click(function() {
if (_content._af_loadurl) {
if (wait == false) {
_heading.setBusy();
_content.hide();
wait = true;
jQuery.get(_content._af_loadurl, function(data) {
_content.html(data);
_content._af_loadurl = null;
_content.show();
wait = false;
_heading.unsetBusy();
});
}
}
else
_content.toggle();
}).disableSelection();
x.remove();
if (startHidden)
_content.hide();
return;
}
jQuery.fn.hideableArea = function(startHidden, type) {
var x = jQuery(this);
var id = x.attr('id'), className = x.attr('class');
x.attr('id', id + '_old');
var _outer = jQuery('<div id="' + id + '_af_hideableArea" class="' + className + '"></div>').insertBefore(x);
var _heading = x.find('> h3').detach();
var _message = x.find('> h4').detach().appendTo(_outer);
var _content = jQuery('<div class="content">' + x.html() + '</div>').appendTo(_outer);
_heading.attr('class', 'actionButton').html('<span></span> ' + _heading.html()).prependTo(_outer).click(function() {
_content.toggle();
_heading.find('> span').html( (_content.css('display') == 'none') ? 'Show' : 'Hide' );
}).disableSelection();
x.remove();
if (startHidden) {
_heading.find('> span').html('Show');
_content.hide();
}
else
_heading.find('> span').html('Hide');				
}
jQuery.fn.tabbedArea = function(initialTabPos) {
var x = jQuery(this);
var id = x.attr('id'), className = x.attr('class');
var _outer = jQuery('<div id="' + id + '_af_tabbedArea" class="' + className + '"><ul class="tabs"></ul><ul class="content"></ul></div>').insertBefore(x);
var _tabs = _outer.find('> .tabs');
var _content = _outer.find('> .content');
var _firstTab = null, _activeTab = null, n = 0;
if (!initialTabPos)
initialTabPos = 0;
jQuery(this)
.find('> li')
.each(function() {
var x = jQuery(this);
var y = x.find('> h2');
var title = y.html();
y.remove();
var content = x.html();
var tc = jQuery('<li>' + content + '</li>').appendTo(_content);
var tt = jQuery('<li class="taboff">' + title + '</li>').appendTo(_tabs);
tt.click(function() {
if (_activeTab != null)
_activeTab.removeClass('tabon').addClass('taboff');
_activeTab = jQuery(this).removeClass('taboff').addClass('tabon');
_content.find('> li').hide();
tc.show();
});
tc.hide();
if (_firstTab == null && n == initialTabPos)
_firstTab = tt;
n++;
});
x.remove();
if (_firstTab != null)
_firstTab.trigger('click');
}
jQuery.fn.windowedPopup = function(id, url, width, height) {
var x = jQuery(this);
x.click(function(e) {
var left, top;
e.preventDefault();
if (height > screen.height)
{
height = screen.height;
top = 0;
}
else
top = (screen.height - height) / 2;
left = (screen.width - width) / 2;
var features = 'location=1,resizable=1,scrollbars=1,status=0,toolbar=0,menubar=0,directories=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top;
var w = window.open(url, id, features);
w.focus();
});
}
jQuery.fn.commentForm = function() {
var x = jQuery(this), f = x.find('form');
x.find('.reply').click(function(e) {
e.preventDefault(); 
var b = f.find('.body').focus(), r = jQuery(this);
b.val(((b.val().length > 0) ? b.val() + '\n\n' : '') + '@' + r.attr('title') + ': '); 
});
}
jQuery.fn.flexForm = function(conditions, states) {
var t = jQuery(this), id = t.attr('id'), submit = t.find('.form-button,input[type="submit"]');
t.find('input').keypress(function(e) { if (e.which == 13) { e.preventDefault(); t.submit(); } });
submit.click(function(e) { e.preventDefault(); t.submit(); });
t.submit(function() {
submit.attr('disabled', 'disabled').addClass('disabled');
});
t.flexForm_applyStates = function(states, initial) {
var x, speed = (initial ? 0 : 'fast');
var inList = jQuery(), outList = jQuery();
for (k in states)
{
x = t.find('[id="' + id + '-conditional-' + k + '"]');
if (states[k])
{
if (!x.visible())
inList = inList.add(x);
}
else
{
if (x.visible())
outList = outList.add(x);
}
}
if (outList.length > 0)
outList.fadeOut(speed, function() {
outList.find('input,select,textarea').attr('disabled', true).addClass('disabled');
inList.fadeIn(speed, function() {
inList.find('input,select,textarea').attr('disabled', false).removeClass('disabled');
});
});
else if (inList.length > 0)
inList.fadeIn(speed, function() {
inList.find('input,select,textarea').attr('disabled', false).removeClass('disabled');
});
};
var x, y, z, a, b;
var source, sourceId;
for (x in conditions)
{
sourceId = id + '-' + x;
source = t.find('[id="' + sourceId + '"]'); 
source.change(function(e, initial) {
var sourceValue = source.val();
var newStates = jQuery.extend(true, {}, states);
for (y in conditions[x])
{
if (sourceValue == y)
{
for (z in conditions[x][y])
newStates[z] = conditions[x][y][z];
}
}
t.flexForm_applyStates(newStates, initial);
}).trigger('change', true);
}
};
});
function af_joinQueryString(qsa)
{
var a = Array();
var s = '';
for (var i in qsa)
{
a.push(i + '=' + qsa[i]);
}
s = a.join('&');
return s;
}
function af_splitQueryString(qs)
{
var a = qs.split('&');
var b;
var c = Array();
var i;
for(i=0;i < a.length;i++)
{
b = a[i].split('=');
if (b[0] && b[1])
c[ b[0] ] = b[1];
}
return c;
}
function af_reload()
{
location.reload(true);
}
function af_redirectAndReplace(u)
{
self.parent.window.location.replace(u);
}
function af_redirect(u)
{
self.parent.window.location.href = u;
}
function af_getPref(title, key)
{
var cookie_name = title + '_prefs';
s = af_getCookie(cookie_name);
if (s == null)
return null;
prefs = af_splitQueryString(s);
return prefs[key];
}
function af_setPref(title, key, value, reload)
{
var cookie_name = title + '_prefs';
var prefs, s, a;
s = af_getCookie(cookie_name);
if (s == null)
{
a = Array();
a[key] = value;
s = af_joinQueryString(a);
}
else
{
prefs = af_splitQueryString(s);
if (value == '')
delete prefs[key];
else
prefs[key] = value;	
s = af_joinQueryString(prefs);
}
af_setCookie(cookie_name, s, 365);
if (reload == true)
window.location.reload();
}
function af_clearPref(title, key, reload)
{
af_setPref(title, key, '', reload);
}
function af_setCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function af_getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0)
{
value = unescape(c.substring(nameEQ.length,c.length));
return value;
}
}
return null;
}
jQuery(function() {
if ( jQuery.browser.msie && jQuery.browser.version <= 7  )
{ }
else
{
jQuery('.checkboxLabel').each(function() {
var t = jQuery(this), x = t.prev('.checkboxButton'), b = x.find('input');
t
.disableSelection()
.css('cursor', 'pointer')
.click(function() {
if (b)
b.trigger('click');
});
});
jQuery('.radioLabel').each(function() {
var t = jQuery(this), x = t.prev('.radioButton'), b = x.find('input.radio');
t
.disableSelection()
.css('cursor', 'pointer')
.click(function() {
if (b)
b.attr('checked', 1).trigger('click');
});
});
}
});
function af_WebWidget_Form_TableContainer(tableId,controlFieldName,min,max,columns,orderable)
{
this.instanceName = tableId;
this.table = document.getElementById(tableId);
this.controlField = document.getElementById(controlFieldName);
this.columns = columns;
this.columnsLength = 0;
for (x in columns)
this.columnsLength++;
this.min = min;
this.max = max;
this.orderable = orderable;
this.txt_actionsColumn = '<input type="button" class="button actionButton" value="&times;" onclick="' + this.instanceName + '.deleteRow(this);">';
if (this.orderable == true)
{
this.txt_actionsColumn += '<input type="button" class="button actionButton" value="&uArr;" onclick="' + this.instanceName + '.moveRowUp(this);">' +
'<input type="button" class="button actionButton" value="&dArr;" onclick="' + this.instanceName + '.moveRowDown(this);">';
}
this.txt_idRegExpSuffix = '\_\%ID\%';
this.txt_classRow1 = 'row1';
this.txt_classRow2 = 'row2';
this.txt_classEmptyRow = 'rowEmpty';
this.emptyRowIndex = -1;
}
af_WebWidget_Form_TableContainer.prototype =
{
addEmptyRow: function()
{
tr = this.table.insertRow(this.table.rows.length);
tr.className = this.txt_classEmptyRow;
td = tr.insertCell(tr.cells.length);
td.innerHTML = this.txt_actionsColumn;
td.colSpan = this.columnsLength + 1;
td.innerHTML = 'No rows added yet. Click on <strong>Add Row</strong> to add one.';
this.emptyRowIndex = tr.rowIndex;
return tr;
},
swapRows: function(x,y)
{
for(k in this.columns)
{
eX = document.getElementById(k + '_' + x);
eY = document.getElementById(k + '_' + y);
if (eX.type == "checkbox" && eY.type == "checkbox")
{
tmp = eX.checked;
eX.checked = eY.checked;
eY.checked = tmp;
}
else
{
tmp = eX.value;
eX.value = eY.value;
eY.value = tmp;
}
}
return true;
},
moveRowUp: function(t)
{
row = t.parentNode.parentNode;
x = row.rowIndex;
if (x < 2)
return false;
return this.swapRows(x, x - 1);
},
moveRowDown: function(t)
{
n = parseInt(this.controlField.value);
row = t.parentNode.parentNode;
x = row.rowIndex;
if (x >= n)
return false;
return this.swapRows(x, x + 1);
},
addRow: function(id)
{
n = parseInt(this.controlField.value);
if (n >= this.max)
{
alert('You may only have up to ' + this.max + ' rows in this table.');
return false;
}
if (this.getCount() == 0 && this.emptyRowIndex != -1)
{
this.table.deleteRow(this.emptyRowIndex);
this.emptyRowIndex = -1;
}
this.incCount();
n = parseInt(this.controlField.value);
tr = this.table.insertRow(this.table.rows.length);
if (n % 2 == 0)
tr.className = this.txt_classRow2;
else
tr.className = this.txt_classRow1;
td = tr.insertCell(tr.cells.length);
td.innerHTML = this.txt_actionsColumn;
td.className = 'actions';
for(k in this.columns)
{		
td = tr.insertCell(tr.cells.length);
rx = new RegExp(k + this.txt_idRegExpSuffix, 'g');
c = this.columns[k];
td.innerHTML = c.replace(rx, k + '_' + n);
if (td.innerHTML.indexOf('type="hidden"') >= 0
||	td.innerHTML.indexOf('type=hidden') >= 0)
td.className = 'hidden';
}
return tr;
},
deleteRow: function(t)
{
n = parseInt(this.controlField.value);
if (n <= this.min)
{
alert('You must have at least ' + this.min + ' rows in this table.');
return false;
}
row = t.parentNode.parentNode;
if (!row)
return false;
start = row.rowIndex;
this.table.deleteRow(row.rowIndex);
this.decCount();
this.shiftRowsUp(start + 1);
if (this.getCount() == 0)
this.addEmptyRow();
return true;
},
getCount: function()
{
return parseInt(this.controlField.value);
},
decCount: function()
{
this.controlField.value = parseInt(this.controlField.value) - 1;
return true;
},
incCount: function()
{
this.controlField.value = parseInt(this.controlField.value) + 1;
return true;
},
shiftRowsUp: function(start)
{
oldCount = parseInt(this.controlField.value) + 1;
if (start > oldCount)
return;
for(i=start; i <= oldCount;i++)
{	
for(k in this.columns)
{
e = document.getElementById(k + '_' + i);
if (e == null)
continue;
newId = k + '_' + (i - 1);
e.id = e.name = newId;
}
tr = this.table.rows[i - 1];
if ((i - 1) % 2 == 0)
tr.className = this.txt_classRow2;
else
tr.className = this.txt_classRow1;
}
return true;
}
}
function af_WebWidget_Form_MSHandler_Target(mId, operator, value)
{
this.mId = mId;
this.operator = operator;
this.value = value;
}
af_WebWidget_Form_MSHandler_Target.prototype = {
evaluate: function()
{
var i, v, vv, value, operator, f, result = true;
value = jQuery('#' + this.mId).val();
if (jQuery('#' + this.mId).is(':checkbox'))
{
f = jQuery('input:checkbox[name=' + this.mId + ']:checked');
if (f.length)
value = f.val();
else
return false;
}
if (value == null)
{
f = jQuery('input:radio[name=' + this.mId + ']:checked');
if (f.length)
value = f.val();
else
return false;
}
if (this.value instanceof Array)
vv = this.value;
else
vv = new Array(this.value);
for (i in vv)
{
v = vv[i];
operator = parseInt(this.operator);
switch(operator)
{
case 1: // equal (OR)
result = (value == v);
if (result == true)
return true;
break;
case 2: // not equal (AND)
result = result && (value != v);
break;
case 3: // greater than (AND)
result = result && (value > v);
break;
case 4: // less than (AND)
result = result && (value < v);
break;
default:
return false;
}
}
return result;
}
}
function af_WebWidget_Form_MSHandler(instanceName)
{
this.instanceName = instanceName;
this.targets = new Array();
this.deps = new Array();
}
af_WebWidget_Form_MSHandler.prototype = {
addTarget: function(targetId, mId, operator, value)
{
x = new af_WebWidget_Form_MSHandler_Target(mId, operator, value);
this.targets[targetId] = x;
if (this.deps[mId] == null)
this.deps[mId] = new Array();
this.deps[mId].push(targetId);
return true;
},
checkM: function(mId)
{
if (this.deps[mId] == null || this.deps[mId].length == 0)
return false;
for (i=0;this.deps[mId][i];i++)
{
targetId = this.deps[mId][i];
target = this.targets[targetId];
if (target == null)
continue;
if (target.evaluate() == false)
this.hideTarget(targetId);
else
this.showTarget(targetId);
}
return true;
},
setFormRowClass: function(e, className)
{
e.className = className;	
return true;
},
hideTarget: function(targetId)
{
var e = document.getElementById('row_' + targetId);
jQuery(e).removeClass('visible').addClass('hidden');
this.setDisabledState(e, true);
},
showTarget: function(targetId)
{
var e = document.getElementById('row_' + targetId);
jQuery(e).removeClass('hidden').addClass('visible');
this.setDisabledState(e, false);
},
setDisabledState: function(e, state)
{
var l = e.childNodes.length;
var i,x;
for (i=0;i < l;i++)
{
x = e.childNodes[i];
if (x.nodeName == "INPUT"
||  x.nodeName == "SELECT"
||  x.nodeName == "TEXTAREA")
x.disabled = state;
else
this.setDisabledState(x, state);
}
return true;
}
}