var cur_position = 0;var calculator_index = 0;function isValidEmailAddress(emailAddress) {	var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);	return pattern.test(emailAddress);};function show_step(index){	var total_steps= $('#list-buttons').children().length;	$('#list-buttons li').removeClass('selected');	$('#list-buttons > li').eq(index).addClass('selected');	$('.btn-end-calculation').hide();	$('.calc-content > div').hide();	$('.calc-content > div').eq(index).show();	$('.calculator-content-nav .btn-prev, .calculator-content-nav .btn-next').css({visibility: 'visible'});	if(index == total_steps -1)	{		$('.btn-end-calculation').show();	}	if(index <= 0){		$('.calculator-content-nav .btn-prev').css({visibility: 'hidden'});	}	if(index >=  $('#list-buttons').children().length -1){		$('.calculator-content-nav .btn-next').css({visibility: 'hidden'});	}}jQuery(function() {	//-------------------------------------------------------------	//	CALCULATOR	//-------------------------------------------------------------	if(jQuery.screwDefaultButtons){		 $('#calculator input:checkbox').screwDefaultButtons({			checked: "url("+relPath+"images/checked.png)",			unchecked:  "url("+relPath+"images/unchecked.png)",			width: 11,			height: 12		});	}	$('.btn-start').click(function(e){		e.preventDefault();		$('.calc-content').removeClass('calc-content-bg');		$('.calculator-content-last').toggleClass('calculator-content-nav calculator-content-last');		$('#list-buttons li').css({cursor:'pointer'});		$('#list-buttons li').click(function(e){			e.preventDefault();			calculator_index= $(this).index();			show_step(calculator_index);		});		$(this).parents('.calc-start').remove();		show_step(0);	});	$('.calculator-content-nav .btn-next').live('click', function(e){		e.preventDefault();		calculator_index++;		show_step(calculator_index);	});	$('.calculator-content-nav .btn-prev').live('click', function(e){		e.preventDefault();		calculator_index--;		show_step(calculator_index);	});	$('#calculator-form .btn-prev').live('click', function(e){		e.preventDefault();		$('.calc-content').removeClass('calc-content-bg');		$('#list-buttons').toggle();		$('#calculator-form').toggle();		$('.calculator-content-last').toggleClass('calculator-content-nav calculator-content-last');		$('.calculator-content-nav a').show();		$('#send-calculator-result').find("div").text("");		show_step(calculator_index);	});	$('.btn-end-calculation').click(function(e){		e.preventDefault();		var data='';		$('.calc-final .component-list').html("");		$('.calc-step input:checked').each(function(){			data= "<dt>"+$(this).parents('dt').find('label').text()+"</dt>";			data+= "<dd>"+$(this).parents('dt').next().text()+"</dd>"			$('.calc-final .component-list').append(data);		});		if(data=='')		{			return false;		}		var total_steps= $('#list-buttons').children().length;		show_step(total_steps);		$('.calc-content').addClass('calc-content-bg');		$('#list-buttons').toggle();		$('#calculator-form').toggle();		$('.calculator-content-nav a').hide();		$('.calculator-content-nav').toggleClass('calculator-content-nav calculator-content-last');	});	$('#send-calculator-result a').click(function(e){		e.preventDefault();		$this= $(this);		var data_name= $('#calculator-form input[name=contact_name]').val();		var data_email= $('#calculator-form input[name=contact_email]').val();		var data_telephone= $('#calculator-form input[name=contact_telephone]').val();		var data_results= "<dl>"+$('.calc-final .component-list').find("dt").wrapInner("<b />").end().html()+"</dl>";		var data_subscribe=  $('#calculator-form input[name=contact_subscribe]').is(':checked');		if(!data_name ){			$this.parent("div").find("div").html('<b>Proszę wypełnić wszystkie pola.</b>');			return false;		}		else if(!data_telephone && !data_email)		{			$this.parent("div").find("div").html('<b>Proszę wypełnić wszystkie pola.</b>');			return false;		}		else if(!data_email && !data_telephone)		{			$this.parent("div").find("div").html('<b>Proszę wypełnić wszystkie pola.</b>');			return false;		}		else if(data_email && !isValidEmailAddress(data_email)){			$this.parent("div").find("div").html('<b>Pole E-mail musi zawierać poprawny adres email.</b>');			return false;		}		$.post("/calculator/send_results/", { contact_name: data_name, contact_email: data_email, contact_telephone: data_telephone, calculation_results: data_results, contact_subscribe: data_subscribe},			function(data) {				$this.parent("div").html("Dziękujemy za wysłanie wiadomości. Skontaktujemy się z Państwem najpóźniej następnego dnia roboczego.");				$('#calculator-form .btn-prev').remove();			}		);	});	$(document).bind('afterClose.facebox', function() {		$('.addboxes').hide();		$('#mainbox').show();	});	$('#form-quiz').submit(function() {		 var options = {				success:  function(data){					if(data.type== 'error'){						$('#response-quiz').css('color','red');						$('#response-quiz').html(data.messages);					}					else					{						$('#response-quiz').load(data.messages);						$('.feedback-questionary').remove();					}				},				clearForm: false,				resetForm: false,				dataType: 'json'			};			$(this).ajaxSubmit(options);			return false;		});		$('.show-inputs').click(function(){			$(this).parents('li').find('.gray_box_optional').toggle();		});		var mdos = $('input[name="mdos"]').val();		$('.facebox').facebox();		if(mdos) {			$.facebox.loading();			$('#facebox').show();		}		$("div#partnersScroll").smoothDivScroll({			autoScroll: "onstart",			autoScrollDirection: "endlessloopright",			autoScrollStep: 1,			autoScrollInterval: 30		});		/* Polish initialisation for the jQuery UI date picker plugin. */		/* Written by Jacek Wysocki (jacek.wysocki@gmail.com). */		$.datepicker.regional['pl'] = {						closeText: 'Zamknij',						prevText: '',						nextText: '',						currentText: 'Dziś',						monthNames: ['Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec',						'Lipiec','Sierpień','Wrzesień','Październik','Listopad','Grudzień'],						monthNamesShort: ['Sty','Lu','Mar','Kw','Maj','Cze',						'Lip','Sie','Wrz','Pa','Lis','Gru'],						dayNames: ['Niedziela','Poniedziałek','Wtorek','Środa','Czwartek','Piątek','Sobota'],						dayNamesShort: ['Nie','Pn','Wt','Śr','Czw','Pt','So'],						dayNamesMin: ['N','Pn','Wt','Śr','Cz','Pt','So'],						weekHeader: 'Tydz',						dateFormat: 'yy-mm-dd',						firstDay: 1,						isRTL: false,						showMonthAfterYear: false,						yearSuffix: ''};		$.datepicker.setDefaults($.datepicker.regional['pl']);		$( "#datepicker" ).datepicker();		$('#selecttime').selectbox();		$( ".datepicker" ).datepicker();		$('.selecttime').selectbox();		$('select.long').selectbox({inputClass: 'longselect'});		$("#up").fontscale("p, a, h1, h2 ,h3","up",{unit:"percent",increment:10});		$("#down").fontscale("p, a, h1, h2, h3","down",{unit:"percent",increment:10});		$("#reset").fontscale("p, a, h1, h2, h3","reset");		$('#arrow-left').click(function() {			if(cur_position <= 0) {				return false;			}			var search = --cur_position;			var i = 0;			$('.hidden-content').each(function() {				if(i == search) {					$('.hidden-content').hide();					$(this).show();				}				i++;			});			if(search == 0) {				$('#arrow-right').children('img').attr('src', relPath+'images/arrow-right-active.png');				$('#arrow-left').children('img').attr('src', relPath+'images/arrow-left-unactive.png');			}			return false;		});		$('#arrow-right').click(function() {			var max = 0;			$('.hidden-content').each(function() {				max++;			});			if((max-1) <= cur_position) {				return false;			}			var search = ++cur_position;			var i = 0;			$('.hidden-content').each(function() {				if(i == search) {					$('.hidden-content').hide();					$(this).show();				}				i++;			});			if((i-1) == search) {				$('#arrow-right').children('img').attr('src', relPath+'images/arrow-right-unactive.png');				$('#arrow-left').children('img').attr('src', relPath+'images/arrow-left-active.png');			}			return false;		});		$(".accordion").accordion({active: false, collapsible: true, autoHeight: false});		/* */		$('#consultations').submit(function() {			var div = $(this);			$.post('/consultations/', $(this).serialize(), function(data) {				if(data.ok == 0) {					alert(data.message);					return false;				}				$(div).find('div').html('<p>'+data.message+'</p>');			}, 'json');			return false;		});		$('#contact').submit(function() {			$.post('/contact/', $(this).serialize(), function(data) {				if(data.ok == 0) {					alert(data.message);					return false;				}				$('#form').html('<p>'+data.message+'</p>');			}, 'json');			return false;		});		$('.lightbox').lightBox();		$('*[rel=lightbox]').lightBox();		$('.closefacebox').click(function() {			$(document).trigger('close.facebox')			return false;		});		/*** MENU ***/		/**** NEWSLETTER ***/		$('#newsletter').submit(function() {			var ti = $(this).parent();			$.post('/newsletter/', $(this).serialize(), function(data) {				if(data.ok == 0) {					alert(data.message);				} else {					$(ti).html('<p>'+data.message+'</p>');				}			}, 'json');			return false;		});		$('#newsletterinput').focus(function() {			var data = $(this).attr('title');			if($(this).val() == data) $(this).val('');		});		$('#newsletterinput').blur(function() {			var data = $(this).attr('title');			if($(this).val() == '') $(this).val(data);		});		/*** SHOP DELIVERY (ODBIÓR OSOBISTY) ***/		$('select[name="f_delivery"]').change(function() {			if($(this).val() == 2) {				$('.delivery').show();			} else {				$('.delivery').hide();			}		});});function deleteParent(what) {	$(what).parent().remove();}
