LightboxOptions = Object.extend({ imageCheckerCreated: false, cbbCreated: false, maxImageWidth: 580, fileLoadingImage: '/images/lightbox/loading_ru.gif', fileBottomNavCloseImage: '/images/lightbox/closelabel.png', overlayOpacity: 0, animate: true, animate_bg: true, resizeSpeed: 5, borderSize: 10, labelLoading: 'Загрузка. Пожалуйста подождите... <br /><img src="/e.gif" class="ajaxLoader" />', labelSave: "<img src=\"/e.gif\" class=\"save\"/>Сохранить (оригинал)", labelImage: "Изображение", labelOf: "из", caption_next: "&gt;&gt;", caption_prev: "&lt;&lt;", caption_prev_help: "Смотреть предыдущее изображение", caption_next_help: "Смотреть следующее изображение" }, window.LightboxOptions || {}); var LB_IframeCount = 0; var Lightbox = Class.create(); var LightBoxHTMLCreated = false; Lightbox.prototype = { imageArray: [], LoadedForms: [], LoadedFormsJS: [], lastImage: -1, lastImageWidth: 0, Started: false, LikeVideo: false, LikeForm: false, Iframe_count: 0, activeImage: undefined, initialize: function( ){ }, init: function( likeinit){ }, restart: function(){ this.start(this.imageLink, this.LikeVideo, this.LikeForm);}, ShowOverlay: function(opacity, dur){ $('overlay').hide(); if (opacity >0){ new Effect.Appear($('overlay'),{duration: dur, from: 0.0, to: opacity});}}, ShowBox: function(SlideDur, overlayDur){ $('lightboxc').hide(); new Effect.Parallel( [ new Effect.SlideDown($('lightboxc'), { sync: true, duration: SlideDur, delay: overlayDur }), new Effect.Appear($('lightboxc'), { sync: true, duration: SlideDur, delay: overlayDur }) ], {duration: SlideDur, afterFinish: (function(){this.overlaySize()}).bind(this) } );}, SetBoxPosition: function(screenWidth, marginTop, boxWidth ){ var arrayPageScroll = document.viewport.getScrollOffsets(); var Top = marginTop + arrayPageScroll[1]; var Left = (screenWidth - boxWidth)/2 + arrayPageScroll[0]; $('lightboxc').setStyle({ top: Top + 'px', left: Left + 'px' });}, overlaySize: function(){ var arrayPageSize = this.getPageSize(); $('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' });}, screenWidth: function(){ var Swidth=0; try{ var view = document.viewport; Swidth = view.getWidth(); if (Swidth<=0){ Swidth = screen.width -50;}}catch(e){}; return Swidth;}, start: function(imageLink, likevideo, likeform, likeajax){ this.imageLink = imageLink; this.LikeImage = true; this.LikeVideo = likevideo; this.LikeForm = likeform; this.LikeAjax = likeajax; if (this.LikeVideo || this.LikeForm || this.LikeAjax ) this.LikeImage = false; rel = imageLink.getAttribute("rel"); var i = rel.indexOf('lightbox'); var params = []; if (i != -1){ i = rel.indexOf('['); if (i >0 ){ p = rel.substring(i+1, rel.length-1); try{ eval("params = {"+p+"};");}catch(e){};}} group = MyLightBoxGetGroup(rel); this.overlayDuration = LightboxOptions.animate ? 0.2 : 0; this.SlideDuration = 0.6; var Swidth=this.screenWidth(); if (!LightBoxHTMLCreated){ LightBoxHTMLCreated = true; objBody = $$('body')[0]; objBody.appendChild(Builder.node('div',{id:'overlay'})); objBody.appendChild(Builder.node('div',{id:'lightboxc', 'class':'lightboxc_a'}));} this.overlaySize(); $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' }); this.lb_video = this.lb_image = this.lb_form = null; this.aobj = null; if (this.LikeVideo){ } else if(this.LikeAjax){ this.aobj = this.lb_form = new LightboxAjax(this.overlayDuration, this.SlideDuration, params); this.lb_form.start(imageLink, group, Swidth);} else if(this.LikeForm){ this.aobj = this.lb_form = new LightboxForm(this.overlayDuration, this.SlideDuration, params); this.lb_form.start(imageLink, group, Swidth);} else if (this.LikeImage){ this.aobj = this.lb_image = new LightboxImage(this.overlayDuration, this.SlideDuration, params); this.lb_image.start(imageLink, group, Swidth);} Event.observe(document.onresize ? document : window, "resize", (function(event){ this.overlaySize(); this.aobj.SetBoxPosition(this.screenWidth());}).bind(this) ); return;}, SubmitForm: function (but_div, pref_){ this.lb_form.SubmitForm(but_div, pref_);}, SubmitResponse: function(flag, form, message){ this.lb_form.SubmitResponse(flag, form, message);}, enableKeyboardNav: function(){ document.observe('keydown', this.keyboardAction);}, disableKeyboardNav: function(){ document.stopObserving('keydown', this.keyboardAction);}, keyboardAction: function(event){ var keycode = event.keyCode; var escapeKey; if (event.DOM_VK_ESCAPE){ escapeKey = event.DOM_VK_ESCAPE;} else { escapeKey = 27;} var key = String.fromCharCode(keycode).toLowerCase(); if (key.match(/x|o|c/) || (keycode == escapeKey)){ this.end();} else if ((key == 'p') || (keycode == 37)){ if (this.activeImage != 0){ this.disableKeyboardNav(); this.changeImage(this.activeImage - 1);}} else if ((key == 'n') || (keycode == 39)){ if (this.activeImage != (this.imageArray.length - 1)){ this.disableKeyboardNav(); this.changeImage(this.activeImage + 1);}} }, end: function(){ Event.observe(document.onresize ? document : window, "resize", (function(event){})); this.disableKeyboardNav(); new Effect.SlideUp($('lightbox'), { duration: this.SlideDuration, afterFinish: (function(){}) }); if (LightboxOptions.overlayOpacity >0){ new Effect.Fade(this.overlay, { duration: this.overlayDuration, delay: this.SlideDuration });} $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' }); this.Started = false; this.lastImage = -1;}, getPageSize: function(){ 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){ xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight;} else { xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight;} var windowWidth, windowHeight; if (self.innerHeight){ if(document.documentElement.clientWidth){ windowWidth = document.documentElement.clientWidth;} else { windowWidth = self.innerWidth;} windowHeight = self.innerHeight;} else if (document.documentElement && document.documentElement.clientHeight){ windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight;} else if (document.body){ windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight;} if(yScroll < windowHeight){ pageHeight = windowHeight;} else { pageHeight = yScroll;} if(xScroll < windowWidth){ pageWidth = xScroll;} else { pageWidth = windowWidth;} var body = $$('body')[0]; if (body.offsetWidth > pageWidth) pageWidth = body.offsetWidth; if (body.offsetHeight > pageHeight) pageHeight = body.offsetHeight; return [pageWidth, pageHeight];}}; var LightboxImage = Class.create(); LightboxImage.prototype = { target: null, overlayOpacity: 0.25, ImageDescOff: true, FormWidth: 900, MarginTop: 5, ImageMaxWidth: 685, ImageMaxHeight: 420, images: [], maxImageNum: 0, initialize: function(overlayDur, slideDur, params ){ this.params = params; this.SlideDuration = slideDur; this.overlayDuration = overlayDur;}, restart: function(){ this.createForm(); LightBox.SetBoxPosition(this.screenWidth, this.MarginTop, this.FormWidth ); this.Started = true; this.Assembly();}, start: function(target, group, screenWidth, imageNum){ this.lastImage = -1; this.imageNum = this.activeImage = imageNum = this.getnum(target)-1; this.group = group; this.target = target; this.screenWidth = screenWidth; LightBox.ShowOverlay(this.overlayOpacity, this.overlayDuration); $('overlay').observe('click', (function(event){ event.stop(); this.end();}).bind(this)); this.images = []; if (group == 'lightbox'){ params = MyLightBoxGetParams(imageLink.getAttribute("rel")); this.maxImageNum = imageNum; this.images[imageNum] = {watered: params.iwatered, title: this.target.title, small:params.ismall, save:params.isave};} else { tags = lightboxCollection.groups[group]; for(i=0; i < tags.length; i++){ num = this.getnum(tags[i])-1; params = MyLightBoxGetParams(tags[i].getAttribute("rel")); if (params.iwatered.length > 0){ if (num > this.maxImageNum) this.maxImageNum = num; this.images[num] = {watered: params.iwatered, title: this.target.title, small:params.ismall, save:params.isave};}} } this.createForm(); $('lightboxc').hide(); $('lightboxc').setStyle({ top: '10px', left: '0px' }); $('lightboxc').show(); this.ActivateSmallImages(); this.changeImage(this.imageNum); $('lightboxc').hide(); this.SetBoxPosition(this.screenWidth); LightBox.ShowBox(this.SlideDuration, this.overlayDuration); this.Started = true;}, SetBoxPosition: function (screenWidth){ LightBox.SetBoxPosition(screenWidth, this.MarginTop, this.FormWidth );}, createForm: function (){ var item_id = ''; try{ item_id = this.params.item_id;}catch(e){}; var buy_btn = '<div id="submit_button" class="submit_button"><a id="btnSend" href="/question/foritem/'+item_id+'" class="send2 btn" title="Сделать запрос" ><img src="/e.gif" /><br/><div class="span">Сделать запрос</div></a></div>'; var row1 = '<tr><td class="row"><div class="lb_cwidth"><div class="bt"><div></div></div></div></td></tr>'; var row2 = '<tr><td class="row rowl"><div class="bl lb_cwidth" ><div class="br"><div class="contbg">'; row2 +=' <div class="top_images_div">'; row2 +=' <div class="bClose"><a id="btnClose" class="close_ico" title="Скрыть фотографии" ><img src="/e.gif" alt="Скрыть фотографии"/></a></div>'; row2 +=' </div>'; row2 +=' </div></div></div></td></tr>'; var row4 = '<tr><td id="lb_image_td" class="row rowl"><div class="bl lb_cwidth"><div class="br"><div class="contbg lb_image"><table class="table p100" border="0"><tr><td align="center"><div id="lb_image"></div></td><td rowspan="2" class="lb_td_sm_images"><div id="lb_sm_images" class="lb_sm_images"></div></td></tr><tr><td><div class="lb_caption"><span id="lb_icaption"></span>&nbsp;<span id="numberDisplay"></span></div></td></tr></table></div></div></div></td></tr>'; var row3 = ''; var row5 = '<tr><td class="row"><div class="bl lb_cwidth row_bot"><div class="br"><div class="contbgs">'; row5 += ' <table class="table p100"><tr><td class="bot_title"> '; row5 += ' <div class="nav_arrows" id="lb_nav_arrows"><div class="arrow_right"><a onclick="return false;" id="lb_NextLink" href="#" class="flink" title="'+LightboxOptions.caption_next_help+'"><img class="arrow_right" src="/e.gif" alt="'+LightboxOptions.caption_next_help+'" /></a></div><div class="arrow_left"><a onclick="return false;" id="lb_PrevLink" href="#" class="flink" title="'+LightboxOptions.caption_prev_help+'"><img alt="'+LightboxOptions.caption_prev_help+'" class="arrow_left" src="/e.gif" /></a></div></div> '; row5 += ' <div class="ico_gallery"><div class="ico"><div id="ico_gal_title" class="gallery">&nbsp;</div></div></div>'; row5 += ' <div id="bot_title"></div>'; row5 += ' <div id="bot_price" class="bot_price"></div>'; row5 += ' </td></tr>'; row5 += ' <tr><td class="bClose2"><a href="#" title="Скрыть фотографии" class="lclose" id="btnClose2">Скрыть</a></td></tr>'; row5 += ' </table></div></div></div></div></td></tr>'; var row6 = '<tr><td class="row"><div class="lb_cwidth"><div class="bb"><div></div></td></tr>'; var html = '<div id="lightbox" class="lightbox lightboxi fimage_width"><table class="table p100" cellpadding="0" cellspacing="0">'+row1+row2+row3+row4+row5+row6+' </table></div>'; $('lightboxc').innerHTML = html; var inrow = 1; if (this.images.length>1){ var html = '<table class="table p100"><tr><td align="center"><table id="lb_sm_images_tbl" class="table" cellpadding="0" cellspacing="0">'; var ids = ''; var sumw = 0; var counter = 0; var j = 0; var ids = []; var si_height = 0; for (var i=0; i<this.images.length;i++){ { if ( this.images[i] != undefined){ var id = 'lightboxsi_'+counter; ids.push([id, i]); j++; if (j == 1){ si_height++; html += '<tr><td></td>';} html += '<td class="smalli"><a onclick="return false;" href="#" title="Показать изображение '+(j)+'" class=""><img onclick="return false;" class="smalli" id="'+id+'" src="'+this.images[i].small+'" /></a></td>'; if (j == inrow){ html += '<td></td></tr>'; j = 0;} counter++;}} } this.ids = ids; if (j != 0 && j != inrow) html += '<td></td></tr>'; this.si_height = si_height*60+ (si_height)*2; $('lb_sm_images').innerHTML = html+'</table></td></tr></table>';} else { $('lb_nav_arrows').innerHTML = '';} try{ var maker_model = Trim(this.params.maker+' '+this.params.model); if (maker_model.length > 0 ) maker_model = '<div class="manuf_model">'+maker_model+'</div>'; $('ico_gal_title').innerHTML = maker_model; var body = Trim(this.params.body); var sub_title = Trim(this.params.sub_title); if (body.length > 0 && sub_title.length > 0){ body += ', '+sub_title;}else { if (sub_title.length > 0){ body = sub_title;}} var incompl = Trim(this.params.incompl); if (incompl.length > 0){ incompl = '<div class="item_compl">'+incompl+'</div>';} $('bot_title').innerHTML = '<div class="item_body">'+body+'</div>'+incompl; var bot_price = Trim(this.params.price); if (bot_price.length > 0){ bot_price = '<div class="price-title">Цена</div><div class="price-value"><span class="i-rub">'+bot_price+'</span></div>';} var status = Trim(this.params.status); if (status.length > 0){ bot_price += '<div class="price-status">'+status+'</div>';} $('bot_price').innerHTML = bot_price;}catch(err){} this.BaseBtn();}, ActivateSmallImages: function(){ try{ for(var j = 0;j<this.ids.length;j++){ eval('$("'+this.ids[j][0]+'").observe(\'click\', (function(event){ event.stop(); this.changeImage('+this.ids[j][1]+');}).bindAsEventListener(this));');}}catch(e){};}, BaseBtn: function(){ try{ $('btnClose').observe('click', (function(event){ event.stop(); this.end();}).bind(this)); $('btnClose2').observe('click', (function(event){ event.stop(); this.end();}).bind(this)); $('lb_PrevLink').observe('click', (function(event){ event.stop(); this.changeImage(this.activeImage - 1);}).bindAsEventListener(this)); $('lb_NextLink').observe('click', (function(event){ event.stop(); this.changeImage(this.activeImage + 1);}).bindAsEventListener(this));} catch(e){}}, changeImage: function(imageNum){ if (imageNum >= this.images.length) imageNum = 0; else if (imageNum < 0) imageNum = this.maxImageNum; if (this.images[imageNum] != undefined){ inum = imageNum; this.activeImage = inum; var t = this.images[inum].title; if (t!='') t += '.'; if (this.ImageDescOff) t = ''; $('lb_icaption').update(t).show(); { if (this.images.length >= 1 && !this.ImageDescOff){ $('numberDisplay').update( LightboxOptions.labelImage + ' ' + (inum +1 ) + ' ' + LightboxOptions.labelOf + ' ' + this.images.length).show();} else { $('numberDisplay').update('').show();} if (LightboxOptions.animate){ var src = '/e.gif'; var loading = 'Загрузка'; width = this.ImageMaxWidth; height = this.ImageMaxHeight; if (this.lastImage >= 0){ src = this.images[this.lastImage].watered; if (this.lastImageWidth > 0) width=this.lastImageWidth; if (this.lastImageHeight > 0) height=this.lastImageHeight;} width=this.ImageMaxWidth; if (!LightboxOptions.animate_bg) src = '/e.gif'; loading = '<div style="text-align:center; width:'+this.ImageMaxWidth+'px;" ><div id="loader" style="background: url('+src+') no-repeat center; width:'+width+'px; height:'+height+'px;"><div id="loaderbg" style="display:none; width:'+width+'px; height:'+height+'px;"><img width="'+this.ImageMaxWidth+'" height="'+height+'" style="background: url('+LightboxOptions.fileLoadingImage+') no-repeat center;" src="/e.gif" alt="Загрузка" /></div></div></div>'; this.img_height = height; $('lb_image').innerHTML = loading; new Effect.Appear('loaderbg',{duration: 0.5, from: 0.0, to: 0.45});} this.imgPreloader = new Image(); this.imgPreloader.onload = (function(){ this.ShowImage();}).bind(this); this.imgPreloader.src = this.images[this.activeImage].watered; this.lastImage = this.activeImage;}} }, UpdateLbImage: function(pref_, height){ }, ShowImage: function(){ var width = ''; this.lastImageWidth = this.imgPreloader.width; this.lastImageHeight = this.imgPreloader.height; if (this.imgPreloader.width > this.ImageMaxWidth){ this.lastImageWidth = this.ImageMaxWidth; width=' width="'+this.ImageMaxWidth+'" ';} $('lb_image').innerHTML = '<div style="width:'+this.ImageMaxWidth+'px; text-align:center; display:block;"><img'+width+' id="test_lightbox_image" src="'+this.images[this.activeImage].watered+'" /></div>'; this.UpdateLbImage('', this.imgPreloader.height);}, getnum: function(tag){ var params = MyLightBoxGetParams(tag.getAttribute("rel")); var num = 1; if (params != null && params != undefined ){ num = params.position;} return num;}, end: function(){ LightBox.end(); if (this.overlayOpacity >0){ new Effect.Fade($('overlay'), { duration: this.overlayDuration, delay: this.SlideDuration });} this.Started = false;}}; var LightboxForm = Class.create(); LightboxForm.prototype = { target: null, overlayOpacity: 0.65, params: [], LoaderWidth: 500, FormWidth: 900, MarginTopForm: 0, MarginTopPreloader: 70, LoadedForms: [], LoadedFormsJS: [], Iframe_count: 0, initialize: function(overlayDur, slideDur, params ){ this.params = params; this.SlideDuration = slideDur; this.overlayDuration = overlayDur;}, restart: function(){ this.createPreloader(); LightBox.SetBoxPosition(this.screenWidth, this.MarginTop, this.LoaderWidth ); this.Started = true; this.LoadForm(this.params[0]);}, start: function(target, group, screenWidth){ this.group = group; this.target = target; this.screenWidth = screenWidth; this.Loading = true; this.params.title = target.title; LightBox.ShowOverlay(this.overlayOpacity, this.overlayDuration); $('overlay').observe('click', (function(){})); this.SetBoxPosition(screenWidth); this.createPreloader(); LightBox.ShowBox(this.SlideDuration, this.overlayDuration); this.Started = true; this.LoadForm(this.params[0]);}, SetBoxPosition: function(screenWidth){ if (this.Loading){ LightBox.SetBoxPosition(screenWidth, this.MarginTopPreloader, this.LoaderWidth );} else { LightBox.SetBoxPosition(screenWidth, this.MarginTopForm, this.FormWidth );}}, createPreloader: function(){ $('lightboxc').innerHTML = '<div id="lightbox" class="lightbox lightbox_w inquiry"><div class="preloader"><div class="close"><a id="btnCloseForm" title="Закрыть"><img src="/e.gif" alt="Закрыть"/></a></div><div class="loading">'+LightboxOptions.labelLoading+'</div></div></div>'; this.BaseBtn();}, BaseBtn: function(){ $('btnCloseForm').observe('click', (function(event){ event.stop(); this.end();}).bind(this));}, createForm: function(){ var btnClose = '<div class="btnclose"><a id="btnCloseForm" class="close btn" title="Скрыть"><img src="/e.gif" /><br/>Скрыть</a></div>'; var caption = '<div class="caption"><span id="lbf_caption">&nbsp;</span></div>'; var row1 = '<tr><td class="cell1"><div class="ccell1"><div class="btl"></div></div></td><td class="cell2"><div class="cell2b h100"><div class="ccell2"><div class="btr"><div class="v2cell2b"></div></div></div></div></td></tr>'; var row2 = '<tr class="row2 row1"><td class="cell1"><div class="ccell12"><div class="i1"><div class="ic1"> '+caption+'</div></div></div></td><td class="cell22"><div class="cell2b h100"><div class="ccell22"><div class="i2"><div class="ic2"><div class="cell2b h100">'+btnClose+'</div></div></div></div></div></td></tr>'; var row3 = '<tr class="row1"><td id="formcell" class="cell1"><div class="ccell12"><div id="lb_content_i1" class="i1"><div id="lb_content_ic1" class="ic1"><div id="lb_content"></div></div></div></div></td><td id="clearcell" class="cell22"><div class="containerh100"><div class="ccell22"><div id="clearfields_i2" class="i2"><div id="clearfields_ic2" class="ic2"><div class="cell2b h100" id="clearFields"></div></div></div></div></div></td></tr>'; var row4 = '<tr><td class="cell1"><div class="ccell13"><div class="i1"><div class="ic12" id="lbf_captcha"></div></div><div class="bbl"></div></div></td><td class="cell2"><div class="cell2b h100"><div class="ccell23"><div class="i2"><div class="ic22"><div class="cell2b h100" id="lbf_submit"></div></div></div><div class="bbr"><div class="v2cell2b2"></div></div></div></div></td></tr>';; var fullform = '<table class="ftable table p100" cellspacing="0" cellpadding="0">'+row1+row2+row3+row4+'</table>'; var html = '<div id="lightbox" class="lightbox form_width inquiry">'+fullform+'</div>'; $('lightboxc').innerHTML = html; this.BaseBtn();}, LoadForm: function(src){ this.src = src; if (this.LoadedForms[src] == null || true){ src = ReplaceAll(src, ' ', '%20'); new Ajax.Request( src, { requestHeaders: "", onComplete: this.ajaxForm.bind(this) }); return true;} else { this.ShowLoadedForm(0);}}, ajaxForm: function(response, update){ this.FormUpdate = false; if (update != undefined) this.FormUpdate = update; var answer = ''; try { answer = unescape(response.responseText);}catch(e){}; if (answer == '' || answer == undefined || answer == "undefined") answer = response; eval(answer); res = ajaxform; answer = res[1][1]; js = RunJS(answer); this.LoadedForms[this.src] = res; this.LoadedFormsJS[this.src] = js; this.ShowLoadedForm(0);}, ShowLoadedForm: function (error){ this.error = error; var dur =0.2; if (!this.FormUpdate){ new Effect.SlideUp($('lightboxc'), {duration: dur, afterFinish: this.ApplyLoadedForm.bind(this) });} else { this.ApplyLoadedForm();}}, ApplyLoadedForm: function(){ if (!this.FormUpdate) this.createForm(); if (this.error == 1){ $('lb_content').innerHTML = 'error';} else { this.Loading = false; var form = this.LoadedForms[this.src]; $('lbf_caption').update(form[0][1]).show(); $('clearFields').innerHTML = form[4][1]; $('lbf_captcha').innerHTML = form[5][1]; $('lbf_submit').innerHTML = form[3][1]; $('lb_content').innerHTML = this.getAjaxForm(form[1][1], this.src); this.evalCounter = 0; this.EvalTimerID = setInterval(this.evalJS, 500);} if (!this.FormUpdate){ $('lightboxc').hide(); $('lightboxc').setStyle({ top: '-10000px', left: '0px' }); $('lightboxc').show();} this.UpdateAfterForm(); if (!this.FormUpdate){ $('lightboxc').hide(); this.SetBoxPosition(this.screenWidth); LightBox.ShowBox(this.SlideDuration, this.overlayDuration);} this.FormUpdate = true;}, getAjaxForm: function (form_, action){ this.iframe_name = 'lightbox_iframe_target_'+this.Iframe_count; this.form_name = 'unique_lb_form_'+ this.Iframe_count; this.form_guid = 'unique_lb_form_guid_'+ this.Iframe_count; this.form_guid_answer = 'unique_lb_form_guid_answer_'+ this.Iframe_count; this.Iframe_count++; LB_IframeCount++; var Form = '<div class="p100" style="text-align:left;"><a name="aerrors"></a><form id="'+this.form_name+'" action="'+this.getAction(action, '/submit')+'" enctype="multipart/form-data" target="'+this.iframe_name+'" method="post" >'; Form += form_ + '<iframe name="'+this.iframe_name+'" id="'+this.iframe_name+'" width="1" height="1" style="display:none;" >no iframe</iframe>'; Form += '<input type="hidden" name="guid" id="'+this.form_guid+'" /><input type="hidden" name="guid_answer" id="'+this.form_guid_answer+'"/></form></div>'; return Form;}, getAction: function (action, postfix){ pos = action.indexOf('?'); if (pos != -1){ base = action.substring(0, pos); params = action.substring(pos, action.length); return base+postfix+params;} else return action+postfix;}, evalJS: function(){ evalgood_1 = false; try{ var js = this.LoadedFormsJS[this.src]+' evalgood_1 = true;'; eval(js);}catch(e){} if (evalgood_1){ clearInterval(this.EvalTimerID);} else { this.evalCounter++; if (this.evalCounter == 120){ clearInterval(this.EvalTimerID); $('lb_content').innerHTML = '{t_}Извните, но загрузить форму не удалось. Обновите страницу и попытайтесь еще раз. <br/> Спасибо за понимание.{/t_}';}} }, UpdateAfterForm: function(pref_){ var p = ''; if (pref_ != undefined) p = pref_; var h = $(p+'lb_content').offsetHeight+'px'; var ids = 'formcell clearcell clearfields_i2 clearfields_ic2 lb_content_ic1 lb_content_i1 clearfields_i2'; $w(ids).each(function(id){ try{$(p+id).style.height = h;}catch(e){}});}, SubmitForm: function (but_div, pref_){ but_div = pref_+but_div; this.Form_but_div = but_div; $(but_div).innerHTML = '<div class="submit_sending">Отправка. Пожалуйста подождите... <br /><img src="/e.gif" class="ajaxLoader" /></a>'; try{ $(this.form_guid_answer).value = $(pref_+'guid_answer').value; $(this.form_guid).value = $(pref_+'guid').value;}catch(e){}; SubmitForm(this.form_name);}, SubmitResponse: function(flag, form, message){ if (flag == 1){ this.ajaxForm(form, true); x = $(this.Form_but_div).innerHTML; $(this.Form_but_div).innerHTML = x + '<span>Вы допустили ошибки ввода - они указаны в форме.</span>';} else { this.LoadedForms[this.src] = null; if (message == undefined || message == '') message = 'Заявка успешно отправлена.'; $(this.Form_but_div).innerHTML = '<div class="btnsuccess"><a id="btnsuccess" class="success btn" ><img src="/e.gif" /><br/>' + message + '</a><span><a id="new_form_link" href="#">Повторить</a>&nbsp;&nbsp;<a id="close_form_link" href="#" title="Скрыть форму">Скрыть</a></span></div>'; $('close_form_link').observe('click', (function(event){ event.stop(); this.end();}).bind(this)); $('new_form_link').observe('click', (function(event){ event.stop(); this.restart() }).bind(this));}}, end: function(){ LightBox.end(); if (this.overlayOpacity >0){ new Effect.Fade($('overlay'), { duration: this.overlayDuration, delay: this.SlideDuration });} this.Started = false; clearInterval(this.EvalTimerID);}}; var LightboxAjax = Class.create(); LightboxAjax.prototype = { target: null, overlayOpacity: 0.25, params: [], LoaderWidth: 500, FormWidth: 900, MarginTopForm: 70, MarginTopPreloader: 70, LoadedForms: [], LoadedFormsJS: [], initialize: function(overlayDur, slideDur, params ){ this.params = params; this.SlideDuration = slideDur; this.overlayDuration = overlayDur;}, restart: function(){ this.createPreloader(); LightBox.SetBoxPosition(this.screenWidth, this.MarginTop, this.LoaderWidth ); this.Started = true; this.LoadForm(this.params.link);}, start: function(target, group, screenWidth){ this.group = group; this.target = target; this.screenWidth = screenWidth; this.Loading = true; if (this.params.preloader == undefined ) this.params.preloader = true; this.params.title = target.title; LightBox.ShowOverlay(this.overlayOpacity, this.overlayDuration); $('overlay').observe('click', (function(event){ event.stop(); this.end();}).bind(this)); this.SetBoxPosition(screenWidth); if (this.params.preloader){ this.createPreloader(); LightBox.ShowBox(this.SlideDuration, this.overlayDuration);} this.Started = true; this.LoadForm(this.params.link);}, SetBoxPosition: function(screenWidth){ if (this.Loading){ LightBox.SetBoxPosition(screenWidth, this.MarginTopPreloader, this.LoaderWidth );} else { LightBox.SetBoxPosition(screenWidth, this.MarginTopForm, this.FormWidth );}}, createPreloader: function(){ $('lightboxc').innerHTML = '<div id="lightbox" class="lightbox lightboxi lightbox_w inquiry"><div class="preloader preloader_w"><div class="bClose"><a id="btnClose" class="close_ico" title="Скрыть" ><img src="/e.gif" alt="Скрыть"/></a></div><div class="loading">'+LightboxOptions.labelLoading+'</div></div></div>'; this.params.preloader = true; this.BaseBtn();}, BaseBtn: function(){ try{ $('btnClose').observe('click', (function(event){ event.stop(); this.end();}).bind(this)); $('btnClose2').observe('click', (function(event){ event.stop(); this.end();}).bind(this));}catch(e){}}, createForm: function (){ var item_id = ''; try{ item_id = this.params.item_id;}catch(e){}; var row1 = '<tr><td class="row"><div class="lb_cwidth"><div class="bt"><div></div></div></div></td></tr>'; var row2 = '<tr><td class="row rowl"><div class="bl lb_cwidth" ><div class="br"><div class="contbg">'; row2 +=' <div class="top_images_div">'; row2 +=' <div class="bClose"><a id="btnClose" class="close_ico" title="Скрыть" ><img src="/e.gif" alt="Скрыть"/></a></div>'; row2 +=' </div>'; row2 +=' </div></div></div></td></tr>'; var row4 = '<tr><td id="lb_image_td" class="row rowl"><div class="bl lb_cwidth"><div class="br"><div class="contbg lb_image"><table class="table p100" border="0"><tr><td colspan="2" align="center"><div id="lb_content" class="loading"></div></td></tr><tr><td><div class="lb_caption"><span id="lb_icaption"></span>&nbsp;<span id="numberDisplay"></span></div></td></tr></table></div></div></div></td></tr>'; var row3 = ''; var row5 = '<tr><td class="row"><div class="bl lb_cwidth row_bot"><div class="br"><div class="contbgs">'; row5 += ' <table class="table p100"><tr><td class="bot_title"> '; row5 += ' <div class="nav_arrows" id="lb_nav_arrows"><div class="arrow_right"><a id="lb_NextLink" href="#" class="flink" title="'+LightboxOptions.caption_next_help+'"><img class="arrow_right" src="/e.gif" alt="'+LightboxOptions.caption_next_help+'" /></a></div><div class="arrow_left"><a id="lb_PrevLink" href="#" class="flink" title="'+LightboxOptions.caption_prev_help+'"><img alt="'+LightboxOptions.caption_prev_help+'" class="arrow_left" src="/e.gif" /></a></div></div> '; row5 += ' <div class="ico_gallery"><div class="ico"><div id="ico_gal_title" class="gallery">&nbsp;</div></div></div>'; row5 += ' <div id="bot_title"></div>'; row5 += ' <div id="bot_price" class="bot_price"></div>'; row5 += ' </td></tr>'; row5 += ' <tr><td class="bClose2"><a href="#" title="Скрыть" class="lclose" id="btnClose2">Скрыть</a></td></tr>'; row5 += ' </table></div></div></div></div></td></tr>'; var row6 = '<tr><td class="row"><div class="lb_cwidth"><div class="bb"><div></div></td></tr>'; var html = '<div id="lightbox" class="lightbox lightboxi fimage_width"><table class="table p100" cellpadding="0" cellspacing="0">'+row1+row2+row3+row4+row5+row6+' </table></div>'; $('lightboxc').innerHTML = html; $('lb_nav_arrows').innerHTML = ''; $('ico_gal_title').innerHTML = '<div class="manuf_model">'+ this.params.title +'</div>'; this.BaseBtn();}, LoadForm: function(src){ this.src = src; if (this.LoadedForms[src] == null || true){ src = ReplaceAll(src, ' ', '%20'); new Ajax.Request( src, { requestHeaders: "", onComplete: this.ajaxForm.bind(this) }); return true;} else { this.ShowLoadedForm(0);}}, ajaxForm: function(response, update){ this.FormUpdate = false; if (update != undefined) this.FormUpdate = update; var answer = ''; try { answer = unescape(response.responseText);}catch(e){}; if (answer == '' || answer == undefined || answer == "undefined") answer = response; js = RunJS(answer); this.LoadedForms[this.src] = answer; this.LoadedFormsJS[this.src] = js; this.ShowLoadedForm(0);}, ShowLoadedForm: function (error){ this.error = error; var dur =0.2; if (!this.FormUpdate){ if (this.params.preloader){ new Effect.SlideUp($('lightboxc'), {duration: dur, afterFinish: this.ApplyLoadedForm.bind(this) });} else { this.ApplyLoadedForm();}} else { this.ApplyLoadedForm();}}, ApplyLoadedForm: function(){ if (!this.FormUpdate){ $('lightboxc').hide(); $('lightboxc').setStyle({ top: '-10000px', left: '0px' }); $('lightboxc').show();} if (!this.FormUpdate) this.createForm(); if (this.error == 1){ $('lb_content').innerHTML = 'error';} else { this.Loading = false; var form = this.LoadedForms[this.src]; $('lb_content').innerHTML = form; this.evalCounter = 0; this.EvalTimerID = evalJS(this.LoadedFormsJS[this.src], 20);} if (!this.FormUpdate){ $('lightboxc').hide(); this.SetBoxPosition(this.screenWidth); LightBox.ShowBox(this.SlideDuration, this.overlayDuration);} this.FormUpdate = true;}, end: function(){ LightBox.end(); if (this.overlayOpacity >0){ new Effect.Fade($('overlay'), { duration: this.overlayDuration, delay: this.SlideDuration });} this.Started = false; evalJSCancel(this.EvalTimerID);}}; function MyLightBoxGetParams(rel){ var i = rel.indexOf('lightbox'); if ( i != -1 && rel.indexOf('[') >0 ){ var params = []; p = rel.substring(i+9, rel.length-1); var params = []; try{ eval("params = {"+p+"};"); return params;}catch(e){};} return null;} function MyLightBoxGetGroup(rel){ var params = MyLightBoxGetParams(rel); var group = 'lightbox'; if (params != null && params != undefined ){ group = params.id;} return group;} var LightBox = null; function collectLightBox(){ objBody = $$('body')[0]; objBody.appendChild(Builder.node('div',{id:'lightbox_temp', style:'position:absolute; top:-10000px;'})); var selects = $$('a[rel^=lightbox]'); selects.each(function(tag){ var rel = tag.getAttribute("rel"); group = MyLightBoxGetGroup(rel); if (group != ''){ lightboxCollection.Add(group, tag); var func = null; var likevideo = false; var likeform = false; var likeajax = false; if (rel.indexOf('lightboxvideo') != -1 ){ likevideo = true;} if (rel.indexOf('lightboxform') != -1 ){ likeform = true;} if (rel.indexOf('lightboxajax') != -1 ){ likeajax = true;} tag.observe('click', (function(event){ var target = event.findElement('a[rel^=lightbox]') || event.findElement('area[rel^=lightbox]'); if (target){ event.stop(); LightBox.start(target, likevideo, likeform, likeajax);}}).bind(this));}});} function detectLightBox(){}; var lightboxCollection = null; function LightBoxInit(){ lightboxCollection = new TagCollection("lightboxCollection1"); lightboxCollection.SetDetector(detectLightBox);} function reCollectLightBox(){ LightBoxInit(); collectLightBox();} LightBoxInit(); document.observe('dom:loaded', function (){collectLightBox(); LightBox = new Lightbox();} );
