/* Fejléc fixálás */

$(function() {
	
	var anitime=250;
	
    var stickyHeaderTop = $('#logo_div').offset().top;
	var scrollcheck=true;
    $(window).scroll(function() {
    	
    	var scrollle=true;
    	var scrolltop=$(window).scrollTop();
    	if(scrolltop <= stickyHeaderTop){scrollle=false;}else if(scrolltop > stickyHeaderTop){scrollle=true;}
    	
       if (scrollcheck && scrollle){
        	
        	scrollcheck=false;
        	
        	$('#logo_div').css({position: 'fixed', top: '0px'});
        	
        	return;
        	
        	//$('#promo0').fadeOut( "slow", function() {});
        	if($('#promo0').css('display') != 'none')
        	{
        		$('#promo0').slideToggle( "slow", function() {
        			//$('#cont0').css({paddingTop: '50px'});
        			}
        		);
        	}
        	if($('#visitors0').css('display') != 'none')        	
        	{
        		$('#visitors0').slideToggle( "slow");
        	}
        	
        	$('.logo_div_right').css({marginTop: '8px'});
        	
        	
        	$( "#menu0" ).hide(0);  
			$( ".logo_div_right" ).show(0); 
        	$( "#menu_search_div0" ).show(0);
        	$( "#header_xml" ).hide(0);
        	
        	
        	
        	
	        	$( "#other_logos_face" ).removeClass( "other_logos_face" );
	        	$( "#other_logos_face" ).addClass( "other_logos_face2" );
	        	
	        	$( "#menus" ).removeClass( "menus" );
	        	$( "#menus" ).addClass( "menus2" );
	        	
	        	$( "#logo_div" ).removeClass( "logo_div" );
	        	$( "#logo_div" ).addClass( "logo_div00" );
	        	
	        	$( "#logosvg" ).removeClass( "logosvg1" );
	        	$( "#logosvg" ).addClass( "logosvg2" );
	        	
	        	$( "#logotextsvg" ).removeClass( "logotextsvg1" );
	        	$( "#logotextsvg" ).addClass( "logotextsvg2" );        	
	        	
	        	
	                      
	           
	            $('.other_logos_b').css({display: 'none'});
	            if(!$('#buffer').length){
	                $('<div/>',{
	                    id: 'buffer',
	                    css: {
	                        height: $('#logo_div').height()   
	                    }
	                }).prependTo('body');
	            }
        	
        	
        	
        	
        	
        	
        }
    	else if(!scrollle ) {
    	 	
    	 	scrollcheck=true;
    	 	
    	 	$('#logo_div').css({position: 'relative', top: '0px'});    	 	
    	 	
    	 	return;
        	
        	$( "#other_logos_face" ).removeClass( "other_logos_face2" );
        	$( "#other_logos_face" ).addClass( "other_logos_face" );
        	
        	$( "#menus" ).removeClass( "menus2" );
        	$( "#menus" ).addClass( "menus" );
    	 	
    	 	$( "#logo_div" ).removeClass( "logo_div00" );
        	$( "#logo_div" ).addClass( "logo_div" );
    	 	
    	 	$( "#logosvg" ).removeClass( "logosvg2" );
        	$( "#logosvg" ).addClass( "logosvg1" );
        	
        	$( "#logotextsvg" ).removeClass( "logotextsvg2" );
        	$( "#logotextsvg" ).addClass( "logotextsvg1" );       
        	
        	$( "#menu0" ).show(0);  
			$( ".logo_div_right" ).hide(0); 
        	$( "#menu_search_div0" ).hide(0);
        	$( "#header_xml" ).show(0);
        	
    	 	
    	 		 	
    	 	
    	 	 	
    	 	
    	 	$('#cont0').css({paddingTop: '70px'});
    	 	//$('#promo0').css({marginTop: '0px'});
    	 	$('.logo_div_right').css({marginTop: '28px'});
        	
    	 	
    	 	
            
            
           
            //$('.other_logos_b').css({display: 'block'});
            $('#buffer').remove();
			
        }
        
    });
});
/*
$(function() {
	
	var anitime=250;
	
    var stickyHeaderTop = $('#logo_div').offset().top; console.log(stickyHeaderTop);
	var scrollcheck=true;
    $(window).scroll(function() {
    	
    	var scrollle=true;
    	var scrolltop=$(window).scrollTop();
    	if(scrolltop <= stickyHeaderTop){scrollle=false;}else if(scrolltop > stickyHeaderTop){scrollle=true;}
    	
       if (scrollcheck && scrollle){
        	
        	//$('#promo0').fadeOut( "slow", function() {});
        	if($('#promo0').css('display') != 'none')
        	{
        		$('#promo0').slideToggle( "slow", function() {
        			//$('#cont0').css({paddingTop: '50px'});
        			}
        		);
        	}
        	if($('#visitors0').css('display') != 'none')        	
        	{
        		$('#visitors0').slideToggle( "slow");
        	}
        	
        	$('.logo_div_right').css({marginTop: '8px'});
        	
        	$( "#menu0" ).fadeOut(250);
        	
        	
        	$( "#header_xml" ).fadeOut( 100, function() {
        		$( "#menu_search_div0" ).show(anitime);
        		$( ".logo_div_right" ).fadeIn(anitime);
        	});
        	
        	
	        	$( "#other_logos_face" ).removeClass( "other_logos_face" );
	        	$( "#other_logos_face" ).addClass( "other_logos_face2" );
	        	
	        	$( "#menus" ).removeClass( "menus" );
	        	$( "#menus" ).addClass( "menus2" );
	        	
	        	$( "#logo_div" ).removeClass( "logo_div" );
	        	$( "#logo_div" ).addClass( "logo_div00" );
	        	
	        	$( "#logosvg" ).removeClass( "logosvg1" );
	        	$( "#logosvg" ).addClass( "logosvg2" );
	        	
	        	$( "#logotextsvg" ).removeClass( "logotextsvg1" );
	        	$( "#logotextsvg" ).addClass( "logotextsvg2" );        	
	        	
	        	scrollcheck=false;
	        	
	            $('#logo_div').css({position: 'fixed', top: '0px'});
	            
	                      
	           
	            $('.other_logos_b').css({display: 'none'});
	            if(!$('#buffer').length){
	                $('<div/>',{
	                    id: 'buffer',
	                    css: {
	                        height: $('#logo_div').height()   
	                    }
	                }).prependTo('body');
	            }
        	
        	
        	
        	
        	
        	
        }
    	else if(!scrollle ) {
    	 	
        	
        	$( "#other_logos_face" ).removeClass( "other_logos_face2" );
        	$( "#other_logos_face" ).addClass( "other_logos_face" );
        	
        	$( "#menus" ).removeClass( "menus2" );
        	$( "#menus" ).addClass( "menus" );
    	 	
    	 	$( "#logo_div" ).removeClass( "logo_div00" );
        	$( "#logo_div" ).addClass( "logo_div" );
    	 	
    	 	$( "#logosvg" ).removeClass( "logosvg2" );
        	$( "#logosvg" ).addClass( "logosvg1" );
        	
        	$( "#logotextsvg" ).removeClass( "logotextsvg2" );
        	$( "#logotextsvg" ).addClass( "logotextsvg1" );       
        	
        	$( "#menu0" ).fadeIn(250);  
			
        	
        	//$( "#menu0" ).fadeIn(500);   	 
        	
        		
    	 	
    	 	$( ".logo_div_right" ).fadeOut( 1, function() {
    	 		$( "#menu_search_div0" ).hide(1);
			   $( "#header_xml" ).fadeIn(700);    
			   
			});
    	 	
    	 		 	
    	 	
    	 	 	
    	 	
    	 	$('#cont0').css({paddingTop: '70px'});
    	 	//$('#promo0').css({marginTop: '0px'});
    	 	$('.logo_div_right').css({marginTop: '28px'});
        	
    	 	
    	 	scrollcheck=true;
    	 	
    	 	$('#logo_div').css({position: 'relative', top: '0px'});
            
            
           
            //$('.other_logos_b').css({display: 'block'});
            $('#buffer').remove();
			
        }
        
    });
});
*/
/* Fejléc fixálás - vége */

