$(document).ready
(
	function()
	{
		imagePreview();
		
		$('#gallery a').lightBox();
		
		$('#registration').submit
		(
			function ()
			{
				var submit = true;
				
				if (submit && $('#username').val() == '')
				{
					alert('Zadajte svoju e-mailovú adresu znovu');
					$('#username').focus();
					submit = false;
				}
				
				if (submit && $('#password').val() == '')
				{
					alert('Zadajte heslo');
					$('#password').focus();
					submit = false;
				}
				
				if (submit && $('#password_again').val() == '')
				{
					alert('Zadajte heslo znovu');
					$('#password_again').focus();
					submit = false;
				}
				
				if
				(
					submit
					&& $('#password').val() != ''
					&& $('#password').val() != $('#password_again').val()
				)
				{
					alert('Zadané heslá nie sú rovnaké');
					$('#password').focus();
					submit = false;
				}
				
				if (submit && $('#e_mail').val() == '')
				{
					alert('Zadajte svoju e-mailovú adresu');
					$('#e_mail').focus();
					submit = false;
				}
				
				if (submit && !check_email_address($('#e_mail').val()))
				{
					alert('Zadaná e-mailová adresa nemá správny formát');
					$('#e_mail').focus();
					submit = false;
				}
				
				if (submit && $('#first_name').val() == '')
				{
					alert('Zadajte svoje meno');
					$('#first_name').focus();
					submit = false;
				}
				
				if (submit && $('#surname').val() == '')
				{
					alert('Zadajte svoje priezvisko');
					$('#surname').focus();
					submit = false;
				}
				
				if (submit && $('#ico').val() == '')
				{
					alert('Zadajte svoje IČO');
					$('#ico').focus();
					submit = false;
				}
				
				if (submit && $('#domov_telefon').val() == '')
				{
					alert('Zadajte svoje telefónne číslo');
					$('#domov_telefon').focus();
					submit = false;
				}
				
				if (submit)
				{
					disable_button('registration_submit');
				}
				
				return submit;
			}
		);
		
		$('#update').submit
		(
			function ()
			{
				var submit = true;
				
				if (submit && $('#username').val() == '')
				{
					alert('Zadajte svoju e-mailovú adresu znovu');
					$('#username').focus();
					submit = false;
				}
				
				if
				(
					submit
					&& $('#password').val() != ''
					&& $('#password').val() != $('#password_again').val()
				)
				{
					alert('Zadané heslá nie sú rovnaké');
					$('#password').focus();
					submit = false;
				}
				
				if (submit && $('#e_mail').val() == '')
				{
					alert('Zadajte svoju e-mailovú adresu');
					$('#e_mail').focus();
					submit = false;
				}
				
				if (submit && !check_email_address($('#e_mail').val()))
				{
					alert('Zadaná e-mailová adresa nemá správny formát');
					$('#e_mail').focus();
					submit = false;
				}
				
				if (submit && $('#first_name').val() == '')
				{
					alert('Zadajte svoje meno');
					$('#first_name').focus();
					submit = false;
				}
				
				if (submit && $('#surname').val() == '')
				{
					alert('Zadajte svoje priezvisko');
					$('#surname').focus();
					submit = false;
				}
				
				if (submit && $('#ico').val() == '')
				{
					alert('Zadajte svoje IČO');
					$('#ico').focus();
					submit = false;
				}
				
				if (submit && $('#domov_telefon').val() == '')
				{
					alert('Zadajte svoje telefónne číslo');
					$('#domov_telefon').focus();
					submit = false;
				}
				
				if (submit)
				{
					disable_button('registration_submit');
				}
				
				return submit;
			}
		);
		
		$('#forgotten_password').submit
		(
			function ()
			{
				var submit = true;
				
				if (submit && $('#e_mail').val() == '')
				{
					alert('Zadajte svoju E-mailovú adresu');
					$('#e_mail').focus();
					submit = false;
				}
				
				if (submit && !check_email_address($('#e_mail').val()))
				{
					alert('Zadaná e-mailová adresa nemá správny formát');
					$('#e_mail').focus();
					submit = false;
				}
				
				if (submit)
				{
					disable_button('forg_pasw_submit');
				}
				
				return submit;
			}
		);
		
		$('#cat_all, #cat_only').click
		(
			function ()
			{
				switch ($(this).attr('id'))
				{
					case 'cat_all':
						$('#cat_only').removeClass('sel');
						$('#cat_all').addClass('sel');
						$('#retaz').css({'background-image':'url(\'/editor/images/design/retaz.png\')'});
						var search = 'F';
					break;
					case 'cat_only':
						$('#cat_all').removeClass('sel');
						$('#cat_only').addClass('sel');
						$('#retaz').css({'background-image':'url(\'/editor/images/design/spojena-retaz.gif\')'});
						var search = 'T';
					break;
				}
				
				$.ajax
				(
					{
						type: 'GET',
						url: '/editor/scripts/ajax/search/search_category.ajax.php',
						data: 'search_category=' + search,
						success: function(req)
						{
							if (req == 'T' && $('#menu_250').hasClass('sel'))
							{
								$('#search_form .textil').show();
							}
							else
							{
								$('#search_form .textil').hide();
							}
						}
					}
				);
			}
		);
		
		$('#material').change
		(
			function ()
			{
				if ($(this).val() == '53')
				{
					$('#search_form .textil').show();
				}
				else
				{
					$('#search_form .textil').hide();
				}
			}
		);
		
		$('#search_form .textil2').show();
		
		$('.category_search').css({'bottom':'1px'});
		
		$('#search_form, #title_search_form, #product_code_search_form').submit
		(
			function ()
			{
				if ($('#cat_only').hasClass('sel'))
				{
					var li_id = new Array(0,0);
					
					$('#left_menu li.sel').each
					(
						function(index)
						{
							li_id[index] = $(this).attr('id').split('_')['1'];
						}
					);

					$('.kategoria_id').val(li_id['0']);
					$('.pod_kategoria_id').val(li_id['1']);
				}
			}
		);
		
		$('.add_basket').click
		(
			function ()
			{
				var basket_id = $(this).attr('id').split('_')['1'];
				
				$('#basket_' + basket_id).submit();
				
				return false;
			}
		);
		
		$('.clear_basket').click
		(
			function ()
			{
				var conf = confirm('Naozaj chcete vyprázdniť košík?');
				
				if (conf == true)
				{
					if ($(this).attr('href') != undefined)
					{
						return true;
					}
					else
					{
						window.location.href = '/editor/scripts/custom_modules/basket/basket_submit.php?submit_type=clear&follow_page=/424';
						return true;
					}
				}
				
				return false;
			}
		);
		
		$('select.potlac').change
		(
			function ()
			{
				var product_id = $(this).attr('id').substr('6');
				
				if ($(this).val() != '0')
				{
					$('#farba_' + product_id).attr('disabled', false);
					
					$.ajax
					(
						{
							type: 'GET',
							url: '/editor/scripts/ajax/products/colors.ajax.php',
							data: 'potlac_id=' + $(this).val() + '&pocet=' + $('#pocet_' + product_id).val(),
							success: function(req)
							{
								var list = req.getElementsByTagName('data');
								
								$('#farba_' + product_id).removeOption(/./);
								
								for (index = 0; index < list.length; index++)
								{
									var pocet = list[index].getElementsByTagName('pocet')[0].childNodes[0].nodeValue;
									var title = list[index].getElementsByTagName('title')[0].childNodes[0].nodeValue;
									
									$('#farba_' + product_id).addOption(pocet, title, false);
								}
							}
						}
					);
				}
				else
				{
					$('#farba_' + product_id).attr('disabled', true);
					$('#farba_' + product_id).removeOption(/./);
					$('#farba_' + product_id).addOption('0', 'Počet farieb', false);
					$('#farba_' + product_id).change();
				}
			}
		);
		
		$('select.farba, select.prirazka').change
		(
			function ()
			{
				var product_id = $(this).attr('id').substr('6');
				
				if ($('#farba_' + product_id).val() > '0')
				{
					$('#prira_' + product_id).attr('disabled', false);
					$('#priprava_' + product_id).attr('disabled', false);
					/*
					$.ajax
					(
						{
							type: 'GET',
							url: '/editor/scripts/ajax/products/product_potlac_price.ajax.php',
							data: 'potlac_id=' + $('#dekor_' + product_id).val() + '&pocet=' + $('#pocet_' + product_id).val() + '&farba=' + $('#farba_' + product_id).val() + '&prirazka=' + $('#prira_' + product_id).val(),
							success: function(req)
							{
								$('#cena_ks_' + product_id).html(req.getElementsByTagName('formated_price')[0].childNodes[0].nodeValue);
								$('#cena_celkom_' + product_id).html(req.getElementsByTagName('formated_price_all')[0].childNodes[0].nodeValue);
							}
						}
					);
					*/
				}
				else
				{
					$('#prira_' + product_id).attr('disabled', true);
					$('#priprava_' + product_id).attr('disabled', true);
					$('#cena_ks_' + product_id).html('');
					$('#cena_celkom_' + product_id).html('');
				}
			}
		);
		
		$('.add_custom').click
		(
			function ()
			{
				$.ajax
				(
					{
						type: 'POST',
						url: '/editor/scripts/custom_modules/basket/basket_submit.php',
						data: 'type=custom&value=' + escape($(this).attr('title')) + '&price=' + $('#vektorizacia_cena').val() + '&count=1',
						success: function(req)
						{
							window.location.href = '/424';
						}
					}
				);
				
				disable_button('vektorizacia');
			}
		);
		
		$('.custom_item_button').click
		(
			function ()
			{
				var submit = true;
				
				if (submit == true && ($('#custom_nazov').val() == '' || $('#custom_nazov').val() == 'text'))
				{
					alert('Zadajte názov položky');
					$('#custom_nazov').focus();
					submit = false;
				}
				
				if (submit == true && ($('#custom_ks').val() == '' || $('#custom_ks').val() == 'ks'))
				{
					alert('Zadajte počet kusov');
					$('#custom_ks').focus();
					submit = false;
				}
				
				if (submit == true && ($('#custom_cena').val() == '' || $('#custom_cena').val() == 'cena'))
				{
					alert('Zadajte cenu položky');
					$('#custom_cena').focus();
					submit = false;
				}
				
				if (submit == true)
				{
					$.ajax
					(
						{
							type: 'POST',
							url: '/editor/scripts/custom_modules/basket/basket_submit.php',
							data: 'type=custom&value=' + escape($('#custom_nazov').val()) + '&price=' + $('#custom_cena').val() + '&count=' + $('#custom_ks').val(),
							success: function(req)
							{
								window.location.href = '/424';
							}
						}
					);
					
					disable_button('custom_item_button');
				}
			}
		);
		/*
		$('#vysivka_item_button').click
		(
			function ()
			{
				var submit = true;
				
				if (submit == true && $('#vysivka_produkt').val() == '')
				{
					alert('Vyberte tovar, ku ktorému chcete pridať výšivku');
					$('#vysivka_produkt').focus();
					submit = false;
				}
				
				if (submit == true && $('#vysivka_cena').val() == '')
				{
					alert('Zadajte cenu výšivky');
					$('#vysivka_cena').focus();
					submit = false;
				}
				
				if (submit == true)
				{
					$.ajax
					(
						{
							type: 'POST',
							url: '/editor/scripts/custom_modules/basket/basket_submit.php',
							data: 'type=vysivka&value=' + $('#vysivka_produkt').val() + '&price=' + $('#vysivka_cena').val(),
							success: function(req)
							{
								window.location.href = '/18061';
							}
						}
					);
					
					disable_button('vysivka_item_button');
				}
			}
		);
		*/
		$('#search_reset').click
		(
			function ()
			{
				$('#title').val('');
				$('#objednavkove_cislo').val('');
				$('#searchfield').val('');
				$('#typ_podmienky_1').attr('checked', true);
				$('#cena_od').val('');
				$('#cena_do').val('');
				$('#dodavatel_id').selectOptions('0');
				$('#material').selectOptions('0');
				$('#farba').selectOptions('0');
				$('#vyrazy').selectOptions('0');
				$('#textil_type').selectOptions('0');
				$('#textil_prevedenie').selectOptions('0');
				$('#textil_znacka').selectOptions('0');
				$('#textil_gramaz').selectOptions('0');
				$('#textil_kategoria').selectOptions('0');
				
				$('#search_form .textil').hide();
			}
		);
		
		var options =
		{
			'direction' : 'right'
		};
		function callback()
		{
			$('.ako_hladat, .objednat_inak').effect('slide', options, 1000, callback).delay(3000).fadeOut();
		};
		$('.ako_hladat, .objednat_inak').effect('slide', options, 1000, callback).delay(3000).fadeOut();
		
		$('#external_users').change
		(
			function ()
			{
				var klient_id = $(this).val();
				
				if ($(this).val() > '0')
				{
					$('#ajax_loader').html('<img src="/editor/images/design/ajax-loader.gif" alt="" />');
					
					$.ajax
					(
						{
							type: 'GET',
							url: '/editor/scripts/ajax/order/external_user.ajax.php',
							data: 'co_id=' + $(this).val(),
							success: function(req)
							{
								$('input:text').val('');
								$('#fakturovanie input:text').attr('disabled', true);
								$('#fakt_address').attr('checked', false);
								
								if (req.getElementsByTagName('dod_firma')[0].childNodes[0].nodeValue != '0')
								{
									$('#dod_firma').val(req.getElementsByTagName('dod_firma')[0].childNodes[0].nodeValue);
								};
								if (req.getElementsByTagName('dod_first_name')[0].childNodes[0].nodeValue != '0')
								{
									$('#dod_surname').val(req.getElementsByTagName('dod_first_name')[0].childNodes[0].nodeValue);
								};
								if (req.getElementsByTagName('dod_ulica')[0].childNodes[0].nodeValue != '0')
								{
									$('#dod_ulica').val(req.getElementsByTagName('dod_ulica')[0].childNodes[0].nodeValue);
								};
								if (req.getElementsByTagName('dod_mesto')[0].childNodes[0].nodeValue != '0')
								{
									$('#dod_mesto').val(req.getElementsByTagName('dod_mesto')[0].childNodes[0].nodeValue);
								};
								if (req.getElementsByTagName('dod_psc')[0].childNodes[0].nodeValue != '0')
								{
									$('#dod_psc').val(req.getElementsByTagName('dod_psc')[0].childNodes[0].nodeValue);
								};
								if (req.getElementsByTagName('dod_ico')[0].childNodes[0].nodeValue != '0')
								{
									$('#dod_ico').val(req.getElementsByTagName('dod_ico')[0].childNodes[0].nodeValue);
								};
								if (req.getElementsByTagName('dod_dic')[0].childNodes[0].nodeValue != '0')
								{
									$('#dod_dic').val(req.getElementsByTagName('dod_dic')[0].childNodes[0].nodeValue);
								};
								if (req.getElementsByTagName('dod_telefon')[0].childNodes[0].nodeValue != '0')
								{
									$('#dod_telefon').val(req.getElementsByTagName('dod_telefon')[0].childNodes[0].nodeValue);
								};
								if (req.getElementsByTagName('dod_cislo_uctu')[0].childNodes[0].nodeValue != '0')
								{
									$('#dod_cislo_uctu').val(req.getElementsByTagName('dod_cislo_uctu')[0].childNodes[0].nodeValue);
								};
								if (req.getElementsByTagName('dod_kod_banky')[0].childNodes[0].nodeValue != '0')
								{
									$('#dod_kod_banky').val(req.getElementsByTagName('dod_kod_banky')[0].childNodes[0].nodeValue);
								};
								
								$('#ajax_loader').html('');
							}
						}
					);
					
					$.getJSON
					(
						'https://firmsoft.sketch.sk/remote.php?jsoncallback=?',
						{ id: $(this).val() },
						function(data)
						{
							$('.obratova_zlava').html(data.client.actualBargainPercent + ' %');
							$('#obratova_zlava').val(data.client.actualBargainPercent);
							$('.klient_celkom').html(Math.round(data.client.totalPrice));
							$('#klient_celkom').val(Math.round(data.client.totalPrice));
							$('.hranica').html(Math.round(data.client.nextLimit));
							$('#hranica').val(Math.round(data.client.nextLimit));
							$('.chyba_do_hranice').html(Math.round(data.client.priceToLimit));
							$('#chyba_do_hranice').val(Math.round(data.client.priceToLimit));
							$('.klient_celkom, .hranica, .chyba_do_hranice').priceFormat
							(
								{
									prefix: '',
									postfix: ' €',
									thousandsSeparator: ' ',
									centsSeparator: '',
									centsLimit: 0,
									showCents: false,
									model: 'html'
								}
							);
							
							$('#klient_celkom, #hranica, #chyba_do_hranice').priceFormat
							(
								{
									prefix: '',
									postfix: ' €',
									thousandsSeparator: ' ',
									centsSeparator: '',
									centsLimit: 0,
									showCents: false
								}
							);
							
							$('#json_uplatni').click
							(
								function ()
								{
									$.ajax
									(
										{
											type: 'GET',
											url: '/editor/scripts/ajax/order/zlava.ajax.php',
											data: 'zlava=' + data.client.actualBargainPercent,
											success: function(req)
											{
												$('#uplatnena_zlava').val(data.client.actualBargainPercent);
												$('.uplatnena_zlava').html(data.client.actualBargainPercent + ' %');
												
												$('#dialog-form').dialog("close");
											}
										}
									);
								}
							);
							
							$('#zlava_uplatni_button').click
							(
								function ()
								{
									$.ajax
									(
										{
											type: 'GET',
											url: '/editor/scripts/custom_modules/basket/darcek_submit.php',
											data: 'ajax=T&darceky=' + $('#zlava_uplatni').html(),
											success: function(req)
											{
												$('#uplatnena_zlava').val(req);
												$('.uplatnena_zlava').html(req + ' %');
												$('#dialog-form').dialog("close");
											}
										}
									);
								}
							);
							
							if (data.client.actualBargainPercent > 0)
							{
								$('#dialog-form').dialog
								(
									{
										width: 600,
										modal: true,
										resizable: false
									}
								);
							}
						}
					);
				}
				else
				{
					$('input:text').val('');
					$('#fakturovanie input:text').attr('disabled', true);
					$('#fakt_address').attr('checked', false);
				}
			}
		);
		
		$('#basket_3_form').submit
		(
			function ()
			{
				var submit = true;
				
				if (submit && $('#dod_firma').val() == '')
				{
					alert('Zadajte názov spoločnosti');
					$('#dod_firma').focus();
					submit = false;
				}
				
				if (submit && $('#dod_first_name').val() == '' && $('#sketch_user').val() != 'T')
				{
					alert('Zadajte svoje meno');
					$('#dod_first_name').focus();
					submit = false;
				}
				
				if (submit && $('#dod_surname').val() == '')
				{
					alert('Zadajte svoje priezvisko');
					$('#dod_surname').focus();
					submit = false;
				}
				
				if (submit && $('#dod_ulica').val() == '')
				{
					alert('Zadajte ulicu adresy dodania');
					$('#dod_ulica').focus();
					submit = false;
				}
				
				if (submit && $('#dod_mesto').val() == '')
				{
					alert('Zadajte mesto adresy dodania');
					$('#dod_mesto').focus();
					submit = false;
				}
				
				if (submit && $('#dod_psc').val() == '')
				{
					alert('Zadajte ulicu adresy dodania');
					$('#dod_psc').focus();
					submit = false;
				}
				
				if (submit && $('#dod_ico').val() == '')
				{
					alert('Zadajte svoje IČO');
					$('#dod_ico').focus();
					submit = false;
				}
				
				if (submit && $('#dod_telefon').val() == '' && $('#sketch_user').val() != 'T')
				{
					alert('Zadajte svoje telefónne číslo');
					$('#dod_telefon').focus();
					submit = false;
				}
				
				if (submit && $('#dod_e_mail').val() == '')
				{
					alert('Zadajte svoju e-mailovú adresu');
					$('#dod_e_mail').focus();
					submit = false;
				}
				
				if ($('#fakt_address').attr('checked') == true)
				{
					if (submit && $('#fakt_firma').val() == '')
					{
						alert('Zadajte názov spoločnosti');
						$('#fakt_firma').focus();
						submit = false;
					}
					
					if (submit && $('#fakt_first_name').val() == '')
					{
						alert('Zadajte svoje meno');
						$('#fakt_first_name').focus();
						submit = false;
					}
					
					if (submit && $('#fakt_surname').val() == '')
					{
						alert('Zadajte svoje priezvisko');
						$('#fakt_surname').focus();
						submit = false;
					}
					
					if (submit && $('#fakt_ulica').val() == '')
					{
						alert('Zadajte ulicu adresy dodania');
						$('#fakt_ulica').focus();
						submit = false;
					}
					
					if (submit && $('#fakt_mesto').val() == '')
					{
						alert('Zadajte mesto adresy dodania');
						$('#fakt_mesto').focus();
						submit = false;
					}
					
					if (submit && $('#fakt_psc').val() == '')
					{
						alert('Zadajte ulicu adresy dodania');
						$('#fakt_psc').focus();
						submit = false;
					}
					
					if (submit && $('#fakt_ico').val() == '')
					{
						alert('Zadajte svoje IČO');
						$('#fakt_ico').focus();
						submit = false;
					}
					
					if (submit && $('#fakt_telefon').val() == '' && $('#sketch_user').val() != 'T')
					{
						alert('Zadajte svoje telefónne číslo');
						$('#fakt_telefon').focus();
						submit = false;
					}
				}
				
				if (submit && $('#doprava input:radio:checked').val() == undefined)
				{
					alert('Vyberte spôsob doručenia.');
					submit = false;
				}
				
				if (submit && $('#platba input:radio:checked').val() == undefined)
				{
					alert('Vyberte spôsob úhrady.');
					submit = false;
				}
				
				if (submit && $('#obchodnici input:radio:checked').val() == undefined)
				{
					alert('Vyberte obchodníka.');
					submit = false;
				}
				
				return submit;
			}
		);
		
		$('#fakt_address').click
		(
			function ()
			{
				if ($(this).attr('checked') == true)
				{
					$('#fakturovanie table').removeClass('hidden');
					$('#fakturovanie input:text').attr('disabled', false);
				}
				else
				{
					$('#fakturovanie table').addClass('hidden');
					$('#fakturovanie input:text').attr('disabled', true);
				}
			}
		);
		
		if ($('#fakt_address').attr('checked') == false)
		{
			$('#fakturovanie input:text').attr('disabled', true);
		}
		
		$('#basket_4_form').submit
		(
			function ()
			{
				var submit = true;
				
				if ($('#suhlas').attr('checked') == false)
				{
					alert('Pre potvrdenie objednávky musíte súhlasiť s obchodnými podmienkami');
					$('#suhlas').focus();
					submit = false;
				}
				
				return submit;
			}
		);
		
		$('.datum').datepicker
		(
			{
				numberOfMonths: 1,
				dateFormat: 'yy-mm-dd',
				dayNamesMin: ['Ne', 'Po', 'Ut', 'St', 'Št', 'Pi', 'So'],
				monthNames: ['Január','Február','Marec','Apríl','Máj','Jún','Júl','August','September','Október','November','December'],
				firstDay: 1,
				nextText: 'Neskôr',
				prevText: 'Skôr'
			}
		);
		
		$('#login_username').focus(function (){$(this).removeClass('meno');});
		$('#login_password').focus(function (){$(this).removeClass('heslo');});
		
		$('#login_username').blur(function (){if ($(this).val() == ''){$(this).addClass('meno');}});
		$('#login_password').blur(function (){if ($(this).val() == ''){$(this).addClass('heslo');}});
		
		if ($('#login_username').val()!=''){$('#login_username').removeClass('meno');}
		if ($('#login_password').val()!=''){$('#login_password').removeClass('heslo');}
		
		$('#dodavatel_id').change
		(
			function ()
			{
				$('.dodavatel_id').val($(this).val());
			}
		);
		
		$('.add_gift1').click(function(){addGift($(this).val());});
		$('.add_gift2').click(function(){addGift($(this).attr('rel'));});
		
		$('.reorder a').click
		(
			function ()
			{
				var direction = $(this).attr('rel');
				var tr = $(this).parent().parent().parent();
				var potlac_tr = $('#reorder_sub_' + tr.attr('id').substr('8'));
				
				switch (direction)
				{
					case 'up':
						if (tr.prev().attr('id') != '' && tr.prev().attr('id') != undefined)
						{
							tr.insertBefore(tr.prev().prev());
							potlac_tr.insertBefore(potlac_tr.prev().prev());
						}
					break;
					case 'down':
						if (potlac_tr.next().attr('id') != '')
						{
							potlac_tr.insertAfter(potlac_tr.next().next());
							tr.insertAfter(tr.next().next());
						}
					break;
				}
				
				var position = '1';
				$('.poradie').each
				(
					function ()
					{
						$(this).val(position);
						position++;
					}
				);
				
				$.ajax
				(
					{
						type: 'POST',
						url: '/editor/scripts/ajax/order/change_positions.ajax.php',
						data: $('.poradie').serialize(),
						success: function(req)
						{
						}
					}
				);
				
				return false;
			}
		);
		
		$('#list_tools select').change
		(
			function ()
			{
				window.location.href = $(this).val();
			}
		);
		
		$('.dialog_close').click
		(
			function ()
			{
				$('#dialog-form').dialog("close");
			}
		);
		
		$('.iconInfo').hover
		(
			function ()
			{
				$('.iconInfo .content').hide();
				$(this).find('.content').fadeIn();
			},
			function ()
			{
				$(this).find('.content').hide();
			}
		);
		
		$('.changePrice').click
		(
			function ()
			{
				var codes = $(this).attr('rel').split('_');
				
				if (codes[1] > '0')
				{
					var pos = $(this).position();
					$('#changePrice').css
					(
						{
							'top': pos.top + 'px',
							'left': pos.left + 45 + 'px'
						}
					).fadeIn();
					$('#changePrice input[name="productId"]').val(codes[1]);
				}
				
				return false;
			}
		);
		
		$('#title').attr('autocomplete', 'off');
		$('#title').keypress
		(
			function ()
			{
				$('#title').autocomplete
				(
					{
						//define callback to format results
						source: function(req, add)
						{
							//pass request to server
							$.getJSON
							(
								'/editor/scripts/custom_scripts/export/search.json.php?callback=?',
								req,
								function(data)
								{
									//create array for response objects
									var suggestions = [];
									
									//process response
									$.each
									(
										data,
										function(i, val)
										{
											suggestions.push(val.result);
										}
									);
									
									//pass array to callback
									add(suggestions);
								}
							);
						}
						/*,
						close: function(event, ui)
						{
							if ($('#title').val() != '')
							{
								$('#quick_search').submit();
							}
						}
						*/
					}
				);
			}
		);
	}
);

function disable_button(button_id)
{
	$('#' + button_id).attr('disabled', 'disabled');
	$('#' + button_id).val('Čakajte prosím');
}

function check_email_address(email)
{
	var re = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	if (!re.test(email))
	{
		return false;
	}
	else
	{
		return true;
	}
}

function addGift(gift_id)
{
	$.ajax
	(
		{
			type: 'POST',
			url: '/editor/scripts/custom_modules/basket/basket_submit.php',
			data: 'type=low_darcek&gift_id=' + gift_id,
			success: function(req)
			{
			}
		}
	);
}
