$(document).ready(function(){
    var WindowHeight=window.innerHeight;
    var windowWidth=window.innerWidth;
   
    $(window).resize(function(){
        $("#win_size").html("<b>"+window.innerWidth+"</b>");
       
    });
    var prevScrollpos = window.pageYOffset;
    $(window).scroll(function(){   
        var CurrentScrollpos = window.pageYOffset;
        scroll_style(CurrentScrollpos,$(".mainMenu"),100,"menu_stylingONscroll");
        scroll_style(CurrentScrollpos,$(".Goup"),200,"GoupShow");
    });


    function scroll_style(y,obj,range,clsNAME){
        if(y>range){
            obj.addClass(clsNAME);
        }else{obj.removeClass(clsNAME);}
    }
     // فانکشن تعیین وضعیت اندازه ی صفحه 
     function Status(){
        var winWidth=$(window).width();
        if(winWidth>=1182){
            return "xlg";
        }else if (winWidth>=975){
            return "lg";
        }else if (winWidth>=863){
            return "xmd";
        }else if (winWidth>=750){
            return "md";
        }else if (winWidth>=606){
            return "xsm";
        }else if (winWidth>=464){
            return "sm";
        }else if (winWidth>=309){
            return "xs";
        }else{
            return "xss";
        }

    } 


    /*------------------------Slider---------------*/


$(".slider_fade > div:first-child > .arrow > span").click(function(){
    var obj=$(this).parent().parent();
    var index=1;
    if($(this).index()==0){index=0;}
    clickarrowslider(obj,index);
  });
  function clickarrowslider(obj,index){
    var sl=obj.children().eq(2);
    var x=sl.attr("data-slidecount");
    var y=sl.attr("data-slideactive");
    var c=0;
    if(index==0){c=y*1-1;if(c<0){c=x-1;}}else{c=y*1+1;if(c>x-1){c=0;}}
    sliderun(sl,c,y);
    intervalsliderun(obj);
  }
  $(".slider_fade > div:first-child >.button > span").click(function(){
    var obj=$(this).parent().parent();
    var sl=obj.children().eq(2);
    sliderun(sl,$(this).index(),(sl.attr("data-slideactive")*1));
    intervalsliderun(obj);
  });
  function intervalsliderun(obj){
    clearInterval(slidlistrun[obj.parent().attr("data-slideIndex")*1]);
    slidlistrun[obj.parent().attr("data-slideIndex")*1]=setInterval(function(){clickarrowslider(obj,1);},obj.parent().attr("data-slideTime")*1000);
  }
  function sliderun(sl,c,y){
    sl.children().each(function(){$(this).css("display","none")});
    sl.children().eq(c).css("display",'block');
    sl.attr("data-slideactive",c);
    sl.parent().children().eq(1).children().eq(y).toggleClass("active");
    sl.parent().children().eq(1).children().eq(c).toggleClass("active");
  }
  var slidlistrun=[];
  sliderautorun();
  function sliderautorun(){
    var i=0;
    $(".slider_fade").each(function() {
      var obj=$(this).children().eq(0);
      slidlistrun[i]=setInterval(function(){clickarrowslider(obj,1);},obj.parent().attr("data-slideTime")*1000);
      i++;
    });
  }
  

});


