var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
};
var qs =
{
touchUrl: function (url)
{
$.ajax({
url: url,
type: 'GET',
async: false
});
}
};
var Qs_Array =
{
get: function (data, field, defaultValue)
{
if (typeof field != 'undefined') {
field = field.replace(/\]/g, '');
var parts = field.split(/\[/);
while ((name = array_shift(parts))) {
if (!array_key_exists(name, data)) {
return (typeof defaultValue != 'undefined') ? defaultValue : null;
}
data = data[name];
}
}
return data;
},
set: function (data, field, value)
{
if (typeof field == 'undefined') {
return false;
}
field = field.replace(/\]/g, '');
var parts = field.split(/\[/);
var _data = data;
while ((name = array_shift(parts))) {
if (parts.length == 0) {
_data[name] = value;
break;
}
if (!array_key_exists(name, _data)) {
_data[name] = {};
}
_data = _data[name];
}
return true;
},
isAssoc: function (array)
{
var i = 0;
for (var j in array) {
if (parseInt(j, 10) != i++) {
return true;
}
}
return false;
},
collapse: function(array, belongsTo)
{
if (typeof belongsTo == 'undefined') {
belongsTo = '';
}
result = {};
for (var key in array) {
var value = array[key];
var itemBelongsTo = belongsTo + (empty(belongsTo) ? key : '[' + key + ']');
if (is_array(value)) {
result = array_merge(result, Qs_Array.collapse(value, itemBelongsTo));
} else {
result[itemBelongsTo] = value;
}
}
return result;
}
};
var Form_Element_Select = {
/**
*
* @param HTMLSelectElement element
* @param options Object
* @param value String
* @param mixed emptyTitle string|bool|undefined
*/
setOptions:function (element, options, value, emptyTitle) {
var i;
var emptyOption = false;
if (typeof emptyTitle == 'string') {
emptyOption = document.createElement('OPTION');
emptyOption.text = emptyTitle;
emptyOption.value = '';
} else if (true === emptyTitle) {
var firstOption = element.options.item(0);
if (firstOption) {
emptyOption = document.createElement('OPTION');
emptyOption.text = firstOption.text;
emptyOption.value = firstOption.value;
}
}
for (i = element.options.length - 1; i >= 0; i--) {
element.remove(i);
}
if (false !== emptyOption) {
element.options.add(emptyOption);
}
var isAssoc = Qs_Array.isAssoc(options);
for (i in options) {
var option = document.createElement('OPTION');
option.value = isAssoc ? i : options[i].value;
option.text = isAssoc ? options[i] : options[i].text;
element.options.add(option);
}
this.setValue(element, value);
},
enable: function (element, value)
{
element.disabled = false;
if (typeof value != 'undefined') {
element.value = value;
}
},
disable: function (element, title)
{
element.value = '';
element.disabled = true;
if (typeof title != 'undefined') {
Form_Element_Select.setOptions(element, {}, title)
}
},
getValue:function (element) {
if (element.multiple) {
var value = [];
for (var j in element.options) {
if (
element.options[j] != null
&& typeof element.options[j].tagName == 'string'
&& element.options[j].tagName == 'OPTION'
&& element.options[j].selected
) {
value.push(element.options[j].value);
}
}
return value;
} else {
return element.value;
}
},
setValue:function (element, value) {
if (element.multiple) {
if (!is_array(value)) {
value = [value];
}
for (var j in element.options) {
if (
element.options[j] != null
&& typeof element.options[j].tagName == 'string'
&& element.options[j].tagName == 'OPTION'
) {
element.options[j].selected = in_array(element.options[j].value, value);
}
}
} else {
element.value = value;
}
}
};
var Qs_Message = Class.create();
Qs_Message.prototype = {
initialize: function (messages)
{
this.messages = messages;
},
get: function (name, language)
{
if (typeof language == 'undefined') {
language = CURR_LANG;
}
if (typeof this.messages[language] == 'undefined') {
return '';
}
if (typeof this.messages[language][name] == 'string') {
return this.messages[language][name];
}
if (typeof this.messages[DEFAULT_LANGUAGE][name] == 'string') {
return this.messages[DEFAULT_LANGUAGE][name];
}
return '';
}
};
function is_string (/*anything*/ it)
{
return !!arguments.length && it != null && (typeof it == "string" || it instanceof String); // Boolean
}
function is_array (/*anything*/ it)
{
return it && (it instanceof Array || typeof it == "array"); // Boolean
}
var Qs_Form = {
message: new Qs_Message({
'eng': {
'invalidInformationEntered': 'Please review the comments marked in red and make appropriate corrections.',
'pleaseCorrectTheseFields': ''
}
}),
options: {
errorDisplayMethod: 'HTML'
},
formOptions: {},
init: function (idForm, options)
{
var form = document.getElementById(idForm);
if (!form) {
alert('Form (id = ' + idForm + ') is not available');
return false;
}
if (!form.tagName || form.tagName != 'FORM') {
alert('Element (id = ' + idForm + ') is not a form - tagName = ' + form.tagName);
return false;
}
if (options) {
Qs_Form.formOptions[idForm] = options;
}
$(form).unbind('submit.form-plugin').bind('submit.form-plugin', Qs_Form.onSubmit);
$(':submit,input:image', form).unbind('click.form-plugin').bind('click.form-plugin', Qs_Form.buttonOnClick);
},
buttonOnClick: function (e)
{
var form = this.form;
form.clk = this;
if (this.type == 'image') {
if (e.offsetX != undefined) {
form.clk_x = e.offsetX;
form.clk_y = e.offsetY;
} else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
var offset = $(this).offset();
form.clk_x = e.pageX - offset.left;
form.clk_y = e.pageY - offset.top;
} else {
form.clk_x = e.pageX - this.offsetLeft;
form.clk_y = e.pageY - this.offsetTop;
}
}
setTimeout(function() {
form.clk = form.clk_x = form.clk_y = null;
}, 10);
},
getOption: function (name)
{
return Qs_Form.options[name];
},
setErrorDisplayMethod: function (idForm, value)
{
Qs_Form.setFormOption(idForm, 'errorDisplayMethod', value);
},
getErrorDisplayMethod: function (idForm)
{
return Qs_Form.getFormOption(idForm, 'errorDisplayMethod');
},
setFormOption: function (idForm, name, value)
{
if (typeof Qs_Form.formOptions[idForm] == 'undefined') {
Qs_Form.formOptions[idForm] = {};
}
Qs_Form.formOptions[idForm][name] = value;
},
getFormOption: function (idForm, name)
{
if (typeof Qs_Form.formOptions[idForm] == 'undefined' || typeof Qs_Form.formOptions[idForm][name] == 'undefined') {
return Qs_Form.getOption(name);
}
return Qs_Form.formOptions[idForm][name];
},
callExternal: function (spec)
{
if (typeof spec == 'string') {
$.globalEval(spec + '.call(this)');
} else if (typeof spec == 'object' && spec != null) {
var scriptHtml = '';
for (var callback in spec) {
var params = new Array();
if (is_numeric(callback)) {
if (typeof spec[callback] == 'string') {
callback = spec[callback]
} else if (typeof spec[callback] == 'object'
&& typeof spec[callback] != null
) {
var key = array_key(spec[callback]);
params = spec[callback][key]
callback = key;
} else {
continue;
}
} else {
params = spec[callback];
}
scriptHtml += callback;
if (params.length) {
scriptHtml += '.apply(this, ' + json_encode(params) + ');\n';
} else {
scriptHtml += '.call(this);\n';
}
}
if (scriptHtml.length) {
$.globalEval(scriptHtml);
}
}
},
onSubmitSuccess: function (response, form)
{
var id = $(form).attr('id');
Qs_Form.setFormOption(id, 'response', response)
if (response.isValid) {
if (form) {
var onSuccessCallback = Qs_Form.getFormOption($(form).attr('id'), 'onSuccessCallback');
if (typeof onSuccessCallback == 'undefined') {
form.submit();
} else {
Qs_Form.callExternal(onSuccessCallback);
}
}
} else {
var onErrorCallback = Qs_Form.getFormOption($(form).attr('id'), 'onErrorCallback');
if (typeof onErrorCallback != 'undefined') {
Qs_Form.callExternal(onErrorCallback);
return true;
}
Qs_Form.displayErrors(id);
}
return response;
},
displayErrors: function (id)
{
var response = Qs_Form.getFormOption(id, 'response');
var form = document.getElementById(id);
var displayMethod = Qs_Form.getErrorDisplayMethod(id);
switch (displayMethod) {
case 'ALERT':
var message = Qs_Form.message.get('invalidInformationEntered') + '\n';
message += Qs_Form.prepareErrorsAlert(response.errors, response.elements);
message += '\n\n' + Qs_Form.message.get('pleaseCorrectTheseFields');
var name = array_key(response.errors);
if (form[name] && form[name].focus) {
form[name].focus();
} else if (form[name + '[input]'] && form[name + '[input]'].focus) { // встановлення фокуса для каптчі
form[name + '[input]'].focus();
}
$.scrollTo('#' + name + '-label');
alert(message);
break;
case 'HTML':
Qs_Form.displayErrorsHtml(form, response.errors);
var elementName = array_key(response.errors);
var idElement = Qs_Array.get(response.elements, elementName + '[id]');
if (idElement == null) {
idElement = elementName;
}
var name = array_key(response.errors);
var focusKey = null;
if (form[name] && form[name].focus) {
focusKey = name;
} else if (form[name + '[input]'] && form[name + '[input]'].focus) { // встановлення фокуса для каптчі
focusKey = name + '[input]';
}
if (focusKey != null) {
if ($('[name="' + focusKey + '"]:visible', form).size()) {
form[focusKey].focus();
}
}
var formPrependId = Qs_Form.getFormOption(id, 'prependId');
if (formPrependId) {
name = id + '-' + name;
}
//$.scrollTo('#' + idElement + '-label');
alert(
Qs_Form.message.get('invalidInformationEntered')
+ '\n'
+ Qs_Form.message.get('pleaseCorrectTheseFields')
);
break;
default:
alert('Qs_Form. Unknown errorDisplayMethod "' + displayMethod + '"');
}
if (typeof response.captcha == 'object' && response.captcha != null) {
for (var name in response.captcha) {
var captcha = $('#' + name + '-element');
if ($(captcha).size() != 0) {
$('img:first', captcha).attr('src', response.captcha[name].src);
$('#' + name + '-id', captcha).attr('value', response.captcha[name].id);
$('#' + name + '-input', captcha).attr('value', '');
}
}
}
},
prepareErrorsAlert: function (errors, titles)
{
var messages = '';
for (var element in errors) {
var message = '';
var isTitle = true;
for (var errorIndex in errors[element]) {
if (typeof errors[element][errorIndex] == 'string') {
message += '\n - ' + errors[element][errorIndex];
} else {
messages += Qs_Form.prepareErrorsAlert(errors[element], titles[element]);
isTitle = false;
break;
}
}
if (isTitle && message != '') {
messages += '\n' + titles[element] + ':' + message;
}
}
return messages;
},
displayErrorsHtml: function (form, errors, belongsTo)
{
for (var element in errors) {
var html = '';
var elementName;
if (typeof belongsTo != 'undefined') {
elementName = belongsTo + '[' + element + ']';
} else {
elementName = element;
}
for (var errorIndex in errors[element]) {
if (typeof errors[element][errorIndex] == 'string') {
html += '
' + errors[element][errorIndex] + '';
} else {
Qs_Form.displayErrorsHtml(form, errors[element], elementName);
break;
}
}
if (html != '') {
html = '';
var idForm = $(form).attr('id');
var response = Qs_Form.getFormOption(idForm, 'response')
var id = Qs_Array.get(response.elements, elementName + '[id]');
if (null == id) {
id = elementName.replace(/\[\]$/, '').replace(/\]/g, '').replace(/\[/g, '-');
}
var formPrependId = Qs_Form.getFormOption(idForm, 'prependId');
if (formPrependId) {
id = idForm + '-' + id;
}
$('#' + id + '-element').append(html);
}
}
},
onSubmitError: function (request, textStatus, errorThrown)
{
alert(textStatus + ' ' + errorThrown);
},
onSubmitComplete: function (XMLHttpRequest, textStatus, form)
{
var idForm = $(form).attr('id');
Qs_Form.formOptions[idForm]['processRequest'] = false;
},
removeElementsErrors: function (form)
{
$('ul.errors', form).remove();
},
editorsTriggerSave: function (form)
{
if (typeof tinyMCE != 'undefined') {
tinyMCE.triggerSave();
}
if (typeof FCKeditorAPI != 'undefined') {
for (var i = 0; i < form.elements.length; i++) {
if (form.elements[i].tagName == 'TEXTAREA') {
var fckObject = FCKeditorAPI.GetInstance(form.elements[i].name);
if (typeof fckObject != 'undefined') {
if (fckObject.IsDirty()) {
fckObject.UpdateLinkedField();
}
}
}
}
}
},
onSubmit: function (spec)
{
var form;
if (this.tagName == 'FORM') {
form = this;
} else {
form = spec;
}
var idForm = $(form).attr('id');
Qs_Form.editorsTriggerSave(form);
Qs_Form.removeElementsErrors(form);
if (typeof Qs_Form.formOptions[idForm]['processRequest'] == 'undefined'
|| Qs_Form.formOptions[idForm]['processRequest'] != true) {
Qs_Form.formOptions[idForm]['processRequest'] = true;
var options = {
url: $(form).attr('action'),
type: 'POST',
dataType: 'json',
data: Qs_Form.toObject(form),
success: function (data)
{
Qs_Form.onSubmitSuccess(data, form);
},
error: Qs_Form.onSubmitError,
complete: function (XMLHttpRequest, textStatus)
{
Qs_Form.onSubmitComplete(XMLHttpRequest, textStatus, form)
}
};
$.ajax(options);
}
return false;
},
setValue: function(/*Object*/obj, /*String*/name, /*String*/value)
{
var val = obj[name];
if(is_string(val)) {
if (name.substr(-2) == '[]') {
obj[name] = [val, value];
} else {
obj[name] = value;
}
} else if (is_array(val)) {
val.push(value);
} else {
obj[name] = value;
}
},
toObject: function (/*DOMNode||String*/ formNode)
{
var ret = {};
var exclude = 'file|submit|image|reset|button|';
if (is_string(formNode)) {
formNode = document.getElementById(formNode);
}
for (var i = 0; i Searching... ');
$.post('keyword', { keyword:$('#keywordinput').val()}, function(data) {
if (data=='error') {
$('#textkeyword').html('Search our site or enter a site keyword: There is no such keyword at our web site ');
} else {
$('#textkeyword').html('Search our site or enter a site keyword: Found. Redirecting... ');
window.location=data;
}
});
}
function closeAccessTip(a)
{
$.ajax({
'url': a.href,
data: {action: 'close_access_tip'},
dataType: 'json',
error: function (request, textStatus, errorThrown) {
//alert(textStatus +' ' + errorThrown);
},
success: function(data) {
if (data.success != 'undefined' && data.success != null) {
$('#memeber-access-tip').remove();
}
},
complete: function(request, textStatus) {}
});
$('#memeber-access-tip').remove();
return false;
}
function outMoney(amount)
{
var val = 0;
if (typeof amount == 'string') {
val = parseFloat(amount);
} else if (typeof amount == 'number') {
val = amount;
} else {
return '';
}
return '$'+addCommas(val.toFixed(2));
}
function addCommas(nStr)
{
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
function getElementPos(obj){
var l = 0;
var t = 0;
var w = obj.offsetWidth;
var h = obj.offsetHeight;
while (obj) {
l += obj.offsetLeft;
t += obj.offsetTop;
if ((obj.tagName != "TABLE") && (obj.tagName != "BODY")) {
l += (obj.clientLeft)?obj.clientLeft:0;
t += (obj.clientTop)?obj.clientTop:0;
}
obj = obj.offsetParent;
}
var res = new Object();
res.x = l;
res.y = t;
res.left = l;
res.top = t;
res.w = w;
res.h = h;
res.width = w;
res.height = h;
return res;
}
function urlencode( str )
{
// URL-encodes string
//
// + discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_urlencode/
// + version: 809.1713
// + original by: Philip Peterson
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: AJ
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// % note: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
// * example 1: urlencode('Kevin van Zonneveld!');
// * returns 1: 'Kevin+van+Zonneveld%21'
// * example 2: urlencode('http://kevin.vanzonneveld.net/');
// * returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
// * example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
// * returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
var histogram = {}, histogram_r = {}, code = 0, tmp_arr = [];
var ret = str.toString();
var replacer = function(search, replace, str) {
var tmp_arr = [];
tmp_arr = str.split(search);
return tmp_arr.join(replace);
};
// The histogram is identical to the one in urldecode.
histogram['!'] = '%21';
histogram['%20'] = '+';
// Begin with encodeURIComponent, which most resembles PHP's encoding functions
ret = encodeURIComponent(ret);
for (search in histogram) {
replace = histogram[search];
ret = replacer(search, replace, ret) // Custom replace. No regexing
}
// Uppercase for full PHP compatibility
return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
return "%"+m2.toUpperCase();
});
return ret;
}
// {{{ number_format
function number_format( number, decimals, dec_point, thousands_sep ) {
// Format a number with grouped thousands
//
// + discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_number_format/
// + version: 809.2411
// + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfix by: Michael White (http://getsprink.com)
// + bugfix by: Benjamin Lupton
// + bugfix by: Allan Jensen (http://www.winternet.no)
// + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
// + bugfix by: Howard Yeend
// * example 1: number_format(1234.5678, 2, '.', '');
// * returns 1: 1234.57
var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
var d = dec_point == undefined ? "." : dec_point;
var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}// }}}
function sprintf ( ) {
// http://kevin.vanzonneveld.net
// + original by: Ash Searle (http://hexmen.com/blog/)
// + namespaced by: Michael White (http://getsprink.com)
// + tweaked by: Jack
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Paulo Ricardo F. Santos
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Brett Zamir (http://brett-zamir.me)
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// * example 1: sprintf("%01.2f", 123.1);
// * returns 1: 123.10
// * example 2: sprintf("[%10s]", 'monkey');
// * returns 2: '[ monkey]'
// * example 3: sprintf("[%'#10s]", 'monkey');
// * returns 3: '[####monkey]'
var regex = /%%|%(\d+\$)?([-+\'#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuidfegEG])/g;
var a = arguments, i = 0, format = a[i++];
// pad()
var pad = function (str, len, chr, leftJustify) {
if (!chr) {chr = ' ';}
var padding = (str.length >= len) ? '' : Array(1 + len - str.length >>> 0).join(chr);
return leftJustify ? str + padding : padding + str;
};
// justify()
var justify = function (value, prefix, leftJustify, minWidth, zeroPad, customPadChar) {
var diff = minWidth - value.length;
if (diff > 0) {
if (leftJustify || !zeroPad) {
value = pad(value, minWidth, customPadChar, leftJustify);
} else {
value = value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length);
}
}
return value;
};
// formatBaseX()
var formatBaseX = function (value, base, prefix, leftJustify, minWidth, precision, zeroPad) {
// Note: casts negative numbers to positive ones
var number = value >>> 0;
prefix = prefix && number && {'2': '0b', '8': '0', '16': '0x'}[base] || '';
value = prefix + pad(number.toString(base), precision || 0, '0', false);
return justify(value, prefix, leftJustify, minWidth, zeroPad);
};
// formatString()
var formatString = function (value, leftJustify, minWidth, precision, zeroPad, customPadChar) {
if (precision != null) {
value = value.slice(0, precision);
}
return justify(value, '', leftJustify, minWidth, zeroPad, customPadChar);
};
// doFormat()
var doFormat = function (substring, valueIndex, flags, minWidth, _, precision, type) {
var number;
var prefix;
var method;
var textTransform;
var value;
if (substring == '%%') {return '%';}
// parse flags
var leftJustify = false, positivePrefix = '', zeroPad = false, prefixBaseX = false, customPadChar = ' ';
var flagsl = flags.length;
for (var j = 0; flags && j < flagsl; j++) {
switch (flags.charAt(j)) {
case ' ': positivePrefix = ' '; break;
case '+': positivePrefix = '+'; break;
case '-': leftJustify = true; break;
case "'": customPadChar = flags.charAt(j+1); break;
case '0': zeroPad = true; break;
case '#': prefixBaseX = true; break;
}
}
// parameters may be null, undefined, empty-string or real valued
// we want to ignore null, undefined and empty-string values
if (!minWidth) {
minWidth = 0;
} else if (minWidth == '*') {
minWidth = +a[i++];
} else if (minWidth.charAt(0) == '*') {
minWidth = +a[minWidth.slice(1, -1)];
} else {
minWidth = +minWidth;
}
// Note: undocumented perl feature:
if (minWidth < 0) {
minWidth = -minWidth;
leftJustify = true;
}
if (!isFinite(minWidth)) {
throw new Error('sprintf: (minimum-)width must be finite');
}
if (!precision) {
precision = 'fFeE'.indexOf(type) > -1 ? 6 : (type == 'd') ? 0 : undefined;
} else if (precision == '*') {
precision = +a[i++];
} else if (precision.charAt(0) == '*') {
precision = +a[precision.slice(1, -1)];
} else {
precision = +precision;
}
// grab value using valueIndex if required?
value = valueIndex ? a[valueIndex.slice(0, -1)] : a[i++];
switch (type) {
case 's': return formatString(String(value), leftJustify, minWidth, precision, zeroPad, customPadChar);
case 'c': return formatString(String.fromCharCode(+value), leftJustify, minWidth, precision, zeroPad);
case 'b': return formatBaseX(value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'o': return formatBaseX(value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'x': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'X': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad).toUpperCase();
case 'u': return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'i':
case 'd':
number = parseInt(+value, 10);
prefix = number < 0 ? '-' : positivePrefix;
value = prefix + pad(String(Math.abs(number)), precision, '0', false);
return justify(value, prefix, leftJustify, minWidth, zeroPad);
case 'e':
case 'E':
case 'f':
case 'F':
case 'g':
case 'G':
number = +value;
prefix = number < 0 ? '-' : positivePrefix;
method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())];
textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) % 2];
value = prefix + Math.abs(number)[method](precision);
return justify(value, prefix, leftJustify, minWidth, zeroPad)[textTransform]();
default: return substring;
}
};
return format.replace(regex, doFormat);
}
function vdie()
{
var __getType = function( inp ) {
var type = typeof inp, match;
if (type == 'object' && !inp) {
return 'null';
}
if (type == "object") {
if (!inp.constructor) {
return 'object';
}
var cons = inp.constructor.toString();
if (match = cons.match(/(\w+)\(/)) {
cons = match[1].toLowerCase();
}
var types = ["boolean", "number", "string", "array"];
for (key in types) {
if (cons == types[key]) {
type = types[key];
break;
}
}
}
return type;
};
var content = '';
for (var i =0; i < arguments.length; i++) {
content += (i + 1) + ') [' + __getType(arguments[i]) + '] ' + print_r(arguments[i], true) + '\n';
}
alert(content);
}
function print_r (array, return_val) {
// http://kevin.vanzonneveld.net
// + original by: Michael White (http://getsprink.com)
// + improved by: Ben Bryan
// + input by: Brett Zamir (http://brett-zamir.me)
// + improved by: Brett Zamir (http://brett-zamir.me)
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// - depends on: echo
// * example 1: print_r(1, true);
// * returns 1: 1
var output = "", pad_char = " ", pad_val = 4, d = this.window.document;
var getFuncName = function (fn) {
var name = (/\W*function\s+([\w\$]+)\s*\(/).exec(fn);
if (!name) {
return '(Anonymous)';
}
return name[1];
};
var repeat_char = function (len, pad_char) {
var str = "";
for (var i=0; i < len; i++) {
str += pad_char;
}
return str;
};
var formatArray = function (obj, cur_depth, pad_val, pad_char) {
if (cur_depth > 0) {
cur_depth++;
}
var base_pad = repeat_char(pad_val*cur_depth, pad_char);
var thick_pad = repeat_char(pad_val*(cur_depth+1), pad_char);
var str = "";
if (typeof obj === 'object' && obj !== null && obj.constructor && getFuncName(obj.constructor) !== 'PHPJS_Resource') {
str += "Array\n" + base_pad + "(\n";
for (var key in obj) {
if (obj[key] instanceof Array) {
str += thick_pad + "["+key+"] => "+formatArray(obj[key], cur_depth+1, pad_val, pad_char);
} else {
str += thick_pad + "["+key+"] => " + obj[key] + "\n";
}
}
str += base_pad + ")\n";
} else if (obj === null || obj === undefined) {
str = '';
} else { // for our "resource" class
str = obj.toString();
}
return str;
};
output = formatArray(array, 0, pad_val, pad_char);
if (return_val !== true) {
if (d.body) {
this.echo(output);
}
else {
try {
d = XULDocument; // We're in XUL, so appending as plain text won't work; trigger an error out of XUL
this.echo(''+output+'
');
}
catch (e) {
this.echo(output); // Outputting as plain text may work in some plain XML
}
}
return true;
} else {
return output;
}
}
function getPageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = window.innerWidth + window.scrollMaxX;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
// console.log(self.innerWidth);
// console.log(document.documentElement.clientWidth);
if (self.innerHeight) { // all except Explorer
if(document.documentElement.clientWidth){
windowWidth = document.documentElement.clientWidth;
} else {
windowWidth = self.innerWidth;
}
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
// console.log("xScroll " + xScroll)
// console.log("windowWidth " + windowWidth)
// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = xScroll;
} else {
pageWidth = windowWidth;
}
// console.log("pageWidth " + pageWidth)
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
var _showProcessingBox = true;
function showProcessingBox()
{
if (!_showProcessingBox) {
return false;
}
var pageSize = getPageSize();
$('#processing-box-contaier').css('height', pageSize[1] + 'px');
$('#processing-box').css('top', Math.floor(pageSize[3]/2) + 'px');
$('#processing-box').css('left', (Math.floor(pageSize[2]/2) - 60) + 'px');
$('#processing-box-contaier').show();
$('#processing-box').show();
}
function hideProcessingBox()
{
$('#processing-box-contaier').hide();
$('#processing-box').hide();
}
function count (mixed_var, mode) {
// Count the number of elements in a variable (usually an array)
//
// version: 909.322
// discuss at: http://phpjs.org/functions/count
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Waldo Malqui Silva
// + bugfixed by: Soren Hansen
// * example 1: count([[0,0],[0,-4]], 'COUNT_RECURSIVE');
// * returns 1: 6
// * example 2: count({'one' : [1,2,3,4,5]}, 'COUNT_RECURSIVE');
// * returns 2: 6
var key, cnt = 0;
if (mixed_var === null){
return 0;
} else if (mixed_var.constructor !== Array && mixed_var.constructor !== Object){
return 1;
}
if (mode === 'COUNT_RECURSIVE') {
mode = 1;
}
if (mode != 1) {
mode = 0;
}
for (key in mixed_var){
cnt++;
if ( mode==1 && mixed_var[key] && (mixed_var[key].constructor === Array || mixed_var[key].constructor === Object) ){
cnt += this.count(mixed_var[key], 1);
}
}
return cnt;
}
function md5 (str) {
// http://kevin.vanzonneveld.net
// + original by: Webtoolkit.info (http://www.webtoolkit.info/)
// + namespaced by: Michael White (http://getsprink.com)
// + tweaked by: Jack
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Brett Zamir (http://brett-zamir.me)
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// - depends on: utf8_encode
// * example 1: md5('Kevin van Zonneveld');
// * returns 1: '6e658d4bfcb59cc13f96c14450ac40b9'
var xl;
var rotateLeft = function (lValue, iShiftBits) {
return (lValue<>>(32-iShiftBits));
};
var addUnsigned = function (lX,lY) {
var lX4,lY4,lX8,lY8,lResult;
lX8 = (lX & 0x80000000);
lY8 = (lY & 0x80000000);
lX4 = (lX & 0x40000000);
lY4 = (lY & 0x40000000);
lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
if (lX4 & lY4) {
return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
}
if (lX4 | lY4) {
if (lResult & 0x40000000) {
return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
} else {
return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
}
} else {
return (lResult ^ lX8 ^ lY8);
}
};
var _F = function (x,y,z) { return (x & y) | ((~x) & z); };
var _G = function (x,y,z) { return (x & z) | (y & (~z)); };
var _H = function (x,y,z) { return (x ^ y ^ z); };
var _I = function (x,y,z) { return (y ^ (x | (~z))); };
var _FF = function (a,b,c,d,x,s,ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(_F(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var _GG = function (a,b,c,d,x,s,ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(_G(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var _HH = function (a,b,c,d,x,s,ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(_H(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var _II = function (a,b,c,d,x,s,ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(_I(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var convertToWordArray = function (str) {
var lWordCount;
var lMessageLength = str.length;
var lNumberOfWords_temp1=lMessageLength + 8;
var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
var lWordArray=new Array(lNumberOfWords-1);
var lBytePosition = 0;
var lByteCount = 0;
while ( lByteCount < lMessageLength ) {
lWordCount = (lByteCount-(lByteCount % 4))/4;
lBytePosition = (lByteCount % 4)*8;
lWordArray[lWordCount] = (lWordArray[lWordCount] | (str.charCodeAt(lByteCount)<>>29;
return lWordArray;
};
var wordToHex = function (lValue) {
var wordToHexValue="",wordToHexValue_temp="",lByte,lCount;
for (lCount = 0;lCount<=3;lCount++) {
lByte = (lValue>>>(lCount*8)) & 255;
wordToHexValue_temp = "0" + lByte.toString(16);
wordToHexValue = wordToHexValue + wordToHexValue_temp.substr(wordToHexValue_temp.length-2,2);
}
return wordToHexValue;
};
var x=[],
k,AA,BB,CC,DD,a,b,c,d,
S11=7, S12=12, S13=17, S14=22,
S21=5, S22=9 , S23=14, S24=20,
S31=4, S32=11, S33=16, S34=23,
S41=6, S42=10, S43=15, S44=21;
str = this.utf8_encode(str);
x = convertToWordArray(str);
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
xl = x.length;
for (k=0;k 127 && c1 < 2048) {
enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
} else {
enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
}
if (enc !== null) {
if (end > start) {
utftext += string.substring(start, end);
}
utftext += enc;
start = end = n+1;
}
}
if (end > start) {
utftext += string.substring(start, string.length);
}
return utftext;
}
function addtooltips()
{
$('.member_tooltip').cluetip({attribute: 'id', width:400, cluetipClass: 'rounded', dropShadow:false, arrows: true});
}
var Member = {
hasStatus: function (member, id_status)
{
if (is_array(id_status)) {
for (var id in id_status) {
if (Member._hasStatus(member, id)) {
return true;
}
}
return false;
}
return Member._hasStatus(member, id_status);
},
_hasStatus: function (member, id_status)
{
return (intval(member.id_mncar_type) > 0 && intval(member.id_mncar_status) == id_status)
|| (intval(member.id_mncar_l_type) > 0 && intval(member.id_mncar_l_status) == id_status)
|| (intval(member.id_misc_type) > 0 && intval(member.id_misc_status) == id_status);
}
}