//**************************************************************************************
//* /home3/yhekobro/public_html/skk-svarka.ru/js/libs/common/jquery.imagecbox.js
//**************************************************************************************
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
jQuery.fn.imagecbox_set = function (state) {
return this.each(function () {
id = "#" + $(this).attr("id");
$(id).prop("checked", state);
if ($(id).is(":checked"))
set_image($(id), $(this).data("checked_image"));
else
set_image($(id), $(this).data("unchecked_image"));
});
// -----------------------------------------------------------------------------
function set_image(checkbox, image) {
id = "#" + checkbox.attr("id") + "_img";
$(id).attr("src", image);
}
};
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
jQuery.fn.imagecbox = function (options) {
return this.each(function () {
if ($(this).data("base_image") !== undefined) return;
if ($(this).attr("id") === undefined) {
do {
id = Math.floor(Math.random() * 1024 * 1024);
} while ($("#icb_id_" + id).length != 0);
$(this).attr("id", "icb_id_" + id);
}
$(this).data("parent_event", options.track_parent);
bi = options.image.replace(/\//g, '__').replace(/\./g, '_');
$(this).data("base_image", bi);
if (!document.getElementById("__image_check_box_checked_image_" + bi)) {
$("body").append("");
$("body").append("");
$("body").append("");
}
p = options.image.lastIndexOf(".");
iName = options.image.substr(0, p);
iExt = options.image.substr(p, options.image.legth);
ci = iName + "_checked" + iExt;
uci = iName + "_unchecked" + iExt;
oi = iName + "_over" + iExt;
$(this).data("checked_image", ci);
$(this).data("unchecked_image", uci);
$(this).data("over_image", oi);
cin = "#__image_check_box_checked_image_" + bi;
ucin = "#__image_check_box_unchecked_image_" + bi;
oin = "#__image_check_box_over_image_" + bi;
$(this).data("checked_image_name", cin);
$(this).data("unchecked_image_name", ucin);
$(this).data("over_image_name", oin);
$(cin).attr('src', ci);
$(ucin).attr('src', uci);
$(oin).attr('src', oi);
init_image_checkbox($(this));
});
// -----------------------------------------------------------------------------
function init_image_checkbox(cb) {
i_id = cb.attr("id") + "_img";
image_id = "#" + i_id;
if (!document.getElementById(cb.attr("id") + "_img")) {
cb.css("display", "none");
if (!cb.is(":checked"))
cb.after("");
else
cb.after("");
$(image_id).mousedown(_mousedown);
$(image_id).mouseenter(_mouseenter);
$(image_id).mouseleave(_mouseleave);
if (cb.data("parent_event") && cb.parent() && cb.parent()[0].nodeName != 'BODY') {
cb.parent().mousedown(_parentmousedown);
cb.parent().mouseenter(_parentmouseenter);
cb.parent().mouseleave(_parentmouseleave);
}
}
else {
if (cb.is(":checked"))
$(image_id).attr("src", cb.data("checked_image"));
else
$(image_id).attr("src", cb.data("unchecked_image"));
}
};
// -----------------------------------------------------------------------------
function _mousedown(event) {
id = "#" + $(this).attr("id");
id = id.substring(0, id.length - 4);
over_image_name = $(id).data("over_image_name");
if ($(id).is(":checked")) {
if ($(over_image_name).attr("height") && $(over_image_name).attr("width"))
$(this).attr("src", $(id).data("over_image"));
else
$(this).attr("src", $(id).data("unchecked_image"));
}
else
$(this).attr("src", $(id).data("checked_image"));
if ($(id).attr('onclick'))
$(id).click();
else
$(id).prop("checked", !$(id).prop("checked"));
event.stopPropagation();
};
function _parentmousedown(event) {
$(this).children("input[type=checkbox]").each(function () {
over_image_name = $(this).data("over_image_name");
id = "#" + $(this).attr("id");
image_id = id + "_img";
if ($(id).is(":checked")) {
if ($(over_image_name).attr("height") && $(over_image_name).attr("width"))
$(image_id).attr("src", $(this).data("over_image"));
else
$(image_id).attr("src", $(this).data("unchecked_image"));
}
else
$(image_id).attr("src", $(this).data("checked_image"));
if ($(id).attr('onclick'))
$(id).click();
else
$(id).prop("checked", !$(id).prop("checked"));
});
event.stopPropagation();
};
// -----------------------------------------------------------------------------
function _mouseenter() {
id = "#" + $(this).attr("id");
id = id.substring(0, id.length - 4);
over_image_name = $(id).data("over_image_name");
if ($(over_image_name).attr("height") && $(over_image_name).attr("width")) {
if (!$(id).is(":checked"))
$(this).attr("src", $(id).data("over_image"));
}
};
function _parentmouseenter() {
$(this).children("input[type=checkbox]").each(function () {
over_image_name = $(this).data("over_image_name");
if ($(over_image_name).attr("height") && $(over_image_name).attr("width")) {
id = "#" + $(this).attr("id");
if (!$(id).is(":checked"))
$(id + "_img").attr("src", $(this).data("over_image"));
}
});
};
// -----------------------------------------------------------------------------
function _mouseleave() {
id = "#" + $(this).attr("id");
id = id.substring(0, id.length - 4);
over_image_name = $(id).data("over_image_name");
if ($(over_image_name).attr("height") && $(over_image_name).attr("width")) {
if (!$(id).is(":checked"))
$(this).attr("src", $(id).data("unchecked_image"));
}
};
function _parentmouseleave() {
$(this).children("input[type=checkbox]").each(function () {
over_image_name = $(this).data("over_image_name");
if ($(over_image_name).attr("height") && $(over_image_name).attr("width")) {
id = "#" + $(this).attr("id");
if (!$(id).is(":checked"))
$(id + "_img").attr("src", $(this).data("unchecked_image"));
}
});
};
// -----------------------------------------------------------------------------
};
//**************************************************************************************
//* /home3/yhekobro/public_html/skk-svarka.ru/js/libs/common/main.js
//**************************************************************************************
/*
* The dialog class
*/
var dialog = {
ajaxManagerUrl: '/data_manager.php',
frames: new Array(),
closeHandlers: new Array(),
waitHtml: '
',
scrollWidth: 0,
heightMax: $(window).height() * 5 / 6
};
/*
* Open the dialog contains waiter icon.
*/
dialog.openWithWaiter = function () {
this.open(this.waitHtml, 200);
};
/*
* Disable vertical scroller before show first dialog
*/
dialog.hideScroller = function () {
if (this.frames.length) return;
body = $('body');
w0 = $(window).innerWidth();
body.css('overflow-y', 'hidden');
w1 = $(window).innerWidth();
marginLeft = parseInt(body.css('margin-left'), 10);
this.scrollWidth = Math.ceil((w1 - w0) / 2);
marginLeft -= this.scrollWidth;
body.css('margin-left', marginLeft + 'px');
try {
dialog.offsetDesignElements(-this.scrollWidth);
}
catch (err) {
}
};
/*
* Disable vertical scroller before show first dialog
*/
dialog.showScroller = function () {
if (this.frames.length) return;
body = $('body');
marginLeft = parseInt(body.css('margin-left'), 10);
marginLeft += this.scrollWidth;
body.css({'margin-left': marginLeft + 'px', 'overflow-y': 'scroll'});
try {
dialog.offsetDesignElements(this.scrollWidth);
}
catch (err) {
}
};
/*
* Open the dialog contains HTML code.
*
* html - The HTML code inserting into dialog container.
* width - The width of opened dialog in pixels.
*/
dialog.open = function (html, width, closeHandler) {
dialog.hideScroller();
dialogId = get_unique_id();
this.frames.push(dialogId);
if (typeof closeHandler !== 'undefined') {
this.closeHandlers.push(closeHandler);
} else {
this.closeHandlers.push(null);
}
w = $(window).width();
this.heightMax = $(window).height() * 5 / 6;
h = this.heightMax;
hd = $(document).height();
body = $("body");
// add white layer
body.append('');
zIndex = core.getMaxZIndex() + 1;
dialogWhiteBox = $('#dialog_white_box_' + dialogId);
dialogWhiteBox.css('z-index', zIndex);
dialogWhiteBox.animate({opacity: '0.7'}, 500);
// add dialog container
body.append('');
dialogHtml = "" + html + "
";
dialogElement = $('#' + dialogId);
zIndex++;
dialogElement.html(dialogHtml);
dialogElement.append("");
dialogElement.css('width', width + 'px');
dialogElement.css('z-index', zIndex);
dialogElement.screenCenter().fadeIn();
};
/*
* Generate the unique ID for created dialog.
*/
dialog.getUniqueId = function () {
do {
randomIntId = Math.floor(Math.random() * Math.random() * 18954785965458745895);
id = 'uid_' + randomIntId.toString(36).substr(2, 8);
l = $('#' + id).length;
} while (l != 0);
return id;
};
/*
* Change the active dialog contents.
*
* html - The new HTML code for dialog.
* width - The new width of dialog in pixels (if 'null' then width will not changing).
*/
dialog.change = function (html, width) {
if (!this.frames.length) return;
dialogId = this.frames[this.frames.length - 1];
$('#dialog_container_' + dialogId).html(html);
if (width != null) $('#' + dialogId).css({width: width + 'px'});
this.center();
};
/*
* Close the topmost dialog.
*/
dialog.close = function () {
dialogId = this.frames[this.frames.length - 1];
// if define close handler execute it
closeHandler = this.closeHandlers[this.closeHandlers.length - 1];
if (closeHandler !== null) {
closeHandler();
}
this.frames.pop();
this.closeHandlers.pop();
$('#dialog_white_box_' + dialogId).fadeOut(function () {
$('#dialog_white_box_' + dialogId).remove();
});
$('#' + dialogId).fadeOut(function () {
$('#' + dialogId).html('').remove();
});
this.showScroller();
};
/*
* Return ID of frame element of active dialog.
*/
dialog.getFrameId = function () {
return this.frames[this.frames.length - 1];
};
/*
* Return ID of inner frame element of active dialog.
*/
dialog.getInnerId = function () {
return "dialog_container_" + this.frames[this.frames.length - 1];
};
/*
* Replace active dialog to center of screen.
*/
dialog.center = function () {
dialogId = this.getFrameId();
$('#' + dialogId).screenCenter();
};
// -----------------------------------------------------------------------------------------------
dialog.offsetDesignElements = function (offsetX) {
x = parseInt($("#header_static_container").css('left'), 10);
x += offsetX;
$("#header_static_container").css('left', x + 'px');
};
// -----------------------------------------------------------------------------------------------
// index page
// -----------------------------------------------------------------------------------------------
var index = {
ajaxManagerUrl: '/data_manager.php'
};
index.teasersToggle = function () {
containerHeight = $("#teasers_container").height();
wrapperHeight = $("#teasers_wrapper").height();
if (containerHeight < wrapperHeight) {
$("#teasers_container").animate({'height': wrapperHeight + "px"}, 1000);
$("#teasers_more_button").html("teasers_less_button");
}
else {
$("#teasers_container").animate({'height': "170px"}, 1000);
$("#teasers_more_button").html("teasers_more_button");
}
};
index.QAToggle = function (num) {
answer = $("#answer_" + num);
if (answer.css('display') == "none") {
$(".qa").each(function () {
id = $(this).attr("data-id");
$("#answer_" + id).slideUp(300);
});
answer.slideDown(300);
} else {
answer.slideUp(300);
}
};
// -----------------------------------------------------------------------------------------------
// Заявка на расчет
// -----------------------------------------------------------------------------------------------
var requestCalc = {
ajaxManagerUrl: '/data_manager.php'
};
requestCalc.ceilTypeChange = function () {
ceilType = $("#ceil_type").val();
if (ceilType == -1) {
$("#ceil_type_other_row").show(200);
}
else {
$("#ceil_type_other_row").hide(200);
}
};
requestCalc.lightsTypeChange = function () {
lightsType = $("#lights_type").val();
if (lightsType == -1) {
$("#light_type_other_row").show(200);
}
else {
$("#light_type_other_row").hide(200);
}
};
requestCalc.save = function () {
ceilType = $("#ceil_type").val();
ceilTypeOther = $("#ceil_type_other").val().trim();
roomLength = $("#room_length").val().trim();
roomWidth = $("#room_width").val().trim();
roomHeight = $("#room_height").val().trim();
lightsType = $("#lights_type").val();
lightTypeOther = $("#light_type_other").val().trim();
lightsCount = $("#lights_count").val().trim();
lightsPower = $("#lights_power").val().trim();
lightsHeight = $("#lights_height").val().trim();
lightness = $("#lightness").val().trim();
hours = $("#hours").val().trim();
days = $("#days").val().trim();
price = $("#price").val().trim();
contacts = $("#contacts").val().trim();
comments = $("#comments").val().trim();
if ((ceilType == -1 && ceilTypeOther == '') ||
ceilType == 0 ||
roomLength == '' ||
roomWidth == '' ||
roomHeight == '' ||
lightsType == 0 ||
(lightsType == -1 && lightTypeOther == '') ||
lightsType == 0 ||
lightsHeight == '' ||
lightness == '' ||
hours == '' ||
days == '' ||
contacts == ''
) {
_show_warning('request_calc_js_error_header', 'request_calc_js_error_text');
return;
}
$.post(requestCalc.ajaxManagerUrl, {
section: "requestCalcSend",
ceilType: ceilType,
ceilTypeOther: ceilTypeOther,
roomLength: roomLength,
roomWidth: roomWidth,
roomHeight: roomHeight,
lightsType: lightsType,
lightTypeOther: lightTypeOther,
lightsCount: lightsCount,
lightsPower: lightsPower,
lightsHeight: lightsHeight,
lightness: lightness,
hours: hours,
days: days,
price: price,
contacts: contacts,
comments: comments
});
$("#request_calc_form").slideUp(500, function () {
$("#request_complete").slideDown(300);
});
};
// -----------------------------------------------------------------------------------------------
// Заявка на поставку
// -----------------------------------------------------------------------------------------------
var requestDelivery = {
ajaxManagerUrl: '/data_manager.php'
};
requestDelivery.save = function () {
company = $("#company").val().trim();
address = $("#address").val().trim();
contact_name = $("#contact_name").val().trim();
phone = $("#phone").val().trim();
email = $("#email").val().trim();
info = $("#info").val().trim();
var products = '';
$(".product_selector").each(function () {
name = $(this).attr('data-name');
value = $(this).val().trim();
value = parseInt(value, 10);
if (value) {
products += name + ' - ' + value + ' шт.\n';
}
});
if (company == '' ||
address == '' ||
name == '' ||
phone == '' ||
email == '' ||
products == ''
) {
_show_warning('request_delivery_js_error_header', 'request_delivery_js_error_text');
return;
}
$.post(requestDelivery.ajaxManagerUrl, {
section: "requestDeliverySend",
company: company,
address: address,
name: contact_name,
phone: phone,
email: email,
products: products,
info: info
});
$("#request_delivery_form").slideUp(500, function () {
$("#request_complete").slideDown(300);
});
};
// -----------------------------------------------------------------------------------------------
// Сделанные проекты
// -----------------------------------------------------------------------------------------------
var projectImagesScroll = {};
projectImagesScroll.scrollLeft = function (step, width) {
strip = $("#scrollStrip");
if (strip.is(':animated')) return;
position = strip.position();
if (position.left == 0) {
newLeft = -(width - step);
strip.animate({left: newLeft}, 1000);
} else {
newLeft = position.left + step;
strip.animate({left: newLeft}, 500);
}
};
projectImagesScroll.scrollRight = function (step, width) {
strip = $("#scrollStrip");
if (strip.is(':animated')) return;
position = strip.position();
if (position.left <= -(width - step)) {
newLeft = 0;
strip.animate({left: newLeft}, 1000);
} else {
newLeft = position.left - step;
strip.animate({left: newLeft}, 500);
}
};
//**************************************************************************************
//* /home3/yhekobro/public_html/skk-svarka.ru/js/libs/common/core.js
//**************************************************************************************
// *****************************************************************************
// ******
// ****** Common procedures
// ******
// *****************************************************************************
// Divs for waiting icon
document.write('');
document.write('');
document.write('');
document.write('');
var getResult, execQueryFinish;
var loading_icon = "loading_32.gif";
var loading_icon_24 = "loading_24.gif";
var _info_frames = new Array();
// -----------------------------------------------------------------------------
jQuery.fn.screenCenter = function () {
w = $(window);
this.css("position", "absolute");
this.css("top", (w.height() - this.height()) / 2 + w.scrollTop() + "px");
this.css("left", (w.width() - this.width()) / 2 + w.scrollLeft() + "px");
return this;
}
// -----------------------------------------------------------------------------
jQuery.fn.elementCenter = function (id) {
e = $('#' + id);
this.css("position", "absolute");
this.css("top", (e.innerHeight() - this.height()) / 2 + e.offset().top + "px");
this.css("left", (e.innerWidth() - this.width()) / 2 + e.offset().left + "px");
return this;
}
// -----------------------------------------------------------------------------
function mask_screen(func) {
mask_width = $(window).width();
mask_height = $(document).height();
$('.grey_box').css({
top: '0px',
left: '0px',
width: mask_width + 'px',
height: mask_height + 'px',
opacity: '0.5'
}).fadeIn();
$(".wait_slider").screenCenter().fadeTo('slow', '1', func);
}
// -----------------------------------------------------------------------------
function mask_element(id, func) {
qid = '#' + id;
if ($(qid).length == 0 || $('body').css('display') == 'none')
func();
else {
mask_width = $(qid).innerWidth();
mask_height = $(qid).innerHeight();
mask_top = $(qid).offset().top + 1;
mask_left = $(qid).offset().left + 1;
mask_border = $(qid).css('border');
mask_border_radius = $(qid).css('borderRadius');
$('.grey_box').css({
top: mask_top + 'px',
left: mask_left + 'px',
width: mask_width + 'px',
height: mask_height + 'px',
opacity: '0.6',
border: mask_border,
borderRadius: mask_border_radius
}).show();
$('.wait_slider').elementCenter(id).fadeTo(300, '1', func);
}
}
// -----------------------------------------------------------------------------
function mask_element_noicon(id, func) {
mask_width = $('#' + id).innerWidth();
mask_height = $('#' + id).innerHeight();
mask_top = $('#' + id).offset().top + 1;
mask_left = $('#' + id).offset().left + 1;
mask_border = $('#' + id).css('border');
$('.grey_box').css({
top: mask_top + 'px',
left: mask_left + 'px',
width: mask_width + 'px',
height: mask_height + 'px',
opacity: '0.5',
border: mask_border
}).show();
func();
}
// -----------------------------------------------------------------------------
function mask_screen_noicon(func) {
mask_width = $(window).width();
mask_height = $(document).height();
$('.grey_box').offset({top: 0, left: 0}).css({
top: '0px',
left: '0px',
width: mask_width + 'px',
height: mask_height + 'px',
opacity: '0.5'
}).fadeIn(300);
func();
}
// -----------------------------------------------------------------------------
function clear_mask() {
$('.wait_slider').fadeOut();
$('.grey_box').fadeOut();//.css({width: '0px', height: '0px'});
}
// -----------------------------------------------------------------------------
function execQueryCallback(data) {
getResult = data;
}
// -----------------------------------------------------------------------------
function execQuery(url, params) {
$.ajaxSetup({async: false});
$.post(url, params, execQueryCallback, 'text');
$.ajaxSetup({async: true});
return getResult;
}
// -----------------------------------------------------------------------------
String.prototype.trim = function () {
return this.replace(/^\s*|\s*$/, '');
}
// -----------------------------------------------------------------------------
function get_unique_id() {
do {
n = Math.floor(Math.random() * Math.random() * 18954785965458745895);
id = 'uid_' + Math.floor(Math.random() * Math.random() * 18954785965458745895).toString(36).substr(2, 8);
l = $('#' + id).length;
} while (l != 0)
return id;
}
// -----------------------------------------------------------------------------
function info_frame_show(title, html, info_width) {
__info_show_id = get_unique_id();
_info_frames.push(__info_show_id);
w = $(window).width();
h = $(window).height();
hd = $(document).height();
$("body").append('');
$('#white_box_' + __info_show_id).css({width: w + 'px', height: hd + 'px', opacity: '0.7'}).fadeIn();
if (info_width == null) {
info_width = w * 2 / 3;
if (info_width > 600) info_width = 600;
}
if (title != '')
info_html = "";
else
info_html = '';
h = h * 3 / 4;
$("body").append('');
info_html = info_html + "" + html + "
";
$('#' + __info_show_id).html(info_html);
$('#' + __info_show_id).css('width', info_width + 'px');
$('#' + __info_show_id).screenCenter().fadeIn();
}
// -----------------------------------------------------------------------------
function info_frame_change(title, html, width) {
__info_change_id = _info_frames[_info_frames.length - 1];
$('#info_window_container_' + __info_change_id).html(html);
if (width != null) $('#' + __info_change_id).css('width', width + 'px');
if (title != '') $("#info_window_header_" + __info_change_id).html(title + "
");
$('#' + __info_change_id).screenCenter();
}
// -----------------------------------------------------------------------------
function info_frame_close() {
__info_close_id = _info_frames[_info_frames.length - 1];
_info_frames.pop();
$('#white_box_' + __info_close_id).fadeOut(function () {
$('#white_box_' + __info_close_id).remove();
});
$('#' + __info_close_id).fadeOut(function () {
$('#' + __info_close_id).html('').remove();
});
}
// -----------------------------------------------------------------------------
function info_frame_id() {
return _info_frames[_info_frames.length - 1];
}
// -----------------------------------------------------------------------------
function info_frame_inner_id() {
return "info_window_container_" + _info_frames[_info_frames.length - 1];
}
// -----------------------------------------------------------------------------
function info_frame_center() {
__info_center_id = _info_frames[_info_frames.length - 1];
$('#' + __info_center_id).screenCenter();
}
// -----------------------------------------------------------------------------
function confirm_box(title, html, func, args) {
$("#_show_dialog:ui-dialog").dialog("close");
$("#_show_dialog:ui-dialog").dialog("destroy");
$("#_show_dialog").attr("title", title);
$("#_show_dialog").html(html);
$("#_show_dialog").dialog({
modal: true,
draggable: true,
resizable: false,
zIndex: 999999,
buttons: {
"Да": function () {
$(this).dialog("close");
func(args);
},
"Нет": function () {
$(this).dialog("close");
}
}
});
}
// -----------------------------------------------------------------------------
function _show_warning(title, text) {
$("#_show_dialog:ui-dialog").dialog("close");
$("#_show_dialog:ui-dialog").dialog("destroy");
$("#_show_dialog").attr("title", title);
html = "\
\
" + text + "
\
\
";
$("#_show_dialog").html(html);
$("#_show_dialog").dialog({
modal: true,
draggable: true,
resizable: false,
width: 400,
dialogClass: "_info_dialogs",
buttons: {
"Ok": function () {
$(this).dialog("close");
}
}
});
}
// -----------------------------------------------------------------------------
function _show_info(title, text) {
$("#_show_dialog:ui-dialog").dialog("close");
$("#_show_dialog:ui-dialog").dialog("destroy");
$("#_show_dialog").attr("title", title);
html = "\
" + text + "
\
\
";
$("#_show_dialog").html(html);
$("#_show_dialog").dialog({
modal: true,
draggable: true,
resizable: false,
width: 400,
dialogClass: "_info_dialogs",
buttons: {
"Ok": function () {
$(this).dialog("close");
}
}
});
}
// -----------------------------------------------------------------------------
function input_check_number(event) {
event = event || window.event;
target = event.target || event.srcElement;
if (window.event) key = window.event.keyCode; //IE
else key = event.which; //firefox
if (key < 32) return true;
if (key >= 48 && key <= 57) return true;
if ((key == 44 || key == 46) && $(target).val().indexOf(String.fromCharCode(key)) == -1) return true; // запятая и точка
return false;
}
// -----------------------------------------------------------------------------
function num_to_text(num) {
var i = 0, type = ['Bytes', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb'];
while ((num / 1000 | 0) && i < type.length - 1) {
num /= 1024;
i++;
}
return num.toFixed(2) + ' ' + type[i];
}
// -----------------------------------------------------------------------------
var md5unicode = new function () {
var l = 'length',
h = [
'0123456789abcdef', 0x0F, 0x80, 0xFFFF,
0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476
],
x = [
[0, 1, [7, 12, 17, 22]],
[1, 5, [5, 9, 14, 20]],
[5, 3, [4, 11, 16, 23]],
[0, 7, [6, 10, 15, 21]]
],
A = function (x, y, z) {
return (((x >> 16) + (y >> 16) + ((z = (x & h[3]) + (y & h[3])) >> 16)) << 16) | (z & h[3])
},
B = function (s) {
var n = ((s[l] + 8) >> 6) + 1, b = new Array(1 + n * 16).join('0').split('');
for (var i = 0; i < s[l]; i++)b[i >> 2] |= s.charCodeAt(i) << ((i % 4) * 8);
return (b[i >> 2] |= h[2] << ((i % 4) * 8), b[n * 16 - 2] = s[l] * 8, b)
},
R = function (n, c) {
return (n << c) | (n >>> (32 - c))
},
C = function (q, a, b, x, s, t) {
return A(R(A(A(a, q), A(x, t)), s), b)
},
F = function (a, b, c, d, x, s, t) {
return C((b & c) | ((~b) & d), a, b, x, s, t)
},
G = function (a, b, c, d, x, s, t) {
return C((b & d) | (c & (~d)), a, b, x, s, t)
},
H = function (a, b, c, d, x, s, t) {
return C(b ^ c ^ d, a, b, x, s, t)
},
I = function (a, b, c, d, x, s, t) {
return C(c ^ (b | (~d)), a, b, x, s, t)
},
_ = [F, G, H, I],
S = (function () {
with (Math)for (var i = 0, a = [], x = pow(2, 32); i < 64; a[i] = floor(abs(sin(++i)) * x));
return a
})(),
X = function (n) {
for (var j = 0, s = ''; j < 4; j++)
s += h[0].charAt((n >> (j * 8 + 4)) & h[1]) + h[0].charAt((n >> (j * 8)) & h[1]);
return s
};
return function (s) {
var $ = B('' + s), a = [0, 1, 2, 3], b = [0, 3, 2, 1], v = [h[4], h[5], h[6], h[7]];
for (var i, j, k, N = 0, J = 0, o = [].concat(v); N < $[l]; N += 16, o = [].concat(v), J = 0) {
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
for (k = 0; k < 4; k++, a.unshift(a.pop()))
v[b[k]] = _[i](
v[a[0]],
v[a[1]],
v[a[2]],
v[a[3]],
$[N + (((j * 4 + k) * x[i][1] + x[i][0]) % 16)],
x[i][2][k],
S[J++]
);
for (i = 0; i < 4; i++)
v[i] = A(v[i], o[i]);
}
;
return X(v[0]) + X(v[1]) + X(v[2]) + X(v[3]);
}
};
// -----------------------------------------------------------------------------
var trans = [];
for (var i = 0x410; i <= 0x44F; i++)
trans[i] = i - 0x350; // А-Яа-я
trans[0x401] = 0xA8; // Ё
trans[0x451] = 0xB8; // ё
function md5(str) {
var ret = [];
for (var i = 0; i < str.length; i++) {
var n = str.charCodeAt(i);
if (typeof trans[n] != 'undefined')
n = trans[n];
if (n <= 0xFF)
ret.push(n);
}
return md5unicode(String.fromCharCode.apply(null, ret));
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// image loader procedure
// -----------------------------------------------------------------------------
var _swfu, _uploaded_files = new Array();
// -----------------------------------------------------------------------------
function _load_image(func, file_mask, uniqname) {
delete _swfu;
html = "\
\
\
\
";
info_frame_show('Загрузка файла', html, 302);
_swfu = new SWFUpload(
{
upload_url: "/uploader/upload.php",
flash_url: "/uploader/swfupload.swf",
file_size_limit: "10 MB",
file_types: file_mask,
file_types_description: "Files",
file_upload_limit: 1,
button_placeholder_id: "_loader_button_holder",
button_image_url: "/images/upload_button.png",
button_width: 148,
button_height: 27,
button_text: "Выберите файл",
button_text_style: ".uploadButtonText { color: #666666; font-size: 11px; font-weight: bold; font-family: Sans-Serif;}",
button_text_left_padding: 30,
button_text_top_padding: 4,
button_action: SWFUpload.BUTTON_ACTION.SELECT_FILES,
button_disabled: false,
button_cursor: SWFUpload.CURSOR.HAND,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
// swfupload_loaded_handler : swfupload_loaded_function,
// file_dialog_start_handler : file_dialog_start_function,
file_queued_handler: _uploader_fileQueued,
file_queue_error_handler: _uploader_fileQueueError,
// file_dialog_complete_handler : fileDialogComplete,
upload_start_handler: _uploader_uploadStart,
upload_progress_handler: _uploader_uploadProgress,
upload_error_handler: _uploader_uploadError,
// upload_success_handler : upload_success_function,
upload_complete_handler: _uploader_uploadComplete,
// debug_handler : debug_function,
// debug: true,
custom_settings: {
complete_func: func,
uname: '',
}
}
);
if (uniqname) {
rnd = Math.random() * 1234567890 + (new Date).getTime();
rnd = md5(rnd.toString());
_swfu.customSettings.uname = rnd;
}
}
// -----------------------------------------------------------------------------
function _uploader_fileQueued(file) {
$("#_loader_progress_block").html("\
\
\
");
uname = _swfu.customSettings.uname;
if (uname == '') {
_swfu.customSettings.uname = file.name;
_swfu.addFileParam(file.id, "upload_file_real_name", file.name);
}
else {
pos = file.name.lastIndexOf('.');
if (pos != -1) {
ext = file.name.substring(pos);
uname = uname + ext;
_swfu.customSettings.uname = uname;
}
_swfu.addFileParam(file.id, "upload_file_real_name", uname);
}
_swfu.startUpload();
}
// -----------------------------------------------------------------------------
function debug_function(message) {
alert(message);
}
// -----------------------------------------------------------------------------
function _uploader_fileQueueError() {
}
function _uploader_uploadStart() {
}
// -----------------------------------------------------------------------------
function _uploader_uploadProgress(file, bytes, total) {
w100 = 300;
w = parseInt(w100 * bytes / total);
if (bytes == total) w = w100;
$("#_loader_progress_bar").css({"width": w + "px"});
$("#_loader_progress_text").html(num_to_text(bytes) + " из " + num_to_text(total));
}
// -----------------------------------------------------------------------------
function _uploader_uploadError(file, error, message) {
alert(message);
}
// -----------------------------------------------------------------------------
function _uploader_uploadComplete(file) {
complete_function = _swfu.customSettings.complete_func;
$("#_loader_progress_block").after("Идет обработка загруженного файла ...
");
complete_function(_swfu.customSettings.uname);
_swfu.destroy();
}
// -----------------------------------------------------------------------------
var core = {};
core.setCookie = function (cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires;
};
core.getCookie = function (cname) {
var name = cname + "=";
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);
if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
}
return "";
};
core.isEmail = function (email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return regex.test(email);
};
core.getMaxZIndex = function () {
var highest = -999;
$("*").each(function () {
var current = parseInt($(this).css("z-index"), 10);
// if (current == 1999999) current = 0;
id = $(this).attr('id');
if (id == 'colorbox' || id == 'cboxOverlay' || id == 'cboxWrapper') current = 0;
if (current && highest < current) highest = current;
});
return highest;
};