if (!adminpanel)
{
truesize();
}
var clearident=false;
var x=0;
var oldcolnum;
var resizefun=[];
//browser.display.focus_ring_width = 0 ;
function addimg()
{
$('.tovimg.hided:first').css('display','none').removeClass('hided').slideDown() ;
}
function delimg(x)
{
//console.log($(ob).attr('id'));
$('#tovimg'+x).slideUp();
}
function setupdatecoord()
{
$( "#response .butresize" ).draggable(
{
containment: "parent", stop:function()
{
updatecoord() ;
}
});
updatecoord();
}
function updatecoord()
{
var position = $("#response .butresize").position();
if (position)
{
var relativeX = position.left;
var relativeY = position.top;
$("#imgcoord").val([relativeX, relativeY]);
}
}
function reloadcapcha(ob)
{
img=$(ob).next();
img.attr('src', ('/jscripts/c.php?'+rand(1,1000000)) );
}
$.ajaxSetup({
type: "POST",
cache:false,
dataType:'text',
error: function (XMLHttpRequest, textStatus, errorThrown)
{
////console.log('error:', XMLHttpRequest,'stat:', textStatus, errorThrown );
// typically only one of textStatus or errorThrown
// will have info
//this; // the options for this ajax request
}
});
$('#footer').append('
');
//,
$("#nav li, #hmenu li, #left .m2-L,#left .m3-L,#left .m4-L,#left .m5-L,#right .m2-L,#right .m3-L,#right .m4-L,#right .m5-L, #cmenu .cmenu-L, #cmenu .dalee-L, #left ul.MenuBarVertical li").hover( function ()
{
$(this).addClass("ov");
},
function ()
{
$(this).removeClass("ov");
}
);
function price_line(pattern,num)
{
patter=pattern.split( '?' );
//if ( sizeof(patter)==1 ) return ;
if ( patter.length==1 ) return ;
x=0;
var n2,p2,out,stop;
patter.forEach( function(patte)
{
x++;
patt= patte.split( '-' );
n1=n2;
p1=p2;
n2=trim(patt[1]);
p2=trim(patt[0]);
//v(get_defined_vars());
//exit();
if (!stop)
{
if ( x==1 )
{
n1=1;
p1=p2;
//console.log(n1,p1,n2,p2,x);
if( n2 > num )
{
out= p2;
stop=1;
}
}
else if ( (x == patter.length) && (n2<= num) )
{
out= (p2);
stop=1;
}
else if ( num < n2 )
{
//v(get_defined_vars());
out= Number(p1) + Number((num-n1)*( p2 - p1 ) / ( n2 - n1 ));
stop=1;
}
}
});
return out;
}
$(window).click(function ()
{
$('#maintab .admenu .incontext').fadeOut('fast');
uput();
});
$('body').mousemove(function (e)
{
curX= e.pageX;
curY = e.pageY;
//$("#coord").text("( e.pageX, e.pageY ) - " + pageCoords);
$("#coord").html(" X: " + e.pageX + " Y: " + e.pageY + " H: " + (e.pageY-usY)+ " W: " + (e.pageX-usX) );
$("#coord").css('top',e.pageY+3).css('left',e.pageX+3);
});
var prekey,usX,usY,curX,curY;
$(document).keyup(function(event)
{
$("#coord").html('');
//alert();
prekey=0;
});
$(document).keydown(function(event)
{
$("#coord").html(" "+(event.keyCode));
if (event.keyCode==17 )
{
//alert('rere');
usX=curX;
usY=curY;
//alert(usX);
}
/*else
{
prekey=event.keyCode;
}*/
//alert();
});
function subscriber(form)
{
if ( checkmyform(form) )
{
email=$('.emailsubscribe');
$.fancybox('');
$.get( hrpref+'--?&subscriber='+email.val(),
function(data)
{
setTimeout("$.fancybox('Спасибо за подписку!')",1000);
email.val('');
});
return false;
}
return false;
}
function deltovcart(id)
{
$('#incen .fullcart').css('opacity',0.2) ;
////console.log(id);
$.ajax({dataType:'text', type:'GET',url:hrpref+'cart--?' , cache:false, data:({deltovcart: id }), success: function(data)
{
dat=data.split('[fc]');
$('#incen .fullcart').css('opacity',1) ;
if ( dat[1] )
{
$('#outfullcart').html( (dat[1]));
}
else
{
cartclear_jq();
}
cartminiup(dat[2]);
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{
//console.log(XMLHttpRequest, textStatus, errorThrown) ;
// typically only one of textStatus or errorThrown
// will have info
this; // the options for this ajax request
}
});
}
function cartminiup(data)
{
//alert(data);
if ( $('#cartmini').attr('id') )
{
$('#cartmini').html(data);
//console.log(1);
}
else if ( $('.blockcart').attr('class') )
{
$('.blockcart').replaceWith(data);
//console.log(2,data);
}
else if ( data )
{
$('#inleft').prepend(data);
}
else
{
$('.blockcart').remove();
cartclear_jq();
}
}
function prigl()
{
$.fancybox('
');
});
}
else if (dat[1]=='added')
{
$.fancybox('
Данный товар уже добавлен в корзину
');
}
});
return false;
}
function cartclear_jq()
{
$('#gozakazform,#center .clearcart,#center .renum,#outfullcart').remove()
}
// Добавить в Избранное Добавить в Избранное
function add_favorite(a) {
title=document.title;
url=document.location;
try {
// Internet Explorer
window.external.AddFavorite(url, title);
}
catch (e) {
try {
// Mozilla
window.sidebar.addPanel(title, url, "");
}
catch (e) {
// Opera
if (typeof(opera)=="object") {
a.rel="sidebar";
a.title=title;
a.url=url;
return true;
}
else {
// Unknown
alert('Нажмите Ctrl-D чтобы добавить страницу в закладки');
}
}
}
return false;
}
function checkmyform(ob)
{
var fal;
////console.log( $(ob).attr('name') );
th=func_get_arg(0) ;
ea=$(th).find(' .need input:visible, .need textarea:visible, .need select:visible');
ea.each(function()
{
if ($(this).val()=='' || ( $(this).attr('alt') && $(this).attr('alt')==$(this).val() ) )
{
fal=1;
}
});
if (fal)
{
$.fancybox('
Необходимо заполнить все поля, отмеченные звёздочкой
');
return false;
}
else
{
if ( !adminpanel ) {
$("form .hidden:hidden[rel!=opt]").remove();
}
//alert('уд');
$(".hint").val('');
// cписок видимых форм
var oldname;
var formnames;
$(ob).find(' .i_t input:visible[type=text], .i_t input:visible[type=password], .i_t textarea:visible, input:visible[type=checkbox], input:visible[type=radio], select:visible ').each( function(k,inp)
{
n=$(inp).attr('name');
//console.log(n);
if (n!==oldname)
{
formnames=formnames? formnames+','+n : n ;
}
oldname=n;
});
$(ob).append('');
return true;
}
}
function searchadm()
{
sa=$('#ssad').val();
if( sa )
{
$("#adcont").css('opacity',0.2);
$.post('/myadmin.php', { searchadm:sa }, function(data)
{
//$('#th'+id).slideDown( 200 );
$("#adcont").html('
'+data+'
').css('opacity',1);
//setTimeout( 'location.replace(window.location.href);',1000);
truesize();
});
}
return false;
}
function cache_img_flush()
{
$('*').each(function(){ im=$(this).css('background-image'); ; $(this).css('background-image',str_replace('.png','.png?'+rand(1000,100000),str_replace('.png','.png?'+rand(1000,100000 ) , im ) )); });
}
function setcheckval()
{
var objdep;
var dps='';
var old={};
$('form div[group]').each(function(){
sep=dps? ';' : '';
grp=($(this).attr('group'));
eval ( ('bool='+ grp + ';')) ;
dps=dps+(dp);
});
// form input[type=checkbox],form input[type=radio], form select
////console.log(dps);
arr=dps.substr(0, dps.length-1).split(';');
////console.log(arr);
$.each(arr, function(k, v)
{
if( (arr[k]) && arr[k]!==' ' && old[arr[k]]!==1 ){
old[arr[k]]=1;
$(('#'+arr[k]))
.change(function() {
//console.log( 'cn', $(this).attr('id') );
checkval();
//checkval();
});
};
}
);
checkval();
}
function ini_set (varname, newvalue) {
// Set a configuration option, returns false on error and the old value of the configuration option on success
//
// version: 1109.2015
// discuss at: http://phpjs.org/functions/ini_set
// + original by: Brett Zamir (http://brett-zamir.me)
// % note 1: This will not set a global_value or access level for the ini item
// * example 1: ini_set('date.timezone', 'America/Chicago');
// * returns 1: 'Asia/Hong_Kong'
var oldval = '',
that = this;
this.php_js = this.php_js || {};
this.php_js.ini = this.php_js.ini || {};
this.php_js.ini[varname] = this.php_js.ini[varname] || {};
oldval = this.php_js.ini[varname].local_value;
var _setArr = function (oldval) { // Although these are set individually, they are all accumulated
if (typeof oldval === 'undefined') {
that.php_js.ini[varname].local_value = [];
}
that.php_js.ini[varname].local_value.push(newvalue);
};
switch (varname) {
case 'extension':
if (typeof this.dl === 'function') {
this.dl(newvalue); // This function is only experimental in php.js
}
_setArr(oldval, newvalue);
break;
default:
this.php_js.ini[varname].local_value = newvalue;
break;
}
return oldval;
}
function krsort (inputArr, sort_flags) {
// Sort an array by key value in reverse order
//
// version: 1109.2015
// discuss at: http://phpjs.org/functions/krsort
// + original by: GeekFG (http://geekfg.blogspot.com)
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Brett Zamir (http://brett-zamir.me)
// % note 1: The examples are correct, this is a new way
// % note 2: This function deviates from PHP in returning a copy of the array instead
// % note 2: of acting by reference and returning true; this was necessary because
// % note 2: IE does not allow deleting and re-adding of properties without caching
// % note 2: of property position; you can set the ini of "phpjs.strictForIn" to true to
// % note 2: get the PHP behavior, but use this only if you are in an environment
// % note 2: such as Firefox extensions where for-in iteration order is fixed and true
// % note 2: property deletion is supported. Note that we intend to implement the PHP
// % note 2: behavior by default if IE ever does allow it; only gives shallow copy since
// % note 2: is by reference in PHP anyways
// % note 3: Since JS objects' keys are always strings, and (the
// % note 3: default) SORT_REGULAR flag distinguishes by key type,
// % note 3: if the content is a numeric string, we treat the
// % note 3: "original type" as numeric.
// - depends on: i18n_loc_get_default
// * example 1: data = {d: 'lemon', a: 'orange', b: 'banana', c: 'apple'};
// * example 1: data = krsort(data);
// * results 1: {d: 'lemon', c: 'apple', b: 'banana', a: 'orange'}
// * example 2: ini_set('phpjs.strictForIn', true);
// * example 2: data = {2: 'van', 3: 'Zonneveld', 1: 'Kevin'};
// * example 2: krsort(data);
// * results 2: data == {3: 'Kevin', 2: 'van', 1: 'Zonneveld'}
// * returns 2: true
var tmp_arr = {},
keys = [],
sorter, i, k, that = this,
strictForIn = false,
populateArr = {};
switch (sort_flags) {
case 'SORT_STRING':
// compare items as strings
sorter = function (a, b) {
return that.strnatcmp(b, a);
};
break;
case 'SORT_LOCALE_STRING':
// compare items as strings, based on the current locale (set with i18n_loc_set_default() as of PHP6)
var loc = this.i18n_loc_get_default();
sorter = this.php_js.i18nLocales[loc].sorting;
break;
case 'SORT_NUMERIC':
// compare items numerically
sorter = function (a, b) {
return (b - a);
};
break;
case 'SORT_REGULAR':
// compare items normally (don't change types)
default:
sorter = function (b, a) {
var aFloat = parseFloat(a),
bFloat = parseFloat(b),
aNumeric = aFloat + '' === a,
bNumeric = bFloat + '' === b;
if (aNumeric && bNumeric) {
return aFloat > bFloat ? 1 : aFloat < bFloat ? -1 : 0;
} else if (aNumeric && !bNumeric) {
return 1;
} else if (!aNumeric && bNumeric) {
return -1;
}
return a > b ? 1 : a < b ? -1 : 0;
};
break;
}
// Make a list of key names
for (k in inputArr) {
if (inputArr.hasOwnProperty(k)) {
keys.push(k);
}
}
keys.sort(sorter);
// BEGIN REDUNDANT
this.php_js = this.php_js || {};
this.php_js.ini = this.php_js.ini || {};
// END REDUNDANT
strictForIn = this.php_js.ini['phpjs.strictForIn'] && this.php_js.ini['phpjs.strictForIn'].local_value && this.php_js.ini['phpjs.strictForIn'].local_value !== 'off';
populateArr = strictForIn ? inputArr : populateArr;
// Rebuild array with sorted key names
for (i = 0; i < keys.length; i++) {
k = keys[i];
tmp_arr[k] = inputArr[k];
if (strictForIn) {
delete inputArr[k];
}
}
for (i in tmp_arr) {
if (tmp_arr.hasOwnProperty(i)) {
populateArr[i] = tmp_arr[i];
}
}
return strictForIn || populateArr;
}
function strtr (str, from, to) {
// Translates characters in str using given translation tables
//
// version: 1109.2015
// discuss at: http://phpjs.org/functions/strtr
// + original by: Brett Zamir (http://brett-zamir.me)
// + input by: uestla
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Alan C
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Taras Bogach
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
// + input by: jpfle
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
// - depends on: krsort
// - depends on: ini_set
// * example 1: = {'hello' : 'hi', 'hi' : 'hello'};
// * example 1: strtr('hi all, I said hello', )
// * returns 1: 'hello all, I said hi'
// * example 2: strtr('aaabaaccasdeooo', 'aao','aao');
// * returns 2: 'aaabaaccasdeooo'
// * example 3: strtr('aaaaaaaa', 'a', 'a');
// * returns 3: 'aaaaaaaa'
// * example 4: strtr('http', 'pthxyz','xyzpth');
// * returns 4: 'zyyx'
// * example 5: strtr('zyyx', 'pthxyz','xyzpth');
// * returns 5: 'http'
// * example 6: strtr('aa', {'a':1,'aa':2});
// * returns 6: '2'
var fr = '',
i = 0,
j = 0,
lenStr = 0,
lenFrom = 0,
tmpStrictForIn = false,
fromTypeStr = '',
toTypeStr = '',
istr = '';
var tmpFrom = [];
var tmpTo = [];
var ret = '';
var match = false;
// Received replace_pairs?
// Convert to normal from->to chars
if (typeof from === 'object') {
tmpStrictForIn = this.ini_set('phpjs.strictForIn', false); // Not thread-safe; temporarily set to true
from = this.krsort(from);
this.ini_set('phpjs.strictForIn', tmpStrictForIn);
for (fr in from) {
if (from.hasOwnProperty(fr)) {
tmpFrom.push(fr);
tmpTo.push(from[fr]);
}
}
from = tmpFrom;
to = tmpTo;
}
// Walk through subject and replace chars when needed
lenStr = str.length;
lenFrom = from.length;
fromTypeStr = typeof from === 'string';
toTypeStr = typeof to === 'string';
for (i = 0; i < lenStr; i++) {
match = false;
if (fromTypeStr) {
istr = str.charAt(i);
for (j = 0; j < lenFrom; j++) {
if (istr == from.charAt(j)) {
match = true;
break;
}
}
} else {
for (j = 0; j < lenFrom; j++) {
if (str.substr(i, from[j].length) == from[j]) {
match = true;
// Fast forward
i = (i + from[j].length) - 1;
break;
}
}
}
if (match) {
ret += toTypeStr ? to.charAt(j) : to[j];
} else {
ret += str.charAt(i);
}
}
return ret;
}
function checkval ()
{
$('form .hidden').each(function()
{
eval (('bool='+$(this).attr('group') + ';')) ;
// alert(0.5);
if (bool )
{
//alert(1);
if( $(this).css('display')=='none')
{
$(this).slideDown('fast', function(){ } );
$('#ihi'+$(this).attr('id')).val('') ;
}
if ( $(this).attr('rel')=='spanopt' )
{
rep='' ;
//alert(rep);
$(this).after(rep);
$(this).remove() ;
}
}
else
{
if ( $(this).css('display')!=='none' )
{
$(this).slideUp("fast");
$('#ihi'+$(this).attr('id')).val('1') ;
}
if ( $(this).attr('rel')=='opt' )
{
rep='
'+$(this).text() + '
' ;
//alert(rep);
$(this).after(rep);
$(this).remove() ;
}
}
});
$('.hidden:hidden input[type=text],.hidden:hidden textarea').val('');
summ=new Number();
$('form .i_r:visible, form input[type=checkbox]').each(function()
{
val= Number( vlh( $(this).attr('id') ));
summ+= (val ? val : 0) ;
});
if (summ > 0 )
{
$('#itogo').html(' Итого: '+summ+' рублей');
$('#valsumm').val( ' Итого: '+summ+' рублей' );
}
}
function vl(id)
{
div=$('#'+id+':visible');
if (div.attr('rel')=='rad' )
{
out = div.find('input:checked').val();
}
else if (div.attr('type')=='checkbox')
{
out= div.attr('checked');
}
else
{
out = div.val();
}
//alert(out);
return out;
}
function vlh(id)
{
var out='';
div=$('#'+id+':visible');
if (div.attr('rel')=='rad' )
{
out = div.find('input:checked').attr('rel');
}
else if (div.attr('type')=='checkbox' && div.attr('checked') )
{
out= div.attr('rel');
}
//alert(out);
return out;
}
function screenHeight(){
return $(window).height();
}
function screenWidth(){
return $(window).width();
}
// isset(window, "globalValue") - можно
function isset () {
// + original by: Kevin van Zonneveld
// + improved by: FremyCompany
// + improved by: Onno Marsman
// * example 1: isset( undefined, true);
// * returns 1: false
// * example 2: isset( 'Kevin van Zonneveld' );
// * returns 2: true
var a=arguments, l=a.length, i=0;
if (l===0) {
throw new Error('Empty isset');
}
while (i!==l) {
if (typeof(a[i])=='undefined' || a[i]===null) {
return false;
} else {
i++;
}
}
return true;
}
function chreg(reg)
{
curid=$('#adcont input[name=id]').val();
curmode=$('#adcont input[name=mode]').val();
location.replace('/myadmin.php?id='+curid+'&mode='+curmode+'&chreg='+reg);
}
function ajaxform()
{
$('.ajaxform')
.bind('form-pre-serialize', function(e)
{
if ( $('.tiny input').attr('name') )
{
tinyMCE.triggerSave();
}
})
.ajaxForm({
//target: '#output1',
beforeSerialize: beforeSerialize,
success: ajaxformSuccess
});
}
function tinyGetFromAjax()
{
$('.tiny').each(function()
{
ifr=$(this).find('iframe').contents().find('body').html();
$(this).find('textarea').val( ifr );
});
}
function beforeSerialize ()
{
if ( checkmyform() )
{
$('#adcont').fadeTo(0,0.1);
x=0;
var imgs=[];
$.each($('.tovimg:visible'),function()
{
imgs[x++]=$(this).attr('rel');
});
$('#imgs').val( implode(',', imgs ) );
}
else
{
return false;
}
}
var xml_special_to_escaped_one_map = {
'&': '&',
'"': '"',
'<': '<',
'>': '>'
};
var escaped_one_to_xml_special_map = {
'&': '&',
'"': '"',
'<': '<',
'>': '>'
};
function encodeXml(string) {
return string.replace(/([\&"<>])/g, function(str, item) {
return xml_special_to_escaped_one_map[item];
});
};
function decodeXml(string) {
return string.replace(/("|<|>|&)/g,
function(str, item) {
return escaped_one_to_xml_special_map[item];
});
}
function getVarValueFromURL(url, varName) {
var query = url.substring(url.indexOf('?') + 1);
var vars = query.split("&");
for (var i=0;i');
//alert(res[0]);
$('#response').html(res[1]);
$('#tovimg').html(dt[6]);
setupdatecoord();
selector='#ss'+dt[2];
//alert (selector);
$(selector).remove();
$(selector).remove();
$(selector).remove();
$('#'+dt[2]).prepend(dt[1]);
newevent(dt[2]);
$('#'+dt[2]).attr('class','t-'+dt[3]);
$('#'+dt[2]).attr('class','t-'+dt[3]);
$('#'+dt[2]).attr('class','t-'+dt[3]);
$('#adcont input[name=ident]').val(dt[4]);
$('#adcont input[name=url]').val('');
mode=$('#adcont input[name=mode]').val();
if ( (mode=='0') && (dt[5]!=='') )
{
$('.inadm').html('');
$('.inadm').html('');
$('.inadm').html('');
$('.inadm').append(dt[5]);
setajax();
}
}
else
{
if ( responseText.split('