/* Rendezés lenyitás */
$(window).click(function () {
				if($('#lenyilo').is(':visible'))
				{
					$("#lenyilo").hide();
				}		
				
			});
			
$(document).ready(function() {	
	$("#logo_cats_click").click(function (event) {
					event.stopPropagation();		
					$("#lenyilo").slideToggle( "medium", function() {
					    // Animation complete.
					    if($('#top_lenyilo').is(':visible'))
						{
							$("#top_lenyilo").hide();
						}	
					  });
				});
});
/* Rendezés lenyitás - vége */

/* Multi site lenyitás */
/*
$(function () {    
	  $('.sites_menu_div').hover(function () {
		$('#site_lenyilo', this).stop(true, true).delay(100).slideDown(500);
	  }, function () {
		$('#site_lenyilo', this).stop(true, true).slideUp(500);
	  });
});*/

/* Multi site lenyitás - vége */

/* Help Layers */
$(document).ready(function() {
  function helplayers_on() {
    $(".helplayer").fadeToggle( "slow", function() {
    // Animation complete.
  	});
  };
  function helplayers_off() {
    $(".helplayer").fadeToggle( "slow", function() {
	    // Animation complete.
	  });
  };
  setTimeout(function(){ helplayers_on(); }, 2000);
  setTimeout(function(){ helplayers_off(); }, 7000);
})

