var pd_created = false;var pd_opened = false;var pd_action = false;jQuery.extend({DynamicForm: {method: 'post',modules: ['newsletter'],uid: '',use_container: false,h: '',Form: function(uid, use_container) {this.uid = uid;if (use_container) {this.use_container = true;}return this;},Begin: function(url, css_class, stop_ajax) {if (css_class != undefined && css_class != null) {css_class = ' class="' + css_class + '"';}if (stop_ajax == 1) {var ajax = '';} else {var ajax = 'SendAjaxForm(\'' + this.uid + '\'); ';}this.h += '<form id="form_' + this.uid + '" action="' + url + '" method="' + this.method + '"' + css_class + ' onsubmit="' + ajax + 'return false;">';this.h += '<span>';if (! this.use_container) {document.write(this.h);this._ResetHandler();}return this;},End: function() {this.h += '</span>';this.h += '</form>';if (this.use_container) {$('#form_container_' + this.uid).html(this.h);} else {document.write(this.h);}this._ResetHandler();CheckboxFix();return this;},Module: function(module, sig, image) {if (module == this.modules[0]) {this.h += '<input type="text" name="email" class="newsletter" />';this.h += '<input type="hidden" name="sig" value="' + sig + '" />';this.h += '<input type="image" name="submit" src="' + image + '" class="button" />';}if (! this.use_container) {document.write(this.h);this._ResetHandler();}return this;},FieldText: function(desc, name, value, required) {this.h += '<div class="mbform">';this.h += '<label for="form_' + this.uid + '_'+ name + '">' + desc + '</label>';this.h += '<input type="text" id="form_' + this.uid + '_'+ name + '" name="' + name + '" value="' + value + '"' + (required == true ? ' class="required"' : '') + ' />';this.h += '</div>';if (! this.use_container) {document.write(this.h);this._ResetHandler();}return this;},FieldHidden: function(name, value) {this.h += '<div>';this.h += '<input type="hidden" name="' + name + '" value="' + value + '" />';this.h += '</div>';if (! this.use_container) {document.write(this.h);this._ResetHandler();}return this;},FieldLongText: function(desc, name, value, required) {this.h += '<div class="mbform">';this.h += '<label for="form_' + this.uid + '_'+ name + '">' + desc + '</label>';this.h += '<textarea id="form_' + this.uid + '_'+ name + '" name="' + name + '" cols="1" rows="1"' + (required == true ? ' class="required"' : '') + '>' + value + '</textarea>';this.h += '</div>';if (! this.use_container) {document.write(this.h);this._ResetHandler();}return this;},FieldButton: function(image) {this.h += '<div class="button_l200">';this.h += '<input type="image" name="submit" src="' + image + '" class="button" />';this.h += '</div>';if (! this.use_container) {document.write(this.h);this._ResetHandler();}return this;},Basket: function(image) {this.h += '<input type="image" name="submit" src="' + image + '" class="button" />';if (! this.use_container) {document.write(this.h);this._ResetHandler();}return this;},_ResetHandler: function() {this.h = '';}}});function SendAjaxForm(uid) {var form = $('#form_' + uid);var ok = true;form.find('input[name="email"]').each(function() {if (! /^[a-z0-9\.\_\-]+@(?:[a-z0-9\-]+\.)+([a-z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$/i.test($(this).val())) {ok = false;}});form.find('input.required, textarea.required').each(function() {if ($(this).val().length == 0) {ok = false;}});if (! ok) {return false;}$.post(form.attr('action'),form.serialize(),function(result) {if (result.status == 'ok') {form.html(result.message);} else {alert(result.message);}},'json');}function AddToBasket(id) {var form = $('#form_' + id);form.find('.button').attr('disabled', true);$.post(form.attr('action'),form.serialize(),function(result) {if (result.status == 'ok') {$('#dialog_openwin').dialog('close');ReloadBasketBar();} else {alert(result.message);}},'json');}function CreateOpenWinDialog() {if (! pd_created) {$('body').append('<div id="dialog_openwin"></div>');var height = $(window).height();height = height * 0.9;$(function() {$('#dialog_openwin').dialog({'bgiframe': true,'width': 900,'height': height,'resizable': false,'modal': true,'buttons': false,'title': false,'autoOpen': false,'dialogClass': 'dialog_openwin','close': function(event, ui) {pd_opened = false;}});});pd_created = true;if ($.browser.mozilla) {$(document).keypress(function(e) {if (pd_opened && pd_action) {switch (e.keyCode) {case 39:if ($('#dialog_openwin a.ow_navi_right').size() == 1) {$('#dialog_openwin a.ow_navi_right').click();}break;case 37:if ($('#dialog_openwin a.ow_navi_left').size() == 1) {$('#dialog_openwin a.ow_navi_left').click();}break;case 13:if ($('#dialog_openwin form.basket input.button').size() == 1) {$('#dialog_openwin form.basket input.button').click();}break;}}});} else {$(document).keypress(function(e) {if (pd_opened && pd_action) {switch (e.keyCode) {case 39:if ($('#dialog_openwin a.ow_navi_right').size() == 1) {$('#dialog_openwin a.ow_navi_right').click();}break;case 37:if ($('#dialog_openwin a.ow_navi_left').size() == 1) {$('#dialog_openwin a.ow_navi_left').click();}break;case 13:if ($('#dialog_openwin form.basket input.button').size() == 1) {$('#dialog_openwin form.basket input.button').click();}break;}}});}}}function AjaxConfig(id, url, sig) {document.write('<div id="' + id + '" class="hide">');document.write(sig + '|' + url);document.write('</div>');}function ReloadBasketBar() {var config = $('#basket_cart_config');if (config.size() == 1) {var config_data = config.html().split('|');if (config_data[0] != undefined && config_data[1] != undefined) {$.post(config_data[1].replace('&amp;', '&'),{'sig': config_data[0]},function(result) {if (result) {$('#basket_cart').html(result);$('#basket_cart').removeClass('hide');} else {$('#basket_cart').addClass('hide');}},'html');}}}function LoadOrderBox(step, uid) {var config = $('#order_box_config');if (step == 3) {var form = $('#form_' + uid);var ok = true;form.find('input[name="email"]').each(function() {if (! /^[a-z0-9\.\_\-]+@(?:[a-z0-9\-]+\.)+([a-z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$/i.test($(this).val())) {ok = false;}});form.find('input.required, textarea.required').each(function() {if ($(this).val().length == 0) {ok = false;}});if (! ok) {return false;}}if (config.size() == 1) {var config_data = config.html().split('|');if (config_data[0] != undefined && config_data[1] != undefined) {var locality = 0;if (step == 2) {locality = $('#basket_inbox form select[name="locality"] option:selected').val();}if (step == 3) {$.post(config_data[1].replace('&amp;', '&'),{'sig': config_data[0],'step': step,'locality': form.find('input[name="locality"]').val(),'cname': form.find('input[name="cname"]').val(),'cemail': form.find('input[name="cemail"]').val(),'caddress': form.find('input[name="caddress"]').val(),'cphone': form.find('input[name="cphone"]').val(),'cnote': form.find('textarea[name="cnote"]').val()},function(result) {if (result.status == 'ok') {$('#basket_box').html(result.content);} else {alert(result.message);}},'json');} else {$.post(config_data[1].replace('&amp;', '&'),{'sig': config_data[0],'step': step,'locality': locality},function(result) {if (result) {$('#basket_inbox').html(result);CheckboxFix();}},'html');}}}}function CheckboxFix() {$('input[type="checkbox"], input[type="radio"]').css({width: 'auto', height: 'auto'});}jQuery.fn.LoadProductWin = function(params) {var obj = $(this);if (obj.length >= 1) {obj = obj.eq(0);if (params.action == 'basket') {pd_action = params.action;} else {pd_action = 'detail';}if (obj.attr('href') != undefined) {url = obj.attr('href');} else if (obj.attr('action') != undefined) {url = obj.attr('action');} else {return false;}$('#dialog_openwin').html('<span class="loader"></span>');$.post(url,{'form_action': 'openwin','ajax': 1,'action': pd_action},function(content) {$('#dialog_openwin').html(content);CheckboxFix();});}};$().ready(function() { $('.footer2 .logos img').hover(function() {$(this).attr('src', $(this).attr('src').replace(/\/foologo_/, '/foologoc_'));}, function() {$(this).attr('src', $(this).attr('src').replace(/\/foologoc_/, '/foologo_'));}); $('.footer3').addClass('hand').click(function() {window.open($(this).find('a').eq(0).attr('href'));}); $('.tech_info').css('opacity', 0.7); CheckboxFix(); $('span.hot[title]').css('cursor', 'help').tipsy({gravity: 'e', html: true}); $('a.openwin').live('click', function() {CreateOpenWinDialog();if (! pd_opened) {$('#dialog_openwin').dialog('open');pd_opened = true;}$(this).LoadProductWin({'action': 'detail'});return false;}); $('form.basket input.button').live('click', function() {CreateOpenWinDialog();if (! pd_opened) {$('#dialog_openwin').dialog('open');pd_opened = true;}$(this).parents('form').LoadProductWin({'action': 'basket'});return false;}); var last_opacity;$('#dialog_openwin .ow_content .ow_det_container').live('mouseenter', function() {last_opacity = $(this).css('opacity');$(this).animate({'opacity': 1});}).live('mouseleave', function() {$(this).animate({'opacity': last_opacity});}); $('#dialog_openwin a[href$="#close"]').live('click', function() {$('#dialog_openwin').dialog('close');}); $('#basket_cart a[id^="remove_from_basket"]').live('click', function() {var config = $('#remove_from_basket_config');var item = $(this).attr('href').split('#');if (config.size() == 1 && item[1] != undefined) {var config_data = config.html().split('|');if (config_data[0] != undefined && config_data[1] != undefined) {$.post(config_data[1].replace('&amp;', '&'),{'sig': config_data[0],'id': item[1]},function(result) {if (result.status == 'ok') {if (result.returned == 1) {ReloadBasketBar();} else {window.location.reload();}}},'json');}}return false;}); $('#basket_inbox form input[name="control"]').live('change', function() {if ($(this).attr('checked')) {$('#basket_inbox form select[name="locality"]').val(0).attr('disabled', false);} else {$('#basket_inbox form select[name="locality"]').val(0).attr('disabled', true);$('#basket_inbox form input.button').attr('disabled', true);}});$('#basket_inbox form select[name="locality"]').live('change', function() {if ($(this).val() > 0) {$('#basket_inbox form input.button').attr('disabled', false);} else {$('#basket_inbox form input.button').attr('disabled', true);}});});
