PageRenderTime 33ms CodeModel.GetById 2ms app.highlight 24ms RepoModel.GetById 1ms app.codeStats 1ms

/upload/catalog/view/theme/default/template/checkout/checkout.tpl

https://bitbucket.org/elena_dyavolova/omf
Smarty Template | 929 lines | 788 code | 141 blank | 0 comment | 106 complexity | feb33b0d62dcb4eec2ead129b88379bb MD5 | raw file
  1<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
  2<div id="content"><?php echo $content_top; ?>
  3  <div class="breadcrumb">
  4    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
  5    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
  6    <?php } ?>
  7  </div>
  8  <h1><?php echo $heading_title; ?></h1>
  9  <div class="checkout">
 10    <div id="checkout">
 11      <div class="checkout-heading"><?php echo $text_checkout_option; ?></div>
 12      <div class="checkout-content"></div>
 13    </div>
 14    <?php if (!$logged) { ?>
 15    <div id="payment-address">
 16      <div class="checkout-heading"><span><?php echo $text_checkout_account; ?></span></div>
 17      <div class="checkout-content"></div>
 18    </div>
 19    <?php } else { ?>
 20    <div id="payment-address">
 21      <div class="checkout-heading"><span><?php echo $text_checkout_payment_address; ?></span></div>
 22      <div class="checkout-content"></div>
 23    </div>
 24    <?php } ?>
 25    <?php if ($shipping_required) { ?>
 26    <div id="shipping-address">
 27      <div class="checkout-heading"><?php echo $text_checkout_shipping_address; ?></div>
 28      <div class="checkout-content"></div>
 29    </div>
 30    <div id="shipping-method">
 31      <div class="checkout-heading"><?php echo $text_checkout_shipping_method; ?></div>
 32      <div class="checkout-content"></div>
 33    </div>
 34    <?php } ?>
 35    <div id="payment-method">
 36      <div class="checkout-heading"><?php echo $text_checkout_payment_method; ?></div>
 37      <div class="checkout-content"></div>
 38    </div>
 39    <div id="confirm">
 40      <div class="checkout-heading"><?php echo $text_checkout_confirm; ?></div>
 41      <div class="checkout-content"></div>
 42    </div>
 43  </div>
 44  <?php echo $content_bottom; ?></div>
 45<script type="text/javascript"><!--
 46$('#checkout .checkout-content input[name=\'account\']').live('change', function() {
 47	if ($(this).attr('value') == 'register') {
 48		$('#payment-address .checkout-heading span').html('<?php echo $text_checkout_account; ?>');
 49	} else {
 50		$('#payment-address .checkout-heading span').html('<?php echo $text_checkout_payment_address; ?>');
 51	}
 52});
 53
 54$('.checkout-heading a').live('click', function() {
 55	$('.checkout-content').slideUp('slow');
 56	
 57	$(this).parent().parent().find('.checkout-content').slideDown('slow');
 58});
 59<?php if (!$logged) { ?> 
 60$(document).ready(function() {
 61	$.ajax({
 62		url: 'index.php?route=checkout/login',
 63		dataType: 'html',
 64		success: function(html) {
 65			$('#checkout .checkout-content').html(html);
 66				
 67			$('#checkout .checkout-content').slideDown('slow');
 68		},
 69		error: function(xhr, ajaxOptions, thrownError) {
 70			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
 71		}
 72	});	
 73});		
 74<?php } else { ?>
 75$(document).ready(function() {
 76	$.ajax({
 77		url: 'index.php?route=checkout/payment_address',
 78		dataType: 'html',
 79		success: function(html) {
 80			$('#payment-address .checkout-content').html(html);
 81				
 82			$('#payment-address .checkout-content').slideDown('slow');
 83		},
 84		error: function(xhr, ajaxOptions, thrownError) {
 85			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
 86		}
 87	});	
 88});
 89<?php } ?>
 90
 91// Checkout
 92$('#button-account').live('click', function() {
 93	$.ajax({
 94		url: 'index.php?route=checkout/' + $('input[name=\'account\']:checked').attr('value'),
 95		dataType: 'html',
 96		beforeSend: function() {
 97			$('#button-account').attr('disabled', true);
 98			$('#button-account').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
 99		},		
100		complete: function() {
101			$('#button-account').attr('disabled', false);
102			$('.wait').remove();
103		},			
104		success: function(html) {
105			$('.warning, .error').remove();
106			
107			$('#payment-address .checkout-content').html(html);
108				
109			$('#checkout .checkout-content').slideUp('slow');
110				
111			$('#payment-address .checkout-content').slideDown('slow');
112				
113			$('.checkout-heading a').remove();
114				
115			$('#checkout .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
116		},
117		error: function(xhr, ajaxOptions, thrownError) {
118			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
119		}
120	});
121});
122
123// Login
124$('#button-login').live('click', function() {
125	$.ajax({
126		url: 'index.php?route=checkout/login/validate',
127		type: 'post',
128		data: $('#checkout #login :input'),
129		dataType: 'json',
130		beforeSend: function() {
131			$('#button-login').attr('disabled', true);
132			$('#button-login').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
133		},	
134		complete: function() {
135			$('#button-login').attr('disabled', false);
136			$('.wait').remove();
137		},				
138		success: function(json) {
139			$('.warning, .error').remove();
140			
141			if (json['redirect']) {
142				location = json['redirect'];
143			} else if (json['error']) {
144				$('#checkout .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '</div>');
145				
146				$('.warning').fadeIn('slow');
147			}
148		},
149		error: function(xhr, ajaxOptions, thrownError) {
150			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
151		}
152	});	
153});
154
155// Register
156$('#button-register').live('click', function() {
157	$.ajax({
158		url: 'index.php?route=checkout/register/validate',
159		type: 'post',
160		data: $('#payment-address input[type=\'text\'], #payment-address input[type=\'password\'], #payment-address input[type=\'checkbox\']:checked, #payment-address input[type=\'radio\']:checked, #payment-address input[type=\'hidden\'], #payment-address select'),
161		dataType: 'json',
162		beforeSend: function() {
163			$('#button-register').attr('disabled', true);
164			$('#button-register').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
165		},	
166		complete: function() {
167			$('#button-register').attr('disabled', false); 
168			$('.wait').remove();
169		},			
170		success: function(json) {
171			$('.warning, .error').remove();
172						
173			if (json['redirect']) {
174				location = json['redirect'];				
175			} else if (json['error']) {
176				if (json['error']['warning']) {
177					$('#payment-address .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
178					
179					$('.warning').fadeIn('slow');
180				}
181				
182				if (json['error']['firstname']) {
183					$('#payment-address input[name=\'firstname\'] + br').after('<span class="error">' + json['error']['firstname'] + '</span>');
184				}
185				
186				if (json['error']['lastname']) {
187					$('#payment-address input[name=\'lastname\'] + br').after('<span class="error">' + json['error']['lastname'] + '</span>');
188				}	
189				
190				if (json['error']['email']) {
191					$('#payment-address input[name=\'email\'] + br').after('<span class="error">' + json['error']['email'] + '</span>');
192				}
193				
194				if (json['error']['telephone']) {
195					$('#payment-address input[name=\'telephone\'] + br').after('<span class="error">' + json['error']['telephone'] + '</span>');
196				}	
197					
198				if (json['error']['company_id']) {
199					$('#payment-address input[name=\'company_id\'] + br').after('<span class="error">' + json['error']['company_id'] + '</span>');
200				}	
201				
202				if (json['error']['tax_id']) {
203					$('#payment-address input[name=\'tax_id\'] + br').after('<span class="error">' + json['error']['tax_id'] + '</span>');
204				}	
205																		
206				if (json['error']['address_1']) {
207					$('#payment-address input[name=\'address_1\'] + br').after('<span class="error">' + json['error']['address_1'] + '</span>');
208				}	
209				
210				if (json['error']['city']) {
211					$('#payment-address input[name=\'city\'] + br').after('<span class="error">' + json['error']['city'] + '</span>');
212				}	
213				
214				if (json['error']['postcode']) {
215					$('#payment-address input[name=\'postcode\'] + br').after('<span class="error">' + json['error']['postcode'] + '</span>');
216				}	
217				
218				if (json['error']['country']) {
219					$('#payment-address select[name=\'country_id\'] + br').after('<span class="error">' + json['error']['country'] + '</span>');
220				}	
221				
222				if (json['error']['zone']) {
223					$('#payment-address select[name=\'zone_id\'] + br').after('<span class="error">' + json['error']['zone'] + '</span>');
224				}
225				
226				if (json['error']['password']) {
227					$('#payment-address input[name=\'password\'] + br').after('<span class="error">' + json['error']['password'] + '</span>');
228				}	
229				
230				if (json['error']['confirm']) {
231					$('#payment-address input[name=\'confirm\'] + br').after('<span class="error">' + json['error']['confirm'] + '</span>');
232				}																																	
233			} else {
234				<?php if ($shipping_required) { ?>				
235				var shipping_address = $('#payment-address input[name=\'shipping_address\']:checked').attr('value');
236				
237				if (shipping_address) {
238					$.ajax({
239						url: 'index.php?route=checkout/shipping_method',
240						dataType: 'html',
241						success: function(html) {
242							$('#shipping-method .checkout-content').html(html);
243							
244							$('#payment-address .checkout-content').slideUp('slow');
245							
246							$('#shipping-method .checkout-content').slideDown('slow');
247							
248							$('#checkout .checkout-heading a').remove();
249							$('#payment-address .checkout-heading a').remove();
250							$('#shipping-address .checkout-heading a').remove();
251							$('#shipping-method .checkout-heading a').remove();
252							$('#payment-method .checkout-heading a').remove();											
253							
254							$('#shipping-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');									
255							$('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');	
256
257							$.ajax({
258								url: 'index.php?route=checkout/shipping_address',
259								dataType: 'html',
260								success: function(html) {
261									$('#shipping-address .checkout-content').html(html);
262								},
263								error: function(xhr, ajaxOptions, thrownError) {
264									alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
265								}
266							});	
267						},
268						error: function(xhr, ajaxOptions, thrownError) {
269							alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
270						}
271					});	
272				} else {
273					$.ajax({
274						url: 'index.php?route=checkout/shipping_address',
275						dataType: 'html',
276						success: function(html) {
277							$('#shipping-address .checkout-content').html(html);
278							
279							$('#payment-address .checkout-content').slideUp('slow');
280							
281							$('#shipping-address .checkout-content').slideDown('slow');
282							
283							$('#checkout .checkout-heading a').remove();
284							$('#payment-address .checkout-heading a').remove();
285							$('#shipping-address .checkout-heading a').remove();
286							$('#shipping-method .checkout-heading a').remove();
287							$('#payment-method .checkout-heading a').remove();							
288
289							$('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');	
290						},
291						error: function(xhr, ajaxOptions, thrownError) {
292							alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
293						}
294					});			
295				}
296				<?php } else { ?>
297				$.ajax({
298					url: 'index.php?route=checkout/payment_method',
299					dataType: 'html',
300					success: function(html) {
301						$('#payment-method .checkout-content').html(html);
302						
303						$('#payment-address .checkout-content').slideUp('slow');
304						
305						$('#payment-method .checkout-content').slideDown('slow');
306						
307						$('#checkout .checkout-heading a').remove();
308						$('#payment-address .checkout-heading a').remove();
309						$('#payment-method .checkout-heading a').remove();								
310						
311						$('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');	
312					},
313					error: function(xhr, ajaxOptions, thrownError) {
314						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
315					}
316				});					
317				<?php } ?>
318
319				$.ajax({
320					url: 'index.php?route=checkout/payment_address',
321					dataType: 'html',
322					success: function(html) {
323						$('#payment-address .checkout-content').html(html);
324							
325						$('#payment-address .checkout-heading span').html('<?php echo $text_checkout_payment_address; ?>');
326					},
327					error: function(xhr, ajaxOptions, thrownError) {
328						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
329					}
330				});
331			}	 
332		},
333		error: function(xhr, ajaxOptions, thrownError) {
334			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
335		}
336	});	
337});
338
339// Payment Address	
340$('#button-payment-address').live('click', function() {
341	$.ajax({
342		url: 'index.php?route=checkout/payment_address/validate',
343		type: 'post',
344		data: $('#payment-address input[type=\'text\'], #payment-address input[type=\'password\'], #payment-address input[type=\'checkbox\']:checked, #payment-address input[type=\'radio\']:checked, #payment-address input[type=\'hidden\'], #payment-address select'),
345		dataType: 'json',
346		beforeSend: function() {
347			$('#button-payment-address').attr('disabled', true);
348			$('#button-payment-address').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
349		},	
350		complete: function() {
351			$('#button-payment-address').attr('disabled', false);
352			$('.wait').remove();
353		},			
354		success: function(json) {
355			$('.warning, .error').remove();
356			
357			if (json['redirect']) {
358				location = json['redirect'];
359			} else if (json['error']) {
360				if (json['error']['warning']) {
361					$('#payment-address .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
362					
363					$('.warning').fadeIn('slow');
364				}
365								
366				if (json['error']['firstname']) {
367					$('#payment-address input[name=\'firstname\']').after('<span class="error">' + json['error']['firstname'] + '</span>');
368				}
369				
370				if (json['error']['lastname']) {
371					$('#payment-address input[name=\'lastname\']').after('<span class="error">' + json['error']['lastname'] + '</span>');
372				}	
373				
374				if (json['error']['telephone']) {
375					$('#payment-address input[name=\'telephone\']').after('<span class="error">' + json['error']['telephone'] + '</span>');
376				}		
377				
378				if (json['error']['company_id']) {
379					$('#payment-address input[name=\'company_id\']').after('<span class="error">' + json['error']['company_id'] + '</span>');
380				}	
381				
382				if (json['error']['tax_id']) {
383					$('#payment-address input[name=\'tax_id\']').after('<span class="error">' + json['error']['tax_id'] + '</span>');
384				}	
385														
386				if (json['error']['address_1']) {
387					$('#payment-address input[name=\'address_1\']').after('<span class="error">' + json['error']['address_1'] + '</span>');
388				}	
389				
390				if (json['error']['city']) {
391					$('#payment-address input[name=\'city\']').after('<span class="error">' + json['error']['city'] + '</span>');
392				}	
393				
394				if (json['error']['postcode']) {
395					$('#payment-address input[name=\'postcode\']').after('<span class="error">' + json['error']['postcode'] + '</span>');
396				}	
397				
398				if (json['error']['country']) {
399					$('#payment-address select[name=\'country_id\']').after('<span class="error">' + json['error']['country'] + '</span>');
400				}	
401				
402				if (json['error']['zone']) {
403					$('#payment-address select[name=\'zone_id\']').after('<span class="error">' + json['error']['zone'] + '</span>');
404				}
405			} else {
406				<?php if ($shipping_required) { ?>
407				$.ajax({
408					url: 'index.php?route=checkout/shipping_address',
409					dataType: 'html',
410					success: function(html) {
411						$('#shipping-address .checkout-content').html(html);
412					
413						$('#payment-address .checkout-content').slideUp('slow');
414						
415						$('#shipping-address .checkout-content').slideDown('slow');
416						
417						$('#payment-address .checkout-heading a').remove();
418						$('#shipping-address .checkout-heading a').remove();
419						$('#shipping-method .checkout-heading a').remove();
420						$('#payment-method .checkout-heading a').remove();
421						
422						$('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');	
423					},
424					error: function(xhr, ajaxOptions, thrownError) {
425						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
426					}
427				});
428				<?php } else { ?>
429				$.ajax({
430					url: 'index.php?route=checkout/payment_method',
431					dataType: 'html',
432					success: function(html) {
433						$('#payment-method .checkout-content').html(html);
434					
435						$('#payment-address .checkout-content').slideUp('slow');
436						
437						$('#payment-method .checkout-content').slideDown('slow');
438						
439						$('#payment-address .checkout-heading a').remove();
440						$('#payment-method .checkout-heading a').remove();
441													
442						$('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');	
443					},
444					error: function(xhr, ajaxOptions, thrownError) {
445						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
446					}
447				});	
448				<?php } ?>
449				
450				$.ajax({
451					url: 'index.php?route=checkout/payment_address',
452					dataType: 'html',
453					success: function(html) {
454						$('#payment-address .checkout-content').html(html);
455					},
456					error: function(xhr, ajaxOptions, thrownError) {
457						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
458					}
459				});				
460			}	  
461		},
462		error: function(xhr, ajaxOptions, thrownError) {
463			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
464		}
465	});	
466});
467
468// Shipping Address			
469$('#button-shipping-address').live('click', function() {
470	$.ajax({
471		url: 'index.php?route=checkout/shipping_address/validate',
472		type: 'post',
473		data: $('#shipping-address input[type=\'text\'], #shipping-address input[type=\'password\'], #shipping-address input[type=\'checkbox\']:checked, #shipping-address input[type=\'radio\']:checked, #shipping-address select'),
474		dataType: 'json',
475		beforeSend: function() {
476			$('#button-shipping-address').attr('disabled', true);
477			$('#button-shipping-address').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
478		},	
479		complete: function() {
480			$('#button-shipping-address').attr('disabled', false);
481			$('.wait').remove();
482		},			
483		success: function(json) {
484			$('.warning, .error').remove();
485			
486			if (json['redirect']) {
487				location = json['redirect'];
488			} else if (json['error']) {
489				if (json['error']['warning']) {
490					$('#shipping-address .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
491					
492					$('.warning').fadeIn('slow');
493				}
494								
495				if (json['error']['firstname']) {
496					$('#shipping-address input[name=\'firstname\']').after('<span class="error">' + json['error']['firstname'] + '</span>');
497				}
498				
499				if (json['error']['lastname']) {
500					$('#shipping-address input[name=\'lastname\']').after('<span class="error">' + json['error']['lastname'] + '</span>');
501				}	
502				
503				if (json['error']['email']) {
504					$('#shipping-address input[name=\'email\']').after('<span class="error">' + json['error']['email'] + '</span>');
505				}
506				
507				if (json['error']['telephone']) {
508					$('#shipping-address input[name=\'telephone\']').after('<span class="error">' + json['error']['telephone'] + '</span>');
509				}		
510										
511				if (json['error']['address_1']) {
512					$('#shipping-address input[name=\'address_1\']').after('<span class="error">' + json['error']['address_1'] + '</span>');
513				}	
514				
515				if (json['error']['city']) {
516					$('#shipping-address input[name=\'city\']').after('<span class="error">' + json['error']['city'] + '</span>');
517				}	
518				
519				if (json['error']['postcode']) {
520					$('#shipping-address input[name=\'postcode\']').after('<span class="error">' + json['error']['postcode'] + '</span>');
521				}	
522				
523				if (json['error']['country']) {
524					$('#shipping-address select[name=\'country_id\']').after('<span class="error">' + json['error']['country'] + '</span>');
525				}	
526				
527				if (json['error']['zone']) {
528					$('#shipping-address select[name=\'zone_id\']').after('<span class="error">' + json['error']['zone'] + '</span>');
529				}
530			} else {
531				$.ajax({
532					url: 'index.php?route=checkout/shipping_method',
533					dataType: 'html',
534					success: function(html) {
535						$('#shipping-method .checkout-content').html(html);
536						
537						$('#shipping-address .checkout-content').slideUp('slow');
538						
539						$('#shipping-method .checkout-content').slideDown('slow');
540						
541						$('#shipping-address .checkout-heading a').remove();
542						$('#shipping-method .checkout-heading a').remove();
543						$('#payment-method .checkout-heading a').remove();
544						
545						$('#shipping-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');							
546						
547						$.ajax({
548							url: 'index.php?route=checkout/shipping_address',
549							dataType: 'html',
550							success: function(html) {
551								$('#shipping-address .checkout-content').html(html);
552							},
553							error: function(xhr, ajaxOptions, thrownError) {
554								alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
555							}
556						});
557					},
558					error: function(xhr, ajaxOptions, thrownError) {
559						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
560					}
561				});	
562				
563				$.ajax({
564					url: 'index.php?route=checkout/payment_address',
565					dataType: 'html',
566					success: function(html) {
567						$('#payment-address .checkout-content').html(html);
568					},
569					error: function(xhr, ajaxOptions, thrownError) {
570						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
571					}
572				});					
573			}
574		},
575		error: function(xhr, ajaxOptions, thrownError) {
576			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
577		}
578	});	
579});
580
581// Guest
582$('#button-guest').live('click', function() {
583	$.ajax({
584		url: 'index.php?route=checkout/guest/validate',
585		type: 'post',
586		data: $('#payment-address input[type=\'text\'], #payment-address input[type=\'checkbox\']:checked, #payment-address input[type=\'radio\']:checked, #payment-address input[type=\'hidden\'], #payment-address select'),
587		dataType: 'json',
588		beforeSend: function() {
589			$('#button-guest').attr('disabled', true);
590			$('#button-guest').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
591		},	
592		complete: function() {
593			$('#button-guest').attr('disabled', false); 
594			$('.wait').remove();
595		},			
596		success: function(json) {
597			$('.warning, .error').remove();
598			
599			if (json['redirect']) {
600				location = json['redirect'];
601			} else if (json['error']) {
602				if (json['error']['warning']) {
603					$('#payment-address .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
604					
605					$('.warning').fadeIn('slow');
606				}
607								
608				if (json['error']['firstname']) {
609					$('#payment-address input[name=\'firstname\'] + br').after('<span class="error">' + json['error']['firstname'] + '</span>');
610				}
611				
612				if (json['error']['lastname']) {
613					$('#payment-address input[name=\'lastname\'] + br').after('<span class="error">' + json['error']['lastname'] + '</span>');
614				}	
615				
616				if (json['error']['email']) {
617					$('#payment-address input[name=\'email\'] + br').after('<span class="error">' + json['error']['email'] + '</span>');
618				}
619				
620				if (json['error']['telephone']) {
621					$('#payment-address input[name=\'telephone\'] + br').after('<span class="error">' + json['error']['telephone'] + '</span>');
622				}	
623					
624				if (json['error']['company_id']) {
625					$('#payment-address input[name=\'company_id\'] + br').after('<span class="error">' + json['error']['company_id'] + '</span>');
626				}	
627				
628				if (json['error']['tax_id']) {
629					$('#payment-address input[name=\'tax_id\'] + br').after('<span class="error">' + json['error']['tax_id'] + '</span>');
630				}	
631																		
632				if (json['error']['address_1']) {
633					$('#payment-address input[name=\'address_1\'] + br').after('<span class="error">' + json['error']['address_1'] + '</span>');
634				}	
635				
636				if (json['error']['city']) {
637					$('#payment-address input[name=\'city\'] + br').after('<span class="error">' + json['error']['city'] + '</span>');
638				}	
639				
640				if (json['error']['postcode']) {
641					$('#payment-address input[name=\'postcode\'] + br').after('<span class="error">' + json['error']['postcode'] + '</span>');
642				}	
643				
644				if (json['error']['country']) {
645					$('#payment-address select[name=\'country_id\'] + br').after('<span class="error">' + json['error']['country'] + '</span>');
646				}	
647				
648				if (json['error']['zone']) {
649					$('#payment-address select[name=\'zone_id\'] + br').after('<span class="error">' + json['error']['zone'] + '</span>');
650				}
651			} else {
652				<?php if ($shipping_required) { ?>	
653				var shipping_address = $('#payment-address input[name=\'shipping_address\']:checked').attr('value');
654				
655				if (shipping_address) {
656					$.ajax({
657						url: 'index.php?route=checkout/shipping_method',
658						dataType: 'html',
659						success: function(html) {
660							$('#shipping-method .checkout-content').html(html);
661							
662							$('#payment-address .checkout-content').slideUp('slow');
663							
664							$('#shipping-method .checkout-content').slideDown('slow');
665							
666							$('#payment-address .checkout-heading a').remove();
667							$('#shipping-address .checkout-heading a').remove();
668							$('#shipping-method .checkout-heading a').remove();
669							$('#payment-method .checkout-heading a').remove();		
670															
671							$('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');	
672							$('#shipping-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');									
673							
674							$.ajax({
675								url: 'index.php?route=checkout/guest_shipping',
676								dataType: 'html',
677								success: function(html) {
678									$('#shipping-address .checkout-content').html(html);
679								},
680								error: function(xhr, ajaxOptions, thrownError) {
681									alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
682								}
683							});
684						},
685						error: function(xhr, ajaxOptions, thrownError) {
686							alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
687						}
688					});					
689				} else {
690					$.ajax({
691						url: 'index.php?route=checkout/guest_shipping',
692						dataType: 'html',
693						success: function(html) {
694							$('#shipping-address .checkout-content').html(html);
695							
696							$('#payment-address .checkout-content').slideUp('slow');
697							
698							$('#shipping-address .checkout-content').slideDown('slow');
699							
700							$('#payment-address .checkout-heading a').remove();
701							$('#shipping-address .checkout-heading a').remove();
702							$('#shipping-method .checkout-heading a').remove();
703							$('#payment-method .checkout-heading a').remove();
704							
705							$('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');	
706						},
707						error: function(xhr, ajaxOptions, thrownError) {
708							alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
709						}
710					});
711				}
712				<?php } else { ?>				
713				$.ajax({
714					url: 'index.php?route=checkout/payment_method',
715					dataType: 'html',
716					success: function(html) {
717						$('#payment-method .checkout-content').html(html);
718						
719						$('#payment-address .checkout-content').slideUp('slow');
720							
721						$('#payment-method .checkout-content').slideDown('slow');
722							
723						$('#payment-address .checkout-heading a').remove();
724						$('#payment-method .checkout-heading a').remove();
725														
726						$('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
727					},
728					error: function(xhr, ajaxOptions, thrownError) {
729						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
730					}
731				});				
732				<?php } ?>
733			}	 
734		},
735		error: function(xhr, ajaxOptions, thrownError) {
736			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
737		}
738	});	
739});
740
741// Guest Shipping
742$('#button-guest-shipping').live('click', function() {
743	$.ajax({
744		url: 'index.php?route=checkout/guest_shipping/validate',
745		type: 'post',
746		data: $('#shipping-address input[type=\'text\'], #shipping-address select'),
747		dataType: 'json',
748		beforeSend: function() {
749			$('#button-guest-shipping').attr('disabled', true);
750			$('#button-guest-shipping').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
751		},	
752		complete: function() {
753			$('#button-guest-shipping').attr('disabled', false); 
754			$('.wait').remove();
755		},			
756		success: function(json) {
757			$('.warning, .error').remove();
758			
759			if (json['redirect']) {
760				location = json['redirect'];
761			} else if (json['error']) {
762				if (json['error']['warning']) {
763					$('#shipping-address .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
764					
765					$('.warning').fadeIn('slow');
766				}
767								
768				if (json['error']['firstname']) {
769					$('#shipping-address input[name=\'firstname\']').after('<span class="error">' + json['error']['firstname'] + '</span>');
770				}
771				
772				if (json['error']['lastname']) {
773					$('#shipping-address input[name=\'lastname\']').after('<span class="error">' + json['error']['lastname'] + '</span>');
774				}	
775										
776				if (json['error']['address_1']) {
777					$('#shipping-address input[name=\'address_1\']').after('<span class="error">' + json['error']['address_1'] + '</span>');
778				}	
779				
780				if (json['error']['city']) {
781					$('#shipping-address input[name=\'city\']').after('<span class="error">' + json['error']['city'] + '</span>');
782				}	
783				
784				if (json['error']['postcode']) {
785					$('#shipping-address input[name=\'postcode\']').after('<span class="error">' + json['error']['postcode'] + '</span>');
786				}	
787				
788				if (json['error']['country']) {
789					$('#shipping-address select[name=\'country_id\']').after('<span class="error">' + json['error']['country'] + '</span>');
790				}	
791				
792				if (json['error']['zone']) {
793					$('#shipping-address select[name=\'zone_id\']').after('<span class="error">' + json['error']['zone'] + '</span>');
794				}
795			} else {
796				$.ajax({
797					url: 'index.php?route=checkout/shipping_method',
798					dataType: 'html',
799					success: function(html) {
800						$('#shipping-method .checkout-content').html(html);
801						
802						$('#shipping-address .checkout-content').slideUp('slow');
803						
804						$('#shipping-method .checkout-content').slideDown('slow');
805						
806						$('#shipping-address .checkout-heading a').remove();
807						$('#shipping-method .checkout-heading a').remove();
808						$('#payment-method .checkout-heading a').remove();
809							
810						$('#shipping-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
811					},
812					error: function(xhr, ajaxOptions, thrownError) {
813						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
814					}
815				});				
816			}	 
817		},
818		error: function(xhr, ajaxOptions, thrownError) {
819			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
820		}
821	});	
822});
823
824$('#button-shipping-method').live('click', function() {
825	$.ajax({
826		url: 'index.php?route=checkout/shipping_method/validate',
827		type: 'post',
828		data: $('#shipping-method input[type=\'radio\']:checked, #shipping-method textarea'),
829		dataType: 'json',
830		beforeSend: function() {
831			$('#button-shipping-method').attr('disabled', true);
832			$('#button-shipping-method').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
833		},	
834		complete: function() {
835			$('#button-shipping-method').attr('disabled', false);
836			$('.wait').remove();
837		},			
838		success: function(json) {
839			$('.warning, .error').remove();
840			
841			if (json['redirect']) {
842				location = json['redirect'];
843			} else if (json['error']) {
844				if (json['error']['warning']) {
845					$('#shipping-method .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
846					
847					$('.warning').fadeIn('slow');
848				}			
849			} else {
850				$.ajax({
851					url: 'index.php?route=checkout/payment_method',
852					dataType: 'html',
853					success: function(html) {
854						$('#payment-method .checkout-content').html(html);
855						
856						$('#shipping-method .checkout-content').slideUp('slow');
857						
858						$('#payment-method .checkout-content').slideDown('slow');
859
860						$('#shipping-method .checkout-heading a').remove();
861						$('#payment-method .checkout-heading a').remove();
862						
863						$('#shipping-method .checkout-heading').append('<a><?php echo $text_modify; ?></a>');	
864					},
865					error: function(xhr, ajaxOptions, thrownError) {
866						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
867					}
868				});					
869			}
870		},
871		error: function(xhr, ajaxOptions, thrownError) {
872			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
873		}
874	});	
875});
876
877$('#button-payment-method').live('click', function() {
878	$.ajax({
879		url: 'index.php?route=checkout/payment_method/validate', 
880		type: 'post',
881		data: $('#payment-method input[type=\'radio\']:checked, #payment-method input[type=\'checkbox\']:checked, #payment-method textarea'),
882		dataType: 'json',
883		beforeSend: function() {
884			$('#button-payment-method').attr('disabled', true);
885			$('#button-payment-method').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
886		},	
887		complete: function() {
888			$('#button-payment-method').attr('disabled', false);
889			$('.wait').remove();
890		},			
891		success: function(json) {
892			$('.warning, .error').remove();
893			
894			if (json['redirect']) {
895				location = json['redirect'];
896			} else if (json['error']) {
897				if (json['error']['warning']) {
898					$('#payment-method .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
899					
900					$('.warning').fadeIn('slow');
901				}			
902			} else {
903				$.ajax({
904					url: 'index.php?route=checkout/confirm',
905					dataType: 'html',
906					success: function(html) {
907						$('#confirm .checkout-content').html(html);
908						
909						$('#payment-method .checkout-content').slideUp('slow');
910						
911						$('#confirm .checkout-content').slideDown('slow');
912						
913						$('#payment-method .checkout-heading a').remove();
914						
915						$('#payment-method .checkout-heading').append('<a><?php echo $text_modify; ?></a>');	
916					},
917					error: function(xhr, ajaxOptions, thrownError) {
918						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
919					}
920				});	
921			}
922		},
923		error: function(xhr, ajaxOptions, thrownError) {
924			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
925		}
926	});	
927});
928//--></script> 
929<?php echo $footer; ?>