/* Help Layers - vége */

/* kategória lenyíló */
function openalcat(maincatid)
	{		
			event.stopPropagation();		
			$(".alkategoria").hide();
			$("#alkategoria_"+maincatid).toggle("fast");
			
			$(".kategoria").removeClass("kategoria_aktiv");
			$("#kategoria_"+maincatid).addClass("kategoria_aktiv");
	}	
	
function openalcat_m(maincatid)
	{		
			$("#alkategoria_"+maincatid).css('left', '0');
			$(".kategoria").css('right', '100%');
	}	
	
function closealcat_m(maincatid)
	{		
			$("#alkategoria_"+maincatid).css('left', '100%');
			$(".kategoria").css('right', '0');
	}	
	
$(document).ready(function() {
	$(".kategoria_menu_click").click(function (event) {
				if($('#kategoria_lenyilo').is(':visible'))
				{
					event.stopPropagation();		
					$("#kategoria_lenyilo").slideUp( "medium", function() {
					$(".alkategoria").hide();
					$(".kategoria").removeClass("kategoria_aktiv");
				});				
				}else{	
					event.stopPropagation();		
					$("#kategoria_lenyilo").slideDown( "medium", function() {
					$(".alkategoria").hide();
					$(".kategoria").removeClass("kategoria_aktiv");					
						
				});
				}
	});
});
	
$(window).click(function () {
				if($('#kategoria_lenyilo').is(':visible'))
				{
					event.stopPropagation();		
					$("#kategoria_lenyilo").slideUp();
					$(".alkategoria").hide();
				}			
			});	
/* kategória lenyíló vége */	

/* top termék lenyitás */
$(document).ready(function() {
	
	$(window).click(function () {
				if($('#top_lenyilo').is(':visible'))
				{
					$("#top_lenyilo").hide();
				}		
				
			});
	
	$(".top_termekek_div").click(function (event) {
					event.stopPropagation();		
					$("#top_lenyilo").slideToggle( "medium", function() {
					    // Animation complete.
					    if($('#lenyilo').is(':visible'))
						{
							$("#lenyilo").hide();
						}		
					  });
				});
				
	
				
});	
/* top termék lenyitás - vége */

/* 18+ */
function func18(id) {
				
				/*
				var fulladarray = JSON.parse(readCookie('adu_cookie'));
				
				if(fulladarray!==null)
				{					
					fulladarray.push(id);
					var adarray = fulladarray;
				}
				else
				{
					var adarray=[id];
				}
				
				document.cookie = 'adu_cookie='+JSON.stringify(adarray)+';max-age=86400;path=/';	
				*/
				
				document.cookie = 'adu_cookie=1;max-age=86400;path=/';	
				
				//$("#product_adu_"+id).hide();		
				
				$(".product_adu").hide();	
				$(".product_adu_min").hide();
							
}

function func18_no(id) {
				
				document.cookie = 'adu_cookie=0;max-age=86400;path=/';	
				
				$(".ad_button").hide();		
				$(".ad_button_no").hide();				
}

