PageSourceSearch

https://artlofthotel.com/cdn/js/core.js

js artlofthotel.com collected 2026-10-09 00:01:24 UTC 88,571 bytes, 2,428 lines download raw bytes

1function round(value, decimals) {
2  return Number(Math.round(value+'e'+decimals)+'e-'+decimals);
3}
4
5$(document).ready(function() {
6    /* PRODUCT RATING*/
7	$(".rate-p").rateYo({
8        rating: $(".rate-p").attr('ratingvalue'),
9       
10        fullStar: true,
11        starWidth: "20px",
12        onSet: function (rating, rateYoInstance) {
13 
14            //alert("Rating is set to: " + rating);
15            var productid =$(this).attr('productid') ;
16            updateProductRating(productid,rating);
17       }
18
19    }).on("rateyo.change", function (e, data) {
20 
21                var rating = data.rating;
22                $(this).next().text(rating);
23
24              });
25
26    /* PRODUCT RATING END */
27	/*	VAUCHER HANDLERS START	*/
28	$('.cms_couponButton').on("click", function(){
29		checkCoupon();
30	});
31	$('.cms_couponRemove').on("click", function(){
32        if (confirm('Ukloniti vaučer?')) {
33			removeCoupon();
34		}
35	});
36	/*	VAUCHER HANDLERS END	*/
37	
38	//Log User Data
39	userLogDataInsertUpdate();
40    // product attr
41    // $('.product-attr-triger').on('click', function() {
42    //     $('.product-attr-li').find('i').css('display', 'none');
43    //     $(this).find('i').css('display', 'block');
44    // });
45    // .product attr
46    //ORDER CREATE RESERVATION
47    $('.cms_order-to-reservation').on('click', function(e){
48        $this = $(this);
49        e.preventDefault(); 
50        e.stopImmediatePropagation();   
51        var data = {
52            action : 'create_reservation',
53			grr: $(".g-recaptcha-response").val()
54        };
55        $.ajax({
56            type: "POST",
57            data: data,
58            url: "index.php",
59            error: function (XMLHttpRequest, textStatus, errorThrown) {
60                alert("ERROR:" + errorThrown);
61            },
62            success: function (response) {
63				var a = JSON.parse(response);
64				if(a['status'] == 'success')
65				{
66					$('.bankform').remove();
67					$('body').append(a['form']);
68					if($(".bankform").length > 0){
69						$(".bankform").submit();
70					}
71                	//window.location = $($this).attr('href');
72				}else{
73					alertify.error(a['message']);	
74				}
75            }
76        });     
77    });
78    $('.cms_order-to-reservationB2B').on('click', function(e){
79        $this = $(this);
80        e.preventDefault(); 
81        e.stopImmediatePropagation();   
82        var data = {
83            action : 'create_reservationB2B'
84        };
85        $.ajax({
86            type: "POST",
87            data: data,
88            url: "index.php",
89            error: function (XMLHttpRequest, textStatus, errorThrown) {
90                alert("ERROR:" + errorThrown);
91            },
92            success: function (response) {
93				var a = JSON.parse(response);
94				if(a['status'] == 'success')
95				{
96					$('.bankform').remove();
97					$('body').append(a['form']);
98					if($(".bankform").length > 0){
99						$(".bankform").submit();
100					}
101				}else{
102					alertify.error(a['message']);	
103				}
104				//window.location = $($this).attr('href');
105            }
106        });     
107    });
108    //ORDER TO CHECKOUT
109    $('.cms_order-to-checkout').on('click', function(e){ 
110        $this = $(this);
111        e.preventDefault(); 
112        e.stopImmediatePropagation();   
113        var data = {
114            action : 'updateshopcartcomment',
115            comment: $('.cms_shopcartComment').val()
116        };
117        $.ajax({
118            type: "POST",
119            data: data,
120            url: "index.php",
121            error: function (XMLHttpRequest, textStatus, errorThrown) {
122                alert("ERROR:" + errorThrown);
123            },
124            success: function (response) {
125                window.location = $($this).attr('href');
126            }
127        });     
128    });
129    //ORDER FINISH
130    //cms_finish_order
131    $('.cms_delivery_choise-trigger').on('click', function() {
132        
133        
134        	if($(this).val()=='p'){
135        		$('.cms_delivery_choise-trigger').removeClass('-checked');
136        		$(this).addClass('-checked');
137        		$('.cms_delivery_service').removeAttr('checked');
138        		$(this).attr('checked','checked');
139        		if($(this).hasClass('-checked')){
140        			$(".cms_delivery_pickup_checkout-choise").show();
141        			$(".cms_delivery_service_checkout-choise").hide();
142        			$(".cms_delivery_metod").attr('deliverymetod','p');
143        		}	
144        	}
145            if($(this).val()=='d'){
146            	$('.cms_delivery_choise-trigger').removeClass('-checked');
147            	$(this).addClass('-checked');
148            	$('.cms_delivery_personal').removeAttr('checked');
149            	$(this).attr('checked','checked');
150        		if($(this).hasClass('-checked')){
151            		$(".cms_delivery_pickup_checkout-choise").hide();
152        			$(".cms_delivery_service_checkout-choise").show();
153        			$(".cms_delivery_metod").attr('deliverymetod','d');
154        		}	
155        	}
156        
157    });
158    $('.cms_delivery_personal_input').on('click', function() {
159    	var id=$(this).val();
160    	$('.cms_delivery_personal_input').each(function(){
161      		if($(this).val() !== id){
162       		 	$(this).removeAttr("checked");
163      		}
164    	});
165    	$(this).attr( "checked", 'checked' );
166    });
167    $('.cms_delivery_service_input').on('click', function() {
168    	var id=$(this).val();
169    	$('.cms_delivery_service_input').each(function(){
170      		if($(this).val() !== id){
171       		 	$(this).removeAttr("checked");
172      		}
173    	});
174    	$(this).attr( "checked", 'checked' );
175    });
176    $("#cms_order-customer-form").on("submit", function(event) {
177    	event.preventDefault();
178    	var langid = $(this).attr('lang');
179    	var currentLangCode = $(this).attr('langcode');
180        var orderData = {};
181        //var orderRecipientData = {};
182        var haserror = false;
183
184        
185        $('#cms_order-customer-form').find("input").each(function() {
186        	//alert($(this).val());
187        if(!$(this).hasClass('cms_recipient') && $(this).attr('name')!='deliveryPersonal' && $(this).attr('name')!='deliveryService' ){
188        	//alert($(this).attr('name'));
189            if ($(this).val() == '') {
190                $(this).parent(".my-label").addClass("has-error");
191                $(this).next(".help-block").removeClass("hide");
192                haserror = true;
193                //alert($(this).attr('name'));
194            } else {
195                $(this).parent(".my-label").removeClass("has-error");
196                $(this).next(".help-block").addClass("hide");
197
198            }
199        } 
200        });
201        //Provera nacina plaćanja
202        if($('.cms_customerPaymentMethod').val() == 'n'){
203        	$(this).parent(".my-label").addClass("has-error");
204            $(this).next(".help-block").removeClass("hide");
205            haserror = true;
206            msg = '';
207            switch (currentLangCode) {
208                case 'lat':
209                    msg = 'Niste odabrali način plaćanja.';
210                    break;
211                case 'eng':
212                    msg = 'You have not selected a payment method.';
213                    break;
214                case 'cir':
215                    msg = 'Нисте одабрали начин плаћања.';
216                    break;
217                 default:
218                    msg = 'Niste odabrali način plaćanja.';
219            }
220            alertify.error(msg);
221        };
222        //Provera nacina dostave
223        var deliveryMetod = $('.cms_delivery_metod').attr('deliverymetod');
224
225        if(deliveryMetod!='h'){
226        	var selected = false;
227			if(deliveryMetod=='p'){
228				
229				 $('.cms_delivery_personal_input').each(function() {
230				 	if($(this).attr('checked')=='checked'){
231				 		selected=true;
232				 	}
233				 });
234        	}
235        	if(deliveryMetod=='d'){
236        		$('.cms_delivery_service_input').each(function() {
237				 	if($(this).attr('checked')=='checked'){
238				 		selected=true;
239				 	}
240				 });
241        	} 
242        	if(!selected){
243        		haserror = true;
244        		if(deliveryMetod=='p'){
245                    msg = '';
246                    switch (currentLangCode) {
247                        case 'lat':
248                            msg = 'Niste odabrali prodavnicu u kojoj želite da preuzmete porudžbinu.';
249                            break;
250                        case 'eng':
251                            msg = 'You have not chosen the store where you want to pickup the order.';
252                            break;
253                        case 'cir':
254                            msg = 'Нисте одабрали продавницу у којој желите да преузмете поруџбину.';
255                            break;
256                         default:
257                            msg = 'Niste odabrali prodavnicu u kojoj želite da preuzmete porudžbinu.';
258                    }
259                    alertify.error(msg);
260        		}
261        		if(deliveryMetod=='d'){
262                    msg = '';
263                    switch (currentLangCode) {
264                        case 'lat':
265                            msg = 'Niste odabrali način dostave.';
266                            break;
267                        case 'eng':
268                            msg = 'You have not selected a delivery method.';
269                            break;
270                        case 'cir':
271                            msg = 'Нисте одабрали начин доставе.';
272                            break;
273                         default:
274                            msg = 'Niste odabrali način dostave.';
275                    }
276                    alertify.error(msg);
277        		}
278        	}       	
279        }
280        //Provera saglasnosti uslova kupovine
281        if(!$('.cms_accept-terms').hasClass('-checked')){
282            haserror = true;
283             msg = '';
284             switch (currentLangCode) {
285                 case 'lat':
286                     msg = 'Niste prihvatili uslove kupovine.';
287                     break;
288                 case 'eng':
289                     msg = 'You did not accept the terms and contitions.';
290                     break;
291                 case 'cir':
292                     msg = 'Нисте прихватили услове куповине.';
293                     break;
294                  default:
295                     msg = 'Niste prihvatili uslove kupovine.';
296             }
297             alertify.error(msg);
298        }
299
300
301
302
303        
304        //console.log(values);
305        if (!haserror) {
306        	$.each($('#cms_order-customer-form').serializeArray(), function(i, field) {
307            	orderData[field.name] = field.value;
308                //alert(field.name);
309        	});
310            var customerName = $("input[name='customerName']" ).val();
311            var customerLastName = $("input[name='customerLastName']" ).val();
312            var customerEmail = $("input[name='customerEmail']" ).val();
313            var customerPhone = $("input[name='customerPhone']" ).val();
314            var customerAddress = $("input[name='customerAddress']" ).val();
315            var customerCity = $("input[name='customerCity']" ).val();
316            var customerZipCode = $("input[name='customerZipCode']" ).val();
317            var customerPaymentType = $("select[name='customerPaymentMethod'] :selected" ).val();
318
319            if($('.dn_recipient-address-trigger').hasClass('-checked')){
320                var recipientName = $("input[name='recipientName']" ).val();
321                var recipientLastName = $("input[name='recipientLastName']" ).val();
322                var recipientPhone = $("input[name='recipientPhone']" ).val();
323                var recipientAddress = $("input[name='recipientAddress']" ).val();
324                var recipientCity = $("input[name='recipientCity']" ).val();
325                var recipientZipCode = $("input[name='recipientZipCode']" ).val();
326
327            } else {
328                var recipientName = '';
329                var recipientLastName = '';
330                var recipientPhone = '';
331                var recipientAddress = '';
332                var recipientCity = '';
333                var recipientZipCode = '';
334            }
335            
336
337            var deliveryType = $('.cms_delivery_metod').attr('deliverymetod');
338            var deliveryPersonalId = 0;
339            var deliveryServiceId = 0; 
340            switch (deliveryType) {
341                 case 'h':
342                     deliveryPersonalId = 0;
343                     deliveryServiceId = 0; 
344                     break;
345                 case 'p':
346                     deliveryPersonalId = parseInt($("input[type='radio'][name='deliveryPersonal']:checked" ).val());
347                     deliveryServiceId = 0; 
348                     break;
349                 case 'd':
350                     deliveryPersonalId = 0;
351                     deliveryServiceId = parseInt($("input[type='radio'][name='deliveryService']:checked" ).val());
352                     break;
353                  default:
354                     deliveryPersonalId = 0;
355                     deliveryServiceId = 0; 
356             }
357            
358            orderSetInfoData(customerName, customerLastName, customerEmail, customerPhone, customerAddress, customerCity, customerZipCode, customerPaymentType, recipientName, recipientLastName, recipientPhone, recipientAddress, recipientCity, recipientZipCode, deliveryType, deliveryPersonalId, deliveryServiceId);
359            //alert('Saljem podatke');//orderData.customerName
360            
361        } else {
362            //alertify.error('Sva polja su obavezna!');
363             msg = '';
364             switch (currentLangCode) {
365                 case 'lat':
366                     msg = 'Sva polja su obavezna!';
367                     break;
368                 case 'eng':
369                     msg = 'All fields are required!';
370                     break;
371                 case 'cir':
372                     msg = 'Сва поља су обавезна!';
373                     break;
374                  default:
375                     msg = 'Sva polja su obavezna!';
376             }
377             alertify.error(msg);
378        }
379    });    
380    //ORDER FINISH END
381
382    //COMMERCIALIST
383    $(".commercialist_remove_select_partnerBTN").on("click", function() {
384    	commercialist_remove_select_partner();
385    });
386    
387    //COMMERCIALIST END
388
389
390	if($('.container_commercilalist_partner').attr('partnerid')>=0){
391		get_commercialist_partners();
392	}
393	$('#cms_select_map').on("change", function() {
394		var coordinates = $(this).val().split(',');
395		var sort =$(this).find(':selected').attr("sortid");
396
397		newlat = 1*coordinates[0],
398		newlng = 1*coordinates[1];
399		//map.setZoom(newzoom);
400		map.setCenter({lat:newlat, lng:newlng});
401		//Clear all infoWindows if opened
402  		for (var i = 0; i < infowindows.length; i++) {
403  			infowindows[i].close();
404  			//var data = markers[i];
405  			//data.infowindow.close(map, markers[i]);
406  		}
407  		//Simulate click on selected marker witch belongs to equivalent select option
408		google.maps.event.trigger(markers[sort], 'click');
409
410	});	
411	
412	$('#order_payment').submit(function(event) {
413        event.preventDefault();
414        if(	$('.cms_payment.active').length > 0){
415			setOrderingPayment($('.order-paymant.active').attr('paymenttype'));
416		}
417
418    });
419	
420	
421	
422	
423    $(".core_extraDetailSelectValueCheckbox").on("click", function() {
424
425        var currpath = window.location.pathname + window.location.search;
426
427        if ($(this).hasClass('selected')) {
428            $(this).removeClass('selected');
429            var reg = "&ed[]=" + $(this).attr('extradetailid');
430            var currpath1 = currpath.replace(reg, '');
431            var currpath1 = currpath1.replace("&&", '&');
432
433            if (currpath[currpath1.length - 1] == '?') {
434                currpath1 = currpath1.slice(0, -1);
435            }
436
437            window.location = currpath1;
438
439        } else {
440            $(this).addClass('selected');
441
442            var str = window.location.pathname;
443            var lastChar = currpath.indexOf('?');
444
445            var char = '';
446            if (lastChar == -1) { char = '?' }
447
448            window.location = window.location + char + "&ed[]=" + $(this).attr('extradetailid');
449
450        }
451    });	
452
453    $(".core_brendsSelectValueCheckbox").on("click", function() {
454
455        var currpath = window.location.pathname + window.location.search;
456
457        if ($(this).hasClass('selected')) {
458            $(this).removeClass('selected');
459            var reg = "&bd[]=" + $(this).attr('brendid');
460            var currpath1 = currpath.replace(reg, '');
461            var currpath1 = currpath1.replace("&&", '&');
462
463            if (currpath[currpath1.length - 1] == '?') {
464                currpath1 = currpath1.slice(0, -1);
465            }
466
467            window.location = currpath1;
468
469        } else {
470            $(this).addClass('selected');
471
472            var str = window.location.pathname;
473            var lastChar = currpath.indexOf('?');
474
475            var char = '';
476            if (lastChar == -1) { char = '?' }
477
478            window.location = window.location + char + "&bd[]=" + $(this).attr('brendid');
479
480        }
481    });	
482	
483	//*********************************--------------------------------------------*************************************************
484	
485	
486	$('.cms_productMinMax').on("submit", function(e){
487		e.preventDefault();
488		minVal = parseInt($(this).find('.cms_minProductValue').val());
489		maxVal = parseInt($(this).find('.cms_maxProductValue').val());
490		//alert(minVal);
491		
492		//var values = Myslider.bootstrapSlider('getValue');
493        var currpath = window.location.pathname + window.location.search;
494        var questionmark = '';
495        if (currpath.search(/\?/g) == -1) { questionmark = '?'; }
496
497		if(minVal>=0 && minVal!=""){
498			if (currpath.search(/&min=[0-9]*\.?[0-9]*/g) > -1) {
499				currpath = currpath.replace(/&min=[0-9]*\.?[0-9]*/g, '&min=' + minVal);
500			} else {
501				currpath = currpath + questionmark + '&min=' + minVal;
502			}
503		} else {
504			currpath = currpath.replace(/&min=[0-9]*\.?[0-9]*/g, '' );
505		}
506		if(maxVal>0 && maxVal!=""){
507			if (currpath.search(/&max=[0-9]*\.?[0-9]*/g) > -1) {
508				currpath = currpath.replace(/&max=[0-9]*\.?[0-9]*/g, '&max=' + maxVal);
509			} else {
510				currpath = currpath + questionmark + '&max=' + maxVal;
511			}
512		}	else {
513			currpath = currpath.replace(/&max=[0-9]*\.?[0-9]*/g, '' );
514		}
515
516        window.location = currpath;
517		
518		
519		
520		
521	});	
522	
523	
524	
525	
526	
527	// 	+/- product
528	/*	Product dec button	*/
529	
530	$(document).on('click', '.cms_productInputDecButton', function(){
531		var currentLangCode = $(this).parents('.cms_productInputDecIncCont').attr('langcode');
532		var step = parseFloat($(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInput').attr('step'));
533		var oldquantity =parseFloat($(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInput').val());
534		var newuantity = Math.round((oldquantity-step)*100)/100  ;
535
536		
537		if(newuantity>=step){
538			$(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInput').val(newuantity);
539		}else {
540			msg = '';
541			switch (currentLangCode) {
542                case 'lat':
543                    msg = 'Minimalna dozvoljena količina je '+step;
544                    break;
545                case 'eng':
546                    msg = 'Minimal alowed quantity is '+step;
547                    break;
548                case 'cir':
549                    msg = 'Минимална дозвољена количина је'+step;
550                    break;
551                 default:
552                 	msg = 'Minimalna dozvoljena količina je '+step;
553            }
554			//alert(msg);
555			alertify.alert(msg);
556
557			$(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInput').val(step);
558		}
559	});
560
561        $(document).on('click', '.cms_productInputDecButtonRequest', function(){
562        var currentLangCode = $(this).parents('.cms_productInputDecIncCont').attr('langcode');
563        var step = parseFloat($(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInputRequest').attr('step'));
564        var oldquantity =parseFloat($(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInputRequest').val());
565        var newuantity = Math.round((oldquantity-step)*100)/100  ;
566
567        
568        if(newuantity>=step){
569            $(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInputRequest').val(newuantity);
570        }else {
571            msg = '';
572            switch (currentLangCode) {
573                case 'lat':
574                    msg = 'Minimalna dozvoljena količina je '+step;
575                    break;
576                case 'eng':
577                    msg = 'Minimal alowed quantity is '+step;
578                    break;
579                case 'cir':
580                    msg = 'Минимална дозвољена количина је'+step;
581                    break;
582                 default:
583                    msg = 'Minimalna dozvoljena količina je '+step;
584            }
585            //alert(msg);
586            alertify.alert(msg);
587
588            $(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInputRequest').val(step);
589        }
590    });
591	
592	/*	Product inc button	*/
593	
594	$(document).on('focus', '.cms_productQtyInput', function(){
595		var theValue = $(this).val();
596        $(this).data("value", theValue);
597	});
598	$(document).on('change', '.cms_productQtyInput', function(){
599		var previousValue = $(this).data("value");
600		var currentLangCode = $(this).parents('.cms_productInputDecIncCont').attr('langcode');
601		var step = parseFloat($(this).attr('step'));
602		var max = parseFloat($(this).attr('max'));
603		var quantity =parseFloat($(this).val());
604		var reminder = quantity % step;
605		var finished = 0;
606		msg = '';
607		if($(this).val()==''){
608			finished = 1;
609			switch (currentLangCode) {
610                case 'lat':
611                    msg = 'Uneta vrednost nije validna.';
612                    break;
613                case 'eng':
614                    msg = 'Entered value is not valid.';
615                    break;
616                case 'cir':
617                    msg = 'Унета вредност није валидна.';
618                    break;
619                 default:
620                 	msg = 'Uneta vrednost nije validna.';
621            }
622			$(this).val(step);
623			//alert(msg);
624			alertify.alert(msg);
625		}
626		if(reminder>0  && finished ==0){
627			switch (currentLangCode) {
628                case 'lat':
629                    msg = 'Uneta vrednost nije validna.\nUneta vrednost mora biti deljiva sa '+step;
630                    break;
631                case 'eng':
632                    msg = 'Entered value is not valid.\nThe enetered value must be divisible with '+step;
633                    break;
634                case 'cir':
635                    msg = 'Унета вредност није валидна.\nУнета вредност мора бити делјива са '+step;
636                    break;
637                 default:
638                 	msg = 'Uneta vrednost nije validna.\nUneta vrednost mora biti deljiva sa '+step;
639            }
640			$(this).val(previousValue);
641			//alert(msg);
642			alertify.alert(msg);
643		}
644		
645
646		if(quantity<step && quantity<=max && finished ==0 ){
647			switch (currentLangCode) {
648                case 'lat':
649                    msg = 'Minimalna dozvoljena količina je '+step;
650                    break;
651                case 'eng':
652                    msg = 'Minimal alowed quantity is '+step;
653                    break;
654                case 'cir':
655                    msg = 'Минимална дозвољена количина је'+step;
656                    break;
657                 default:
658                 	msg = 'Minimalna dozvoljena količina je '+step;
659            }
660			$(this).val(step);
661			//alert(msg);
662			alertify.alert(msg);
663		}
664		if(quantity>max && finished ==0){
665			
666			switch (currentLangCode) {
667                case 'lat':
668                    msg = 'Uneta količina je veća od raspoložive.';
669                    break;
670                case 'eng':
671                    msg = 'Selected quantity is unavailable.';
672                    break;
673                case 'cir':
674                    msg = 'Унета количина је већа од расположиве.';
675                    break;
676                 default:
677                 	msg = 'Uneta količina je veća od raspoložive.';
678            }
679			$(this).val(max);
680			//alert(msg);
681			alertify.alert(msg);
682		}
683		
684
685	});
686
687
688    $(document).on('change', '.cms_productQtyInputRequest', function(){
689        var previousValue = $(this).data("value");
690        var currentLangCode = $(this).parents('.cms_productInputDecIncCont').attr('langcode');
691        var step = parseFloat($(this).attr('step'));
692        var quantity =parseFloat($(this).val());
693        var reminder = quantity % step;
694        var finished = 0;
695        msg = '';
696        if($(this).val()==''){
697            finished = 1;
698            switch (currentLangCode) {
699                case 'lat':
700                    msg = 'Uneta vrednost nije validna.';
701                    break;
702                case 'eng':
703                    msg = 'Entered value is not valid.';
704                    break;
705                case 'cir':
706                    msg = 'Унета вредност није валидна.';
707                    break;
708                 default:
709                    msg = 'Uneta vrednost nije validna.';
710            }
711            $(this).val(step);
712            //alert(msg);
713            alertify.alert(msg);
714        }
715        if(reminder>0  && finished ==0){
716            switch (currentLangCode) {
717                case 'lat':
718                    msg = 'Uneta vrednost nije validna.\nUneta vrednost mora biti deljiva sa '+step;
719                    break;
720                case 'eng':
721                    msg = 'Entered value is not valid.\nThe enetered value must be divisible with '+step;
722                    break;
723                case 'cir':
724                    msg = 'Унета вредност није валидна.\nУнета вредност мора бити делјива са '+step;
725                    break;
726                 default:
727                    msg = 'Uneta vrednost nije validna.\nUneta vrednost mora biti deljiva sa '+step;
728            }
729            $(this).val(previousValue);
730            //alert(msg);
731            alertify.alert(msg);
732        }
733        if(quantity<step && finished ==0 ){
734            switch (currentLangCode) {
735                case 'lat':
736                    msg = 'Minimalna dozvoljena količina je '+step;
737                    break;
738                case 'eng':
739                    msg = 'Minimal alowed quantity is '+step;
740                    break;
741                case 'cir':
742                    msg = 'Минимална дозвољена количина је'+step;
743                    break;
744                 default:
745                    msg = 'Minimalna dozvoljena količina je '+step;
746            }
747            $(this).val(step);
748            //alert(msg);
749            alertify.alert(msg);
750        }
751
752    });
753	
754
755	$(document).on('click', '.cms_productInputIncButton', function(){
756		var currentLangCode = $(this).parents('.cms_productInputDecIncCont').attr('langcode');
757		var step = parseFloat($(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInput').attr('step'));
758		var max = parseFloat($(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInput').attr('max'));
759		var oldquantity =parseFloat($(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInput').val());
760		var newuantity = Math.round((oldquantity+step)*100)/100  ;
761
762		
763		msg = '';
764		if(newuantity>max){
765			switch (currentLangCode) {
766                case 'lat':
767                    msg = 'Кoličina '+newuantity+' je veća od raspoložive.';
768                    break;
769                case 'eng':
770                    msg = 'Quantity '+newuantity+' is unavailable.';
771                    break;
772                case 'cir':
773                    msg = 'Количина '+newuantity+' је већа од расположиве.';
774                    break;
775                 default:
776                 	msg = 'Кoličina '+newuantity+' je veća od raspoložive.';
777            }
778			$(this).val( Math.round((max)*100)/100 );
779			//alert(msg);
780			alertify.alert(msg);
781		} else {
782			$(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInput').val(newuantity);
783		}
784
785
786	});
787
788    $(document).on('click', '.cms_productInputIncButtonRequest', function(){
789        var currentLangCode = $(this).parents('.cms_productInputDecIncCont').attr('langcode');
790        var step = parseFloat($(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInputRequest').attr('step'));
791        var oldquantity =parseFloat($(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInputRequest').val());
792        var newuantity = Math.round((oldquantity+step)*100)/100  ;
793        
794        msg = '';
795        
796        $(this).parents('.cms_productInputDecIncCont').find('.cms_productQtyInputRequest').val(newuantity);
797        
798
799
800    });
801	
802	$('#product_qty').on('blur', function(){
803		if($(this).val() < 0 || isNaN($(this).val()) ){
804			$(this).val(1);
805		}
806	});
807
808    $('#product_request_qty').on('blur', function(){
809        if($(this).val() < 0 || isNaN($(this).val()) ){
810            $(this).val(1);
811        }
812    });
813
814    // .+/- product
815	
816    // gallerys
817    $("[gallery]").fancybox({
818        hash:false
819    });
820	$.fancybox.defaults.hash = false;
821
822    // .gallerys
823    // order
824    $('.order-paymant-check').on('click',function(){
825    	if($(this).hasClass('trigger-collapse')){
826    		$('#collapseUpl').slideDown('fast');
827    	}else{
828    		$('#collapseUpl').slideUp('fast');
829    	}
830    	if($(this).hasClass('trigger-collapse2')){
831    		$('#collapseDelivery2').slideDown('fast');
832    	}else{
833    		$('#collapseDelivery2').slideUp('fast');
834    	}
835    	if($(this).hasClass('trigger-collapse3')){
836    		$('#collapseDelivery3').slideDown('fast');
837    	}else{
838    		$('#collapseDelivery3').slideUp('fast');
839    	}
840
841      	$('.order-paymant-check').removeClass('active');
842      	$('.order-paymant-check').parents('.chose-paymant').find('input').removeAttr('checked');
843        
844      	$(this).parents('.chose-paymant').find('input').attr('checked',true);
845      	$(this).parents('.chose-paymant').find('input').click();
846		$(this).addClass('active');
847		
848
849    });
850    
851    // $('.chose-paymant').on('click',function(){
852
853
854    //     orderA = $('.chose-paymant').attr('aria-controls');
855    //     orderId = $('.collapse').attr('id');
856    //     $('.collapse').removeClass('in');
857
858    //     if(orderA == orderId){
859    //         $('.collapseParent').find('collapse').addClass('in');
860    //     }
861        
862    // });
863
864
865    $('.cms_newDataButton').on('click',function(){
866		$(this).parents('form').find('.disabledInput').removeClass('disabledInput').addClass('enabledInput');
867        
868    });
869    
870
871    // .order
872	
873	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
874	
875
876	$('#delivery1, #delivery2').on('click', function(){
877		$('.delivery_service_cont').find('input[type="radio"]').each(function(){
878			$(this).prop('checked', false);		
879		});	
880		$(this).next('input[type="radio"]').prop('checked', true);
881	});
882	
883
884	/*	USER PANEL	*/
885	
886	$(".changeUserDataButton").on('click', function(){
887		$(".userDataName, .userDataLastname").removeAttr('disabled');
888		$(this).addClass('hide');
889		$(".saveUserDataButton").removeClass('hide');
890		$(".cancelUserDataButton").removeClass('hide');
891	});
892	
893	$(".cancelUserDataButton").on('click', function(){
894		$(".userDataName").val($(".userDataName").attr('olddata')).attr('disabled', true);
895		$(".userDataLastname").val($(".userDataLastname").attr('olddata')).attr('disabled', true);
896		
897		$(this).addClass('hide');
898		$(".saveUserDataButton").addClass('hide');
899		$(".changeUserDataButton").removeClass('hide');
900	});
901	
902	
903	$(".saveUserDataButton").on('click', function(){
904		if($(".userDataName").val() != '' || $(".userDataLastname").val() != ''){
905			var data = {
906				action : 'saveuserdata',
907				userid: $(".personal-info").attr('userid'),
908				name: $(".userDataName").val(),
909				lastname: $(".userDataLastname").val()
910			};
911			
912			$.ajax({
913				type: "POST",
914				data: data,
915				url: "index.php",
916				error: function (XMLHttpRequest, textStatus, errorThrown) {
917					alert("ERROR:" + errorThrown);
918				},
919				success: function (response) {
920					if(response == 1){
921						alertify.success('Uspesno snimljeno!');	
922						
923						$(".userDataName").attr('olddata', $(".userDataName").val()).attr('disabled', true);
924						$(".userDataLastname").attr('olddata', $(".userDataLastname").val()).attr('disabled', true);
925						
926						$(".saveUserDataButton").addClass('hide');
927						$(".cancelUserDataButton").addClass('hide');
928						$(".changeUserDataButton").removeClass('hide');	
929					}
930					else{
931						alertify.error('Greska prilikom snimanja!');		
932					}
933					
934				}
935			});		
936		}
937		else{
938			$(".userDataName").parents('.form-group').addClass('has-error');
939			$(".userDataLastname").parents('.form-group').addClass('has-error');
940			alertify.error('Popunite obavezna polja!');	
941		}
942	});
943	
944	$('.jq_startDateInput').datepicker({
945		format: "yyyy-mm-dd"
946	});
947	$('.jq_endDateInput').datepicker({
948		format: "yyyy-mm-dd"
949	});
950	
951	$('.jq_startDateInput, .jq_endDateInput, .jq_inValuteSelect, .jq_deletedCheckbox').on("change", function() {
952		if ( $.fn.DataTable.isDataTable( $("."+$(".jq_userpanelSectionButton.active").attr('target')+"Table") ) ) {
953			var table = $("."+$(".jq_userpanelSectionButton.active").attr('target')+"Table").DataTable();
954			table.draw();
955		  
956		 // $("."+$(".jq_userpanelSectionButton.active").attr('target')+"Table")
957		}
958	});
959	
960	/*	userpanel open document items modal	*/
961	
962	$(document).on('click', '.jq_openDocumentItemsButton', function(){
963		getDocumentItems($(this));	
964	});
965	
966	$(document).on('click', ".jq_userpanelSectionButton",  function(){
967		var $this = $(this);
968		$(".jq_userpanelSectionButton").removeClass('active');
969		$('.jq_userpanelSectionCont').addClass('hide');
970		$(this).addClass('active');
971		$("."+$(this).attr('target')).removeClass('hide');
972		$('.jq_documentSpecialOption').addClass('hide');
973		$('.jq_documentSpecialOption[doctype="'+$(this).attr('doctype')+'"]').removeClass('hide');
974		$('.jq_dateRangeInputCont').removeClass('hide');
975		if($(this).attr('doctype') == 'upit'){
976			$('.jq_dateRangeInputCont').addClass('hide');
977		}
978		
979		
980		if ( $.fn.DataTable.isDataTable( $("."+$(this).attr('target')+"Table") ) ) {
981			var table = $("."+$(this).attr('target')+"Table").DataTable();
982			table.draw();
983		}
984		else{
985			$("."+$(this).attr('target')+"Table").dataTable({
986				stateSave: true,
987				"processing": true,
988				"serverSide": true,
989				"searching": false,
990				"ajax":{
991						url :"index.php", // json datasource
992						"data"   : function( d ) {
993							d.action= 'getpovratnice',
994							d.startdate = $('.jq_startDateInput').val(),
995							d.enddate = $('.jq_endDateInput').val(),
996							d.doctype = $($this).attr('doctype'),
997							d.invalute = $('.jq_inValuteSelect').val(),
998							d.deleted = $('.jq_deletedCheckbox').prop('checked');
999						},
1000						type: "post",  // method  , by default get
1001						error: function(){  // error handling
1002							$(".employee-grid-error").html("");
1003							$("#example1").append('<tbody class="employee-grid-error"><tr><th colspan="3">Nema vesti u bazi</th></tr></tbody>');
1004							$("#employee-grid_processing").css("display","none");
1005						},
1006						dataSrc: function(d){
1007							//console.log(d);
1008							
1009							for(var i = 0; i < d.aaData.length;i++)
1010							{
1011								if($($this).attr('doctype') == 'e')
1012								{
1013									/*	rezervacije	*/
1014									var arr = '';
1015									for(var j = 0; j < d.aaData[i][4].length;j++)
1016									{
1017										var bc = '<p>'+d.aaData[i][4][j]['number']+' <button class="btn btn-primary btn-sm changeViewButton jq_openDocumentItemsButton" id="'+d.aaData[i][4][j]['documentid']+'" docnumber="'+d.aaData[i][4][j]['number']+'" doctype="r">Otvori</button></p>';
1018										arr+=bc;
1019									}
1020									d.aaData[i][4] = arr;	
1021									d.aaData[i][5] = '<button class="btn btn-default btn-sm changeViewButton jq_openDocumentItemsButton" id="'+d.aaData[i][99]+'" docnumber="'+d.aaData[i][1]+'" doctype="'+$('.jq_userpanelSectionButton.active').attr('doctype')+'">Otvori</button>';				
1022								}
1023								if($($this).attr('doctype') == 'r')
1024								{
1025									/*	fakture	*/
1026									d.aaData[i][6] = '<button class="btn btn-default btn-sm changeViewButton jq_openDocumentItemsButton" id="'+d.aaData[i][99]+'" docnumber="'+d.aaData[i][1]+'" doctype="'+$('.jq_userpanelSectionButton.active').attr('doctype')+'">Otvori</button>';	
1027								}
1028								if($($this).attr('doctype') == 'p')
1029								{
1030									/*	povrat	*/
1031									d.aaData[i][4] = '<button class="btn btn-default btn-sm changeViewButton jq_openDocumentItemsButton" id="'+d.aaData[i][99]+'" docnumber="'+d.aaData[i][1]+'" doctype="'+$('.jq_userpanelSectionButton.active').attr('doctype')+'">Otvori</button>';	
1032								}
1033								if($($this).attr('doctype') == 'k')
1034								{
1035									/*	knjizna	*/
1036									d.aaData[i][4] = '<button class="btn btn-default btn-sm changeViewButton jq_openDocumentItemsButton" id="'+d.aaData[i][99]+'" docnumber="'+d.aaData[i][1]+'" doctype="'+$('.jq_userpanelSectionButton.active').attr('doctype')+'">Otvori</button>';	
1037								}
1038								if($($this).attr('doctype') == 'z')
1039								{
1040									/*	zamena	*/
1041									d.aaData[i][4] = '<button class="btn btn-default btn-sm changeViewButton jq_openDocumentItemsButton" id="'+d.aaData[i][99]+'" docnumber="'+d.aaData[i][1]+'" doctype="'+$('.jq_userpanelSectionButton.active').attr('doctype')+'">Otvori</button>';	
1042								}
1043								
1044							}
1045							
1046							return d.aaData;
1047						}
1048						
1049					},
1050				"language": {
1051						"emptyTable":     "No data available in table",
1052						"info":           "Prikaz _START_ do _END_ od _TOTAL_ dokumenta",
1053						"infoEmpty":      "Prikaz 0 do 0 od 0 vesti",
1054						"infoFiltered":   "(filtrirano od _MAX_ dokumenta)",
1055						"infoPostFix":    "",
1056						"thousands":      ",",
1057						"lengthMenu":     "Prikazi _MENU_ dokumenta",
1058						"loadingRecords": "Ucitavanje...",
1059						"processing":     "Obrada...",
1060						"search":         "Pretraga:",
1061						"zeroRecords":    "Nema rezultata za zadati kriterijum",
1062						"paginate": {
1063							"first":      "Prva",
1064							"last":       "Zadnja",
1065							"next":       "Sledeca",
1066							"previous":   "Predhodna"
1067						}
1068					}
1069				});	
1070			}
1071	});
1072	
1073	/*	USERPANEL END	*/
1074
1075    setTimeout(function() {
1076    	newsL = true;
1077    	if(newsL){
1078    		$('.newsletter-holder').css('right','0');
1079    		var newsL = false;
1080    	}else{
1081    		$('.newsletter-holder').css('right','-370px');
1082    	}
1083       	
1084       	
1085    }, 3000);
1086    $('#close-news').on('click',function(){
1087    	$('.newsletter-holder').css('right','-370px');
1088    });
1089    /*	add new newsletter email	*/
1090
1091    $('.addNewsletterButton').on('click', function(e) {
1092        e.preventDefault();
1093        if ($('.newsletterInput').val() != '') {
1094            var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
1095            if (pattern.test($('.newsletterInput').val())) {
1096                addNewsletter($('.newsletterInput').val());
1097            } else {
1098                alertify.alert("Uneta email adresa nije validna! Unesite validnu email adresu.");
1099            }
1100        } else {
1101            alertify.alert("Unesite email adresu!");
1102        }
1103    });
1104	
1105    $('.addNewsletterButton1').on('click', function(e) {
1106        e.preventDefault();
1107        if ($('.newsletterInput1').val() != '') {
1108            var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
1109            if (pattern.test($('.newsletterInput1').val())) {
1110                addNewsletter($('.newsletterInput1').val());
1111            } else {
1112                alertify.alert("Uneta email adresa nije validna! Unesite validnu email adresu.");
1113            }
1114        } else {
1115            alertify.alert("Unesite email adresu!");
1116        }
1117    });
1118
1119    $('#order_address').submit(function(event) {
1120        event.preventDefault();
1121        var values = {};
1122        $.each($('#order_address').serializeArray(), function(i, field) {
1123            values[field.name] = field.value;
1124        });
1125        console.log(values);
1126
1127        setOrderingAddress(values.ime, values.prezime, values.adresa, values.telefon, values.mesto, values.postbr, values.email);
1128
1129
1130    });
1131	
1132    $('#order_address_delivery').submit(function(event) {
1133        event.preventDefault();
1134        var values = {};
1135        $.each($('#order_address_delivery').serializeArray(), function(i, field) {
1136            values[field.name] = field.value;
1137        });
1138        console.log(values);
1139
1140        setOrderingAddressDelivery(values.ime, values.prezime, values.adresa, values.telefon, values.mesto, values.postbr, values.email);
1141
1142
1143    });
1144
1145    
1146    //dodaj u korpu
1147    $(".product_add_to_shopcart").on('click', function() {
1148        $(this).attr('disabled',true);
1149        var productID = $(this).attr('prodid');
1150        var productName = $(this).attr('prodname');
1151        var productPic = $(this).attr('prodpic');
1152
1153        var productPrice = $(this).attr('prodprice');
1154        var prodtax = $(this).attr('prodtax');
1155        var prodrebate = $(this).attr('prodrebate');
1156        var currentLang = $(this).attr('lang');
1157        var currentLangCode = $(this).attr('langcode');
1158        var productQty = $(this).parent().find('#product_qty').val();
1159        var attr = $(this).attr('attr');
1160        var unitname = $(this).attr('unitname');
1161        var unitstep = $(this).attr('unitstep');
1162
1163
1164        var attrsid = $.map($(".attr-val-select"), function(n) {
1165            return n.id;
1166        });
1167        var atr = [];
1168        var atrval = "-1";
1169
1170        var flag = 1;
1171        var i = 0;
1172        var finalattr = '';
1173
1174        
1175        if($(this).hasClass('productBoxLine')) { //PRODUCT BOX LINE
1176            finalattr = attr;
1177            //alert('y');
1178        } else { //PRODUCT PAGE
1179        	//alert('n');
1180            $(".cms_proDetAttrCont[mandatory='1']").each(function() {
1181                var items = $(this).find('.cms_proDetAttrItem.selected').length;
1182
1183                if (items > 0) {
1184                    atr[i] = [$(this).attr('attrid'), $(this).find('.cms_proDetAttrItem.selected').attr('attrvalid')];
1185                } else {
1186                    atr[i] = [$(this).attr('attrid'), -1];
1187                    flag = 0;
1188                }
1189                i++;
1190                finalattr = JSON.stringify(atr);
1191            });
1192        }
1193
1194
1195
1196
1197        if (flag == 0) {
1198            var msg = "";
1199            switch (currentLangCode) {
1200                case 'lat':
1201                    msg = 'Izaberite atribute proizvoda.';
1202                    break;
1203                case 'eng':
1204                    msg = 'Choose products attributes.';
1205                    break;
1206                case 'cir':
1207                    msg = 'Изаберите атрибуте производа.';
1208                    break;
1209                 default:
1210                 	msg = 'Izaberite atribute proizvoda.';
1211            }
1212            alertify.error(msg);
1213            //showNotification(msg, 'error');
1214        } else {
1215
1216           
1217            var max= 0;
1218             $( ".cms_productInputDecIncCont" ).each(function() {
1219                if( ($( this ).attr('prodid')==productID) && ($( this ).attr('attr')==attr)){
1220                    max =  parseFloat($( this ).find('.cms_productQtyInput').attr('max'));  
1221                }
1222            });
1223            if(max>0){
1224                 addToShopcart(productID, productName, productPrice, prodrebate, prodtax, productPic, productQty, finalattr, currentLang, currentLangCode, unitname, unitstep);
1225            } else {
1226                var msg="";
1227                switch (currentLangCode) {
1228                case 'lat':
1229                    msg = 'Nema raspolozivih kolicina';
1230                    break;
1231                case 'eng':
1232                    msg = 'Nema raspolozivih kolicina';
1233                    break;
1234                case 'cir':
1235                    msg = 'Nema raspolozivih kolicina';
1236                    break;
1237                 default:
1238                    msg = 'Nema raspolozivih kolicina';
1239                 }
1240                 alertify.error(msg);
1241            }
1242
1243        }
1244        $(this).removeAttr('disabled');
1245    });
1246    
1247
1248    $(".product_add_to_shopcart_request").on('click', function() {
1249        $(this).attr('disabled',true);
1250        var productID = $(this).attr('prodid');
1251        var productName = $(this).attr('prodname');
1252        var productPic = $(this).attr('prodpic');
1253        var productPrice = $(this).attr('prodprice');
1254        var prodtax = $(this).attr('prodtax');
1255        var prodrebate = $(this).attr('prodrebate');
1256        var currentLang = $(this).attr('lang');
1257        var currentLangCode = $(this).attr('langcode');
1258        var productQty = $(this).parent().find('#product_request_qty').val();
1259        var attr = $(this).attr('attr');
1260        var unitname = $(this).attr('unitname');
1261        var unitstep = $(this).attr('unitstep');
1262
1263        var attrsid = $.map($(".attr-val-select"), function(n) {
1264            return n.id;
1265        });
1266        var atr = [];
1267        var atrval = "-1";
1268
1269        var flag = 1;
1270        var i = 0;
1271        var finalattr = '';
1272
1273        if ($(this).hasClass('productBoxLine')) { //PRODUCT BOX LINE
1274            finalattr = attr;
1275        } else { //PRODUCT PAGE
1276            $(".cms_proDetAttrCont[mandatory='1']").each(function() {
1277                var items = $(this).find('.cms_proDetAttrItem.selected').length;
1278
1279                if (items > 0) {
1280                    atr[i] = [$(this).attr('attrid'), $(this).find('.cms_proDetAttrItem.selected').attr('attrvalid')];
1281                } else {
1282                    atr[i] = [$(this).attr('attrid'), -1];
1283                    flag = 0;
1284                }
1285                i++;
1286                finalattr = JSON.stringify(atr);
1287            });
1288        }
1289
1290
1291
1292
1293        if (flag == 0) {
1294            var msg = "";
1295            switch (currentLangCode) {
1296                case 'lat':
1297                    msg = 'Izaberite atribute proizvoda.';
1298                    break;
1299                case 'eng':
1300                    msg = 'Choose products attributes.';
1301                    break;
1302                case 'cir':
1303                    msg = 'Изаберите атрибуте производа.';
1304                    break;
1305                 default:
1306                 	msg = 'Izaberite atribute proizvoda.';
1307            }
1308            alertify.error(msg);
1309            //showNotification(msg, 'error');
1310        } else {
1311
1312            addToShopcartRequest(productID, productName, productPrice, prodrebate, prodtax, productPic, productQty, finalattr, currentLang, currentLangCode , unitname, unitstep);
1313        }
1314        $(this).removeAttr('disabled');
1315    });
1316    //ADD TO B2B CHART
1317    $(".product_add_to_shopcartB2B").on('click', function() {
1318        $(this).attr('disabled',true);
1319    	//alert(unitstep);
1320        $this = $(this);
1321         var infoQty = $(this).parent('td').find('.cms_product_with_attribut_quantity_in_chart');
1322
1323        $($this).parent('td').find('span.jq_productLineSpinner').removeClass('hide');
1324        $.ajax({
1325            type: "POST",
1326            data: { action: 'isloged' },
1327            url: "index.php",
1328            error: function(XMLHttpRequest, textStatus, errorThrown) {
1329                alert("ERROR:" + errorThrown);
1330            },
1331            success: function(res) {
1332                if (res == 1) {
1333                    var productID = $($this).attr('prodid');
1334                    var productName = $($this).attr('prodname');
1335                    var productPic = $($this).attr('prodpic');
1336                    var productPrice = $($this).attr('prodprice');
1337                    var prodtax = $($this).attr('prodtax');
1338                    var prodrebate = $($this).attr('prodrebate');
1339                    var currentLang = $($this).attr('lang');
1340                    var currentLangCode = $($this).attr('langcode');
1341                    var productQty = $($this).parent().parent().find('#product_qty').val();
1342                    var attr = $($this).attr('attr');
1343                    var unitname = $($this).attr('unitname');
1344                    var unitstep = $($this).attr('unitstep');
1345                    var flag = 1;
1346                    var atr = [];
1347                    var i = 0;
1348                    var finalattr = '';
1349
1350                    if ($($this).hasClass('b2baddtocart')) {
1351                        finalattr = attr;
1352                    } else {
1353                        $(".cms_proDetAttrCont[mandatory='1']").each(function() {
1354                            var items = $(this).find('.cms_proDetAttrItem.selected').length;
1355
1356                            if (items > 0) {
1357                                atr[i] = [$(this).attr('attrid'), $(this).find('.cms_proDetAttrItem.selected').attr('attrvalid')];
1358                            } else {
1359                                atr[i] = [$(this).attr('attrid'), -1];
1360                                flag = 0;
1361                            }
1362                            i++;
1363                            finalattr = JSON.stringify(atr);
1364                        });
1365                    }
1366                    if (flag == 0) {
1367                        var msg = "";
1368                        switch (currentLangCode) {
1369                            case 'lat':
1370                                msg = 'Izaberite atribute proizvoda.';
1371                                break;
1372                            case 'eng':
1373                                msg = 'Choose products attributes.';
1374                                break;
1375                            case 'cir':
1376                                msg = 'Изаберите атрибуте производа.';
1377                                break;
1378                             default:
1379                             	msg = 'Izaberite atribute proizvoda.';
1380                        }
1381                        //alertify.error(msg);
1382                        showNotification(msg, 'error');
1383                    } else {
1384                        if ($($this).hasClass('b2baddtocart')) {
1385                            setTimeout(function() {
1386                                $($this).parent('td').find('span.jq_productLineSpinner').addClass('hide');
1387                                $($this).parent('td').find('span.jq_productLineOK').removeClass('hide');
1388                            }, 300);
1389
1390                        }
1391                        var max= 0;
1392                         $( ".cms_productInputDecIncCont" ).each(function() {
1393                            if( ($( this ).attr('prodid')==productID) && ($( this ).attr('attr')==attr)){
1394                                max =  parseFloat($( this ).find('.cms_productQtyInput').attr('max'));
1395                                
1396
1397                            }
1398                            
1399                        });
1400                        if(max>0){
1401                        	addToShopcartB2B(productID, productName, productPrice, prodrebate, prodtax, productPic, productQty, finalattr, currentLang, currentLangCode, unitname, unitstep);
1402                        } else {
1403                        	var msg="";
1404                			switch (currentLangCode) {
1405                            case 'lat':
1406                                msg = 'Nema raspolozivih kolicina';
1407                                break;
1408                            case 'eng':
1409                                msg = 'Nema raspolozivih kolicina';
1410                                break;
1411                            case 'cir':
1412                                msg = 'Nema raspolozivih kolicina';
1413                                break;
1414                             default:
1415                             	msg = 'Nema raspolozivih kolicina';
1416                       		 }
1417                       		 alertify.error(msg);
1418                        }
1419                        
1420                        
1421                    }
1422                } else {
1423                	var msg="";
1424                	switch (currentLangCode) {
1425                            case 'lat':
1426                                msg = 'Morate se ulogovati kako bi dodali proizvod u korpu.';
1427                                break;
1428                            case 'eng':
1429                                msg = 'You must login to add product to shopcart.';
1430                                break;
1431                            case 'cir':
1432                                msg = 'Морате се улоговати како би додали производ у корпу.';
1433                                break;
1434                             default:
1435                             	msg = 'Morate se logovati kako bi dodali proizvod u korpu.';
1436                        }
1437                    alertify.error(msg);
1438                }
1439            }
1440        });
1441
1442    $(this).removeAttr('disabled');
1443
1444    });
1445    //ADD TO B2B CHART END //
1446    //ADD TO REQUEST B2B CHART //
1447    $(".product_add_to_shopcart_requestB2B").on('click', function() {
1448        $(this).attr('disabled',true);
1449        $this = $(this);
1450         var infoQty = $(this).parent('td').find('.cms_product_with_attribut_quantity_in_chart');
1451
1452        $($this).parent('td').find('span.jq_productLineSpinner').removeClass('hide');
1453        $.ajax({
1454            type: "POST",
1455            data: { action: 'isloged' },
1456            url: "index.php",
1457            error: function(XMLHttpRequest, textStatus, errorThrown) {
1458                alert("ERROR:" + errorThrown);
1459            },
1460            success: function(res) {
1461                if (res == 1) {
1462                    var productID = $($this).attr('prodid');
1463                    var productName = $($this).attr('prodname');
1464                    var productPic = $($this).attr('prodpic');
1465                    var productPrice = $($this).attr('prodprice');
1466                    var prodtax = $($this).attr('prodtax');
1467                    var prodrebate = $($this).attr('prodrebate');
1468                    var currentLang = $($this).attr('lang');
1469                    var currentLangCode = $($this).attr('langcode');
1470                    var productQty = $($this).parent().parent().find('#product_request_qty').val();
1471                    var attr = $($this).attr('attr');
1472                    var unitname = $($this).attr('unitname');
1473                    var unitstep = $($this).attr('unitstep');
1474                    var flag = 1;
1475                    var atr = [];
1476                    var i = 0;
1477                    var finalattr = '';
1478
1479                    if ($($this).hasClass('b2baddtocart')) {
1480                        finalattr = attr;
1481                    } else {
1482                        $(".cms_proDetAttrCont[mandatory='1']").each(function() {
1483                            var items = $(this).find('.cms_proDetAttrItem.selected').length;
1484
1485                            if (items > 0) {
1486                                atr[i] = [$(this).attr('attrid'), $(this).find('.cms_proDetAttrItem.selected').attr('attrvalid')];
1487                            } else {
1488                                atr[i] = [$(this).attr('attrid'), -1];
1489                                flag = 0;
1490                            }
1491                            i++;
1492                            finalattr = JSON.stringify(atr);
1493                        });
1494                    }
1495                    if (flag == 0) {
1496                        var msg = "";
1497                        switch (currentLangCode) {
1498                            case 'lat':
1499                                msg = 'Izaberite atribute proizvoda.';
1500                                break;
1501                            case 'eng':
1502                                msg = 'Choose products attributes.';
1503                                break;
1504                            case 'cir':
1505                                msg = 'Изаберите атрибуте производа.';
1506                                break;
1507                             default:
1508                             	msg = 'Izaberite atribute proizvoda.';
1509                        }
1510                        //alertify.error(msg);
1511                        showNotification(msg, 'error');
1512                    } else {
1513                        if ($($this).hasClass('b2baddtocart')) {
1514                            setTimeout(function() {
1515                                $($this).parent('td').find('span.jq_productLineSpinner').addClass('hide');
1516                                $($this).parent('td').find('span.jq_productLineOK').removeClass('hide');
1517                            }, 300);
1518
1519                        }
1520                        addToShopcartRequestB2B(productID, productName, productPrice, prodrebate, prodtax, productPic, productQty, finalattr, currentLang, currentLangCode, unitname, unitstep);
1521                    }
1522                } else {
1523                	var msg="";
1524                	switch (currentLangCode) {
1525                            case 'lat':
1526                                msg = 'Morate se ulogovati kako bi dodali proizvod u upit.';
1527                                break;
1528                            case 'eng':
1529                                msg = 'You must login to add product to request.';
1530                                break;
1531                            case 'cir':
1532                                msg = 'Морате се улоговати како би додали производ у упит.';
1533                                break;
1534                             default:
1535                             	msg = 'Morate se ulogovati kako bi dodali proizvod u upit.';
1536                        }
1537                    alertify.error(msg);
1538                }
1539            }
1540        });
1541
1542    $(this).removeAttr('disabled');
1543
1544    });
1545    //ADD TO REQUEST B2B CHART END//
1546
1547
1548    $('.cms_proDetAttrItem').on("click", function() {
1549        $(this).parents('.cms_proDetAttrCont').find('.cms_proDetAttrItem').each(function() {
1550            $(this).removeClass('selected');
1551        });
1552        $(this).addClass('selected');
1553
1554        // if($(this).hasClass('attr-onchange')){
1555        //     $(this).removeClass('attr-onchange');
1556        // }else{
1557            $(this).parents('.product-attr-ul').find('.product-attr-li').removeClass('attr-onchange');
1558            $(this).addClass('attr-onchange');
1559        // } 
1560    });
1561
1562    $(".core_attrSelectValueCheckbox").on("click", function() {
1563
1564        var currpath = window.location.pathname + window.location.search;
1565
1566        if ($(this).hasClass('selected')) {
1567            $(this).removeClass('selected');
1568            var reg = "&at[]=" + $(this).attr('attrvalid');
1569            var currpath1 = currpath.replace(reg, '');
1570            var currpath1 = currpath1.replace("&&", '&');
1571
1572            if (currpath[currpath1.length - 1] == '?') {
1573                currpath1 = currpath1.slice(0, -1);
1574            }
1575
1576            window.location = currpath1;
1577
1578        } else {
1579            $(this).addClass('selected');
1580
1581            var str = window.location.pathname;
1582            var lastChar = currpath.indexOf('?');
1583
1584            var char = '';
1585            if (lastChar == -1) { char = '?' }
1586
1587            window.location = window.location + char + "&at[]=" + $(this).attr('attrvalid');
1588
1589        }
1590    });
1591
1592    //toolbox product sort
1593    $('.cms_CategorySortFilter').on('change', function() {
1594		
1595		//var currpath = window.location.pathname + window.location.search;
1596        //var questionmark = '';
1597        //if (currpath.search(/\?/g) == -1) { questionmark = '?'; }
1598		
1599        var currpath = window.location.search;
1600        var havequest = currpath.indexOf('?');
1601        var type = $(this).val();
1602
1603        if (havequest > -1) {
1604            // ima ?
1605
1606            if (type != '') {
1607                var spos = currpath.indexOf('sort');
1608                if (spos > -1) {
1609                    // ima sort	
1610                    var currpath1 = currpath.replace(/sort=[a-zA-Z0-9]*/g, 'sort=' + $(this).val());
1611                } else {
1612                    var currpath1 = currpath + '&sort=' + $(this).val();
1613                }
1614            } else {
1615                var currpath2 = currpath.replace(/sort=[a-zA-Z0-9]*/g, '');
1616                var currpath1 = currpath2.replace('?&', '?');
1617            }
1618
1619        } else {
1620            var currpath1 = currpath + '?&sort=' + $(this).val();
1621        }
1622        window.location = window.location.pathname + currpath1;
1623    });
1624    //toolbox product limit
1625    $('.cms_CategoryLimitFilter').on('change', function() {
1626        var currpath = window.location.search;
1627        var havequest = currpath.indexOf('?');
1628        var type = $(this).val();
1629		if($(this).val()>=20) {
1630        if (havequest > -1 ) {
1631            // ima ?
1632
1633            if (type != '') {
1634                var spos = currpath.indexOf('limit');
1635                if (spos > -1) {
1636                    // ima limit	
1637                    var currpath1 = currpath.replace(/limit=[a-zA-Z0-9]*/g, 'limit=' + $(this).val());
1638                } else {
1639                    var currpath1 = currpath + '&limit=' + $(this).val();
1640                }
1641            } else {
1642                var currpath2 = currpath.replace(/limit=[a-zA-Z0-9]*/g, '');
1643                var currpath1 = currpath2.replace('?&', '');
1644            }
1645
1646        } else {
1647            var currpath1 = currpath + '?&limit=' + $(this).val();
1648        }
1649		} else {
1650                var currpath2 = currpath.replace(/limit=[a-zA-Z0-9]*/g, '');
1651                var currpath1 = currpath2.replace('?&', '?');			
1652		}
1653        window.location = window.location.pathname + currpath1;
1654    });
1655	//toolbox download category pricelist
1656	$('.cms_exportCategoryPriceListBTN').on('click', function() {
1657		alert('Export cenovnika.');
1658	});
1659	//toolbox end
1660
1661    /*cart*/
1662    $('.cart_refresh').on('click', function() {
1663        var value = $(this).parent().find('input[name="qty"]').val();
1664
1665        if (isNaN(value) || value < 0) {
1666            alertify.alert('Količina mora biti pozitivan ceo broj');
1667            return;
1668        }
1669        var cart_position = $(this).parents('.article_content').attr('cart_position');
1670        setArticleQtyInShopcart(cart_position, value);
1671    });
1672    $('.cart_request_refresh').on('click', function() {
1673        var value = $(this).parent().find('input[name="qty"]').val();
1674
1675        if (isNaN(value) || value < 0) {
1676            alertify.alert('Količina mora biti pozitivan ceo broj');
1677            return;
1678        }
1679        var cart_position = $(this).parents('.article_content').attr('cart_position');
1680        setArticleQtyInShopcartRequest(cart_position, value);
1681    });
1682    $('.cart_refreshB2B').on('click', function() {
1683        var value = $(this).parent().find('input[name="qtyB2B"]').val();
1684        if (isNaN(value) || value < 0) {
1685            alertify.alert('Količina mora biti pozitivan ceo broj');
1686            return;
1687        }
1688        var cart_position = $(this).parents('.article_content').attr('cart_position');
1689        setArticleQtyInShopcartB2B(cart_position, value);
1690    });
1691    $('.cart_clear_article').on('click', function() {
1692        var c = confirm('Da li želite da količinu artikla postavite na 0 ?');
1693        if (c) {
1694            var cart_position = $(this).parents('.article_content').attr('cart_position');
1695            setArticleQtyInShopcart(cart_position, 0);
1696        }
1697    });
1698    $('.cart_clear_articleB2B').on('click', function() {
1699        var c = confirm('Da li želite da količinu artikla postavite na 0 ?');
1700        if (c) {
1701            var cart_position = $(this).parents('.article_content').attr('cart_position');
1702            setArticleQtyInShopcartB2B(cart_position, 0);
1703        }
1704    });
1705
1706    $('.cart_remove_article').on('click', function() {
1707
1708        var c = confirm('Ukloniti proizvod iz korpe?');
1709        if (c) {
1710            var cart_position = $(this).parents('.article_content').attr('cart_position');
1711            removeProdInCart(cart_position);
1712            //removeProdInCartB2B(cart_position);
1713        }
1714
1715    });
1716    $('.cart_request_remove_article').on('click', function() {
1717
1718        var c = confirm('Ukloniti proizvod iz korpe?');
1719        if (c) {
1720            var cart_position = $(this).parents('.article_content').attr('cart_position');
1721            removeProdInCartRequest(cart_position);
1722            //removeProdInCartB2B(cart_position);
1723        }
1724
1725    });
1726
1727    /*	small shopcart functions */
1728
1729
1730    $(".jq_smallShopcartItemDeleteButton").on('click', function() {
1731        var c = confirm('Ukloniti proizvod iz korpe?');
1732        if (c) {
1733            var cart_position = $(this).parents('.smallShopcartItemHolder').attr('productcartid');
1734            removeProdInCart(cart_position);
1735            //removeProdInCartB2B(cart_position);
1736        }
1737
1738    });
1739
1740    $(document).on("click", '.jq_compare', function(e) {
1741
1742        if ($(this).attr('checked')) {
1743            removeFromCompare($(this).parents('.product').attr('productid'));
1744            $(this).removeAttr('style');
1745
1746        } else {
1747            addToCompare($(this).parents('.product').attr('productid'), $(this).parents('.product').find(".jq_smallbox_image").attr('imglink'));
1748        }
1749    });
1750
1751    $(document).on("click", '.cms_addToWishList', function(e) {
1752
1753        if ($(this).find('.cms_iWishList').hasClass('-active')) {
1754            removeFromWishList($(this).parents('.product').attr('productid'));
1755            $(this).find('.cms_iWishList').removeClass('-active');
1756
1757        } else {
1758            addToWishList($(this).parents('.product').attr('productid'));
1759        }
1760    });
1761
1762    $(document).on("click", ".jq_removeFromCompareButton", function(e) {
1763        removeFromCompare($(this).parents('.jq_compareItemCont').attr('productid'));
1764    });
1765
1766    $(document).on("click", ".compareButton", function(e) {
1767        window.location.href = 'uporedi';
1768    });
1769
1770    $(document).on("click", ".cms_wishlistButton", function(e) {
1771        window.location.href = 'listazelja';
1772    });
1773	
1774	$('.cms_removeAllFromCompareButton').on('click', function(){
1775		$('.jq_compareItemCont').each(function(){
1776			removeFromCompare($(this).attr('productid'));
1777		});	
1778	});
1779
1780    // log in modal
1781    $('#exampleModal').on('show.bs.modal', function(event) {
1782        var button = $(event.relatedTarget) // Button that triggered the modal
1783        var recipient = button.data('whatever') // Extract info from data-* attributes
1784        // If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
1785        // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
1786        var modal = $(this)
1787        modal.find('.modal-title').text('New message to ' + recipient)
1788        modal.find('.modal-body input').val(recipient)
1789    })
1790
1791    $(function() {
1792
1793        $('#login-form-link').click(function(e) {
1794            $("#login-form").delay(100).fadeIn(100);
1795            $("#registration-form").fadeOut(100);
1796            $('#register-form-link').removeClass('active');
1797            $(this).addClass('active');
1798            e.preventDefault();
1799        });
1800        $('#register-form-link').click(function(e) {
1801            $("#registration-form").delay(100).fadeIn(100);
1802            $("#login-form").fadeOut(100);
1803            $('#login-form-link').removeClass('active');
1804            $(this).addClass('active');
1805            e.preventDefault();
1806        });
1807
1808    });
1809
1810
1811    /*product page */
1812    $('.product_small_pic').on('click', function() {
1813        //var pic_src = $(this).children('img').attr('src');
1814        var pic_big = $(this).data('big-img');
1815        var pic_medium = $(this).data('medium-img');
1816        //alert(pic_medium);
1817        // $('.product_main_pic_holder').children('.highslide').attr('href', pic_big);
1818        $('.vise-pic-wraper').children('.highslide').attr('href', pic_big);
1819        $('.product_main_pic_holder').find('img').not(".akcija").attr('src', pic_medium);
1820
1821        //$('.product_main_pic_holder').children('.highslide').attr('href', pic_src);
1822        //$('.product_main_pic_holder').find('img').attr('src', pic_src);
1823
1824    });
1825
1826    $('.forgot-password').on('click', function() {
1827        $('.modal').removeClass('fade').modal('hide');
1828    });
1829
1830    /*	price slider	*/
1831    // var Myslider = $('#ex2').bootstrapSlider();
1832
1833    $("#ex2").on("slideStop", function() {
1834        var values = Myslider.bootstrapSlider('getValue');
1835        var currpath = window.location.pathname + window.location.search;
1836        var questionmark = '?';
1837        if (currpath.search(/\?/g) == -1) { questionmark = '?'; }
1838
1839        if (currpath.search(/&min=[0-9]*\.?[0-9]*/g) > -1) {
1840            currpath = currpath.replace(/&min=[0-9]*\.?[0-9]*/g, '&min=' + values[0]);
1841        } else {
1842            currpath = currpath + questionmark + '&min=' + values[0];
1843        }
1844        if (currpath.search(/&max=[0-9]*\.?[0-9]*/g) > -1) {
1845            currpath = currpath.replace(/&max=[0-9]*\.?[0-9]*/g, '&max=' + values[1]);
1846        } else {
1847            currpath = currpath + '&max=' + values[1];
1848        }
1849
1850        window.location = currpath;
1851    });
1852
1853    // .log in modal
1854    // search
1855    $('#search-button').on('click', function(event) {
1856        event.preventDefault();
1857        $(this).find('i').toggleClass('fa-search fa-times');
1858        $('.search-input').toggleClass('show');
1859        $('.search-input').focus();
1860    });
1861
1862    $(".search-input").keypress(function(e) {
1863        if (e.which == 13) {
1864            $(this).removeClass('show');
1865            $('#search-button').find('i').toggleClass('fa-search fa-times');
1866
1867        }
1868    });
1869    $('#search').click(function() {
1870
1871
1872        $('#search-input').focus();
1873    });
1874    // .search
1875    // small search button
1876    $('#search1').click(function() {
1877
1878        $('#search-input1').css('margin-left', '10px');
1879        $('#search-input1').focus();
1880    });
1881    $('.search-button1').click(function() {
1882        hamburger_cross()
1883        $('#wrapper').toggleClass('toggled');
1884
1885    });
1886
1887    
1888
1889    /*	CHANGE LANGUAGE  INPUT, A HREF*/
1890
1891    $(".cms_changeLanguage").on("click", function(e) {
1892        e.preventDefault();
1893        $.ajax({
1894            type: "POST",
1895            url: "index.php",
1896            data: ({
1897                action: "changelang",
1898                langid: $(this).attr('langid')
1899            }),
1900            error: function(XMLHttpRequest, textStatus, errorThrown) {
1901                alert("ERROR");
1902            },
1903            success: function(response) {
1904                window.location.reload();
1905            }
1906        });
1907    });
1908	/*	SELECT LANGUAGE	 SELECT OPTION*/
1909    $(".cms_selectLanguage").on("change", function(e) {
1910        e.preventDefault();
1911        $.ajax({
1912            type: "POST",
1913            url: "index.php",
1914            data: ({
1915                action: "changelang",
1916                langid: $(this).val()
1917            }),
1918            error: function(XMLHttpRequest, textStatus, errorThrown) {
1919                alert("ERROR");
1920            },
1921            success: function(response) {
1922                window.location.reload();
1923            }
1924        });
1925    });
1926
1927    $('#login-form').submit(function(event) {
1928        event.preventDefault();
1929        var values = {};
1930        $.each($('#login-form').serializeArray(), function(i, field) {
1931            values[field.name] = field.value;
1932        });
1933        //console.log(values);
1934        if (values.login_form_username == '' || values.login_form_password == '') {
1935            alertify.alert('Potpunite sva polja.');
1936            return;
1937        }
1938
1939        userLogin(values.login_form_username, values.login_form_password, values.login_form_rememberme);
1940
1941
1942    });
1943
1944     $('#login-form_page').submit(function(event) {
1945        event.preventDefault();
1946        var values = {};
1947        $.each($('#login-form_page').serializeArray(), function(i, field) {
1948            values[field.name] = field.value;
1949        });
1950        //console.log(values);
1951        if (values.login_form_username == '' || values.login_form_password == '') {
1952            alertify.alert('Potpunite sva polja.');
1953            return;
1954        }
1955
1956        userLogin(values.login_form_username, values.login_form_password, values.login_form_rememberme);
1957
1958
1959    });
1960
1961
1962    $('#signOutMenu').on('click', function() {
1963        userLogout();
1964    });
1965
1966    $('#registration-form').submit(function(event) {
1967        event.preventDefault();
1968        var values = {};
1969        var haserror = false;
1970        $('#registration-form').find("input").each(function() {
1971            if ($(this).val() == '') {
1972                $(this).parents(".form-group").addClass("has-error");
1973                $(this).next(".help-block").removeClass("hide");
1974                haserror = true;
1975            } else {
1976                $(this).parents(".form-group").removeClass("has-error");
1977                $(this).next(".help-block").addClass("hide");
1978
1979            }
1980        });
1981
1982
1983        $.each($('#registration-form').serializeArray(), function(i, field) {
1984            values[field.name] = field.value;
1985        });
1986        console.log(values);
1987        if (!haserror) {
1988            userRegistration(values.first_name, values.last_name, values.email, values.password, values.password_confirmation, values.telefon, values.adresa, values.mesto, values.postanskibr);
1989        } else {
1990            alertify.error('Sva polja su obavezna!');
1991        }
1992    });
1993
1994    $('#lost-form').submit(function(event) {
1995        event.preventDefault();
1996        var values = {};
1997        $.each($('#lost-form').serializeArray(), function(i, field) {
1998            values[field.name] = field.value;
1999        });
2000        console.log(values);
2001        lostPass(values.email);
2002    });
2003
2004    $('#order_poruci').submit(function(event) {
2005        event.preventDefault();
2006        var values = {};
2007        $.each($('#order_poruci').serializeArray(), function(i, field) {
2008            values[field.name] = field.value;
2009        });
2010        orderPoruci();
2011    });
2012
2013    /*sakrivanje i prikazivanje uplatnice*/
2014    $('input[type=radio][name=payment]').change(function() {
2015        if (this.value == 'Uplatnicom') {
2016            $('.uplatnica_cont').removeClass('hidden');
2017            //alert('prikaz uplatnice');
2018        } else if (this.value == 'Pouzecem') {
2019            $('.uplatnica_cont').addClass('hidden');
2020            //alert('skrivanje uplatnice');
2021        }
2022    });
2023	
2024	/*sakrivanje i prikazivanje metode placanja*/
2025    $('input[type=radio][name=delivery]').change(function() {
2026        if (this.value == 'KurirskomSlužbom') {
2027            $('.delivery_service_cont').removeClass('hidden');
2028			$('.delivery_shop_cont').addClass('hidden');
2029			$('#deliveryZero').removeAttr('checked');
2030            //alert('prikaz kurirske službe');
2031        } else if (this.value == 'Lično') {
2032            $('.delivery_service_cont').addClass('hidden');
2033			$('.delivery_shop_cont').removeClass('hidden');
2034			$('#deliveryZero').attr('checked');
2035			$('#deliveryNotZero').removeAttr('checked');
2036            //alert('skrivanje kurirske službe');
2037        }
2038    });
2039	
2040    $('#order_delivery').submit(function(event) {
2041        event.preventDefault();
2042        var values = {};
2043		
2044
2045        $.each($('#order_delivery').serializeArray(), function(i, field) {
2046            values[field.name] = field.value;
2047			//alert(field.value);
2048        });
2049        //console.log(values);
2050		setOrderPayment(values.payment);
2051    });
2052	
2053    $('#order_ordering').submit(function(event) {
2054        event.preventDefault();
2055        var values = {};
2056        $.each($('#order_ordering').serializeArray(), function(i, field) {
2057            values[field.name] = field.value;
2058        });
2059		
2060		values['deliveryid'] = $("input[name='deliverypartner']:checked").val();
2061        //console.log(values);
2062
2063        setOrderDelivery(values.delivery,values.deliveryid);
2064
2065
2066    });
2067	
2068    $('#order_orderingB2B').submit(function(event) {
2069        event.preventDefault();
2070
2071        var values = {};
2072        $.each($('#order_orderingB2B').serializeArray(), function(i, field) {
2073            values[field.name] = field.value;
2074        });
2075		
2076		values['deliveryid'] = $("input[name='deliverypartner']:checked").val();
2077        //console.log(values);
2078
2079        setOrderDeliveryB2B(values.delivery,values.deliveryid);
2080
2081
2082    });
2083
2084    /*#######################################################*/
2085	
2086	/**********************************************************************************************************************/
2087	//CONTACT 
2088	$(".jq_contact_form").on('submit', function(e) {
2089		e.preventDefault();
2090		if ($("#name").val() == '' || $("#email").val() == '' || $("#message").val() == '') {
2091			alertify.error('Popunite sva polja!');
2092		} else {
2093			$.ajax({
2094				type: "POST",
2095				data: {
2096					action: 'sendcontactform',
2097					name: $("#name").val(),
2098					mail: $("#email").val(),
2099					phone: $("#phone").val(),
2100					message: $("#message").val()
2101				},
2102				url: "index.php",
2103				error: function(XMLHttpRequest, textStatus, errorThrown) {
2104					alert("ERROR:" + errorThrown);
2105				},
2106				success: function(response) {
2107	
2108					$("#name").val('');
2109					$("#email").val('');
2110					$("#phone").val('');
2111					$("#message").val('');
2112					alertify.success('Poruka uspesno poslata');
2113				}
2114			});
2115		}
2116	});
2117	
2118	//UPDATE USER INFO 
2119	$(".jq_user_updatedata_form").on('submit', function(e) {
2120		e.preventDefault();
2121		if ($("#userName").val() == '' || 
2122			$("#userSurname").val() == '' || 
2123			$("#userEmail").val() == '' || 
2124			$("#userAddress").val() == '' || 
2125			$("#userCity").val() == '' || 
2126			$("#userZip").val() == '' || 
2127			$("#userPhone").val() == '' ) {
2128			alertify.error('Popunite sva obavezna polja!');
2129		} else {
2130			$.ajax({
2131				type: "POST",
2132				data: {
2133					action: 'userupdatedata',
2134					name: $("#userName").val(),
2135					surname: $("#userSurname").val(),
2136					email: $("#userEmail").val(),
2137					address: $("#userAddress").val(),
2138					city: $("#userCity").val(),
2139					zip: $("#userZip").val(),
2140					phone: $("#userPhone").val(),
2141					cellphone: $("#userCellPhone").val()
2142				},
2143				url: "index.php",
2144				error: function(XMLHttpRequest, textStatus, errorThrown) {
2145					alert("ERROR:" + errorThrown);
2146				},
2147				success: function(response) {
2148					var str = window.location.pathname;
2149					if (str.indexOf("userpanel") >= 0)
2150					{
2151						window.location.reload();
2152					}else{
2153						window.location.href = 'pocetna';
2154					}
2155					alertify.success('Podaci su uspešno ažurirani.');
2156				}
2157			});
2158		}
2159	});
2160	
2161	//UPDATE PARTNER INFO 
2162	$(".jq_partner_updatedata_form").on('submit', function(e) {
2163		e.preventDefault();
2164		if ($("#partnerUserName").val() == '' || 
2165			$("#partnerUserSurname").val() == '' || 
2166			$("#partnerUserEmail").val() == '' || 
2167			$("#partnerUserAddress").val() == '' || 
2168			$("#partnerUserCity").val() == '' || 
2169			$("#partnerUserZip").val() == '' || 
2170			$("#partnerUserPhone").val() == '' ||
2171			$("#partnerName").val() == '' || 
2172			$("#partnerNumber").val() == '' ||
2173			$("#partnerCode").val() == '' ||
2174			$("#partnerContactPerson").val() == '' ||
2175			$("#partnerPhone").val() == '' ||
2176			$("#partnerEmail").val() == '' ||
2177			$("#partnerAddress").val() == '' ||
2178			$("#partnerCity").val() == '' ||
2179			$("#partnerZip").val() == '' ) {
2180			alertify.error('Popunite sva obavezna polja!');
2181		} else {
2182			$.ajax({
2183				type: "POST",
2184				data: {
2185					action: 'partnerupdatedata',
2186					name: $("#partnerUserName").val(),
2187					surname: $("#partnerUserSurname").val(),
2188					email: $("#partnerUserEmail").val(),
2189					address: $("#partnerUserAddress").val(),
2190					city: $("#partnerUserCity").val(),
2191					zip: $("#partnerUserZip").val(),
2192					phone: $("#partnerUserPhone").val(),
2193					cellphone: $("#partnerUserCellPhone").val(),
2194					partnername: $("#partnerName").val(),
2195					partnernumber: $("#partnerNumber").val(),
2196					partnercode: $("#partnerCode").val(),
2197					partnercontactperson: $("#partnerContactPerson").val(),
2198					partnerphone: $("#partnerPhone").val(),
2199					partnerfax: $("#partnerFax").val(),
2200					partneremail: $("#partnerEmail").val(),
2201					partnerwebsite: $("#partnerWebsite").val(),
2202					partneraddress: $("#partnerAddress").val(),
2203					partnercity: $("#partnerCity").val(),
2204					partnerzip: $("#partnerZip").val()
2205				},
2206				url: "index.php",
2207				error: function(XMLHttpRequest, textStatus, errorThrown) {
2208					alert("ERROR:" + errorThrown);
2209				},
2210				success: function(response) {
2211					var str = window.location.pathname;
2212					if (str.indexOf("userpanel") >= 0)
2213					{
2214						window.location.reload();
2215					}else{
2216						window.location.href = 'pocetna';
2217					}
2218					alertify.success('Podaci su uspešno ažurirani.');
2219				}
2220			});
2221		}
2222	});
2223	
2224	//*     SEARCH      */
2225	// search 
2226    $('.search').on('click', function() {
2227        setTimeout(function() {
2228            $('#mysearch-input').focus();
2229        }, 100);
2230        $('#search-input-holder').css('left', '0');
2231        $('body').css('overflow-y', 'hidden');
2232        $('.header-fixed').hide();
2233    })
2234
2235    $('#close,#search2').on('click', function() {
2236        $('#search-input-holder').css('left', '100%');
2237        $('body').css('overflow-y', 'scroll');
2238    });
2239
2240    // .search
2241	$(".js-example-basic-multiple").select2({
2242		
2243		
2244    });
2245	
2246    $('.cms_searchFormInput').on('keyup paste', function() {
2247
2248        // attrval: ($('.cms_searchFilterButton').hasClass('collapsed'))? '':$(".cms_searchFilterAttrval").val()
2249
2250        if ($(this).val() != '' && ($(this).val()).length > 2) {
2251            $('.cms_searchAllResultsButton').removeClass('hide').find('a').attr('href', 'pretraga?q=' + $(this).val());
2252            $('.cms_searchLoadingIcon').removeClass('hide');
2253            $.ajax({
2254                type: "POST",
2255                data: {
2256                    action: 'search',
2257                    q: $(".cms_searchFormInput").val(),
2258                    brend: ($('.cms_searchFilterButton').hasClass('collapsed')) ? '' : $(".cms_searchFilterBrend").val(),
2259                    category: ($('.cms_searchFilterButton').hasClass('collapsed')) ? '' : $(".cms_searchFilterCategory").val(),
2260					attrval: ($('.cms_searchFilterButton').hasClass('collapsed')) ? '' : $(".cms_searchFilterAttrval").val()
2261                },
2262                url: "index.php",
2263                error: function(XMLHttpRequest, textStatus, errorThrown) {
2264                    console.log("ERROR:" + errorThrown);
2265                },
2266                success: function(response) {
2267                    var a = JSON.parse(response);
2268                    $('.cms_searchResultCont').html('');
2269                    $('.cms_searchFoundTotalHolder').html(a[0]);
2270                    for (var i = 0; i < a[1].length; i++) {
2271
2272                        var clone = $('.cms_productboxContModelTemplate').clone(true).removeClass('hide').removeClass('cms_productboxContModelTemplate');
2273
2274                        $(clone).find('a').attr('href', a[1][i].productlink);
2275                        var img = 'fajlovi/noimg.png';
2276                        if (a[1][i].image != '') img = 'fajlovi/product/small/' + a[1][i].image
2277                        $(clone).find('.b-product-pic').css('background-image', "url('" + img + "')");
2278
2279                        $(clone).find('.b-product-name').find('a').html(a[1][i].name+'<br />'+a['strings']['code']+a[1][i]['code']);
2280                        //brend = a[1][i].manufname;
2281                        //brend = brend.replace(/ */g ,'');
2282						b = a[1][i].brendimage;
2283                        //if (brend == 'PIAZZA') b = 'views/theme/img/piazza.jpg';
2284                        $(clone).find('.b-brend').find('img').attr('src', b);
2285                        $(clone).find('.cms_priceModalHolder').addClass('hide');
2286                        $(clone).find('.b-stiker-holder').html('');
2287
2288                        if ((a[1][i].extradetail).length > 0) {
2289                            for (var j = 0; j < (a[1][i].extradetail).length; j++) {
2290                                console.log(a[1][i].extradetail[j].image);
2291                                var img = $(document.createElement('img')).addClass('img-responsive').attr('src', a[1][i].extradetail[j].image);
2292                                console.log(img);
2293                                $(clone).find('.b-stiker-holder').append(img);
2294                            }
2295                        }
2296
2297                        if (a[1][i].rebate > 0) {
2298                            $(clone).find('.cms_productboxModalRebateImg').attr('src', a['strings']['actionimage']).removeClass('hide');
2299                            /*var oldprice = parseFloat(a[1][i].price) * ((parseFloat(a[1][i].tax) + 100) * 0.01) * ((parseFloat(a[1][i].nivpercent) + 100) * 0.01);
2300                            var newprice = parseFloat(a[1][i].price) * ((parseFloat(a[1][i].tax) + 100) * 0.01);*/
2301                            $(clone).find('.cms_productboxModalRebateAmount').removeClass('hide').html('-' + a[1][i]['actionrebate'] + '%')
2302                        }
2303                        if (a[1][i].nivpercent > 0) {
2304                            $(clone).find('.cms_productboxModalRebateImg').removeClass('hide');
2305                            $(clone).find('.cms_oldPriceAmountHolder').removeClass('hide').prepend((parseFloat(a[1][i].price) * ((parseFloat(a[1][i].tax) + 100) * 0.01) * ((parseFloat(a[1][i].nivpercent) + 100) * 0.01)).toFixed(2));
2306                        }
2307
2308                        $(clone).appendTo($('.cms_searchResultCont'));
2309                    }
2310
2311                    $('.cms_searchLoadingIcon').addClass('hide');
2312
2313                }
2314            });
2315        }
2316    });
2317
2318    $(".cms_searchFormButton").on('click', function(e) {
2319        e.preventDefault();
2320        $('.cms_searchFormInput').trigger('keyup');
2321    });
2322	
2323	
2324	/*	category Mobile Menu START	*/
2325	
2326	
2327
2328    $('#jq_categoryMobileMenuTrigger, #jq_leftMenuTrigger2, #jq_leftMenuTrigger').on('click', function() {
2329		$('.jq_leftMenuSubBody').remove();
2330		menusubcategorydata(0);
2331        TweenMax.to($('.slide-menu'), 0.2, { left: "0" });
2332        $('.main-body-filter').show();
2333        $('body').css('overflow-y','hidden');
2334		
2335    });
2336
2337    $('.jq_leftMenuCloseBtn, .main-body-filter').on('click', function() {
2338        TweenMax.to($('.slide-menu'), 0.2, { left: "-100%" });
2339        $('.main-body-filter').hide();
2340        $('body').css('overflow-y','auto');
2341    });
2342
2343
2344    $('.jq_forwardLeftMenuBtn').on('click', function() {
2345        var clone = $(this).parents('.jq_leftMenuBody').clone(true).addClass('jq_leftMenuSubBody');
2346        var currentName = $(this).parent('.items').find('.links').html();
2347
2348        $(clone).css('left', '100%').attr('data-clickedname', currentName).appendTo('.body-container');
2349		$('.slide-menu .head .title').text(currentName);
2350		menusubcategorydata($(this).parent().attr('catid'));
2351    });
2352
2353    $('.jq_leftMenuBackBtn').on('click', function() {
2354        var prevname = $('.body-container').find('.jq_leftMenuBody:last-child').prev('.jq_leftMenuBody').attr('data-clickedname');
2355        $('.slide-menu .head .title').text(prevname);
2356        TweenMax.to($('.jq_leftMenuBody:last-child'), 0.2, {
2357            left: "100%",
2358            onComplete: function() {
2359                $('.jq_leftMenuBody:last-child').remove();
2360                if ($('.jq_leftMenuBody').length == 1) {
2361                    $('.jq_leftMenuBackBtn').css('visibility', 'hidden');
2362                }
2363            }
2364        });
2365
2366    });
2367	
2368	// var viewportHeight = $(window).height();
2369 //    var leftMenuHeight = $('.jq_leftMenuBody').height()
2370 //    console.log(leftMenuHeight);
2371 //    if (leftMenuHeight >= viewportHeight) {
2372 //        $('.body-container').css('overflow-y', 'scroll');
2373 //    } else {
2374 //        $('.body-container').css('overflow-y', 'hidden');
2375 //    }
2376	/*	category Mobile Menu END	*/
2377	
2378	
2379	
2380});	//	end document ready
2381
2382
2383/*
2384function initialize() {
2385
2386    var map_cord1 = new google.maps.LatLng(43.322795, 21.910472);
2387    var map_cord2 = new google.maps.LatLng(43.323859, 21.928420);
2388	if(document.getElementById('map') != null)
2389	{
2390		var mapCanvas = document.getElementById('map');
2391		var mapOptions = {
2392			center: new google.maps.LatLng(43.3229294, 21.9194596),
2393			zoom: 16,
2394			mapTypeId: google.maps.MapTypeId.ROADMAP,
2395			scrollwheel: false
2396		}
2397		var map = new google.maps.Map(mapCanvas, mapOptions);
2398		var contentString = '<div id="content">' +
2399			'<b>Pro Electronic</b> <br> <small>060 / 4516 - 204</small>' +
2400			'</div>';
2401	
2402		var infowindow = new google.maps.InfoWindow({
2403			content: contentString
2404		});
2405	
2406		var marker1 = new google.maps.Marker({
2407			position: map_cord1,
2408			map: map,
2409			title: 'Pro Electronic"'
2410		});
2411		var marker2 = new google.maps.Marker({
2412			position: map_cord2,
2413			map: map,
2414			title: 'Pro Electronic 2"'
2415		});
2416		marker1.addListener('click', function() {
2417			infowindow.open(map, marker1);
2418		});
2419		marker2.addListener('click', function() {
2420			infowindow.open(map, marker2);
2421		});
2422
2423	}
2424}*/
2425
2426
2427
2428//refreshShopcartSmall();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.