/*
Author: mike@vodopyanov.ru (hired by stellarweb.ru)
*/
function urlencode( str ) {
var ret = str;
ret = ret.toString();
ret = encodeURIComponent(ret);
ret = ret.replace(/%20/g, '+');
return ret;
}
$(window).load(function(){
$('div.brand_wrapper table td div p img').each(function(){
var height = $(this).height();
var half_pic = height/2;
var marg = 20 - half_pic;
$(this).css('margin-top',marg+'px');
});
});
$(function() {
$('ul.menu').NavDropDown({
duration:300,
hoverElement:'li',
hoverClass:'hover',
dropHolder:'div',
showEffect:'slide' // slide, fade, slide&fade
});
$.fn.formLabels();
$('a.notice').live('click',function(){return false;});
$('ul#mainmenu li a').hover(function(){
$(this).parent().css('border-color','#8c8c8c');
$(this).parent().css('background','url(/contents/templates/default/images/menu_hover.png)');
$(this).css('color','#fff5ae');
$(this).addClass('mainmenu_shad');
},function(){
$(this).parent().css('border-color','transparent');
$(this).parent().css('background','none');
$(this).css('color','#0a0052');
$(this).removeClass('mainmenu_shad');
});
$('div.fieldset tr:odd').css('background','#d3d3d5');
$('div#mods_list table tr.info td table').each(function(){
$(this).find('tr:odd').css('background-color','#f4f4f4');
});
$('div#mods_list > table > tbody > tr.mod > td.name').hover(function(){
$(this).css('text-decoration','underline');
},function(){
$(this).css('text-decoration','none');
});
/////////////////////////////////////
$('div.compare table td').each(function(){
if($(this).html()==''){
$(this).html(' ');
}
});
$('div.compare table tbody tr:first-child').remove();
var leftt='';
$('div.compare table tbody td.first').each(function(){
leftt+='
').insertBefore('.compare');
//////////////////////////////////////
var topt='';
$('div.compare table thead td').each(function(i){
if(i!=0)
topt+='
'+$(this).html()+'
';
});
$('div.compare table thead').remove();
$('
'+$('div.compare_wrap').attr('data-model')+'
').insertBefore('.leftt_wrap');
$('div.compare table tr:nth-child(3) td').each(function(i){
$('.topt').find('div:nth-child('+(i+1)+')').css('width',($(this).outerWidth()-1)+'px');
$(this).css('width',$(this).width()+'px');
});
//////////////////////////////////////
$('div.compare').scroll(function(){
$('.topt_wrap').scrollLeft($(this).scrollLeft());
$('.leftt_wrap').scrollTop($(this).scrollTop());
});
/////////////////////////////////////
var xhr;
$('div#brands table td div').hover(function(){
//var ind = $(this).parent().find('td').index(this);
//ind++;
//$(this).parent().parent().find('tr:nth-child(1)').find('td:nth-child('+ind+')').css('border-color','#d3d3d3').css('background-color','#e5e9f5');//.addClass('brands_bg');
//$(this).parent().parent().find('tr:nth-child(2)').find('td:nth-child('+ind+')').css('border-color','#d3d3d3').css('background-color','#e5e9f5');//.addClass('brands_bg');
$(this).css('background-position','0 0');
xhr=$.ajax({
url: '?ajax=query&module=21&func=ModelsList¶ms='+$(this).find('a').attr('rel'),
dataType : "html",
cache: false,
success: function (data) {
var mox = $('div#brands').position().left;
var moy = $('div#brands').position().top;
moy = moy + $('div#brands').outerHeight() +17;
$('div#models_over').html(data).css('left',mox+'px').css('top',moy+'px').show();
var count_li = $('div#models_over').find('.models_list li').length;
if(count_li<6)
$('div#models_over').find('.models_list li').css('width','auto');
}
});
},function(){
xhr.abort();
//var ind = $(this).parent().find('td').index(this);
//ind++;
//$('div#models_over').hide();
//$(this).parent().parent().find('tr:nth-child(1)').find('td:nth-child('+ind+')').css('border-color','transparent').css('background-color','inherit');//.removeClass('brands_bg');
//$(this).parent().parent().find('tr:nth-child(2)').find('td:nth-child('+ind+')').css('border-color','transparent').css('background-color','inherit');//.removeClass('brands_bg');
$(this).css('background-position','-93px 0');
});
$('div#models_over').hide();
$('div#models_over').hover(function(){
$('div.popup_mod').hide();
},function(){
$(this).hide();
});
$('div#models ul.models_list li, div#models_over ul.models_list li').live('mouseenter',function(){
var x = $(this).offset().left;
var y = $(this).offset().top;
y=y-16;
var xpar = $(this).parent().parent().offset().left;
var widthp = $(this).parent().parent().outerWidth();
if(x+$('div.popup_model').outerWidth()>xpar+widthp) x = x - (x+$('div.popup_model').outerWidth()-xpar-widthp) -15;
$('div.popup_mod').hide();
var html='
';
html+='
';
var data = $(this).find('.modsdata').attr('data-alldata');
var tmp = data.split('|');
var i = 0;
for (var key in tmp) {
var prop = tmp[key].split(';');
html+=''+prop[1]+' '+prop[2]+' р ';
i++;
}
html+='
';
$('div.popup_model').html(html).css('left',x+'px').css('top',y+'px').css('display','block');
}).live('mouseleave',function(){
//$('div.popup_model').css('display','none');
//$('div.popup_mod').css('display','none');
});
$('div.popup_model').hover(function(){
$('div#models_over').show();
},function(){
$(this).hide();
//$('div.popup_mod').hide();
});
$('div.popup_mod').hover(function(){
$('div.popup_model').show();
},function(){
$(this).hide();
});
$('div.popup_model td.mods').live('mouseenter',function(){
var x = $(this).parent().find('td:nth-child(2)').offset().left;
var y = $(this).parent().find('td:nth-child(2)').offset().top;
var textdata = $(this).attr('data-details').split(',');
textdata = textdata.join('
');
var html = '
'+$(this).parent().find('td:nth-child(2)').html()
+'
в кредит подарки '+textdata+'
все опции ';
$('div.popup_mod').html(html).css('left',x+'px').css('top',y+'px').css('display','block');
}).live('mouseleave',function(){
});
$('div#mods_list tr.info').hide();
$('div#mods_list tr.opened').toggle('fast');
$('div#mods_list tr.mod').click(function(){
$('tr.info').removeClass('last');
$('tr.info:visible').toggle('fast').addClass('last');
if(!$(this).next('tr.info').hasClass('last')){
$(this).next('tr.info').toggle('fast');
$(window).scrollTo($('tr.info:visible').prev(),500);
}
});
$('div#mods_list > table thead td a').click(function(){
$(window).scrollTo($('div.compare_wrap > a'),500);
return false;
});
var mX;
var mY;
$(document).mousemove(function(event) {
mX = event.pageX;
mY = event.pageY;
});
function closer(){
var moX = $('div#models_over').offset().left;
var moY = $('div#models_over').offset().top;
var moW = moX + $('div#models_over').outerWidth();
var moH = moY + $('div#models_over').outerHeight();
var modelX = $('div.popup_model').offset().left;
var modelY = $('div.popup_model').offset().top;
var modelW = modelX + $('div.popup_model').outerWidth();
var modelH = modelY + $('div.popup_model').outerHeight();
if($('div#models_over').css('display')=='none'){
$('div.popup_model').hide();
$('div.popup_mod').hide();
}
if($('div.popup_model').css('display')=='none'){
$('div.popup_mod').hide();
}
if((mX
modelW) || (mYmodelH)){
if($('div.popup_mod').css('display')=='none'){
$('div.popup_model').hide();
}
}
if((mXmoW) || (mYmoH)){
var isblue=0;
$('div#brands td div').each(function(){
//console.log($(this).css('background'));
if($(this).css('background')=='rgba(0, 0, 0, 0) url(http://avto1001.geosurf.ru/contents/templates/default/images/menu-buttons.png) no-repeat scroll 0px 0px')
isblue=1;
});
if($('div.popup_model').css('display')=='none'&&isblue==0){
$('div#models_over').hide();
}
}
//console.log("mouse - "+mX+";"+mY+" bound - "+modelX+";"+modelW+";"+modelY+";"+modelH);
}
//clearInterval(viewer);
//viewer = setInterval(closer, 1000);
$('select#brand').change(function(){
var val = $(this).find('option:selected').val();
$('select#model').html(' ');
$('select#mod').html(' ');
$('input#price').attr('value','');
$.ajax({
type: "POST",
data: {brandid:val},
dataType: "html",
success: function(data){
$('select#model').append(data);
},
error: function(a,b,c){
alert(a+'\n'+b+'\n'+c);
}
});
});
$('select#model').change(function(){
var val = $(this).find('option:selected').val();
$('select#mod').html(' ');
$('input#price').attr('value','');
$.ajax({
type: "POST",
data: {modelid:val},
dataType: "html",
success: function(data){
$('select#mod').append(data);
},
error: function(a,b,c){
alert(a+'\n'+b+'\n'+c);
}
});
});
$('select#mod').change(function(){
var val = $(this).find('option:selected').val();
$('input#price').attr('value','');
$.ajax({
type: "POST",
data: {modid:val},
dataType: "html",
success: function(data){
$('input#price').attr('value',data);
},
error: function(a,b,c){
alert(a+'\n'+b+'\n'+c);
}
});
});
////////////////////
$(".color .thumbs li img").each(function(){
var img = new Image();
img.src = $(this).attr("ref");
});
$(".color .thumbs li img").click(function(){
var link = $(this).attr("ref");
var img = new Image();
img.src = link;
$(".color .thumbs li").css('border-color','#fff');
$(this).parent().css('border-color','#2e22b0');
$(".color .pic img").css("backgroundImage","url('"+link+"')");
});
$('.call_block a').click(function(){
var phone = $('.call_block input').val();
if(phone==''){
alert('Введите номер телефона');
}else{
$.ajax({
url: '?ajax=query&module=21&func=CallMe¶ms='+phone,
dataType: "html",
cache: false,
success: function (data) {
if(data=="ok"){
alert("Спасибо за заявку! Мы обязательно Вам перезвоним.");
$(window.location).attr('href','http://avto1001.ru/?recall_send');
/*$('.call_block input').val('');*/
}else{
alert("Сервис временно не работает.");
}
},
error: function () {
alert("Сервис отключен.");
}
});
}
return false;
});
});
var fullInterval = new Array();
var fullStep = new Array();
var fullAcceleration = new Array();
var fullSpeed = new Array();
var fullTopSpeed = 30;
var fullStartW = new Array();
var fullStartH = new Array();
var fullEndW = new Array();
var fullEndH = new Array();
var fullSpeedK = new Array();
function setElementOpacity(sElemId, nOpacity)
{
var opacityProp = getOpacityProperty();
var elem = document.getElementById(sElemId);
if (!elem || !opacityProp) return;
if (opacityProp=="filter")
{
nOpacity *= 100;
var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
if (oAlpha)
oAlpha.opacity = nOpacity;
else
elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";
}
else
elem.style[opacityProp] = nOpacity;
}
function getOpacityProperty()
{
if (typeof document.body.style.opacity == 'string') // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9, IE7)
return 'opacity';
else
if (typeof document.body.style.MozOpacity == 'string') // Mozilla 1.6 e ieaaoa, Firefox 0.8
return 'MozOpacity';
else
if (typeof document.body.style.KhtmlOpacity == 'string') // Konqueror 3.1, Safari 1.1
return 'KhtmlOpacity';
else
if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) // Internet Exploder 5.5+
return 'filter';
return false;
}
function hideZoom(id,sW,sH)
{
var zoomBlock = document.getElementById('zoomBlock'+id);
zoomBlock.style.display = 'none';
zoomBlock.style.visibility = 'hidden';
var fsPhoto = document.getElementById('fullScreenPhotoBlock'+id);
fsPhoto.style.width = sW + 'px';
fsPhoto.style.height = sH + 'px';
fsPhoto.style.marginLeft = Math.round((document.documentElement.clientWidth - sW)/2) + 'px';
fsPhoto.style.marginTop = Math.round((document.documentElement.clientHeight - sH)/2) -(-(document.documentElement.scrollTop||document.body.scrollTop)) + 'px';
fsPhoto.style.display = 'none';
fsPhoto.style.visibility = 'hidden';
var fsImage = document.getElementById('fsImage'+id);
fsImage.style.height = sH + 'px';
fsImage.style.width = sW + 'px';
fsImage.style.display = 'none';
fsImage.style.visibility = 'hidden';
delta = new Array(0,4,6,8,8);
for (i = 1; i <= 5; i++)
{
nH = sH + delta[i-1];
document.getElementById('left'+id+'_'+i).style.height = nH + 'px';
document.getElementById('right'+id+'_'+(6-i)).style.height = nH + 'px';
}
for (i = 1; i <= 5; i++)
{
document.getElementById('right'+id+'_'+i).style.marginLeft = sW -(-i) -1 + 'px';
}
document.getElementById('top'+id).style.width = sW + 'px';
document.getElementById('bottom'+id).style.width = sW + 'px';
document.getElementById('bottom'+id).style.marginTop = sW + 'px';
document.getElementById('point'+id+'_2').style.marginLeft = sW -1 + 'px';
document.getElementById('point'+id+'_3').style.marginTop = sW -1 + 'px';
document.getElementById('point'+id+'_4').style.marginLeft = sW -1 + 'px';
document.getElementById('point'+id+'_4').style.marginTop = sW -1 + 'px';
}
function zoomImage(id,photoPath)
{
var zoomBlock = document.getElementById('zoomBlock'+id);
zoomBlock.style.display = 'block';
zoomBlock.style.visibility = 'visible';
zoomBlock.style.height = '1px';
zoomBlock.style.width = '1px';
bodyHeight = document.body.offsetHeight;
if (bodyHeight < document.documentElement.offsetHeight)
{
bodyHeight = document.documentElement.offsetHeight;
}
if (bodyHeight < document.documentElement.clientHeight)
{
bodyHeight = document.documentElement.clientHeight;
}
if (bodyHeight < document.body.offsetHeight)
{
bodyHeight = document.body.offsetHeight;
}
if (bodyHeight < document.body.clientHeight)
{
bodyHeight = document.body.clientHeight;
}
if (bodyHeight < document.documentElement.scrollHeight)
{
bodyHeight = document.documentElement.scrollHeight;
}
if (bodyHeight < document.body.scrollHeight)
{
bodyHeight = document.body.scrollHeight;
}
zoomBlock.style.height = bodyHeight + 'px';
zoomBlock.style.width = document.documentElement.clientWidth + 'px';
setElementOpacity('zoomBlock'+id,0.8);
var fsPhoto = document.getElementById('fullScreenPhotoBlock'+id);
fsPhoto.style.display = 'block';
fsPhoto.style.visibility = 'visible';
sW = fsPhoto.offsetWidth;
sH = fsPhoto.offsetHeight
fsPhoto.style.marginLeft = Math.round((document.documentElement.clientWidth - sW)/2) + 'px';
fsPhoto.style.marginTop = Math.round((document.documentElement.clientHeight - sH)/2) -(-(document.documentElement.scrollTop||document.body.scrollTop)) + 'px';
var fsImage = new Image();
fsImage.onload = function()
{
document.getElementById('fsImage'+id).src = fsImage.src;
document.getElementById('fsImage'+id).style.display = 'block';
document.getElementById('fsImage'+id).style.visibility = 'visible';
animateImage(id,sW,sH,fsImage.width,fsImage.height);
}
var curPhotoNum = eval('photoNum'+id);
fsImage.src = photoPath+id+'/fullscreen_'+eval('gallery'+id+'['+curPhotoNum+'][\'filename\']');
document.getElementById('fsImage'+id).alt = eval('gallery'+id+'['+curPhotoNum+'][\'caption\']');
document.getElementById('fsImage'+id).title = eval('gallery'+id+'['+curPhotoNum+'][\'caption\']');
}
function animateImage(id,sW,sH,newWidth,newHeight)
{
fullStep[id] = sW;
fullEndW[id] = newWidth;
fullEndH[id] = newHeight;
fullAcceleration[id] = 1;
fullSpeed[id] = 0;
fullSpeedK[id] = (newHeight - sH)/(newWidth-sW);
fullInterval[id] = setInterval('animateStep('+id+')',50);
}
function animateStep(id)
{
var fsImage = document.getElementById('fsImage'+id);
var fsPhoto = document.getElementById('fullScreenPhotoBlock'+id);
var zoomBlock = document.getElementById('zoomBlock'+id);
fullSpeed[id] += fullAcceleration[id];
if (fullSpeed[id] > fullTopSpeed)
{
fullSpeed[id] > fullTopSpeed;
}
if (fullEndW[id] - fullStep[id] <= fullSpeed[id]*fullSpeed[id]/(6*fullAcceleration[id]))
{
fullAcceleration[id] = -fullAcceleration[id];
}
fullStep[id] += fullStep[id];
if (fullAcceleration[id] < 0 && fullSpeed[id] == 0)
{
fullStep[id] = fullEndW[id];
}
if (fullStep[id] >= fullEndW[id])
{
fullStep[id] = fullEndW[id];
clearInterval(fullInterval[id]);
fullInterval[id] = null;
fullAcceleration[id] = 0;
fullSpeed[id] = 0;
}
newMarginLeft = Math.round((document.documentElement.clientWidth - fullStep[id])/2);
if (newMarginLeft < 0)
{
newMarginLeft = 30;
}
newMarginTop = Math.round((document.documentElement.clientHeight - fullStep[id]*fullSpeedK[id])/2 -(-(document.documentElement.scrollTop||document.body.scrollTop)));
if (newMarginTop - (document.documentElement.scrollTop||document.body.scrollTop) < 0)
{
newMarginTop = 30 + (document.documentElement.scrollTop||document.body.scrollTop);
}
if (zoomBlock.offsetHeight < (newMarginTop+fullStep[id]*fullSpeedK[id]+30))
{
zoomBlock.style.height = newMarginTop - (-fullStep[id]*fullSpeedK[id]) -(-30) + 'px';
}
if (zoomBlock.offsetWidth < (newMarginLeft+fullStep[id]-1+30))
{
zoomBlock.style.width = newMarginLeft - (-fullStep[id]) -(-30) + 'px';
}
fsPhoto.style.width = fullStep[id] + 'px';
fsPhoto.style.height = Math.round(fullStep[id]*fullSpeedK[id]) + 'px';
fsImage.style.width = fullStep[id] + 'px';
fsImage.style.height = Math.round(fullStep[id]*fullSpeedK[id]) + 'px';
fsPhoto.style.marginLeft = newMarginLeft + 'px';
fsPhoto.style.marginTop = newMarginTop + 'px';
delta = new Array(0,4,6,8,8);
for (i = 1; i <= 5; i++)
{
nH = fullStep[id]*fullSpeedK[id] + delta[i-1];
document.getElementById('left'+id+'_'+i).style.height = Math.round(nH) + 'px';
document.getElementById('right'+id+'_'+(6-i)).style.height = Math.round(nH) + 'px';
}
for (i = 1; i <= 5; i++)
{
document.getElementById('right'+id+'_'+i).style.marginLeft = fullStep[id] -(-i+1) + 'px';
}
document.getElementById('top'+id).style.width = fullStep[id] + 'px';
document.getElementById('bottom'+id).style.width = fullStep[id] + 'px';
document.getElementById('bottom'+id).style.marginTop = Math.round(fullStep[id]*fullSpeedK[id]) + 'px';
document.getElementById('point'+id+'_2').style.marginLeft = fullStep[id] -1 + 'px';
document.getElementById('point'+id+'_3').style.marginTop = Math.round(fullStep[id]*fullSpeedK[id]) -1 + 'px';
document.getElementById('point'+id+'_4').style.marginLeft = fullStep[id] -1 + 'px';
document.getElementById('point'+id+'_4').style.marginTop = Math.round(fullStep[id]*fullSpeedK[id]) -1 + 'px';
if (fullStep[id] == fullEndW[id])
{
fsPhoto.style.width = fullEndW[id] + 'px';
fsPhoto.style.height = fullEndH[id] + 'px';
fsImage.style.width = fullEndW[id] + 'px';
fsImage.style.height = fullEndH[id] + 'px';
document.getElementById('bottom'+id).style.marginTop = fullEndH[id] + 'px';
document.getElementById('point'+id+'_3').style.marginTop = fullEndH[id] -1 + 'px';
document.getElementById('point'+id+'_4').style.marginTop = fullEndH[id] -1 + 'px';
for (i = 1; i <= 5; i++)
{
nH = fullEndH[id] + delta[i-1];
document.getElementById('left'+id+'_'+i).style.height = Math.round(nH) + 'px';
document.getElementById('right'+id+'_'+(6-i)).style.height = Math.round(nH) + 'px';
}
}
}
var slideInterval = new Array();
var picPosition = new Array();
var slideAcceleration = new Array();
var slideSpeed = new Array();
var slideTopSpeed = 50;
function changePicture(id,photoPath,num)
{
if (slideInterval[id] != null)
{
return false;
}
var preloader = document.getElementById('preloader'+id);
preloader.style.display = 'block';
preloader.style.visibility = 'visible';
preloader.style.marginTop = Math.round((eval('galleryPH'+id) - preloader.clientHeight)/2) + 'px';
preloader.style.marginLeft = Math.round((eval('galleryPW'+id) - preloader.clientWidth)/2) + 'px';
var curPhotoNum = eval('photoNum'+id);
var newFileName = photoPath+id+'/full_'+eval('gallery'+id+'['+num+'][\'filename\']');
picPosition[id] = 0;
slideSpeed[id] = 0;
slideAcceleration[id] = 3;
var newPhoto = new Image();
newPhoto.onload = function()
{
preloader.style.display = 'none';
preloader.style.visibility = 'hidden';
startSlide();
}
newPhoto.src = newFileName;
function startSlide()
{
var fullPhoto1 = document.getElementById('fullPhoto1_'+id);
var fullPhoto2 = document.getElementById('fullPhoto2_'+id);
if (num > curPhotoNum)
{
fullPhoto1.src = photoPath+id+'/full_'+eval('gallery'+id+'['+curPhotoNum+'][\'filename\']');
fullPhoto1.alt = eval('gallery'+id+'['+curPhotoNum+'][\'caption\']');
fullPhoto1.title = eval('gallery'+id+'['+curPhotoNum+'][\'caption\']');
fullPhoto1.style.paddingTop = Math.round((eval('galleryPH'+id) - eval('gallery'+id+'['+curPhotoNum+'][\'height\']'))/2) + 'px';
fullPhoto1.style.paddingLeft = Math.ceil((eval('galleryPW'+id) - eval('gallery'+id+'['+curPhotoNum+'][\'width\']'))/2) + 'px';
fullPhoto1.style.paddingRight = Math.floor((eval('galleryPW'+id) - eval('gallery'+id+'['+curPhotoNum+'][\'width\']'))/2) + 'px';
document.getElementById('fullPhotoBlock'+id).style.marginLeft = 0;
fullPhoto2.src = newPhoto.src;
fullPhoto2.alt = eval('gallery'+id+'['+num+'][\'caption\']');
fullPhoto2.title = eval('gallery'+id+'['+num+'][\'caption\']');
fullPhoto2.style.paddingTop = Math.round((eval('galleryPH'+id) - eval('gallery'+id+'['+num+'][\'height\']'))/2) + 'px';
fullPhoto2.style.paddingLeft = Math.ceil((eval('galleryPW'+id) - eval('gallery'+id+'['+num+'][\'width\']'))/2) + 'px';
fullPhoto2.style.paddingRight = Math.floor((eval('galleryPW'+id) - eval('gallery'+id+'['+num+'][\'width\']'))/2) + 'px';
eval('photoNum'+id+' = '+num);
slideInterval[id] = setInterval('slideRight('+id+')',50);
}
else
if (num < curPhotoNum)
{
fullPhoto2.src = photoPath+id+'/full_'+eval('gallery'+id+'['+curPhotoNum+'][\'filename\']');
fullPhoto2.alt = eval('gallery'+id+'['+curPhotoNum+'][\'caption\']');
fullPhoto2.title = eval('gallery'+id+'['+curPhotoNum+'][\'caption\']');
fullPhoto2.style.paddingTop = Math.round((eval('galleryPH'+id) - eval('gallery'+id+'['+curPhotoNum+'][\'height\']'))/2) + 'px';
fullPhoto2.style.paddingLeft = Math.ceil((eval('galleryPW'+id) - eval('gallery'+id+'['+curPhotoNum+'][\'width\']'))/2) + 'px';
fullPhoto2.style.paddingRight = Math.floor((eval('galleryPW'+id) - eval('gallery'+id+'['+curPhotoNum+'][\'width\']'))/2) + 'px';
document.getElementById('fullPhotoBlock'+id).style.marginLeft = -eval('galleryPW'+id) + 'px';
fullPhoto1.src = newPhoto.src;
fullPhoto1.alt = eval('gallery'+id+'['+num+'][\'caption\']');
fullPhoto1.title = eval('gallery'+id+'['+num+'][\'caption\']');
fullPhoto1.style.paddingTop = Math.round((eval('galleryPH'+id) - eval('gallery'+id+'['+num+'][\'height\']'))/2) + 'px';
fullPhoto1.style.paddingLeft = Math.ceil((eval('galleryPW'+id) - eval('gallery'+id+'['+num+'][\'width\']'))/2) + 'px';
fullPhoto1.style.paddingRight = Math.floor((eval('galleryPW'+id) - eval('gallery'+id+'['+num+'][\'width\']'))/2) + 'px';
eval('photoNum'+id+' = '+num);
slideInterval[id] = setInterval('slideLeft('+id+')',50);
}
}
}
function slideRight(id)
{
slideSpeed[id] += slideAcceleration[id];
if (slideSpeed[id] > slideTopSpeed)
{
slideSpeed[id] = slideTopSpeed;
}
if (eval('galleryPW'+id) - picPosition[id] <= slideSpeed[id]*slideSpeed[id]/(6*slideAcceleration[id]))
{
slideAcceleration[id] = -slideAcceleration[id];
}
picPosition[id] += slideSpeed[id];
if (slideAcceleration[id] < 0 && slideSpeed[id] == 0)
{
picPosition[id] = eval('galleryPW'+id);
}
if (picPosition[id] >= eval('galleryPW'+id))
{
picPosition[id] = eval('galleryPW'+id);
clearInterval(slideInterval[id]);
slideInterval[id] = null;
slideAcceleration[id] = 0;
slideSpeed[id] = 0;
}
document.getElementById('fullPhotoBlock'+id).style.marginLeft = -picPosition[id] + 'px';
}
function slideLeft(id)
{
slideSpeed[id] += slideAcceleration[id];
if (slideSpeed[id] > slideTopSpeed)
{
slideSpeed[id] = slideTopSpeed;
}
if (eval('galleryPW'+id) - picPosition[id] <= slideSpeed[id]*slideSpeed[id]/(6*slideAcceleration[id]))
{
slideAcceleration[id] = -slideAcceleration[id];
}
if (slideAcceleration[id] < 0 && slideSpeed[id] == 0)
{
picPosition[id] = eval('galleryPW'+id);
}
picPosition[id] += slideSpeed[id];
if (picPosition[id] >= eval('galleryPW'+id))
{
picPosition[id] = eval('galleryPW'+id);
clearInterval(slideInterval[id]);
slideInterval[id] = null;
slideAcceleration[id] = 0;
slideSpeed[id] = 0;
}
document.getElementById('fullPhotoBlock'+id).style.marginLeft = -eval('galleryPW'+id)-(-picPosition[id]) + 'px';
}
var scrollAcceleration = new Array();
var scrollDirection = new Array();
var scrollSpeed = new Array();
var maxScrollSpeed = 50;
var topScrollSpeed = new Array();
var intervalLength = 50;
var scrX = new Array();
var scroller = new Array();
var previews = new Array();
var stopTO = new Array();
var scrollInterval = new Array();
function getX( oElement ) {
var iReturnValue = 0;
while( oElement != null ) {
iAdd = oElement.offsetLeft;
if (iAdd == undefined)
{
iAdd = 0;
}
iReturnValue = iReturnValue - (-iAdd);
oElement = oElement.parentNode;
}
return iReturnValue;
}
function startScroll(event,id)
{
event = event || window.event;
clearTimeout(stopTO[id]);
previews[id] = document.getElementById('previews'+id);
previewsX = previews[id].offsetLeft;
if (previewsX == 0)
{
previewsX = getX(previews[id]);
}
var x = event.clientX - previewsX;
var w = previews[id].offsetWidth;
scroller[id] = document.getElementById('scroller'+id);
if (x > 0 && x < 0.43*w)
{
scrollAcceleration[id] = 1;
scrollDirection[id] = -1;
dimention = 0.43*w - x;
}
else
if (x > 0.57*w && x < w)
{
scrollAcceleration[id] = 1;
scrollDirection[id] = 1;
dimention = x - 0.57*w;
}
else
{
dimention = 0;
}
topScrollSpeed[id] = dimention/(0.43*w)*maxScrollSpeed;
}
function stopScroll(id)
{
stopTO[id] = setTimeout('goStop('+id+')',40);
}
function goStop(id)
{
if (scrollAcceleration[id] > 0)
{
scrollAcceleration[id] = -3*scrollAcceleration[id];
}
}
function moveScroller(id)
{
if (scrollDirection[id] != 0)
{
remeaningDimention = (scrollDirection[id] > 0 ? scroller[id].clientWidth - previews[id].offsetWidth - scrX[id] : scrX[id]);
if (scrollAcceleration[id] > 0 && remeaningDimention < scrollSpeed[id]*scrollSpeed[id]/(6*scrollAcceleration[id]))
{
scrollAcceleration[id] = -3*scrollAcceleration[id];
}
scrollSpeed[id] = scrollSpeed[id] -(-scrollAcceleration[id]);
if (scrollSpeed[id] < 0)
{
scrollSpeed[id] = 0;
}
if (scrollSpeed[id] > topScrollSpeed[id])
{
scrollSpeed[id] = topScrollSpeed[id];
}
scrX[id] = scrX[id] -(-scrollSpeed[id]*scrollDirection[id]);
if (scrX[id] < 0)
{
scrX[id] = 0;
}
if (scrX[id] > scroller[id].clientWidth - previews[id].offsetWidth)
{
scrX[id] = scroller[id].clientWidth - previews[id].offsetWidth;
}
scrX[id] = Math.round(scrX[id]);
scroller[id].style.marginLeft = - scrX[id] + 'px';
}
}
function filterForm()
{
if (document.getElementById('add-filter-form') == null) return;
var f = document.getElementById('add-filter-form');
if (f.style.visibility != 'visible')
{
f.style.visibility = 'visible';
f.style.display = 'block';
}
else
{
f.style.visibility = 'hidden';
f.style.display = 'none';
}
}
function addToCart(id)
{
var addCount = $('#g-count-'+id).val();
if ((0 -(-addCount)) < 1) return;
var mod = $('#buy-form-'+id+' input[type="radio"]:checked').val();
$.ajax({
converters: {
"text json": jQuery.parseJSON
},
url: '?ajax=query&module=5&func=ToBasket¶ms='+id+'|'+mod+'|'+addCount,
dataType : "xml",
cache: false,
success: function (data) {
updateBasketIcon(data);
},
error: function () {
alert('error');
}
});
}
function updateBasketIcon(data)
{
var cnt = $(data).find('basketData').find('count').text();
var sum = $(data).find('basketData').find('sum').text();
var end = '';
switch (cnt%10)
{
case 1: end = ''; break;
case 2:
case 3:
case 4: end = 'а'; break;
case 5:
case 6:
case 7:
case 8:
case 9:
case 0: end = 'ов'; break;
}
if ((cnt%100 >= 11) && (cnt%100 <= 14))
{
end = 'ов';
}
$('#basket-goods-count').html(cnt+' товар'+end);
$('#basket-goods-price').html('на '+sum+' руб.');
alert('Товар успешно добавлен');
}
function addToCart_without_alert(id)
{
var addCount = $('#g-count-'+id).val();
if ((0 -(-addCount)) < 1) return;
var mod = $('#buy-form-'+id+' input[type="radio"]:checked').val();
$.ajax({
url: '?ajax=query&module=5&func=ToBasket¶ms='+id+'|'+mod+'|'+addCount,
dataType : "json",
cache: false,
success: function (data) {
updateBasketIcon_without_alert(data);
},
error: function () {
alert('error');
}
});
}
function updateBasketIcon_without_alert(data)
{
$.each(data.basketData,
function (i, bdata){
var end = '';
switch (bdata.count%10)
{
case 1: end = ''; break;
case 2:
case 3:
case 4: end = 'а'; break;
case 5:
case 6:
case 7:
case 8:
case 9:
case 0: end = 'ов'; break;
}
if ((bdata.count%100 >= 11) && (bdata.count%100 <= 14))
{
end = 'ов';
}
$('#basket-goods-count').html(bdata.count+' товар'+end);
$('#basket-goods-price').html('на '+bdata.sum+' руб.');
}
);
}
$().ready(function() {
// ниже код для добавление в бд типа заказа робокасса/наличными для страницы Заказ успешно завершен
$('div.robokassa').hide();
$('div.cash').hide();
$('div.bank').hide();
$('#robo-pay-btn').click(function() {
$.ajax({
url: '?ajax=query&module=5&func=SendPayType¶ms=robo'+'|'+orderID,
dataType : "text",
cache: false,
success: function () {
document.getElementById('robokassaform').submit();
},
error: function () {
//alert('Произошла ошибка, перезагрузите страницу и попробуйте еще раз');
}
});
});
$('#cash-pay-btn').click(function() {
$.ajax({
url: '?ajax=query&module=5&func=SendPayType¶ms=cash'+'|'+orderID,
dataType : "text",
cache: false,
success: function () {
document.getElementById('cashform').submit();
},
error: function () {
//alert('Произошла ошибка, перезагрузите страницу и попробуйте еще раз');
}
});
});
$('#bank-pay-btn').click(function() {
$.ajax({
url: '?ajax=query&module=5&func=SendPayType¶ms=bank'+'|'+orderID,
dataType : "text",
cache: false,
success: function () {
document.getElementById('bankform').submit();
},
error: function () {
//alert('Произошла ошибка, перезагрузите страницу и попробуйте еще раз');
}
});
});
$('span.robokassa').click(function() {
$('div.cash').hide();
$('div.bank').hide();
// $('div.order-success').hide();
$('div.robokassa').show();
$.ajax({
url: '?ajax=query&module=5&func=AddToMysql¶ms=robokassa'+'|'+orderID,
dataType : "text",
cache: false,
success: function () {
//alert('Yep, we did it');
},
error: function (xhr) {
alert("Error:"+xhr.status+" "+xhr.statusText);//alert('Произошла ошибка, перезагрузите страницу и попробуйте еще раз');
}
});
});
$('span.cash').click(function() {
$('div.robokassa').hide();
$('div.bank').hide();
$('div.cash').show();
// $('div.order-success').show();
$.ajax({
url: '?ajax=query&module=5&func=AddToMysql¶ms=cash'+'|'+orderID,
dataType : "text",
cache: false,
success: function () {
//$('div.order-success h3').show();
// window.location.href = '/estore/robo/success.html';
},
error: function () {
alert('Произошла ошибка, перезагрузите страницу и попробуйте еще раз');
}
});
});
$('span.bank').click(function() {
$('div.robokassa').hide();
$('div.cash').hide();
$('div.bank').show();
// $('div.order-success').show();
$.ajax({
url: '?ajax=query&module=5&func=AddToMysql¶ms=bank'+'|'+orderID,
dataType : "text",
cache: false,
success: function () {
//$('div.order-success h3').show();
// window.location.href = '/estore/robo/success.html';
},
error: function () {
alert('Произошла ошибка, перезагрузите страницу и попробуйте еще раз');
}
});
});
// показ popup окон:
//$('#wish-dialog').jqm();
//$('#gift-dialog').jqm({trigger: 'a.jqModal-gift'});
/*
// Добавление в базу данных значений введенных пользователем:
var id_value = '0';
var mod = '0';
$('a.jqModal').click(function() {
id_value = $(this).attr('id');
mod = $('#buy-form-'+id_value+' input[type="radio"]:checked').val();
var options_url = {
url: '?ajax=query&module=5&func=GetItemId¶ms='+id_value,
dataType : "text",
cache: false,
success: function (data) {
$('p.sharer').html(' \n\
\n\
\n\
\n\
\n\
');
},
error: function () {
alert('Произошла ошибка, перезагрузите страницу и попробуйте еще раз');
}
};
$.ajax(options_url);
});
$('#wish-dialog-form').validate({
submitHandler: function(form) {
var fio = $('#wish-dialog-form-fio').attr('value');
var phone = $('#wish-dialog-form-phone').attr('value');
var address = $('#wish-dialog-form-address').attr('value');
var options = {
url: '?ajax=query&module=5&func=AddWishToMysql¶ms='+fio+'|'+phone+'|'+address+'|'+id_value+'|'+mod,
dataType : "json",
cache: false,
success: function () {
$('div.after-ajax').show('fast');
var wish_id_from_cookie = $.cookie("my_wish_id");
$('div.after-ajax-html-code')
.html('Этот HTML-код вы можете использовать для публикации своего желания в Интернете:
\n\
');
},
error: function () {
alert('Произошла ошибка, перезагрузите страницу и попробуйте еще раз');
}
};
$(form).ajaxSubmit(options);
} //конец submitHandler
});
// Отправка на e-mail письмо с предложением оплатить желание:
$('div.close-2').hide();
$('button.enter-recipient-form-submit').click(function() {
var email = $('#enter-recipient-e-mail').attr('value');
var options_email = {
url: '?ajax=query&module=5&func=SendWishToMail¶ms='+email,
dataType : "json",
cache: false,
success: function () {
//alert('Yep, we did it');
$('form#enter-recipient-form span.success').fadeIn('fast');
$('div.close-2').fadeIn();
$('div.close-1 a.jqmClose').focus();
},
error: function () {
alert('Произошла ошибка, перезагрузите страницу и попробуйте еще раз');
}
};
$.ajax(options_email);
return false;
});
// пляшите, вам письмо! :)
// выделение текста в textarea для Хочу в подарок
$('div.after-ajax-html-code textarea').live('click', function() {
//this.focus();
this.select();
});
// работа с формой «Хочу подарить»:
$('a.jqModal-gift').click(function() {
id_value = $(this).attr('id');
});
$('#gift-dialog-form').validate({
submitHandler: function(form) {
var fio = $('#gift-dialog-form-fio').attr('value');
var phone = $('#gift-dialog-form-phone').attr('value');
var address = $('#gift-dialog-form-address').attr('value');
var options = {
url: '?ajax=query&module=5&func=AddGiftToMysql¶ms='+fio+'|'+phone+'|'+address,
dataType : "json",
cache: false,
success: function () {
addToCart_without_alert(id_value);
setTimeout(function(){ window.location.replace("/katalog/basket/") }, 600);
},
error: function () {
alert('Произошла ошибка, перезагрузите страницу и попробуйте еще раз');
}
};
$(form).ajaxSubmit(options);
} //конец submitHandler
});
*/
// конец работы с формой «Хочу подарить»
});