function readCookie(name) {
            var nameEQ = name + "=";
            var ca = document.cookie.split(';');
            for (var i = 0; i < ca.length; i++) {
                var c = ca[i];
                while (c.charAt(0) == ' ') c = c.substring(1, c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
            }
            return null;
        }
/* 18+ - vége */

/* Mobil menü */
$(document).ready(function() {	
			$("#menu_link").click(function () {		
				$("#m_menu").slideToggle("fast"); 	
				$("#m_lenyilo").hide();
				$("#menu_search_div").hide();
				$("#menu_cross_div").hide();	
				$("#m_menu_tars").hide();
				$("#menu_cat_div").hide();	
			});
			$("#menu_seq").click(function () {		
				$("#m_lenyilo").slideToggle("fast");				
				$("#menu_search_div").hide();
				$("#m_menu").hide();
				$("#menu_cross_div").hide();
				$("#m_menu_tars").hide();
				$("#menu_cat_div").hide();	
			});
			$("#menu_search").click(function () {		
				$("#menu_search_div").slideToggle("fast");
				$("#m_lenyilo").hide();				
				$("#m_menu").hide();
				$("#menu_cross_div").hide();
				$("#m_menu_tars").hide();
				$("#menu_cat_div").hide();	
			});
			$("#menu_cross").click(function () {		
				$("#menu_cross_div").slideToggle("fast");
				$("#menu_search_div").hide();
				$("#m_lenyilo").hide();				
				$("#m_menu").hide();
				$("#m_menu_tars").hide();
				$("#menu_cat_div").hide();	
			});
			
			$("#cont").click(function () {		
				$("#m_lenyilo").hide();
				$(".m_menu_search_div").hide();
				$("#m_menu").hide();
				$("#menu_cross_div").hide();
				$("#m_menu_tars").hide();
				$("#menu_cat_div").hide();	

			});
			
			$("#tars_link_m").click(function () {		
				$("#m_menu_tars").slideToggle("fast");
				$(".dropdown_arrow").toggleClass('deg90');
				$("#menu_search_div").hide();
				$("#m_lenyilo").hide();				
				$("#menu_cat_div").hide();	
				
			});
			
			$("#menu_cat").click(function () {		
				$("#menu_cat_div").slideToggle("fast");
				$("#menu_search_div").hide();
				$("#m_lenyilo").hide();				
				$("#tars_link_m").hide();	
				$("#m_menu").hide();
				$(".m_menu_search_div").hide();
				$("#menu_cross_div").hide();
			});
			
			$("#news_close").click(function () {
				document.cookie = 'newshiddencookie=1;max-age=86400;path=/';	
				$("#news_div0").hide();	
				$("#news_div").hide();
			});
			
		});	
/* Mobil menü - vége */

/* Mobil info */
$(document).ready(function() {	
			$("#info_choice").click(function () {		
				$("#info_top_menu").toggle();		 	
			});
		});	
/* Mobil info - vége */

/* Keresés */

function keresessubmit()
{
	var text=$("#search_input0").val();
		
		if(text.length>2)
		{
			document.searchform.submit()
		}
}

$(document).ready(function() {	
	$("#search_input").keyup(function () {
		var text=$("#search_input").val();
		
		if(text.length>2)
		{
			$.post( "/search.php?search="+text, function( data ) {
			  $( "#menu_search_list" ).show();
			  $( "#menu_search_list" ).html( data );
			});			
		}
		else
		{
			$( "#menu_search_list" ).hide();
		}
			 	
	});
	$("#search_input0").keyup(function () {	
		var text=$("#search_input0").val();
		$("#searchform").attr('action', '/kereses/'+RemoveAccents(text));
		if(text.length>2)
		{
			$.post( "/search.php?search="+text, function( data ) {
			  $( "#menu_search_list0" ).slideDown("fast");
			  $( "#menu_search_list0" ).html( data );
			});			
		}
		else
		{
			$( "#menu_search_list0" ).hide();
		}
			 	
	});
	$("#search_input0").click(function () {	
		var text=$("#search_input0").val();
		if(text.length>2)
		{
			$.post( "/search.php?search="+text, function( data ) {
			  $( "#menu_search_list0" ).slideDown("fast");
			  $( "#menu_search_list0" ).html( data );
			});			
		}
		else
		{
			$( "#menu_search_list0" ).hide();
		}
			 	
	});
	$(window).click(function () {
				if($('#menu_search_list0').is(':visible'))
				{
					event.stopPropagation();		
					$("#menu_search_list0").slideUp("fast");
				}			
			});	
});	

function RemoveAccents(strAccents) {
var strAccents = strAccents.split('');
var strAccentsOut = new Array();
var strAccentsLen = strAccents.length;
var accents =   'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖŐòóôõöőÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜŰùúûüűÑñŠšŸÿýŽž ';
var accentsOut = "AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUUuuuuuNnSsYyyZz_";
for (var y = 0; y < strAccentsLen; y++) {
if (accents.indexOf(strAccents[y]) != -1) {
strAccentsOut[y] = accentsOut.substr(accents.indexOf(strAccents[y]), 1);
} else
strAccentsOut[y] = strAccents[y];
}
strAccentsOut = strAccentsOut.join('');
return strAccentsOut;
}

/* Keresés - vége */

/* Cégadatok */

$(document).ready(function() {		
		$("#ownerLayerLink").tipTip({defaultPosition: "top",activation: "click", delay:100,keepAlive: true});
	});

/* Cégadatok - vége */

/* Szürke layer felugrókhoz */
$(document).ready(function ($) {
	$("#gray_layer").click(function () {
    	$("#gray_layer").hide();
    	$(".up_text").hide();
    	$(".up_div").hide();
    });
});	
/* Szürke layer felugrókhoz - vége */

/* További oldalak slider */
$(document).ready(function ($) {



	var fullSiteSize=$('#other_site_slider').width();

	var slideCount = $('#other_site_slider_ccc a').length;
	
	var slideWidth = $('#other_site_slider_ccc').width();
	$('#other_site_slider_c').width(slideWidth);
	
	var slideLogoWidth = $('.other_site_link').width();
	slideWidthN=slideCount*slideLogoWidth;
	
	$('#other_site_slider_ccc').width(slideWidthN);
	var slideLeft=0;
	var slideMaxWidth=slideCount*slideLogoWidth;	
	
	
	var slideViewWidth=Math.floor(slideWidth/slideLogoWidth)*slideLogoWidth;
	$('#other_site_slider_cc').width(slideViewWidth);
	
	setInterval(function(){
		
		if(fullSiteSize!=$('#other_site_slider').width())
		{
			var newFullSiteSize=$('#other_site_slider').width();
			var fullSiteSizeNN=newFullSiteSize-fullSiteSize;
			fullSiteSize=newFullSiteSize;
			
			//console.log(slideWidth); console.log($('#other_site_slider_c').width());
			
			slideWidth = slideWidth + fullSiteSizeNN; 
			$('#other_site_slider_c').width(slideWidth);
			
			slideViewWidth=Math.floor(slideWidth/slideLogoWidth)*slideLogoWidth;
			$('#other_site_slider_cc').width(slideViewWidth);
			
			
		}
		
	}, 1000);
	
    function moveLeft() {    	
	    if((slideLeft + slideLogoWidth)>0){return false;}
    	else
    	{    		
    		slideLeft=slideLeft + slideLogoWidth;
	        $('#other_site_slider_ccc').animate({
	            left: slideLeft,
	            width: slideWidthN
	        }, 400);
	     }
    };

    function moveRight() {
    	if((slideWidth - slideLeft)<=slideMaxWidth){
    		slideLeft=slideLeft-slideLogoWidth;
    		 $('#other_site_slider_ccc').animate({
	            left: slideLeft,
	            width: slideWidthN
       		 }, 400);
       	}
    	
               
    };

    $('#other_site_slider_l').click(function () {
    	//clearInterval(interval);
        moveLeft();
    });

    $('#other_site_slider_r').click(function () {
    	//clearInterval(interval);
        moveRight();
    });
 
	 

});
/* További oldalak slider - Vége */

/* Termék galéria */
function galleryValues(id){
		var galleryCount = parseInt($('#gallerycount_'+id).val());
	
		var galleryWidth = parseInt($('.plm_gallery_div').width());
		
		galleryWidthN=galleryCount*galleryWidth;
	
		var galleryMaxWidth=galleryWidthN;	
		
		var galleryLeftPos=0;
		var galleryCountPot=1;
		
		$('#plm_gallery_photos_'+id).width(galleryWidthN);		
		$('.gallery_photo_div').width(galleryWidth);		
		$('#gallerywidth_'+id).val(galleryWidth);
		$('#gallerymaxwidth_'+id).val(galleryMaxWidth);
		$('#galleryleftpos_'+id).val(galleryLeftPos);
		$('#gallerycountpot_'+id).val(galleryCountPot);
	}

function galleryLeft(id){
	
		var galleryCountPot=parseInt($('#gallerycountpot_'+id).val());
		var galleryWidth=parseInt($('.plm_gallery_div').width());
		var galleryCount=parseInt($('#gallerycount_'+id).val());
		
		if(galleryCountPot>1){	    	
			galleryLeftPos=(galleryWidth*(galleryCountPot-2))*-1;
			galleryCountPot--;
		}
    	else
    	{    		
    		galleryCountPot=galleryCount-1;
    		galleryLeftPos=(galleryWidth*(galleryCountPot))*-1;
    		galleryCountPot=galleryCount;
	    }
	    $('#gallerycountpot_'+id).val(galleryCountPot);
	    
	    $(".gdd_class_"+id).css("background", "none"); 
  		$("#gdd_"+id+"_"+galleryCountPot).css("background", "#003643"); 
	    
	    $('#plm_gallery_photos_'+id).animate({
	            left: galleryLeftPos	            
       		 }, 400);
       		 
       	var gddk=$( "#gddk_"+id ).attr('value');	
       	galleryDotSwip (id, galleryCountPot, gddk);
       		 
	}
	
function galleryRight(id) {
		var galleryCountPot=parseInt($('#gallerycountpot_'+id).val());
		var galleryWidth=parseInt($('.plm_gallery_div').width());
		var galleryCount=parseInt($('#gallerycount_'+id).val());
		
    	if(galleryCountPot<galleryCount){
    		galleryLeftPos=(galleryWidth*(galleryCountPot))*-1;
    		galleryCountPot++;    		 
       	}
       	else
       	{
       		galleryLeftPos=0;
       		galleryCountPot=1;
       	}
       	$('#gallerycountpot_'+id).val(galleryCountPot);
       	
       	$(".gdd_class_"+id).css("background", "none"); 
  		$("#gdd_"+id+"_"+galleryCountPot).css("background", "#003643"); 
       	
       	$('#plm_gallery_photos_'+id).animate({
	            left: galleryLeftPos	            
       		 }, 400);
       		 
       	var gddk=$( "#gddk_"+id ).attr('value');	
       	galleryDotSwip (id, galleryCountPot, gddk);
       	 	 
    }
    
function galleryDot (id, count) {
		var galleryWidth=$('.plm_gallery_div').width();
		
  		galleryLeftPos=(galleryWidth*(count-1))*-1;
  		
  		$('#gallerycountpot_'+id).val(count);	
  		 
  		$(".gdd_class_"+id).css("background", "none"); 
  		$("#gdd_"+id+"_"+count).css("background", "#003643"); 
  		 
  		$('#plm_gallery_photos_'+id).animate({
	            left: galleryLeftPos	            
       		 }, 400);       	
	}    

function galleryDotSwip (id, count, gddk) {
		
		var dot_id="gdd_"+id+"_"+count;
    	$( ".gallery_dot_div" ).removeClass( "gallery_dot_div_1" );
    	$( "#"+dot_id ).addClass( "gallery_dot_div gallery_dot_div_1" );
		
		var fixdot=3;
		var maxperrow=5;
		var imagewidth=$('.gallery_dot_div').width()+6;
		$('#plm_bcc_w_'+id).width((imagewidth+2)*gddk);
		
		if(gddk>maxperrow)
		{
				galleryLeftPosDot=(imagewidth*(count-fixdot))*-1;
				
				if(galleryLeftPosDot>0){galleryLeftPosDot=0;}
				if(galleryLeftPosDot<imagewidth*(gddk-maxperrow)*-1){galleryLeftPosDot=imagewidth*(gddk-maxperrow)*-1;}
				console.log(imagewidth*(gddk-maxperrow)*-1);
				$('#plm_bcc_w_'+id).animate({
	            left: galleryLeftPosDot	            
       		 	}, 400);
			
		}
	}    

$(document).ready(function ($) {	

    $('.plm_cl').click(function () {
        galleryLeft($(this).attr('value'));
    });

    $('.plm_cr').click(function () { 	
        galleryRight($(this).attr('value'));
    });
    
    $('.gallery_dot_div, .gallery_rec_div').click(function () { 	
    	var str = $(this).attr('value');
    	var res = str.split(",");
    	
    	var gddk=$( "#gddk_"+res[0] ).attr('value');
    	
        galleryDot(res[0],res[1]);
        
        galleryDotSwip(res[0],res[1], gddk);
        
    });
 
  
	
	  $( "#gallery_photo_div_1" ).on('swipeLeft', function(event) {
	   galleryLeft(1);
	  });
		
		$( "#gallery_photo_div_1" ).on('swipeRight', function(event) {
	    alert('Swiped right!');
	  });	
		
	/* Termék galéria - mouseover */
/*
	$( ".plm_c" )
	  .mouseover(function() {
	     $(this).find(".plm_gal_pic").fadeIn(200);
	  })
	  .mouseout(function() {
	    $(this).find(".plm_gal_pic").fadeOut(200);
	  });
*/	
	/* Termék galéria - mouseover  - Vége*/

});

/* Termék galéria - Vége */

/* Termék galéria MOBIL SWIPER */

function gallerySwiperB(id, num)
{
	var touchstartX = 0;
	var touchendX = 0;
	
	var gesuredZone = document.getElementById(id);
	
	gesuredZone.addEventListener('touchstart', function(event) {
	    touchstartX = event.changedTouches[0].screenX;	   
	}, false);
	
	gesuredZone.addEventListener('touchend', function(event) {
	    touchendX = event.changedTouches[0].screenX;   
	    handleGesure(touchstartX, touchendX, num);
	}, false); 

}

function handleGesure(tsx, tex, num) {
   console.log(tex-10);
   console.log(tsx);
    if (tex < tsx - 70) {
    	galleryRight(num);    
    }
    if (tex > tsx + 70) {
       galleryLeft(num);
    }
   
}

/* Termék galéria MOBIL SWIPER - Vége */

	

/* Vásárlás */

function number_format (number, decimals, dec_point, thousands_sep) {
		number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
		var n = !isFinite(+number) ? 0 : +number,
			prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
			sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
			dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
			s = '',
			toFixedFix = function (n, prec) {
				var k = Math.pow(10, prec);
				return '' + Math.round(n * k) / k;
			};
		// Fix for IE parseFloat(0.55).toFixed(0) = 0;
		s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
		if (s[0].length > 3) {
			s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
		}
		if ((s[1] || '').length < prec) {
			s[1] = s[1] || '';
			s[1] += new Array(prec - s[1].length + 1).join('0');
		}
		return s.join(dec);
	}

function changeCart(d, param, var_id) {
		if(var_id>0){$("#var_id").val(var_id);}else{var var_id=0;$("#var_id").val(var_id);}
		$("#action").val(d);
		$("#param").val(param);
			
		$.post(  
			loadUrl,  
			$("#cartForm").serialize(),
			function(json) {
				//$("#result").html(json);  
				var j = $.parseJSON(json);
				
				if(j.max_1) {
					$(".max1class").each(function() {
						$(this).val('0');
					});					
					$(".kosar_darab2").each(function() {						
						$(this).val('0');
						
					});
				}
				
				//$("#messageBox").html(j.message);
				if(var_id>0 && j.pq00)
				{
					$("#pq0").val(j.pq00);
				}
				else
				{
					if(d=='product_quantity_plus'){document.getElementById("pq0").value=parseInt(document.getElementById("pq0").value)+1;}
					if(d=='product_quantity_minus'){if(document.getElementById("pq0").value>1){document.getElementById("pq0").value=parseInt(document.getElementById("pq0").value)-1;}}
					if(j.max_error && j.max_error>0){document.getElementById("pq0").value=j.max_error;}
				}
				if(j.message){nofancy(j.message);}
				//if(j.message) {	$.fancybox(j.message, {overlayOpacity: 0});}
				if(j.product_quantity)  {$("#product_quantity").val(j.product_quantity);}
				if(j.product_sum_price) {$("#product_sum_price").html(j.product_sum_price);}
				if(j.subproduct_sum_price) { 
					$.each(j.extra_quantity, function(index, value) {
						  $("#subproduct_sum_price_"+index).html(j.subproduct_sum_price[index]);
						 $("#extra_quantity_"+index).val(value);
					});					
				}
				if(j.sumprice1) {
					$("#sumprice1").html(number_format(j.sumprice1, 0, '', ' '));
				}
				if(j.sumprice2) {$("#sumprice2").html(' '+number_format(j.sumprice2, 0, '', ' '));}
				//Variációk
				if(var_id>0){$("#product_quantity_" + var_id).val(j.product_quantity_x); $("#pq0_" + var_id).val(j.product_quantity_x);}
				//Variációk - vége
				//Sávos szállítás
				
				if(j.intsp==1){					
					$(".shpa_price").html("+ " + j.intsp_price + " Ft");
				}
				//Sávos szállítás - vége 
				
			}  
		);  
	}
	
	function nofancy(text)
	{
		$("#gray_layer").show();
		$(".loginBox").center();
		$(".loginBox").show();
		$("#systemmess_text").html(text);
		    
	}
	
	function changePayment() {		

		var payment = $("input[name=payment]:radio:checked").val();
		
			
		$("input[name=shipping]:radio").attr('disabled', true);
		$('input:disabled').closest('.ez-radio').addClass('disabled');				

		var parts = new Array();
		$.each(sp, function(index, value) {
			parts = value.split('-');
			if(payment==parts[1]) {	
				$("input[name=shipping][value="+parts[0]+"]:radio").attr('disabled', false);
				$("input[name=shipping][value="+parts[0]+"]:radio").closest('.ez-radio').removeClass('disabled');
			}
		}); 

		$("input:radio[name=shipping][disabled=false]:first").attr('checked', true);	
		
		changeShipping()
		
		$('input').ezMark({no:'no'});
	  // $('input:radio').lightSwitch();
			
	}
	
	function changeShipping() {
		var shipping = $("input[name=shipping]:radio:checked").val();
		$.post(  
			loadUrl,  
			{shipping: shipping, 
			 task: "changePayment"},
			function(json) {  
				//$("#result").html(json);  
				var j = $.parseJSON(json);
				$("#messageBox").html(j.message);
				if(j.sumprice2) {$("#sumprice2").html(' '+number_format(j.sumprice2, 0, '', ' '));}
			}  
		); 		
	}
	
	function changeShippingPayment() {
		var shippingpayment = $("input[name=shippingpayment]:radio:checked").val();
		if(!shippingpayment) return;
		if(shippingpayment.substr(0,1)==5) {
			$('#pickpack').css('display', '') 
			$('#pickpack').addClass('validate[required]') 
			
		} else {
			$('#pickpack').css('display', 'none') 
			$('#pickpack').removeClass('validate[required]') 
		}		
		$.post(  
			loadUrl,  
			{shippingpayment: shippingpayment, 
			 task: "changePayment"},
			function(json) {  
				//$("#result").html(json);  
				var j = $.parseJSON(json);
				$("#messageBox").html(j.message);
				if(j.sumprice2) {$("#sumprice2").html(' '+number_format(j.sumprice2, 0, '', ' '));}
			}  
		); 		
	}
	
	function copyData() {
		if(!$("#copydata").is(":checked")) {
			$(".bill").show();
			$("#dataDiv").scrollTop($("#billingA").position().top);
		} else { $(".bill").hide(); }
	}
	
/* Vásárlás vége */

/* Heder XML */

function xmlRight(id) {
		var galleryCountPot=parseInt($('#gallerycountpot').val());
		var galleryWidth=parseInt($('.header_xml_prod').width());
		var galleryCount=parseInt($('#gallerycount').val());
		
    	if(galleryCountPot<galleryCount){
    		galleryLeftPos=(galleryWidth*(galleryCountPot))*-1;
    		galleryCountPot++;    		 
       	}
       	else
       	{
       		galleryLeftPos=0;
       		galleryCountPot=1;
       	}
       	$('#gallerycountpot').val(galleryCountPot);
       
       	
       	$('#header_xml_prods').animate({
	            left: galleryLeftPos	            
       		 }, 400);
    }

$(document).ready(function ($) {
	
   	interval=setInterval(function () {
        xmlRight(1);
    }, 5000);
    
    
});	


/* Header XML - vége */

/* Szavazás */
$(document).ready(function() {	
	$(".vote_link").click(function () {
		var link=$(this).prop('rel');
		
		$(".vote_link").html("<span>Már szavaztál</span>");
		
		//console.log(link);
		if(link!="1")
		{
			$.post( link, function( data ) {
				$(".vote_link").attr('rel', '1');
			 	//console.log(data);
			});			
		}
			 	
	});
	
});	
/* Szavazás - vége */
